Changes between Version 1 and Version 2 of SoluzioneEsercizioPython


Ignore:
Timestamp:
Oct 5, 2015, 7:30:06 PM (9 years ago)
Author:
monga
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SoluzioneEsercizioPython

    v1 v2  
    11{{{#!python
     2import crypt
    23import urllib2
    34
    4 url = urllib2.urlopen('http://pastebin.com/raw.php?i=Kmnd6aPp')
    55
    6 dizionario = urllib2.urlopen('https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt')
     6PWDS = urllib2.urlopen("http://pastebin.com/raw.php?i=Kmnd6aPp")
    77
    8 for w in url:
    9   pwd = w.split(':')[1].strip()
    10   print 'Searching for ', pwd
     8passwords = []
    119
    12   salt = pwd[0:2]
     10for i in PWDS:
     11    passwords.append(i.split(':')[1].strip())
    1312
    14   import crypt
     13def 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
    1520
    16   for i in dizionario:
    17     x = crypt.crypt(i, salt)
    18     if x == pwd:
    19       print i, x
    20       break
     21salt = passwords[0][:2]
     22pwd = passwords[0][2:]
    2123
    22   # La password non è nel dizionario, provo combinando lettere e numeri 
    23   from itertools import combinations_with_replacement
     24decritta(salt, pwd)
    2425
    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), pwd
    33         break
    3426
    3527}}}