Skip to content

Commit

Permalink
Completed basic net fuzzer
Browse files Browse the repository at this point in the history
  • Loading branch information
candymate committed Oct 15, 2020
1 parent ee2409e commit 5512103
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pyshark

def parse_pcap(filename):
pkts = pyshark.FileCapture(input_file=filename, use_json=True, include_raw=True)#._packets_from_tshark_sync()
pkts = pyshark.FileCapture(input_file=filename, use_json=True, include_raw=True)
return pkts


Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pyshark
nest_asyncio
37 changes: 25 additions & 12 deletions target.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,48 @@
#!/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
pcap_data = b""
while True:
data = conn.recv(1024)
if not data or len(data) != 1024:
break
else:
pcap_data = b""
while True:
data = conn.recv(1024)
if not data:
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("NXT")

conn.sendall(b"NXT")

0 comments on commit 5512103

Please sign in to comment.