Advertisement
shahak

Untitled

Apr 25th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.80 KB | None | 0 0
  1. import socket
  2. import hashlib
  3.  
  4.  
  5. def md5(n):
  6.     return bytes(hashlib.md5(bytes(str(n), 'utf-8')).hexdigest(),'utf-8')
  7.  
  8.  
  9. def sha512(n):
  10.     return bytes(hashlib.sha512(bytes(str(n), 'utf-8')).hexdigest(),'utf-8')
  11.  
  12. if __name__ == '__main__':
  13.     # Create a TCP/IP socket
  14.     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  15.     BufferSize = 1024
  16.  
  17.     # Connect the socket to the port where the server is listening
  18.     server_address = ('35.204.90.89', 5555)
  19.     sock.connect(server_address)
  20.     question = sock.recv(BufferSize)[:-2]
  21.  
  22.     print(question)
  23.     for i in range(1, 100000):
  24.         hashValue = md5(i)
  25.         if hashValue == question:
  26.             sock.send(sha512(i + 1) + b'\r\n')
  27.             break
  28.  
  29.     autorith = sock.recv(BufferSize)
  30.     print(autorith)
  31.  
  32.     sock.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement