wiki:SoluzioneEsercizioPython

Version 1 (modified by monga, 10 years ago) ( diff )

--

import urllib2

url = urllib2.urlopen('http://pastebin.com/raw.php?i=Kmnd6aPp')

dizionario = urllib2.urlopen('https://raw.githubusercontent.com/eneko/data-repository/master/data/words.txt')

for w in url:
  pwd = w.split(':')[1].strip()
  print 'Searching for ', pwd

  salt = pwd[0:2]

  import crypt

  for i in dizionario:
    x = crypt.crypt(i, salt)
    if x == pwd:
      print i, x
      break

  # La password non è nel dizionario, provo combinando lettere e numeri  
  from itertools import combinations_with_replacement

  alpha = 'abcdefghijklmnopqrstuvwxyz0123456789'

  for i in xrange(1,8):
    for j in combinations_with_replacement(alpha, i):
    
      x = crypt.crypt(''.join(j),salt)
      if  x == pwd:
        print ''.join(j), pwd
        break

Note: See TracWiki for help on using the wiki.