Skip to content

Instantly share code, notes, and snippets.

@V33RU
Forked from RandomInsano/fuzzer.py
Last active November 9, 2023 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save V33RU/5c98cbd4adaa5a541eb80820d909f6f4 to your computer and use it in GitHub Desktop.
Save V33RU/5c98cbd4adaa5a541eb80820d909f6f4 to your computer and use it in GitHub Desktop.
Serial fuzzer written in Python3
#!/usr/bin/env python3
import serial
import binascii
# Open serial port
ser = serial.Serial(
port=input("Enter the USB /dev port"),
baudrate=115200,
timeout=0.005
)
def read_serial(ser):
''' Read any output it might have produced'''
output = bytearray()
while True:
inp = ser.read(size=1) #read a byte
output += inp
if len(inp) < 1:
return bytearray(output)
def send_command(command):
''' Push out a command to the serial port, get data back '''
output = bytearray()
for byte in command:
ser.write([byte])
output += read_serial(ser)
return output
def increment(counter):
carry = 0
for i in range(len(counter)):
byte = counter[i]
if byte == 255:
byte = 0
carry = 1
elif carry == 1:
byte += carry
carry = 0
else:
byte += 1
counter[i] = byte
if carry is not 1:
break
return counter
counter = [0, 0, 0, 0, 0, 0, 0]
print()
while True:
message = bytearray(counter)
print("\rSending: {0} ".format(binascii.hexlify(message)), end='')
response = send_command(message)
if len(response) > 0:
print("\nReceived: {0}\n".format(binascii.hexlify(response)))
counter = increment(counter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment