Cracking hashes with Python

TheRandomPast . wishingforsam at
Tue Nov 26 15:18:33 CET 2013


- Teacher has taught us nothing about MD5. This being the script he wanted
us to write came as a surprise to everyone but complaints about projects
are constantly ignored. This particular teacher is complained about for
this reason every year but nothing ever changes.

This is my code. I hope it looks better? I'm sorry if it doesn't. I'm
trying to get the hang of posting by email :)

[code] import sys, re, hashlib

def dict_attack():
    hashes = raw_input('\nPlease specify hash value: ')

def chklength(hashes):
    if len(hashes) != 32:
        print '[-] Improper length for md5 hash.'

wordlist = open('C:/dictionary.txt')
    words = wordlist
    print "[-] Error: Check your  path.\n"

words = open('C:/dictionary.txt')
print "\n",len(words),"words loaded…" (This line now throws up an error
where it wasn't before: TypeError: object of type 'file' has no len()

for word in words:
    hash = hashlib.md5(word[:-1])
    value = hash.hexdigest()

if hashes == value:
    print "[+] Password is:"+word,"\n"

print('\n1 – Dictionary Check')
print('2 – Exit')
selection = raw_input('\nSelect an option from above: ')

if selection == "1":
elif selection == "2":

print "\n",len(words),"words loaded…" (This line now throws up an error
where it wasn't before: TypeError: object of type 'file' has no len()
 - I'm guessing this is because it's not picking up my file but I can't see
why it shouldn't?

On Tue, Nov 26, 2013 at 1:00 PM, Robert Kern <robert.kern at> wrote:

> On 2013-11-26 10:30, TheRandomPast wrote:
>  and I've started the second part, the part to crack them. If anyone could
>> tell me where I'd find more information on this subject and how to crack
>> them that would be great.
> What resources did your teacher give you? What have you been taught in
> class about this subject?
> --
> Robert Kern
> "I have come to believe that the whole world is an enigma, a harmless
> enigma
>  that is made terrible by our own mad attempt to interpret it as though it
> had
>  an underlying truth."
>   -- Umberto Eco
> --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list