Changes between Version 1 and Version 2 of SoluzioneEsercizioPython
- Timestamp:
- Oct 5, 2015, 7:30:06 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
SoluzioneEsercizioPython
v1 v2 1 1 {{{#!python 2 import crypt 2 3 import urllib2 3 4 4 url = urllib2.urlopen('http://pastebin.com/raw.php?i=Kmnd6aPp')5 5 6 dizionario = urllib2.urlopen('https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt')6 PWDS = urllib2.urlopen("http://pastebin.com/raw.php?i=Kmnd6aPp") 7 7 8 for w in url: 9 pwd = w.split(':')[1].strip() 10 print 'Searching for ', pwd 8 passwords = [] 11 9 12 salt = pwd[0:2] 10 for i in PWDS: 11 passwords.append(i.split(':')[1].strip()) 13 12 14 import crypt 13 def decritta(sale, pwd): 14 d = urllib2.urlopen("https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt") 15 for w in d: 16 if crypt.crypt(w.strip(), sale) == (sale + pwd): 17 print "Trovata!" 18 print w 19 break 15 20 16 for i in dizionario: 17 x = crypt.crypt(i, salt) 18 if x == pwd: 19 print i, x 20 break 21 salt = passwords[0][:2] 22 pwd = passwords[0][2:] 21 23 22 # La password non è nel dizionario, provo combinando lettere e numeri 23 from itertools import combinations_with_replacement 24 decritta(salt, pwd) 24 25 25 alpha = 'abcdefghijklmnopqrstuvwxyz0123456789'26 27 for i in xrange(1,8):28 for j in combinations_with_replacement(alpha, i):29 30 x = crypt.crypt(''.join(j),salt)31 if x == pwd:32 print ''.join(j), pwd33 break34 26 35 27 }}}