As you my know there are two methods
1) using LD_PRELOAD, don`t work if you want to inject into already running (and perhaps even many days) process
2) ptrace. Has the following inherent disadvantages
- target process can be ptraced by somebody else
- victim program can detect ptrace
- you just want to avoid in logs something like ptrace attach of "./a.out"[PID] was attempted by "XXX"
So I developed very rough analogs of famous VirtualAllocEx/VirtualProtectEx + simple hook to hijack execution onto assembly written shellcode to call dlopen/dlsym. Currently only x86_64 supported bcs I am too lazy to rewrite this asm stub
Prerequisites
You must have root privileges and be able to build and load kernel modules. I tested code on kernel 6.8, 5.15 and probably it also can work on 4.x, not sure about more old versions
Lets start lighting the dirty details in reverse order