Jpg Repair with Hexedit

by Vince
in Blog
Hits: 518

According to the description:  "hexedit - view and edit files in hexadecimal or in ASCII".  So how did I end up here?  I was playing a ctf challenge and I came across a picture that was supposed to be a jpg file but was intentionally altered.  Much Googling followed and after trying some fixit-type tools (that didn't work), I ended up on a post that talked about manually repairing the image file with hexedit.

We look at the man pages and it seems simple enough:


Hexedit FILENAME:


What we find that our jpg has been modified to look like a png file.  For the manual repair, I came across several articles that weren't exactly clear but when I searched for jpg hex signature, I came across this Wiki page:


When we scroll down to jpg, we find:


We modify our file to match the Wiki example:


We hit F2 to save and then we're able to open the file:


Honestly, this kind of CTF is outside of my realm but I thought this was pretty cool because it's simple and yet I learned something new.