diff --git a/Client/serversend - mirror - keyboardpress.py b/Client/serversend - mirror - keyboardpress.py index 87dbc6e..c9afede 100644 --- a/Client/serversend - mirror - keyboardpress.py +++ b/Client/serversend - mirror - keyboardpress.py @@ -6,7 +6,7 @@ from pynput.keyboard import Key, Controller keyboard=Controller() # device's IP address -SERVER_HOST = "127.0.0.1" #(socket.gethostbyname(socket.gethostname())) +SERVER_HOST = "0.0.0.0" #(socket.gethostbyname(socket.gethostname())) SERVER_PORT = 10001 # receive 4096 bytes each time BUFFER_SIZE = 128 @@ -25,17 +25,6 @@ print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}") client_socket, address = s.accept() # if below code is executed, that means the sender is connected print(f"[+] {address} is connected.") -# receive the file infos -# receive using client socket, not server socket -received = client_socket.recv(BUFFER_SIZE).decode() -filename, filesize = received.split(SEPARATOR) -# remove absolute path if there is -filename = os.path.basename(filename) -# convert to integer -filesize = int(filesize) -# start receiving the file from the socket -# and writing to the file stream -#with open(filename, "wb") as f: def pressRrelease_char(char): @@ -48,15 +37,9 @@ while True: # nothing is received # file transmitting is done take another time break - # write to the file the bytes we just received - f = open(filename, 'wb') - f.write(bytes_read) - # update the progress bar - f.close() - - g = open(filename, 'r') - ge = g.read() + ge = bytes_read.decode() + print (ge) try: if (ge == "Key.enter"): @@ -143,7 +126,6 @@ while True: pressRrelease_char((ge)) except: print("an error occured with ", ge) - g.close() diff --git a/Client/serversend - mirror - keyboardrelease.py b/Client/serversend - mirror - keyboardrelease.py index 0018dd7..08132ad 100644 --- a/Client/serversend - mirror - keyboardrelease.py +++ b/Client/serversend - mirror - keyboardrelease.py @@ -6,7 +6,7 @@ from pynput.keyboard import Key, Controller keyboard=Controller() # device's IP address -SERVER_HOST = "127.0.0.1" #(socket.gethostbyname(socket.gethostname())) +SERVER_HOST = "0.0.0.0" #(socket.gethostbyname(socket.gethostname())) SERVER_PORT = 10003 # receive 4096 bytes each time BUFFER_SIZE = 128 @@ -25,17 +25,6 @@ print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}") client_socket, address = s.accept() # if below code is executed, that means the sender is connected print(f"[+] {address} is connected.") -# receive the file infos -# receive using client socket, not server socket -received = client_socket.recv(BUFFER_SIZE).decode() -filename, filesize = received.split(SEPARATOR) -# remove absolute path if there is -filename = os.path.basename(filename) -# convert to integer -filesize = int(filesize) -# start receiving the file from the socket -# and writing to the file stream -#with open(filename, "wb") as f: def pressRrelease_char(char): @@ -48,14 +37,8 @@ while True: # nothing is received # file transmitting is done take another time break - # write to the file the bytes we just received - f = open(filename, 'wb') - f.write(bytes_read) - - f.close() - g = open(filename, 'r') - ge = g.read() + ge = bytes_read.decode() print (ge) try: @@ -143,7 +126,7 @@ while True: pressRrelease_char((ge)) except: print("an error occured with ", ge) - g.close() + diff --git a/Client/serversend - mirror - mouse.py b/Client/serversend - mirror - mouse.py index 5654154..56ea7a6 100644 --- a/Client/serversend - mirror - mouse.py +++ b/Client/serversend - mirror - mouse.py @@ -8,7 +8,7 @@ import time mouse=Controller() # device's IP address -SERVER_HOST = "127.0.0.1" #(socket.gethostbyname(socket.gethostname())) +SERVER_HOST = "0.0.0.0" #(socket.gethostbyname(socket.gethostname())) SERVER_PORT = 10002 # receive 4096 bytes each time BUFFER_SIZE = 128 @@ -27,37 +27,20 @@ print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}") client_socket, address = s.accept() # if below code is executed, that means the sender is connected print(f"[+] {address} is connected.") -# receive the file infos -# receive using client socket, not server socket -received = client_socket.recv(BUFFER_SIZE).decode() -filename, filesize = received.split(SEPARATOR) -# remove absolute path if there is -filename = os.path.basename(filename) -# convert to integer -filesize = int(filesize) -# start receiving the file from the socket -# and writing to the file stream -#with open(filename, "wb") as f: - - while True: # read 1024 bytes from the socket (receive) bytes_read = client_socket.recv(BUFFER_SIZE) - if not bytes_read: + if not bytes_read: # nothing is received # file transmitting is done take another time break - # write to the file the bytes we just received - # update the progress bar - f = open(filename, 'wb') - f.write(bytes_read) - f.close() + # read bytes we just received - g = open(filename, 'r') - ge = g.read() + ge = bytes_read.decode() + print (ge) TrR = ge[0:1] @@ -67,7 +50,6 @@ while True: y = int(ge[((int(ge.find(',')+1))):]) x = int(ge[:(int(ge.find(',')))]) - print(x) print(y) mouse.position = (x,y) @@ -78,14 +60,10 @@ while True: else: mouse.click(Button.left, 1) print (TrR) - except: print ("error") - - g.close() - # close the client socket #client_socket.close()