Yonka2019

some1.py

Jun 6th, 2021 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.76 KB | None | 0 0
  1. import re
  2. import socket
  3. import hashlib
  4.  
  5. SERVER_IP = '54.71.128.194'
  6. SERVER_PORT = 99
  7. BUFFER = 1024
  8. AMOUNT_OF_LOCATIONS = 10
  9. KEY_PATTERN = r"0(\d\d)(.+)?$"
  10. LOCATION_DATA_PATTERN = r"^location data \d{1,2}\/10: (.+)$"
  11.  
  12. def main():
  13.     sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  14.     server_address = (SERVER_IP, SERVER_PORT)
  15.     sock.connect(server_address)
  16.     count = 0
  17.     sock.sendall("ENT000Jupiter".encode())
  18.     sock.recv(BUFFER)
  19.  
  20.     code = ""
  21.  
  22.     while count < AMOUNT_OF_LOCATIONS:
  23.         ans = sock.recv(BUFFER).decode()
  24.  
  25.         decrypted = decrypt(ans)
  26.  
  27.         print(decrypted)
  28.  
  29.         if "location data" in decrypted:
  30.             location_data = re.search(LOCATION_DATA_PATTERN, decrypted).group(1)
  31.  
  32.             print(f"---{location_data}")
  33.  
  34.             code += location_data
  35.             count += 1
  36.  
  37.     print(code)
  38.     print(f"FLY000location_md5={hashlib.md5(code.encode()).hexdigest()},airport=nevada25.84,time=15:52,lane=earth.jup,vehicle=2554,fly")
  39.     sock.sendall(f"FLY000location_md5={hashlib.md5(code.encode()).hexdigest()},airport=nevada25.84,time=15:52,lane=earth.jup,vehicle=2554,fly".encode())
  40.     print(sock.recv(BUFFER).decode())
  41.     sock.close()
  42.  
  43.  
  44. def decrypt(data):
  45.     matches = re.search(KEY_PATTERN, data)
  46.     key = int(matches.group(1))  # Getting key from the data
  47.     input_str = xstr(matches.group(2)).lower()  # Data (without the key) and lower()
  48.  
  49.     builder = ""
  50.  
  51.     for num, ch in enumerate(input_str):
  52.         if not ch.isalpha() or num % 2 != 0:
  53.             builder += ch
  54.         else:
  55.             builder += str(chr((ord(ch) - 97 - key) % 26 + 97))
  56.         num += 1
  57.  
  58.     return builder
  59.  
  60.  
  61. def xstr(s):
  62.     return '' if s is None else str(s)
  63.  
  64.  
  65. if __name__ == '__main__':
  66.     main()
Add Comment
Please, Sign In to add comment