ptrace截获其他进程系统调用
来源:互联网 发布:微软云计算 编辑:程序博客网 时间:2024/05/21 13:57
int main(int argc, char *argv[]){if (net_init() != 0){printf("net init fail\n");MYLOG("net init fail");return -1;}pid_t traced_process;struct user_regs_struct regs; long ins; if(argc != 2) { printf("Usage: %s <pid to be traced> \n", argv[0], argv[1]); exit(1); }int wStatus = 0; traced_process = atoi(argv[1]);// Now set our optionsptrace(PTRACE_ATTACH, traced_process, NULL, NULL); wait(&wStatus);ptrace(PTRACE_SETOPTIONS, traced_process, NULL, PTRACE_O_TRACESYSGOOD);ptrace(PTRACE_SYSCALL, traced_process, NULL, NULL); // Wait for the child process to stopwhile (1){wait(&wStatus); // Stopped by our ptrace callif(WSTOPSIG(wStatus) == (SIGTRAP | 0x80)){// We are now entering a system callptrace(PTRACE_GETREGS, traced_process, NULL, ®s);long call = regs.orig_rax;//printf("syscall: %4ld \n", call);if(call == SYS_sendmsg){/* Syscall entry */printf("Write called with %ld, %ld, %ld, %ld \n", regs.rdi, regs.rsi, regs.rdx, regs.rcx);char buff[10240];getdata(traced_process, regs.rsi, buff, regs.rdx);printf("%s\n",buff);}// Wait until we're exiting the system callptrace(PTRACE_SYSCALL, traced_process, NULL, NULL);wait(&wStatus);ptrace(PTRACE_GETREGS, traced_process, NULL, ®s);/* Syscall exit */if(call == SYS_sendmsg){printf("Write returned with %ld \n", regs.rax);}}// Stopped for some other reasonelse{printf("child stopped but not for system call.\n");}fflush(stdout); // flush the outputptrace(PTRACE_SYSCALL, traced_process, NULL, NULL);}ptrace(PTRACE_DETACH, traced_process, NULL, NULL);return 0;}
1 0
- ptrace截获其他进程系统调用
- 【进程间通信】系统调用ptrace()和进程跟踪
- 强悍的ptrace——进程追踪,系统调用能手
- ptrace系统调用
- ptrace系统调用
- 如何截获其他进程的消息响应函数
- Linux系统调用--ptrace函数详解
- Linux系统调用--ptrace函数详解
- ptrace 捕捉系统调用 x64 version
- Linux系统调用--ptrace函数详解
- 调用系统函数pthread_cancel取消进程的其他线程
- 截获或替换linux系统调用
- Pin截获socket系统调用初步分析
- 截获系统调用(sys_call_table/VFS)
- playing with ptrace(Part I) 之二 --- 通过ptrace读取系统调用的参数
- 转:Linux系统调用--ptrace函数详解(2)
- [译] 玩转ptrace (一) 拦截系统调用
- 使用ptrace跟踪进程
- js date和字符串之间的转换
- MYSQL入门学习之六:MYSQL的运算符
- 如何使用Github参与开源项目(以eoe的Android客户端为例)
- Test
- VBA示例
- ptrace截获其他进程系统调用
- oracle 中获取字符串的长度并截取长度
- Android中startActivity中的permission检测与UID机制
- 用户暴增下的收入降低,AWS面临尴尬
- 串的模式匹配
- hr1 = 0x80020009 发生意外。
- MYSQL入门学习之七:MYSQL常用函数
- 开发USB产品模块技术指南
- php返回json数据中文显示的问题