as part of a homework assignment for my security class, I’m supposed to “add a simple function which prints “Hello, World!” to a compiled C Linux binary”. The binary provided is just a compiled main function with 10 NOPs in it.
Normally, I would have written the code needed into the NOP section directly, but we were explicitly told to add a new function to the program.
I have no idea how to do that. I tried putting some code at the end of the binary, but this seems to destroy it. Could somebody clear this up for me?
EDIT: This question sounds somewhat similar.
EDIT 2: Searching for “ELF injection” yields many interesting results.
Perhaps you need to learn more about ELF (espacially if you want to make a program able to “infect” any Linux binary, not just the simple one you’ve got).
The Linux ABI X86-64 supplement could also be useful, and also the Linux Assembly Howto