I'm following an example in the book Hacking: The Art of Exploitation and I am getting different results to the book.
It seems that the strcpy() function in the example compiles to an instruction like:
0x802384c5 <main+27>: call 0x80482C4 <strcpy@plt>
whereas when I compile the same program it removes the call to the library and replaces it with a series of mov instructions:
0x8048475 <main+25>: mov DWORD PTR [eax],0x6c6c6548
0x804847b <main+31>: mov DWORD PTR [eax+0x4],0x6f57206f
0x8048482 <main+38>: mov DWORD PTR [eax+0x8],0x21646c72
0x8048489 <main+45>: mov WORD PTR [eax+0xc],0xa
I understand that the compiler can make various optimizations, but even though it's the default I've even tried compiling it with -O0 which is supposed to prevent optimisations.
How can I compile the code so it references the external library?
I've not done any C or assembly since uni, so be gentle with me :)
With GCC, you can use the -fno-builtin
(disable all builtins) or -fno-builtin-strcpy
(just disable builtin strcpy
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With