RE: Cracking hashes with Python
Hi, I'm assuming you are taking a computer/network security course. Md5 hashing operation is designed to be mathematically unidirectional, you can only attempt to find a collision situation but it's technically impossible to reverse the operation. With that said, it's possible to "crack" or "decrypt" a md5 hash value by searching through a value-hash database to find the most commonly used password under a given hash value. You can see the tool at http://www.md5crack.com/home. Yatong > From: st...@pearwood.info > Subject: Re: Cracking hashes with Python > Date: Tue, 26 Nov 2013 02:55:58 + > To: python-list@python.org > > On Mon, 25 Nov 2013 15:32:41 -0800, TheRandomPast wrote: > > > Hi, > > > > I have a school project to do where I've to download MD5 Hashes from a > > particular website and write a code that will crack them. > > A school project. Right. Heh. :-) > > And which website's hashes would this be? > > > > Does anyone > > know where I'll find out more information on how to do this? There's > > only 4 hashes that I need to do so it doesn't have to be a large script > > just needs to be able to download the hashes from the website. Can > > anyone help me out? > > The size of the script has nothing to do with the number of hashes you > have to crack. Whether it is one hash and one million, the script will be > exactly the same. > > Do you have to write a program to download the hashes, or can you just > browse to the web address with your browser and save them? > > If you have to write your own program, start here: > > https://duckduckgo.com/?q=python+how+to+download+data+from+the+web > > > -- > Steven > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
seeking a framework to automate router configurations
Hi Pythoners, I'm looking for a tool or framework in which I can do a slight modification to achieve the following task: "Asynchronously reset a large number of cisco routers back to their original configurations and push prepared initial configurations to them" I did find some similar existing work such as exscript and trigger, however I was stuck in the following two problems : 1. telneting to a non-default port number (other than 23)2. handling of customized banner messages. can you give some hints on this ? Thanks in advance for your input. Frank -- https://mail.python.org/mailman/listinfo/python-list
RE: seeking a framework to automate router configurations
Hi Chris, Thanks for the advice! I'm aware of this module, the problem is that this is quite a low level module and I would have quite a lot to re-invent specific to telneting to a cisco router. Thanks! > Date: Wed, 18 Dec 2013 14:27:55 +1100 > Subject: Re: seeking a framework to automate router configurations > From: ros...@gmail.com > CC: python-list@python.org > > On Wed, Dec 18, 2013 at 1:40 PM, Frank Cui wrote: > > "Asynchronously reset a large number of cisco routers back to their original > > configurations and push prepared initial configurations to them" > > From the sound of your partial solutions, this is done over a TCP/IP > socket? I don't know how you'd go about authenticating yourself with > the router (unless the factory reset is done some other way, and the > telnet part is just to push the config, in which case you'd be using > the default credentials), but presumably you've worked that part out > already. > > Python has a socket module which is probably what you want here. You > can connect on any port, read what comes back, and send whatever you > need. If the job's simple enough, you might even be able to just > connect, send a fixed blob of text, and then listen for errors in the > response... or even not, and just let the user try it afterwards. > > http://docs.python.org/3/library/socket.html > > Does that look like what you need? > > ChrisA > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
RE: seeking a framework to automate router configurations
Thank you guys for the input, I have determined to go with the plain old "expect" as it seems most easy to go with for this task. Frank > Date: Tue, 17 Dec 2013 19:59:31 -0800 > Subject: Re: seeking a framework to automate router configurations > From: rustompm...@gmail.com > To: python-list@python.org > > On Wednesday, December 18, 2013 8:10:20 AM UTC+5:30, Frank Cui wrote: > > Hi Pythoners, > > I'm looking for a tool or framework in which I can do a slight modification > > to > > achieve the following task: > > "Asynchronously reset a large number of cisco routers back to their original > > configurations and push prepared initial configurations to them" > > I did find some similar existing work such as exscript and trigger, however > > I was stuck in the following two problems : > > 1. telneting to a non-default port number (other than 23) > > 2. handling of customized banner messages. > > can you give some hints on this ? > > For the low level details (exscript/trigger) I dont know. > However for the higher level organization issues you may want to look at > > 1. cuisine > http://stackful-dev.com/cuisine-the-lightweight-chefpuppet-alternative > > which uses > > 2. fabric http://docs.fabfile.org/en/1.8/ > > And maybe > 3. tox http://tox.readthedocs.org/en/latest/ > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Regular Expression : Bad Character Range
Hey guys, I'm trying to compile a regular Expression while encountering the following issue, any hints ? is hyphen "-" or underscore "_" considered any meta character which is not allowed when putting into the range ? Thanks Frank In [2]: re.compile("[\w-_]+>") --- error Traceback (most recent call last) /home/frank/ in () > 1 re.compile("[\w-_]+>") /usr/lib/python2.7/re.pyc in compile(pattern, flags) 188 def compile(pattern, flags=0): 189 "Compile a regular expression pattern, returning a pattern object." --> 190 return _compile(pattern, flags) 191 192 def purge(): /usr/lib/python2.7/re.pyc in _compile(*key) 240 p = sre_compile.compile(pattern, flags) 241 except error, v: --> 242 raise error, v # invalid expression 243 if len(_cache) >= _MAXCACHE: 244 _cache.clear() error: bad character range -- https://mail.python.org/mailman/listinfo/python-list
RE: Regular Expression : Bad Character Range
should have escaped hyphen as it could be used for ranging. sorry for the bother... From: y...@outlook.com To: python-list@python.org Subject: Regular Expression : Bad Character Range Date: Thu, 19 Dec 2013 23:50:52 -0300 Hey guys, I'm trying to compile a regular Expression while encountering the following issue, any hints ? is hyphen "-" or underscore "_" considered any meta character which is not allowed when putting into the range ? Thanks Frank In [2]: re.compile("[\w-_]+>") --- error Traceback (most recent call last) /home/frank/ in () > 1 re.compile("[\w-_]+>") /usr/lib/python2.7/re.pyc in compile(pattern, flags) 188 def compile(pattern, flags=0): 189 "Compile a regular expression pattern, returning a pattern object." --> 190 return _compile(pattern, flags) 191 192 def purge(): /usr/lib/python2.7/re.pyc in _compile(*key) 240 p = sre_compile.compile(pattern, flags) 241 except error, v: --> 242 raise error, v # invalid expression 243 if len(_cache) >= _MAXCACHE: 244 _cache.clear() error: bad character range -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
cascading python executions only if return code is 0
hey guys, I have a requirement where I need to sequentially execute a bunch of executions, each execution has a return code. the followed executions should only be executed if the return code is 0. is there a cleaner or more pythonic way to do this other than the following ? if a() == 0:if b() == 0:c() Thanks for your input. frank -- https://mail.python.org/mailman/listinfo/python-list
RE: cascading python executions only if return code is 0
Thanks, this looks beautiful > To: python-list@python.org > From: __pete...@web.de > Subject: Re: cascading python executions only if return code is 0 > Date: Sun, 22 Dec 2013 20:26:15 +0100 > > Frank Cui wrote: > > > hey guys, > > I have a requirement where I need to sequentially execute a bunch of > > executions, each execution has a return code. the followed executions > > should only be executed if the return code is 0. is there a cleaner or > > more pythonic way to do this other than the following ? > > if a() == 0:if b() == 0:c() > > Thanks for your input. > > frank > > funcs = a, b, c > > # option 1 > for f in funcs: > if f(): > break > > # option 2 > any(f() for f in funcs) > > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
RE: cascading python executions only if return code is 0
sorry, but what if I need to have different parameters in these functions ? > To: python-list@python.org > From: breamore...@yahoo.co.uk > Subject: Re: cascading python executions only if return code is 0 > Date: Sun, 22 Dec 2013 19:31:21 + > > On 22/12/2013 19:17, Roy Smith wrote: > > In article , > > Frank Cui wrote: > > > >> hey guys, > >> I have a requirement where I need to sequentially execute a bunch of > >> executions, each execution has a return code. the followed executions > >> should > >> only be executed if the return code is 0. is there a cleaner or more > >> pythonic > >> way to do this other than the following ? > >> if a() == 0:if b() == 0:c() > >> Thanks for your input. > >> frank > > > > Yup! Just do: > > > > a() or b() or c() > > > > The "or" operation has what's known as "short-circuit" semantics. That > > means, if the first operand is true, it doesn't evaluate the second > > operand. Just make sure that a(), b(), and c() all return something > > which is true if they succeed and false otherwise. > > > > Really? :) > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > -- > https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
RE: cascading python executions only if return code is 0
> To: python-list@python.org > From: n...@nedbatchelder.com > Subject: Re: cascading python executions only if return code is 0 > Date: Sun, 22 Dec 2013 14:49:43 -0500 > > On 12/22/13 2:10 PM, Frank Cui wrote: > > sorry, but what if I need to have different parameters in these functions ? > > Frank, welcome to the group. Common convention is to put your response > below the exiting message, so that the conversation continues down the page. > > (See my answer below... :) > > > > > > > > To: python-list@python.org > > > From: breamore...@yahoo.co.uk > > > Subject: Re: cascading python executions only if return code is 0 > > > Date: Sun, 22 Dec 2013 19:31:21 +0000 > > > > > > On 22/12/2013 19:17, Roy Smith wrote: > > > > In article , > > > > Frank Cui wrote: > > > > > > > >> hey guys, > > > >> I have a requirement where I need to sequentially execute a bunch of > > > >> executions, each execution has a return code. the followed > > executions should > > > >> only be executed if the return code is 0. is there a cleaner or > > more pythonic > > > >> way to do this other than the following ? > > > >> if a() == 0: if b() == 0: c() > > > >> Thanks for your input. > > > >> frank > > > > > > > > Yup! Just do: > > > > > > > > a() or b() or c() > > > > > > > > The "or" operation has what's known as "short-circuit" semantics. That > > > > means, if the first operand is true, it doesn't evaluate the second > > > > operand. Just make sure that a(), b(), and c() all return something > > > > which is true if they succeed and false otherwise. > > > > > > > > > > Really? :) > > > > > > -- > > > My fellow Pythonistas, ask not what our language can do for you, ask > > > what you can do for our language. > > > > > > Mark Lawrence > > > > > > -- > > > https://mail.python.org/mailman/listinfo/python-list > > > > > > The most Python-natural way to deal with your problem would be to have > these functions not return status codes at all. Instead, have them > raise an exception if something goes wrong. Then you can invoke them > most naturally: > > a() > b() > c() > > Execution will continue as long as no exceptions are raised. If you > need to deal with the failure case also, then: > > try: > a() > b() > c() > except Exception as e: > # do something here > > Depending on how you want to deal with failures, you'd probably use your > own subclass of Exception, but this is the general idea. > > Return codes can be awkward, especially in Python which has exception > integrated so fully into the language, library, and culture. > > -- > Ned Batchelder, http://nedbatchelder.com > > -- > https://mail.python.org/mailman/listinfo/python-list Thanks for informing the rules. -- https://mail.python.org/mailman/listinfo/python-list
RE: cascading python executions only if return code is 0
> Date: Sun, 22 Dec 2013 14:27:35 -0800 > Subject: Re: cascading python executions only if return code is 0 > From: rantingrickjohn...@gmail.com > To: python-list@python.org > > On Sunday, December 22, 2013 12:37:04 PM UTC-6, Frank Cui wrote: > > I have a requirement where I need to sequentially execute > > a bunch of executions, each execution has a return code. > > the followed executions should only be executed if the > > return code is 0. is there a cleaner or more pythonic way > > to do this other than the following ? > > > > if a() == 0: > > if b() == 0: > > c() > > Hello Frank. > > I kindly request that you be more specific when asking > questions. Both your question and your example code contain > too many ambiguities. > > I'm still not sure what exact outcome you wish to achieve, > the only certainty is that you wish to perform a linear > execution of "N" members with later executions being affected > by earlier executions. > > Whether you want executions to proceed on failure or proceed > on success is unclear. Here are a few explicit pseudo code > examples that would have removed all ambiguities: > > if fails(a()): > if fails(b()): > c() > > if succeeds(a()): > if succeeds(b()): > c() > > Or if you prefer a purely OOP approach: > > a.foo() > b.foo() > if a.failed: > if b.failed: > c.foo() > > a.foo() > b.foo() > if a.succeeded: > if b.succeeded: > c.foo() > > or you could simplify using a logical one liner: > > if !a() and !b() then c() > if a() and b() then c() > > Of course you could use the "all" function > > if all(a(), b()): > c() > if not any(a(), b()): > c() > > But this "all" depends whether you're testing for success or > testing for failure, and that point is a distant third from > my desperate need of understanding your semantics of "what" > values are *true* and "what" values are *false*. > > I think (sadly) more time is spent attempting to interpret > what an OP is asking rather than attempting to provide a > solution to the problem the OP is suffering, and whilst any > problem solving adventure is likely to improve our > intelligence, fumbling about attempting to decode > ambiguities is indeed time that could have been better spent > IF ONLY the speaker (or writer) had put a small bit more > effort into the question. > > Look Frank, nobody is perfect, we all need to improve our > skills here or there. So don't be offended that my > statements are, well,... "frank". > > > -- > https://mail.python.org/mailman/listinfo/python-list Hi Rick, Thanks for pointing out. I accept your advice and will try to make the questions clearer and more straightforward to interpretate . I already took the suggestion of using exception-based handling over the return code. As to testing whether the previous function fails or succeeds, this doesn't really matter in the sense that I already mentioned a return code of 0. ThanksFrank -- https://mail.python.org/mailman/listinfo/python-list
word replacing in a paragraph
Hey guys, I'm trying to automate a process by initially creating a standard template and then replace some text fields with variable values. [for example, "DATE" in the paragraph will be replaced by the current date value. it doesn't have to be a literal word of "DATE", "DATE" in "TESTDATE" can also be replaced.] Is there some lightweight built-in or 3rd party libraries which are good for such kind of work ? ThanksFrank -- https://mail.python.org/mailman/listinfo/python-list
a web UI to invoke a python script at server side
Hey guys, I'm working on to provide a lightweight web UI for providing an interface to invoke a python script(a sequential script which could involve some system calls) at the server side. The UI should collect some parameters for input into this python script, and conversely the output of the script needs to be returned to the web client side. I haven't done much web programming before, can you provide some hints on how this is usually implemented ? ThanksFrank -- https://mail.python.org/mailman/listinfo/python-list
RE: Python (windows)packet sniffer ARP
> Date: Fri, 31 Jan 2014 07:32:42 -0800 > Subject: Re: Python (windows)packet sniffer ARP > From: betz.m...@gmail.com > To: python-list@python.org > > On Friday, January 31, 2014 2:10:28 AM UTC-5, Ralle wrote: > > Hello > > > > > > > > I am wondering if it possible to create a packet sniffer in windows using > > python that only sniffs for ARP packets. > > A couple of links to get you started: > > http://www.winpcap.org/ > http://code.google.com/p/winpcapy/ > -- > https://mail.python.org/mailman/listinfo/python-list Try scapy Frank -- https://mail.python.org/mailman/listinfo/python-list
Python assignment auto-grading
Hi Folks, I'm seeking some suggestions and recommendations for python assignments auto grading. Hopefully this tool will have all or some of the following attributes : 1) Easy to set up and maintain (i.e. minimal workload in terms of sysadmin and webdev, is there a recommended cloud service ? )2) The main workload from the instructor side would only be writing the test cases and mark distributions on the assignments3) Convenient process for student enrolment and assignment publishing. I have already read this post on stackexchange http://programmers.stackexchange.com/questions/181068/how-to-create-an-auto-grader-in-and-for-python, and hope to know if there is a ready or semi-ready to use open-source projects and products for this purpose which are lightweight and easy to use. ThanksFrank -- https://mail.python.org/mailman/listinfo/python-list
instance has no __call__ method
Hi all, I'm a novice learner of python and get caught in the following trouble and hope experienced users can help me solve it:) Code: --- $ cat Muffle_ZeroDivision.py #!/usr/bin/env python class MuffledCalculator: muffled = False def clac(self,expr): try: return eval(expr) except: if self.muffled: print 'Division by zero is illegal' else: raise -- $ python Python 2.7 (r27:82500, Sep 16 2010, 18:03:06) [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import Muffle_ZeroDivision >>> calc = Muffle_ZeroDivision.MuffledCalculator() >>> calc = ('10/2') >>> calc = Muffle_ZeroDivision.MuffledCalculator() >>> calc('10/2') Traceback (most recent call last): File "", line 1, in AttributeError: MuffledCalculator instance has no __call__ method There is an AttributeError that this instance doesn't have the __call__ method, so how to add this kind of method to my instance? Thanks a lot in advance. Regards Frank.Cui -- http://mail.python.org/mailman/listinfo/python-list
Question on the Module Import
Hi all, I'm quite a novice in doing python,and i wish to ask you guys a question on the module import. Say we have a source file called module1.py. What's the difference between the " import module1 " and " from module1 import * " I know that conventionally by coding style, we dont use the second form,but does the first one also reach the same effect ? (importing all the classes and functions and pollute the namespace?) thanks in advance for your answer. Regards, Frank -- http://mail.python.org/mailman/listinfo/python-list