Skip to content

Instantly share code, notes, and snippets.

@Flameeyes
Created September 4, 2019 10:37
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 Flameeyes/2e90a5923b01b44c2bcdc15186b8efb1 to your computer and use it in GitHub Desktop.
Save Flameeyes/2e90a5923b01b44c2bcdc15186b8efb1 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
#
# SPDX-License-Identifier: MIT
#
# Copyright (c) 2019 Diego Elio Pettenò
import itertools
import serial
all_commands = [
b'$%b\r\n' % bytes(cmd)
for cmd in itertools.product(
range(ord('a'), ord('z')+1), repeat=4)]
first_command = all_commands.index(b'$aaaa\r\n')
def send_command(connection, command):
connection.write(command)
connection.flush()
return connection.readlines()
connection = serial.serial_for_url(
'hwgrep://1a61:3420',
baudrate=19200,
timeout=0.15,
writeTimeout=None,
bytesize=serial.EIGHTBITS,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
xonxoff=False,
rtscts=False,
dsrdtr=False)
send_command(connection, b'$xmem\r\n')
with open('bruteforce.out', 'at') as log:
for cmd in all_commands[first_command:]:
print(f'Sending {cmd!r}')
received = send_command(connection, cmd)
print(f'{received!r}\n')
if received != [b'CMD Fail!\r\n']:
log.write(f'>>> {cmd!r}\n<<< {received!r}\n\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment