免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1679 | 回复: 1
打印 上一主题 下一主题

有关监控系统输入的内核编程问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-27 17:13 |只看该作者 |倒序浏览
我希望实现监控别人系统输入的功能,按照开源项目Sebek的说法可以直接hook sys_read
我就是这么做的
代码如下
asmlinkage ssize_t NewRead (unsigned int fd, char *buf, size_t count)
{
static unsigned int i = 0;
ssize_t nRes;
  //----- run original sys_read....
nRes = pOldRead(fd, buf, count);
  //----- check for error and interest
if(nRes < 1 )
{
  goto OUT;
}
if(NULL!=pFile)
{
  if(fd &&count>1)
  {
   memcpy(Buffer,buf,1023>count?count:1023);
   Buffer[1023>count?count:1023]=0;
   klib_fprintf(pFile,"%u :SysRead %u bytes: \"%s\" .\r\n",i,(unsigned long)count,Buffer);
   i++;
  }
}
OUT:
return nRes;  
}
但是每次这个模块安装之后几秒钟必定挂掉
然后查看的输出信息很复杂
根本和用户输入无关
我想问
1 如何判断这个read函数调用的初始进程是谁
2 我的代码为什么会造成系统崩溃
第一次来这个论坛发贴
希望各位牛人多帮忙
btw klib_fprintf是我自己写的内核态写文件的函数代码

论坛徽章:
0
2 [报告]
发表于 2008-04-27 17:15 |只看该作者

回复 #1 blackbeast 的帖子

再给大家贴一些我在日志文件中读到的信息片段  谁知道这些究竟是什么东西
如何过滤掉
71 :SysRead 129 bytes: "Name:        hald-addon-keyb
State:        S (sleeping)
SleepAVG:        78%
Tgid:        4139
Pid:        4139
PPid:        4125
TracerPid:        0
Uid:        107        107        107        107
Gid:        11" .

72 :SysRead 129 bytes: "Name:        hald-addon-acpi
State:        S (sleeping)
SleepAVG:        78%
Tgid:        4131
Pid:        4131
PPid:        4125
TracerPid:        0
Uid:        107        107        107        107
Gid:        11" .

73 :SysRead 129 bytes: "Name:        hald-runner
State:        S (sleeping)
SleepAVG:        47%
Tgid:        4125
Pid:        4125
PPid:        4124
TracerPid:        0
Uid:        0        0        0        0
Gid:        0        0        0        0
FDSize" .

74 :SysRead 129 bytes: "Name:        hald
State:        S (sleeping)
SleepAVG:        89%
Tgid:        4124
Pid:        4124
PPid:        1
TracerPid:        0
Uid:        107        107        107        107
Gid:        114        114        114        114
" .

75 :SysRead 129 bytes: "Name:        dbus-daemon
State:        S (sleeping)
SleepAVG:        60%
Tgid:        4108
Pid:        4108
PPid:        1
TracerPid:        0
Uid:        103        103        103        103
Gid:        106        106        1" .

76 :SysRead 129 bytes: "Name:        klogd
State:        S (sleeping)
SleepAVG:        78%
Tgid:        4087
Pid:        4087
PPid:        1
TracerPid:        0
Uid:        102        102        102        102
Gid:        103        103        103        103" .
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP