Changes between Initial Version and Version 1 of SoluzioneEsercizioPythonShadow


Ignore:
Timestamp:
Oct 16, 2015, 11:31:03 AM (9 years ago)
Author:
monga
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SoluzioneEsercizioPythonShadow

    v1 v1  
     1{{{#!python
     2
     3import urllib2
     4import crypt
     5
     6PWDS = urllib2.urlopen("http://homes.di.unimi.it/~sisop/lucidi1516/shadow")
     7
     8passwords = []
     9usernames = []
     10for i in PWDS:
     11    passwords.append(i.split(':')[1].strip())
     12    usernames.append(i.split(':')[0].strip())
     13
     14p = passwords[0].split('$')
     15   
     16def decritta(sale, pwd):
     17    print sale, pwd
     18    count = 0
     19    d = urllib2.urlopen("https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt")
     20    for w in d:
     21        count += 1
     22        h = crypt.crypt(w.strip().lower(), "$6$" + sale )
     23        if h.strip() == ("$6$" + sale + "$"+ pwd).strip():
     24            print "Trovata!"
     25            print w
     26            break
     27        if count % 1000 == 0: print count, w.strip(), h
     28
     29    for w in usernames:
     30        wr = list(w[:])
     31        wr.reverse()
     32        wr = "".join(wr)
     33        for x in [w, wr]:
     34            h = crypt.crypt(x.strip().lower(), "$6$" + sale )
     35            if h.strip() == ("$6$" + sale + "$"+ pwd).strip():
     36                print "Trovata!"
     37                print x
     38                break
     39
     40       
     41salt = p[2]
     42pwd = p[3]
     43
     44decritta(salt, pwd)
     45
     46
     47}}}