Advertisement
Guest User

Untitled

a guest
Jan 28th, 2018
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. #!/bin/python3
  2.  
  3. import socket
  4. import rsa
  5. import base64
  6. import time
  7. import binascii
  8.  
  9. TCP_IP = 'challenge01.root-me.org'
  10. TCP_PORT = 51031
  11. BUFFER_SIZE = 1024
  12. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  13. s.connect((TCP_IP, TCP_PORT))
  14.  
  15. n = 456378902858290907415273676326459758501863587455889046415299414290812776158851091008643992243505529957417209835882169153356466939122622249355759661863573516345589069208441886191855002128064647429111920432377907516007825359999
  16. e = 65537
  17. c = 41662410494900335978865720133929900027297481493143223026704112339997247425350599249812554512606167456298217619549359408254657263874918458518753744624966096201608819511858664268685529336163181156329400702800322067190861310616
  18.  
  19. key = rsa.PublicKey(n, e)
  20. # print(key._save_pkcs1_pem())
  21.  
  22. ciphered = rsa.encrypt(b"toto", key)
  23. print(ciphered)
  24.  
  25.  
  26. def recv():
  27.     data = s.recv(BUFFER_SIZE)
  28.     print(data.decode("ascii"))
  29.  
  30.  
  31. def send(toBesend):
  32.     s.send(toBesend)
  33.     s.send(bytearray(chr(10), 'ascii'))
  34.  
  35.  
  36. recv()
  37. send(base64.b64encode(ciphered))
  38. time.sleep(1)
  39. recv()
  40.  
  41. s.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement