import sys # NOTE: displaying "non-printing" characters like the # ones below will likely wreak havoc with your terminal, # since many of them are control characters. Think of # them as "Medusa characters": never look directly at them. # # To use this program, pipe it to a file: # $ python example.py > input # # To "look at" what's in input, run it through a converter # (each tool shown below has its merits; try both!): # $ hexdump -C input # OR # $ xxd input # # Once you have a program that produces the string you # want, pipe it into your program like so: # $ ./prog < input # write 100 binary zero bytes to stdout sys.stdout.buffer.write(b"\x00" * 100) # then write the number 0xaa030201 # remember that A32 is little endian, so the byte # order is swapped before the number is interpreted sys.stdout.buffer.write(b"\x01\x02\x03\xaa")