0

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?

0

2 Answers 2

0

Not really a reverse engineering question but,

Use this in the terminal:

cat textfile.txt | xxd -r -p > image.jpeg

2
  • Thanks, but for which SE site is the question most appropriate?
    – J.Doe
    Commented Mar 24, 2020 at 17:13
  • It is a general technical question. I'd say that it belongs on the main StackOverflow site
    – Yotamz
    Commented Mar 24, 2020 at 17:21
1

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'\x02\n\r'
>>> 

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.

1
  • You could also paste the bytes into something like CyberChef; convert to raw bytes and download the resultant file. Commented Dec 1, 2020 at 23:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.