Graceful way to write unencoded binary to stdout?
From
Bryn@EOTLBBS to
All on Sun Nov 15 06:57:38 2026
Hi!
For context, I've been working through the reverse engineering and binary exploitation wargames over at pwn.college. Took it as an opportunity to start getting more comfortable with python 3 (last significant work I did with python was with python 2)
As you might have surmised by the title and the fact that I had much more experience with python 2, the way python handles strings and byte strings now irks me. For many of the flags, one has to put binary data and pipe it in to stdin of the program you are reverse engineering or exploiting -- this is all fine and dandy if your payload within ASCII's limits of the value being <128 per byte, and a simple print(b'payload'.decode(),end='',sep='') works well. Beyond writing to a file in 'wb' mode with open or using sys.stdout.buffer.write(), i've found no easy way to use the print() statement with any unicode encoding that doesn't end up adding extra bytes I don't want in my output that doesn't involve using a community package.
Is this just the state of handling bytestrings in python in 2026, or is there a more graceful/pythonic way to write binary data to stdout I am not clued in on?
TIA
xo
Bryn
---
■ Synchronet ■ End Of The Line BBS - endofthelinebbs.com