'How to convert a byte stream from a POST request to an image?
I am using mitmproxy to sniff out a POST request that sends an image. However, the image seems to be sent as bytes, and I cannot figure out how to convert those bytes back to an image.
Already tried: Copying and pasting the bytes to a file via notepad++ Using hexedit to create a new file with these bytes Use an online hex to image converter
All of the above methods tell me the file is corrupted.
Part of stream:
START
\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00H\x00H\x00\x00\xff\xe1\x07\x88Exif\x00\x00MM\x00*\x00\x00\x00\x08\x00 \x01\x0f\x00\x02\x00\x00\x00\x06\x00\x00\x00z\x01\x10\x00\x02\x00\x00\x00 \x00\x00\x00\x80\x01\x12\x00\x03\x00\x00\x00\x01\x00\x01\x00\x00\x01\x1a\x00\x05\x00\x00\x00\x01\x00\x00\x00\x8a\x01\x1b\x00\x05\x00\x00\x00\x01\x00\x00\x00\x92\x01(\x00\x03\x00\x00\x00\x01\x00\x02\x00\x00\x011\x00\x02\x00\x00\x00\x05\x00\x00\x00\x9a\x012\x00\x02\x00\x00\x00\x14\x00\x00\x00\xa0\x87i\x00\x04\x00\x00\x00\x01\x00\x00\x00\xb4\x00\x00\x00\x00Apple\x00iPhone 7\x00\x00\x00\x00\x00H\x00\x00\x00\x01\x00\x00\x00H\x00\x00\x00\x0113.3\x00\x002022:05:22 20:33:01\x00\x00$\x82\x9a\x00\x05\x00\x00\x00\x01\x00\x00\x02j\x82\x9d\x00\x05\x00\x00\x00\x01\x00\x00\x02r\x88"\x00\x03\x00\x00\x00\x01\x00\x02\x00\x00\x88'\x00\x03\x00\x00\x00\x01\x01\x90\x00\x00\x90\x00\x00\x07\x00\x00\x00\x040231\x90\x03\x00\x02\x00\x00\x00\x14\x00\x00\x02z\x90\x04\x00\x02\x00\x00\x00\x14\x00\x00\x02\x8e\x90\x10\x00\x02\x00\x00\x00\x07\x00\x00\x02\xa2\x90\x11\x00\x02\x00\x00\x00\x07\x00\x00\x02\xaa\x90\x12\x00\x02\x00\x00\x00\x07\x00\x00\x02\xb2\x91\x01\x00\x07\x00\x00\x00\x04\x01\x02\x03\x00\x92\x01\x00
\x00\x00\x00\x01\x00\x00\x02\xba\x92\x02\x00\x05\x00\x00\x00\x01\x00\x00\x02\xc2\x92\x03\x00
\x00\x00\x00\x01\x00\x00\x02\xca\x92\x04\x00
END:
\x18\xb2\x12\x04\x8f\xd3\xb50.%\xaa\xa22K\xf3`\xf1\xfe5LHX\x90;;JN\xc8\x95\xbe\xef\x04\x90{\x9a\x82\x99*\xc9\x85b@ \x0c\x81Mnb\xc7\xb7\x9c\xdf\xbb\x0f\x90y9\xef\xedC\x924Mu/\xad\xb4ko\xb0\xe4\xefm\xb8\xf4\xc7\xa1\xa6\x99\x99\x08\xde\xd9F\xc7\xc8s\xf8-U\xc6M\x04\xca\xc3\xe5\\s\xcf=y\xc5R\xb8\x1a\xd6\xf6\xaa \xf2\xf8i\x1b\xbf8\xab\x00\x8c\x86Uw\xce{\xe0\xfb\xe2\xb3RD\x12d\xc6\xbed\x84\xb8\x07\xa7\xbf\xadY\xa2,0\x89|\xb6\x95|\xc0\xfc\xe4\xf5\xf6\xac\xc2\xf6 Z\x18cT(w1\x010x\x1b\xbaf\x81^\xe5\xa8\xad\x01\x901b\xaf\x1f\x18\x1fw\x8fJ \xd4\x8a#\xba\x0f=\xd0\x12\xc0\xb7^\xfe\x99\xa0Vf\x8f\x95!\x825b\xa3\x1b\x8bapX\x0e\xd9\xad\x00\x86\x063<|\x90\x1b\x81\xcfLT2\xedm\x0bW\x08N\xe8\x83\x10\xc4\xf1\xc7\x18\xadX\x91V\xee5\xb7\x80(;\x99\xdba8\xfdj4(\xff\xd9
The image is an jpg, and the bytes seem to match JPG standard (Starting with xff, ending with xd9.)
Any help would be greatly appreciated.
Solution 1:[1]
Alright, got it working:
I found this link: https://laurentmeyer.medium.com/understanding-jpeg-format-the-hard-way-57dd34abe2f1
Checked the HEX data of my request, copied the hex codes between xffxd8 and xffxd9, then used a tool on codepen to convert it back into an image.
To convert it back to an image, that worked.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Martijn Deleij |
