-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSignalCommandSamples.py
130 lines (71 loc) · 2.67 KB
/
SignalCommandSamples.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import socket
import sys
import time
from datetime import datetime
TIME_FORMAT4FILES = '%Y-%m-%d-%H-%M-%S'
datetime_start = datetime.now().strftime(TIME_FORMAT4FILES)
time.sleep(3)
# msg = bytes('end'.encode())
# new_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
new_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
new_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
new_socket.bind(('', 5000))
msg = bytes('set udp 192.168.85.67'.encode())
# new_socket.sendto(msg, ('192.168.85.255', 3000))
new_socket.sendto(msg, ('255.255.255.255', 3000))
msg = bytes('set ftp 192.168.85.67'.encode())
new_socket.sendto(msg, ('255.255.255.255', 3000))
msg = bytes('start'.encode())
# new_socket.sendto(msg, ('192.168.85.255', 3000))
new_socket.sendto(msg, ('255.255.255.255', 3000))
time.sleep(600)
msg = bytes('end'.encode())
new_socket.sendto(msg, ('255.255.255.255', 3000))
new_socket.sendto(msg, ('255.255.255.255', 3000))
time.sleep(2)
# datetime_start = '2019-10-02-14-00-20'
datetime_end = '2019-11-01-00-00-00'
msg = bytes(f'upload {datetime_start} {datetime_end}'.encode())
new_socket.sendto(msg, ('255.255.255.255', 3000))
# new_socket.sendto(msg, ('192.168.255.255', 3000))
msg = bytes('status'.encode())
new_socket.sendto(msg, ('255.255.255.255', 3000))
# sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# server_address = ('', 4002)
# sock.bind(server_address)
# sock.connect(('192.168.31.206', 3000))
# opponent_address = ('255.255.255.255', 3000)
# # sock.sendto(opponent_address)
# msg = bytes('start'.encode())
# sock.send(msg)
# sock.sendto(msg, opponent_address)
# sock.connect(('0.0.0.0', 3000))
# sock.connect(opponent_address)
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
client.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.bind(("", 37020))
client.sendto(msg, ('<broadcast>', 3000))
client.sendto(msg, ('255.255.255.255', 3000))
client.sendto(msg, ('192.168.31.206', 3000))
# new_socket.sendto(msg, ('192.168.0.255', 4002))
new_socket.sendto(msg, ('192.168.31.206', 3000))
new_socket.connect(('192.168.31.206', 3000))
new_socket.send(msg)
def send_command(command):
command_encoded = bytes(command.encode())
print(command_encoded)
sock.send(command_encoded)
time.sleep(1)
# sock.close()
send_command('start')
send_command('end')
send_command('status')
sock.sendall(b'start')
sock.connect(("www.python.org", 80))
socket.gethostname()
sock.listen()
new_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
if ip == '':
new_socket.bind((ip, port))
sock = socket.create_connection(('localhost', 10002))