mirror of
https://github.com/h3xduck/TripleCross.git
synced 2025-12-26 03:13:07 +08:00
Successfully added uprobes calculation and hooking at arbitrary function of execve_hijack.
This commit is contained in:
35
src/user/include/modules/injection.h
Normal file
35
src/user/include/modules/injection.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef __MOD_INJECTION_H
|
||||
#define __MOD_INJECTION_H
|
||||
|
||||
#include <linux/bpf.h>
|
||||
#include <bpf/bpf.h>
|
||||
#include <bpf/libbpf.h>
|
||||
#include "kit.skel.h"
|
||||
#include "common.h"
|
||||
|
||||
//Connections
|
||||
int attach_uprobe_execute_command(struct kit_bpf *skel){
|
||||
skel->links.uprobe_execute_command = bpf_program__attach_uprobe(skel->progs.uprobe_execute_command, false, -1, "/home/osboxes/TFG/src/helpers/execve_hijack", 4992);
|
||||
printf("SET\n");
|
||||
return libbpf_get_error(skel->links.tp_sys_enter_execve);
|
||||
}
|
||||
|
||||
int attach_injection_all(struct kit_bpf *skel){
|
||||
return attach_uprobe_execute_command(skel);
|
||||
}
|
||||
|
||||
|
||||
int detach_uprobe_execute_command(struct kit_bpf *skel){
|
||||
int err = detach_link_generic(skel->links.uprobe_execute_command);
|
||||
if(err<0){
|
||||
fprintf(stderr, "Failed to detach fs link\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int detach_injection_all(struct kit_bpf *skel){
|
||||
return detach_uprobe_execute_command(skel);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "sched.h"
|
||||
#include "fs.h"
|
||||
#include "exec.h"
|
||||
#include "injection.h"
|
||||
|
||||
module_config_t module_config = {
|
||||
.xdp_module = {
|
||||
@@ -22,6 +23,10 @@ module_config_t module_config = {
|
||||
.exec_module = {
|
||||
.all = ON,
|
||||
.tp_sys_enter_execve = OFF
|
||||
},
|
||||
.injection_module = {
|
||||
.all = ON,
|
||||
.uprobe_execute_command = OFF
|
||||
}
|
||||
|
||||
};
|
||||
@@ -34,7 +39,8 @@ module_config_attr_t module_config_attr = {
|
||||
},
|
||||
.sched_module = {},
|
||||
.fs_module = {},
|
||||
.exec_module = {}
|
||||
.exec_module = {},
|
||||
.injection_module = {}
|
||||
};
|
||||
|
||||
|
||||
@@ -78,6 +84,13 @@ int setup_all_modules(){
|
||||
}
|
||||
if(ret!=0) return -1;
|
||||
|
||||
//INJECTION
|
||||
if(config.injection_module.all == ON){
|
||||
ret = attach_injection_all(attr.skel);
|
||||
}else{
|
||||
if(config.injection_module.uprobe_execute_command == ON) ret = attach_uprobe_execute_command(attr.skel);
|
||||
}
|
||||
if(ret!=0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,11 @@ typedef struct module_config_t{
|
||||
char tp_sys_enter_execve;
|
||||
}exec_module;
|
||||
|
||||
struct injection_module {
|
||||
char all;
|
||||
char uprobe_execute_command;
|
||||
}injection_module;
|
||||
|
||||
} module_config_t;
|
||||
|
||||
//Configuration struct. Used by the module manager to
|
||||
@@ -58,6 +63,10 @@ typedef struct module_config_attr_t{
|
||||
void* __empty;
|
||||
}exec_module;
|
||||
|
||||
struct injection_module_attr {
|
||||
void* __empty;
|
||||
}injection_module;
|
||||
|
||||
} module_config_attr_t;
|
||||
|
||||
//An unique module configutation struct and attr
|
||||
|
||||
Reference in New Issue
Block a user