Master the fundamental concepts of binary formats through this focused micro-challenge.
Nearly every binary file format begins with a fixed signature called magic bytes that identifies the format before any parsing happens. ELF executables start with 0x7F followed by the ASCII letters E, L, F. PNG images start with 0x89 P N G. The Linux file command identifies thousands of formats this way.
When the kernel executes a file, the very first thing binfmt_elf does is compare the first four bytes against the ELF magic. If they do not match, the kernel tries other handlers (scripts via #!, for example). This cheap check prevents the loader from misinterpreting garbage as a program header.
Common magic signatures you will see in this track:
7f 45 4c 464d 5a (MZ)50 4b 03 04You will read four byte values from stdin and decide whether they form the ELF magic. This mirrors the first check every binary loader performs, and it is the foundation for parsing ELF headers in the next task. Getting comfortable comparing raw bytes against a known signature is a skill you will use in every subsequent binary analysis exercise.
Read four hexadecimal byte values from stdin (separated by whitespace, e.g. "7f 45 4c 46").
Print exactly:
This mirrors the first check every binary loader performs.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github