Advertisement
Nickpips

shifty

Mar 21st, 2016 (edited)
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. #!/usr/bin/python
  2. import socket
  3.  
  4. #tyinternet
  5. def caesar(message, key):
  6.     translated = ''
  7.  
  8.     for symbol in message:
  9.         if symbol.isalpha():
  10.             num = ord(symbol)
  11.             num += key
  12.  
  13.             if symbol.isupper():
  14.                 if num > ord('Z'):
  15.                     num -= 26
  16.                 elif num < ord('A'):
  17.                     num += 26
  18.             elif symbol.islower():
  19.                 if num > ord('z'):
  20.                     num -= 26
  21.                 elif num < ord('a'):
  22.                     num += 26
  23.  
  24.             translated += chr(num)
  25.         else:
  26.             translated += symbol
  27.     return translated
  28.  
  29. dict = open('en_US.dictionary','r').read().split('\n')
  30. dict = dict[0::4] # n33d4sp33d
  31.  
  32. socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  33. socket.connect(("web."+"l"+"a"+"s"+"a"+"c"+"t"+"f"+".com", 4056))
  34.  
  35. while True:
  36.     msg = socket.recv(1024).strip()
  37.     if ("l"+"a"+"s"+"a"+"c"+"t"+"f") in msg:
  38.         print msg
  39.         break
  40.     maxcount = 0
  41.     ans = ''
  42.     for sh in range(0,26):
  43.         count = 0
  44.         dec = caesar(msg,sh)
  45.         for word in dict:
  46.             if word in dec:
  47.                 count = count + 1
  48.         if count >= maxcount:
  49.             maxcount = count
  50.             ans = str(dec)
  51.     socket.send(ans+'\n')
  52.    
  53. socket.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement