remove file necesity
This commit is contained in:
parent
b475adef12
commit
7c7b478250
@ -6,7 +6,7 @@ from pynput.keyboard import Key, Controller
|
|||||||
keyboard=Controller()
|
keyboard=Controller()
|
||||||
|
|
||||||
# device's IP address
|
# device's IP address
|
||||||
SERVER_HOST = "127.0.0.1" #(socket.gethostbyname(socket.gethostname()))
|
SERVER_HOST = "0.0.0.0" #(socket.gethostbyname(socket.gethostname()))
|
||||||
SERVER_PORT = 10001
|
SERVER_PORT = 10001
|
||||||
# receive 4096 bytes each time
|
# receive 4096 bytes each time
|
||||||
BUFFER_SIZE = 128
|
BUFFER_SIZE = 128
|
||||||
@ -25,17 +25,6 @@ print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}")
|
|||||||
client_socket, address = s.accept()
|
client_socket, address = s.accept()
|
||||||
# if below code is executed, that means the sender is connected
|
# if below code is executed, that means the sender is connected
|
||||||
print(f"[+] {address} 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:
|
|
||||||
|
|
||||||
|
|
||||||
def pressRrelease_char(char):
|
def pressRrelease_char(char):
|
||||||
@ -48,14 +37,8 @@ while True:
|
|||||||
# nothing is received
|
# nothing is received
|
||||||
# file transmitting is done take another time
|
# file transmitting is done take another time
|
||||||
break
|
break
|
||||||
# write to the file the bytes we just received
|
|
||||||
f = open(filename, 'wb')
|
|
||||||
f.write(bytes_read)
|
|
||||||
# update the progress bar
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
g = open(filename, 'r')
|
ge = bytes_read.decode()
|
||||||
ge = g.read()
|
|
||||||
|
|
||||||
print (ge)
|
print (ge)
|
||||||
try:
|
try:
|
||||||
@ -143,7 +126,6 @@ while True:
|
|||||||
pressRrelease_char((ge))
|
pressRrelease_char((ge))
|
||||||
except:
|
except:
|
||||||
print("an error occured with ", ge)
|
print("an error occured with ", ge)
|
||||||
g.close()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ from pynput.keyboard import Key, Controller
|
|||||||
keyboard=Controller()
|
keyboard=Controller()
|
||||||
|
|
||||||
# device's IP address
|
# device's IP address
|
||||||
SERVER_HOST = "127.0.0.1" #(socket.gethostbyname(socket.gethostname()))
|
SERVER_HOST = "0.0.0.0" #(socket.gethostbyname(socket.gethostname()))
|
||||||
SERVER_PORT = 10003
|
SERVER_PORT = 10003
|
||||||
# receive 4096 bytes each time
|
# receive 4096 bytes each time
|
||||||
BUFFER_SIZE = 128
|
BUFFER_SIZE = 128
|
||||||
@ -25,17 +25,6 @@ print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}")
|
|||||||
client_socket, address = s.accept()
|
client_socket, address = s.accept()
|
||||||
# if below code is executed, that means the sender is connected
|
# if below code is executed, that means the sender is connected
|
||||||
print(f"[+] {address} 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:
|
|
||||||
|
|
||||||
|
|
||||||
def pressRrelease_char(char):
|
def pressRrelease_char(char):
|
||||||
@ -48,14 +37,8 @@ while True:
|
|||||||
# nothing is received
|
# nothing is received
|
||||||
# file transmitting is done take another time
|
# file transmitting is done take another time
|
||||||
break
|
break
|
||||||
# write to the file the bytes we just received
|
|
||||||
f = open(filename, 'wb')
|
|
||||||
f.write(bytes_read)
|
|
||||||
|
|
||||||
f.close()
|
ge = bytes_read.decode()
|
||||||
|
|
||||||
g = open(filename, 'r')
|
|
||||||
ge = g.read()
|
|
||||||
|
|
||||||
print (ge)
|
print (ge)
|
||||||
try:
|
try:
|
||||||
@ -143,7 +126,7 @@ while True:
|
|||||||
pressRrelease_char((ge))
|
pressRrelease_char((ge))
|
||||||
except:
|
except:
|
||||||
print("an error occured with ", ge)
|
print("an error occured with ", ge)
|
||||||
g.close()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import time
|
|||||||
mouse=Controller()
|
mouse=Controller()
|
||||||
|
|
||||||
# device's IP address
|
# device's IP address
|
||||||
SERVER_HOST = "127.0.0.1" #(socket.gethostbyname(socket.gethostname()))
|
SERVER_HOST = "0.0.0.0" #(socket.gethostbyname(socket.gethostname()))
|
||||||
SERVER_PORT = 10002
|
SERVER_PORT = 10002
|
||||||
# receive 4096 bytes each time
|
# receive 4096 bytes each time
|
||||||
BUFFER_SIZE = 128
|
BUFFER_SIZE = 128
|
||||||
@ -27,19 +27,6 @@ print(f"[*] Listening as {SERVER_HOST}:{SERVER_PORT}")
|
|||||||
client_socket, address = s.accept()
|
client_socket, address = s.accept()
|
||||||
# if below code is executed, that means the sender is connected
|
# if below code is executed, that means the sender is connected
|
||||||
print(f"[+] {address} 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:
|
while True:
|
||||||
@ -49,15 +36,11 @@ while True:
|
|||||||
# nothing is received
|
# nothing is received
|
||||||
# file transmitting is done take another time
|
# file transmitting is done take another time
|
||||||
break
|
break
|
||||||
# write to the file the bytes we just received
|
|
||||||
|
|
||||||
# update the progress bar
|
# read bytes we just received
|
||||||
f = open(filename, 'wb')
|
|
||||||
f.write(bytes_read)
|
ge = bytes_read.decode()
|
||||||
f.close()
|
|
||||||
|
|
||||||
g = open(filename, 'r')
|
|
||||||
ge = g.read()
|
|
||||||
print (ge)
|
print (ge)
|
||||||
|
|
||||||
TrR = ge[0:1]
|
TrR = ge[0:1]
|
||||||
@ -67,7 +50,6 @@ while True:
|
|||||||
y = int(ge[((int(ge.find(',')+1))):])
|
y = int(ge[((int(ge.find(',')+1))):])
|
||||||
x = int(ge[:(int(ge.find(',')))])
|
x = int(ge[:(int(ge.find(',')))])
|
||||||
|
|
||||||
|
|
||||||
print(x)
|
print(x)
|
||||||
print(y)
|
print(y)
|
||||||
mouse.position = (x,y)
|
mouse.position = (x,y)
|
||||||
@ -79,13 +61,9 @@ while True:
|
|||||||
mouse.click(Button.left, 1)
|
mouse.click(Button.left, 1)
|
||||||
print (TrR)
|
print (TrR)
|
||||||
|
|
||||||
|
|
||||||
except:
|
except:
|
||||||
print ("error")
|
print ("error")
|
||||||
|
|
||||||
g.close()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# close the client socket
|
# close the client socket
|
||||||
#client_socket.close()
|
#client_socket.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user