Advertisement
Guest User

PQP

a guest
Dec 11th, 2014
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. #! /bin/python
  3.  
  4. import socket
  5.  
  6. code_03 = {'100010100':'0','101001000':'1','101000100':'2','101000010':'3','100101000':'4','100100100':'5','100100010':'6','101010000':'7','100010010':'8','100001010':'9','110101000':'A','110100100':'B','110100010':'C','110010100':'D','110010010':'E','110001010':'F','101101000':'G','101100100':'H','101100010':'I','100110100':'J','100011010':'K','101011000':'L','101001100':'M','101000110':'N','100101100':'O','100010110':'P','110110100':'Q','110110010':'R','110101100':'S','110100110':'T','110010110':'U','110011010':'V','101101100':'W','101100110':'X','100110110':'Y','100111010':'Z', '101011110':'', '100101110':'-', '111010100':'.', '111010010':' ', '111001010':'$','101101110':'/','101110110':'+','110101110':'%','100100110':'$','111011010':'%','111010110':'/','100110010':'+'}
  7.  
  8. HOST = "adctf2014.katsudon.org"
  9. PORT = 43010
  10.  
  11. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  12. s.connect((HOST, PORT))
  13.  
  14. while 1:
  15. data = s.recv(256) + s.recv(256)
  16.  
  17. print data
  18.  
  19. if '\xe2\x96\x8c' not in data:
  20. break
  21.  
  22. char_codes = []
  23. text = ''
  24.  
  25. data = data.replace(' ', ' ')
  26.  
  27. for i in range(0, len(data)-3, 3):
  28. temp = data[i] + '' + '' + data[i+1] + '' + data[i+2]
  29. if temp == '\xe2\x96\x8c':
  30. text += '10'
  31. elif temp == '\xe2\x96\x88':
  32. text += '11'
  33. elif temp == '\xe2\x96\x90':
  34. text += '01'
  35. elif temp == ' ':
  36. text += '0'
  37. else:
  38. print "Error: ", temp
  39.  
  40. print text
  41.  
  42. out = ""
  43.  
  44. for i in range(0, len(text)-9, 9):
  45. out += code_03[text[i:i+9]]
  46.  
  47. print out[:-2]
  48.  
  49. s.send(out[:-2])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement