Hex Editing

know where to edit, directly edit using hex editor.
only allows in-place editing. No adding new bytes.
But can rewrite padding bytes, dead code, or unused data.

LD_PRELOAD: specify libraries for the linker to load before.

Injecting a code section

By appending bytes to the end of the binary.
Create a section header.
Create a program header.
Rename the section name in .shstrtab
Call the injected code.

PT_NOTE header saft to overwrite.
Need to change type to SHT_PROGBITS.

Injected code will run when the program starts.

Hijacking GOT entries

Replace GOT entry to replace a library call with an injected function.

Only work for library calls.
directly modify direct call instructions.

Position Independent Executables (PIE)