home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 484 / crack.py.zip
Encoding:
Text File  |  2023-01-01  |  902 b   |  49 lines

  1. from sys import argv, exit
  2.  
  3. def str2int(string):
  4.     n=0
  5.     for x in string:
  6.         n+=ord(x)
  7.     return n
  8.  
  9. def decode(string, lsh, rsh, m):
  10.     s = ''
  11.     for i in range(0, len(string)/2, 2):
  12.         try:
  13.             s += str(unichr((((ord(string[i:i+1])^mask)<<j)>>i)))
  14.         except (ValueError,UnicodeEncodeError), ex:
  15.             s='None'
  16.             break
  17.         else:
  18.             for c in s:
  19.                 if (ord(c) < 46) or (ord(c) > 122):
  20.                     s='None'
  21.                     break 
  22.     return s
  23.             
  24.  
  25. infile = open(argv[1])
  26.  
  27. infile.seek(-9, 2)
  28. ext = infile.read()
  29. dot = ext[0:2]
  30.  
  31. infile.close()
  32.  
  33. possibles = 0
  34.  
  35. for i in range (0, 8):
  36.     output = str2int(dot)<<i
  37.  
  38.     for j in range(0, 8):
  39.         output = output>>j
  40.  
  41.         mask = output^ord(unicode('.'))
  42.  
  43.         decrypted = decode(ext, i, j, mask)
  44.         if decrypted != 'None':
  45.             possibles+=1
  46.             print "<<"+str(i),">>"+str(j),"^"+str(mask),"\tstring:",decrypted
  47.  
  48. print "End of cycle,",possibles,"possible algorithms."
  49.