Changes between Initial Version and Version 1 of SoluzioneEsercizioPython


Ignore:
Timestamp:
Oct 6, 2014, 6:41:37 PM (10 years ago)
Author:
monga
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SoluzioneEsercizioPython

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