cybersecurity · intermediate · ~15 min · safe pentest lab

Is the ELF 64-bit?

Read the ELF class field.

Challenge

The EI_CLASS byte at offset 4 is 1 for 32-bit, 2 for 64-bit. Implement int elf_is_64bit(const unsigned char *b) returning 1 if b[4] == 2, else 0.

Starter code

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

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