I was trying to send a string to another application running on a server (which I do not have access to). The string includes null characters. Now I noticed that when I run the following code in a script,
print('abc\x00\x91\x11\x01123')
the output is: abc\x00\x91\x11123.
Athought when I run the same code in the terminal:
python -c 'print("abc\x00\x91\x11\x01123")'
I get as output: abc�123
Which is the desired output in my case. Why do both outputs differ? How do I get the second output when running the print function in a script?
EDIT: I figured out what was causing the difference. pwntools caused that behaviour. But I still can't really figure out why. The following code:
#!/usr/env/python
import pwn
print('abc\x00\x91\x11\x01123')
results in
abc\x00\x91\x11123
When I do not import pwn, the result is as expected: abc�123.