Cracking hashes with Python

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


@RobertKern

- 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: ')
    chklength(hashes)

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


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

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"
    sys.exit(0)


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

if selection == "1":
    dict_attack()
    pass
elif selection == "2":
    sys.exit(0)[/code]


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 gmail.com> 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
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20131126/9813a4b7/attachment.html>


More information about the Python-list mailing list