怎么把截获的系统调用实时地记录到文件???
时间:2003-04-08
来源:互联网
作者: cuicn_21 发布时间: 2003-04-08
作者: cuicn_21 发布时间: 2003-04-08
作者: owl 发布时间: 2003-04-15
作者: keenor 发布时间: 2003-04-16
/************************************* * * kopen.c by keenor [email protected] * gcc -O2 -I/usr/src/linux/include -c -o kopen.o kopen.c * 4/16/2003 * * *********************************** */ #ifndef __KERNEL__ #define __KERNEL__ #endif #ifndef MODULE #define MODULE #endif #include <linux/modversions.h> #include <sys/syscall.h> #include <linux/kernel.h> #include <linux/module.h> #include <asm-i386/uaccess.h> #include <asm-i386/segment.h> #include <linux/types.h> #include <linux/unistd.h> #include <linux/fs.h> extern void *sys_call_table[]; int (*open)(char *, int, int); int kread_init(){ open = sys_call_table[SYS_open]; // printk("<1>%s%x\n", "open=", (unsigned long)open); mm_segment_t old_fs_value=get_fs(); set_fs(get_ds()); int res = open("/aaa", O_CREAT|O_RDWR|O_EXCL, 0640); // printk("<1>%s%d\n", "res of open = ", res); set_fs(old_fs_value); return 0; } void kread_cleanup(){ // } module_init(kread_init); module_exit(kread_cleanup); MODULE_LICENSE("GPL");
注意:redhat等某些dist的某些版本内核并不输出 sys_call_table 符号,这种情况下你可以考虑升级内核:P,或者把原来的内核原码的sys_call_table输出(还是升级内核好

作者: keenor 发布时间: 2003-04-16
作者: cuicn_21 发布时间: 2003-04-22
最初由 owl 发表 做个新的系统调用,创建一个内核模块,拦截所有系统调用,然后用printk打印出来。编写应用程序执行这个调用,然后将这个程序的输出重定向到某个文件不就行了。 |
请问你有没有实现过截获所有的系统调用,我这么做了,但是执行的时候总是出错,请指教!谢谢!
作者: bhlyy1976 发布时间: 2003-05-01
你的初始化里面的code只能算个定义。
但结果不是最终的。
作者: ZeroC 发布时间: 2003-05-09
我写那个代码的时候确实太有点无知和狂妄了。这样的帖子留着只能让人笑话,教人误入歧途。后来总想把这个帖删了,可是已经超过了可以删除的时间。希望斑竹看见的话把我那个code删掉,多谢!
作者: keenor 发布时间: 2003-05-09
呵呵
作者: ZeroC 发布时间: 2003-05-09
还有,我不懂什么叫做overflow,请指教
多谢!
作者: keenor 发布时间: 2003-05-10
因为你的point的指向, 所以这么说的!
作者: ZeroC 发布时间: 2003-05-10
还有,溢出我也不懂,请教什么是溢出呢?是什么溢出呢?
多谢!
作者: keenor 发布时间: 2003-05-10
int kread_init(){
open = sys_call_table[SYS_open];
// printk("<1>%s%x\n", "open=", (unsigned long)open);
mm_segment_t old_fs_value=get_fs();
set_fs(get_ds());
int res = open("/aaa", O_CREAT|O_RDWR|O_EXCL, 0640);
// printk("<1>%s%d\n", "res of open = ", res);
set_fs(old_fs_value);
return 0;
}
void kread_cleanup(){
//
}
-------------------------------------------------------------------
overflow 你的gdb 吧, 不谈。
-----------------------------------------------------------------
我想该写写看
-----------------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
/* SAME TO U
extern void* sys_call_table[];
int (*orig_system)(const char *path);
int find_system(const char *path)
{
return 0;
}
int init_module(void)
{
orig_system=sys_call_table[SYS_system];
sys_call_table[SYS_system]=find_system;
return 0;
}
void cleanup_module(void)
{
sys_call_table[SYS_system]=orig_system;
}
---------------
大多方法都类似,也许是学习老外吧。呵呵
参照LKM_HACKER方法。
作者: ZeroC 发布时间: 2003-05-10
作者: keenor 发布时间: 2003-05-10
呵呵。。。。
作者: ZeroC 发布时间: 2003-05-10

作者: l33t 发布时间: 2003-05-10
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28