-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtarget.py
executable file
·52 lines (38 loc) · 1.1 KB
/
target.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
#!/usr/bin/python3
import socket
import pyshark
import nest_asyncio
import config
import parser
if __name__ == "__main__":
# pyshark async problem resolve
nest_asyncio.apply()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as conn:
conn.connect((config.HOST_IP, config.FUZZ_PORT))
# recv pcap data
while True:
pcap_data = b""
while True:
data = conn.recv(1024)
if not data:
break
# if len(data) % 1024 == 0
if data == b"over":
break
pcap_data += data
if len(data) != 1024:
break
if config.DEBUG:
print("pcap len :", len(pcap_data))
# save file and parse it
with open("rcv.pcap", "wb") as f:
f.write(pcap_data)
pkts = parser.parse_pcap("rcv.pcap")
if config.DEBUG:
pkts.set_debug()
raw_sock = socket.socket(socket.AF_PACKET, socket.SOCK_RAW)
raw_sock.bind((config.INTERFACE_NAME, 0))
for pkt in pkts:
raw_sock.send(bytearray.fromhex(pkt.frame_raw.value))
pkts.close()
conn.sendall(b"NXT")