I'm working on reverse engineering for a homework. The instructor provides some object files(.o) and an executable file. It seems like that those files are all in hexadecimal machine codes. The goal is to write the c code that would compile to this machine code.
The code looks like this (an excerpt from the file):
7f45 4c46 0201 0100 0000 0000 0000 0000
0200 3e00 0100 0000 3004 4000 0000 0000
4000 0000 0000 0000 7819 0000 0000 0000
0000 0000 4000 3800 0900 4000 1f00 1e00
0600 0000 0500 0000 4000 0000 0000 0000
4000 4000 0000 0000 4000 4000 0000 0000
f801 0000 0000 0000 f801 0000 0000 0000
0800 0000 0000 0000 0300 0000 0400 0000
3802 0000 0000 0000 3802 4000 0000 0000
3802 4000 0000 0000 1c00 0000 0000 0000
1c00 0000 0000 0000 0100 0000 0000 0000
0100 0000 0500 0000 0000 0000 0000 0000
0000 4000 0000 0000 0000 4000 0000 0000
d407 0000 0000 0000 d407 0000 0000 0000
0000 2000 0000 0000 0100 0000 0600 0000
100e 0000 0000 0000 100e 6000 0000 0000
100e 6000 0000 0000 1c02 0000 0000 0000
I was only taught to read and do reverse engineering for assembly code. How could I deal with these hex codes? (PS. I'm on a windows laptop) Is there any method that could turn it into assembly codes? Or is there any ways that I could run it, so I can see the input and output?
Thank you so much for your help!
Your file looks like an executable 64bit ELF for Linux. In order to use Linux tools on your Windows laptop you might need to install the emulator WSL first. Then inspect the format of your file in the WSL console with readelf:
It reports
Errorbecause the provided code is incomplete. Tryfile Vickywith your complete assignment file and if it says that the program is ELF64 executable, disassemble it withobjdump -drwC -Mintel Vicky, as @Peter Cordes suggested.The more difficult part of your homework will be then to comprehend meaning of disassembled instructions and formulate an equivalent C code.