wiki:SoluzioneEsercizioPythonShadow
import urllib2
import crypt

PWDS = urllib2.urlopen("http://homes.di.unimi.it/~sisop/lucidi1516/shadow")

passwords = []
usernames = []
for i in PWDS:
    passwords.append(i.split(':')[1].strip())
    usernames.append(i.split(':')[0].strip())

p = passwords[0].split('$')
    
def decritta(sale, pwd):
    print sale, pwd
    count = 0
    d = urllib2.urlopen("https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt")
    for w in d:
        count += 1
        h = crypt.crypt(w.strip().lower(), "$6$" + sale )
        if h.strip() == ("$6$" + sale + "$"+ pwd).strip():
            print "Trovata!"
            print w
            break
        if count % 1000 == 0: print count, w.strip(), h

    for w in usernames:
        wr = list(w[:])
        wr.reverse()
        wr = "".join(wr)
        for x in [w, wr]:
            h = crypt.crypt(x.strip().lower(), "$6$" + sale )
            if h.strip() == ("$6$" + sale + "$"+ pwd).strip():
                print "Trovata!"
                print x
                break

        
salt = p[2]
pwd = p[3]

decritta(salt, pwd)


Last modified 9 years ago Last modified on Oct 16, 2015, 11:31:03 AM
Note: See TracWiki for help on using the wiki.