因此需要有一种更加深入且通用的方式来对 APP 进行全面的监测和绕过。本文即为对这类方案的一些探索和实践。
static int __init init_uprobe_sample(void){int ret;struct path path; ret = kern_path(DEBUGGEE_FILE, LOOKUP_FOLLOW, &path);if (ret) {return -1;} debuggee_inode = igrab(path.dentry->d_inode);path_put(&path); ret = uprobe_register(debuggee_inode,DEBUGGEE_FILE_OFFSET, &uc);if (r...
int ret; struct path path; ret = kern_path(DEBUGGEE_FILE, LOOKUP_FOLLOW, &path); if (ret) { return -1; } debuggee_inode = igrab(path.dentry->d_inode); path_put(&path); ret = uprobe_register(debuggee_inode, DEBUGGEE_FILE_OFFSET, &uc); if (ret < 0) { return -1; } printk...
printk(KERN_INFO"pid: %d\n",current->pid); printk(KERN_INFO"tgid: %d\n",current->tgid); printk(KERN_INFO"prio: %d\n",current->prio);return0; } module_init(print_init); module_exit(print_exit); Makefile obj-m:=module2.o CURRENT_PATH:=$(shell pwd) LINUX_KERNEL_PATH:=/usr/sr...
("Dual BSD/GPL");#define_DEBUG#ifdef _DEBUG#definekprintk(fmt,args...) printk(KERN_ALERT fmt,##args)#definekprintf(fmt,args...) printf(fmt,##args)#definekperror(str) perror(str)#else#definekprintk#definekprintf#definekperror#endif/*Function declaration*/long* get_sys_call_table(void)...
打印信息的级别有好几个,从 DEBUG 到 EMERG,这里使用的是 KERN_ALERT,方便查看打印信息。 创建Kconfig 文件 这个文件是用来对内核进行配置的,当执行 make menuconfig 指令的时候,这个文件就被解析。 先创建文件: 代码语言:javascript 代码运行次数:0 运行 ...
5. ubifs中使用的user_path接口,和kern_path具有相同功能; 6. dirname是挂载目录,比如挂载到/mnt/test目录,则此处dirname="/mnt/test"; 7. 通过如下调用kern_path->filename_loopup->path_loopupat找到struct path, 8. kern_path()找到挂载点的目录项,即此时path.dentry->d_iname=test; ...
KERN_DIR中的内核要事先配置、编译, 为了能编译内核, 要先设置下列环境变量: # 2.1 ARCH, 比如: export ARCH=arm64 # 2.2 CROSS_COMPILE, 比如: export CROSS_COMPILE=aarch64-linux-gnu- # 2.3 PATH, 比如: export PATH=$PATH:/home/book/100ask_roc-rk3399-pc/ToolChain-6.3.1/gcc-linaro-6.3.1-...
printk(KERN_INFO"get info");return0; }staticlonga3_rootkit_ioctl(structfile * __file,unsignedintcmd,unsignedlongparam){return0; } rootkit.h #include<linux/module.h>#include<linux/kernel.h>#include<linux/init.h>#include<linux/fs.h>#include<linux/device.h>// a difficult-to-detect name#...
printk(KERN_ERR "schedule_timeout: wrong timeout " "value %lx\n", timeout); dump_stack(); current->state = TASK_RUNNING; goto out; } } /* 设置超时时间 */ expire = timeout + jiffies; /* 初始化定时器,超时处理函数是 process_timeout,后面再补充说明一下这个函数 */ ...