Cracking hashes with Python

Chris Angelico rosuav at gmail.com
Tue Nov 26 07:48:57 EST 2013


On Tue, Nov 26, 2013 at 10:46 PM, TheRandomPast .
<wishingforsam at gmail.com> wrote:
> Thanks. From what I've been able to find online I've created a dictionary
> file with words and the words I know the hash values to be and I'm trying to
> get it to use that however when I run this I get no errors but it doesn't do
> anything, like ask me to input my hash value. Am i just being stupid?

The code you've pasted to us is a bit mangled. Can you try to post a
clean copy, please? No angle brackets in front of the lines, and
getting the indentation correct, because I think this might be your
problem:

>wordlist = open('C:\dictionary.txt', r)
>try:
>    words = wordlist
>except(IOError):
>  print "[-] Error: Check the path.\n"
>sys.exit(1)

The first part of the problem is that the sys.exit() call isn't
indented, so it's executed whether there's an exception thrown or not.

The second part of the problem is that you're catching an exception
only to emit a message and terminate. Don't. :) Just let the exception
happen; it'll... emit a message and terminate.

The third part of the problem is that you're bracketing the wrong part
of the code in the try/except. The simple assignment isn't going to
fail - the open call will. (Or maybe the readlines below it, but more
likely the open.)

So here's the fixed version of the above code:

words = open('C:/dictionary.txt', r)

Yep, it's really that simple. (Though there's another fragility in
what you had: the use of \d in a quoted string. It happens to have no
meaning, so it happens to work, but if you use "c:\textfile.txt",
you'll get quite the wrong result. You can double the backslash
"c:\\dictionary.txt", or you can use a raw string
r"c:\dictionary.txt", or you can use a forward slash, as I did above.)

See if that helps. If not, posting a clean copy of your current code
will help a lot.

ChrisA



More information about the Python-list mailing list