Reverse Engineering Asked on July 3, 2021
I recently extracted a bunch of raw bytes (from wireshark) into a regular .txt
file.
Because these raw bytes are stored in a text file, all those hex-digits are actually written as ASCII characters on the disk.
Now, I want to interpret the ASCII encoded hex-digits as raw bytes,
because they actually represent a .jpeg
image.
I alredy tried to copy paste the digits into ghex, (I work on Ubuntu) but ghex only allows you to paste data into the interpreted area, not into the byte-manipulation area.
Is there a simple way to do this?
Not really a reverse engineering question but,
Use this in the terminal:
cat textfile.txt | xxd -r -p > image.jpeg
Correct answer by Yotamz on July 3, 2021
Here's my go to in Python3: bytes.fromhex('020a0d')
From there you can interpret how you'd like.
Python 3.7.6 (default, Dec 30 2019, 19:38:26)
>>> hex_str = '020a0d'
>>> bytes.fromhex(hex_str)
b'x02nr'
>>>
As an aside, I've found that storing things as ASCII Hex is one of the better RE habits I've gotten into. You can share the data with others, mark it up, examine it in any editor or IDE. Much better than pushing around an actual binary file.
Answered by pythonpython on July 3, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP