3

Trying to output the hex value of a nop assembly command \x90 to a file :

wahalez@wahalez:~$ echo $(python -c "print('\x90' * 17)") > ok

When examined with hexdump, the result is :

wahalez@wahalez:~$ hexdump -C ok
00000000  c2 90 c2 90 c2 90 c2 90  c2 90 c2 90 c2 90 c2 90  |................|
*
00000020  c2 90 0a                                          |...|
00000023

Why there are c2 between the 90 in the file ? what resulting this and how to overcome this to print only 0x90 ?

  • 2
    Does this answer your question? [Why is the output of print in python2 and python3 different with the same string?](https://stackoverflow.com/questions/42884251/why-is-the-output-of-print-in-python2-and-python3-different-with-the-same-string) – hurlenko Apr 14 '20 at 12:08
  • Partially, when I use it with bytes it is outputing : wahalez@wahalez:~$ echo $(python -c "print(b'\x90\x90')") > ok wahalez@wahalez:~$ hexdump -C ok 00000000 62 27 5c 78 39 30 5c 78 39 30 27 0a |b'\x90\x90'.| 0000000c –  Apr 14 '20 at 12:12
  • 3
    The second answer from the link above shows how to do it properly. Try this: `echo $(python3 -c 'import sys; sys.stdout.buffer.write(b"\x90" * 17)') > ok` – hurlenko Apr 14 '20 at 12:17

0 Answers0