Let's say I have a function foo
in ./elf
. I want to hook it with foo_hook
which is located in my shared object. foo
is not exported from ./elf
.
LD_PRELOAD
is useful for hooking functions in shared objects, but is there a generic way to hook functions in the executable? I consider injecting with ptrace not very generic.
Also, foo_hook
doesn't have to be in a shared object, if there is some other simple way (instead of writing shellcode) it is acceptable.
I prefer not to patch ./elf
, but that is not a necessity. Changing the dynamic linker/RPATH is also ok. Rebuilding ./elf
is not possible.
is there a generic way to hook functions in the executable?
No.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.