-
Notifications
You must be signed in to change notification settings - Fork 1
/
infected.py
35 lines (29 loc) · 1011 Bytes
/
infected.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import socket
import pyautogui
HOST = '127.0.0.1' # The server's hostname or IP address
PORT = 65432 # The port used by the server
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((HOST, PORT))
while True:
data = s.recv(1024)
if not data:
break
data_str = data.decode('utf-8')
print(f"Received: {data_str}")
direction, pixels = data_str.split()
pixels = int(pixels)
print("Direction:", direction)
print("Pixels:", pixels)
print("")
if direction == 'R':
print("Moving right", pixels)
pyautogui.moveRel(pixels, 0)
elif direction == 'L':
print("Moving left", pixels)
pyautogui.moveRel(-pixels, 0)
elif direction == 'U':
print("Moving up", pixels)
pyautogui.moveRel(0, -pixels)
elif direction == 'D':
print("Moving down", pixels)
pyautogui.moveRel(0, pixels)