Convert a hex file to text or code

Hi guys I have a open source hex file that I would like to see what the code is doing, the source file is supposed to be available but all it sees is coming soon.

I have tried some converters online but no luck as I dont know what type of hex file it is etc.

Is there a way to read it ?

Many thanks
M…

firmware.txt (243 KB)

Can you please provide a link to where you got this file.

It's an Intel hex file. https://en.wikipedia.org/wiki/Intel_HEX

Undermentioned: Hi guys I have a open source hex file that I would like to see what the code is doing, the source file is supposed to be available but all it sees is coming soon.

I have tried some converters online but no luck as I dont know what type of hex file it is etc.

Is there a way to read it ?

Many thanks M.....

You can dissasemble the code, but unless you know how to read assembler you're still not going to really know what the code is doing. You can't get back to the original source in C++ from the hex file.

Realistically, when people do "reverse engineering", they usually figure-out what the code is doing and they start-over and write a new program that does he same thing. (Or, they steal the source code or simply copy the hex code.)

You do have to know what it runs on... C/C++ is portable (with some limitations) so you can compile a C/C++ program to run on an Arduino, PC, or Mac, but the machine language hex code only runs on the machine it's intended for. In other words, the hex code is meaningless unless you know what the machine language is.

You can open any file in a [u]Hex Editor[/u] and the Hex Editor will show the ASCII character for any values that can be converted to text (including values that don't represent text). So, if you find a readable string you can read it, or you can change it with the hex editor.

There is a one-to-one relationship between assembly language and machine language (the hex file). That is, every assembly language instruction has a corresponding machine language instruction so it's fairly trivial to [u]disassemble[/u] the machine language and convert it to assembly language.

There are no variables, labels, or comments in machine code, so variables & labels will be simply replaced by memory addresses and there will be no comments in the disassembled code. And, I don't know if there's a disassembler for the AVR or if you'd have to write it yourself or do it by hand.

There are also [u]decompilers[/u] for converting machine code to C or C++. But, I have no idea if you can find one for the AVR/Arduino.

There is NOT a one-to-one relationship between C/C++ and machine language. That means you can't get back the exact-original C/C++ program, but you can get one that functions the same when re-complied. An analogy would be if you gave a homework assignment to write a program that does some particular thing, every student's program would be slightly different although they all do the same thing.

There's more than one way to make a loop and the decompiler might choose a different method from what the original programmer used. Again since there are no variable names in machine code, You might get variable names like "Variable1" and "Variable2" instead of original-meaningful names like "RedLED" or "StartTime". And of course, no comments.

You could decompile to C, Java, or BASIC without knowing the original language used to write the program.

P.S. You might have to convert the Intel hex file to "raw" hex before using any of these tools. (You'd have to check the specs/instructions for the decompiler or disassembler.) I opened it with a hex editor, and because of the Intel formatting I'm not seeing the "real" hex values.... The hex file looks nothing like a "typical" exe file, etc.

Looks a lot like http://www.cmucam.org/attachments/download/1155/pixy_firmware-2.0.8.hex give or take a few bytes.

I think the source is here: https://github.com/charmedlabs/pixy/tree/master/src

johnwasser: Looks a lot like http://www.cmucam.org/attachments/download/1155/pixy_firmware-2.0.8.hex give or take a few bytes.

I think the source is here: https://github.com/charmedlabs/pixy/tree/master/src

OK, how did you find that?

Same as all the replies received.......... from doing their homework. :) :)

Delta_G: OK, how did you find that?

The hex file starts with:

:020000041400E6
:10000000F0790020D900001400F002F800F08AF81E
:100010000AA090E8000C82448344AAF10107DA4563

so I did a Google search for "10000000F0790020D900001400F002F800F08AF81E". That turned up http://ebooks-gratuits.me/recherche/Firmware/txt/4 but I could not find the match on that page. I next tried a search for "020000041400E6" and that turned up the same site. A search for that string on that site turned up two links to the CMUCam site (V2.0.17-lego and V2.0.8 ): http://ebooks-gratuits.me/recherche/020000041400E6/txt/1 From those results it was fairly clear that the hex file was some version of Pixy firmware.