Advertisement
johnburn

wargamesmy crypto300

Jul 4th, 2011
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.71 KB | None | 0 0
  1. #!/usr/bin/python
  2. def permutate(charset, keyLength=None):
  3.     charset=str(charset)
  4.     if keyLength is None:
  5.         keyLength = len(charset)
  6.     hasil=[]
  7.     for x in range(len(charset)):
  8.         y = charset[x:x+1]
  9.         if keyLength == 1:
  10.             hasil.append(y)
  11.         else:
  12.             hasil_ = charset[:x] + charset[x+1:]
  13.             for z in permutate(hasil_, keyLength-1):
  14.                 hasil.append(y + z)
  15.     return hasil
  16.  
  17. cipher = '15,42,62,52,111,58,61,35,62,55,111,38,48,42,32,61,111,51,63,46,59,54,110,114,17,59,114,47,32,39,52,43,114,43,42,55,53,111,38,48,46,38,120,59,58,61,61,55,120,56,51,43,111,51,120,34,59,54,32,32,120,40,62,49,59,49,48,111,59,54,111,38,48,42,114,53,46,38,42,38,42,120,45,39,44,111,52,61,46,32,120,33,61,44,99,114,44,39,55,120,46,37,61,60,61,53,42,60,61,60,33,120,59,58,57,59,114,49,60,114,12,28,25,120,39,51,43,111,63,57,33,51,63,42,54,120,59,61,120,61,55,40,46,59,42,111,38,48,42,114,63,35,59,44,44,58,118,111,5,61,104,36,61,111,54,61,59,55,59,59,55,60,111,38,48,46,38,120,59,58,61,111,53,52,38,38,59,39,114,47,46,33,120,44,51,45,60,55,60,111,48,33,111,51,54,111,51,54,32,63,57,35,43,120,44,51,52,35,55,60,111,19,63,42,60,44,111,1,53,38,38,48,97,114,15,42,114,44,61,59,61,43,114,52,32,61,51,38,60,63,111,52,55,61,114,22,42,61,120,32,60,120,59,58,61,111,27,10,12,114,58,58,38,120,39,55,120,56,51,43,111,60,55,111,58,61,35,34,118,97,124,118,46,38,120,46,62,52,97,114,22,32,37,120,59,58,57,59,114,47,42,114,48,46,36,61,111,43,55,58,32,120,46,38,44,42,60,44,38,61,54,99,114,47,42,114,54,42,55,60,111,11,23,26,114,44,32,114,62,38,60,60,111,51,54,43,114,60,42,33,44,61,61,33,111,19,63,42,60,44,111,1,53,38,38,48,111,39,43,38,60,63,111,51,120,60,39,40,42,32,117,0,31,30,8,127,61,35,59,44,42,127,40,46,33,43,56,61,42,43,114,119,111,52,52,46,53,120,56,58,49,44,58,120,38,33,120,42,39,52,42,32,40,61,61,58,35,55,53,122,107,118,111,26,61,61,55,127,60,114,57,111,38,49,63,126,120,59,58,61,111,57,61,54,114,49,60,114,107,111,49,48,46,32,43,97,88'
  18. cipher_split = [int(i) for i in cipher.split(',')]
  19.  
  20. while len(cipher_split)%3!=0:
  21.     cipher_split.append(0)
  22.  
  23. cipher1=[cipher_split[i:i+3] for i in range(0,len(cipher_split),3)]
  24.  
  25. # charset untuk bruteforce: [a-zA-Z]
  26. # length untuk key diset kpd 3 sbb klu "Three is a crowd" dan ni celen crypto300
  27. for i in permutate('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',3):
  28.     temp=''
  29.     for j in cipher1:
  30.         temp+=''.join((chr(ord(i[0])^j[0]),chr(ord(i[1])^j[1]),chr(ord(i[2])^j[2])))
  31.     # cari perkataan " the " dlm decoded string sebelum stop loop bruteforce
  32.     # sbb biasanya dalam bahasa english perkataan " the " mst ada
  33.     if temp[:-2].count(' the ')>1:
  34.     print 'The key: ' + i[0]+i[1]+i[2]
  35.         print 'Message: ' + temp[:-2]
  36.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement