cybersecurity · intermediate · ~15 min · safe pentest lab

Is it an ELF file?

Recognise the ELF magic number.

Challenge

ELF files start with the magic bytes 0x7F 'E' 'L' 'F'. Implement int is_elf(const unsigned char *b) returning 1 if the first four bytes match, else 0.

Starter code

int is_elf(const unsigned char *b) {
    /* TODO */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.