Python3
Suppose we want to create a binary input to pass as stdin into an executable we wish to test in GDB. Assume that the executable receives 2 inputs, the first will be a fixed string, while the second is a payload value that contains 0x10 bytes of the null character (0x00), followed by the raw bytes value \x12\x34\x56\x78
$ python3 - << 'EOF' > payload.bin
import sys
# first input: fixed string
sys.stdout.buffer.write(b"fixed string value")
payload=b'0'*0x10
payload+=b'\x12\x34\x56\x78'
sys.stdout.buffer.write(payload)
EOFWe can now supply the
payload.binfile as input to the executable to test:
gdb> run < payload.binLast updated