forked from FlagBrew/PKSM-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsendScript.py
More file actions
43 lines (32 loc) · 960 Bytes
/
sendScript.py
File metadata and controls
43 lines (32 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
import socket, os, sys, struct
def send(file, ip):
host = ip
port = 34567
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.sendall(struct.pack('i', os.fstat(file.fileno()).st_size))
s.close()
input("Press enter to send data")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
data = file.read()
s.sendall(data)
s.close()
def main(args):
filename = ""
ip = ""
argCount = len(args)
if argCount == 1:
filename = input("Please enter the filename of the script to send: ")
ip = input("Please enter PKSM's IP: ")
elif argCount == 2:
filename = args[1]
ip = input("Please enter PKSM's IP: ")
elif argCount == 3:
filename = args[1]
ip = sys.argv[2]
with open(filename,'rb') as f:
send(f, ip)
if __name__ == '__main__':
main(sys.argv)