首页
社区
课程
招聘
[原创]SMM Rootkit初步 - 读写SMRAM(带你迈入CPU级Rootkit之门)
发表于: 2009-3-29 14:37 49664

[原创]SMM Rootkit初步 - 读写SMRAM(带你迈入CPU级Rootkit之门)

2009-3-29 14:37
49664
收藏
免费 7
支持
分享
最新回复 (79)
雪    币: 0
活跃值: (954)
能力值: ( LV3,RANK:30 )
在线值:
发帖
回帖
粉丝
51
老师果然厉害!!!
2009-6-5 10:59
0
雪    币: 157
活跃值: (416)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
52
太强大了!俺水平有限,不能学习,只能收藏了!
2009-6-8 14:22
0
雪    币: 186
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
53
SMM LOCK的问题是可以绕过的。看看下面的PRESENATION.

http://cansecwest.com/csw09/csw09-duflot.pdf
2009-7-15 00:28
0
雪    币: 114
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
54
哎,只能收藏
太可怕;
2009-7-15 16:33
0
雪    币: 296
活跃值: (89)
能力值: ( LV15,RANK:340 )
在线值:
发帖
回帖
粉丝
55
这个PPT以前我也看过,里面提到的 MTRRs 方法有篇论文《Attacking SMM Memory via Intel® CPU Cache Poisoning》专门谈过,Windows下不行。
改写SMBASE重新映射SMM内存我虚拟机中没试出来,也许他们模拟得都没那么完善(实际上VM6中光触发SMI就不知飞哪去了)。
这是关于改写SMBASE的一段资料(已经忘了从哪抄出来的了),有兴趣的继续
The attacker has to modify the caching strategy of the SMRAM location (example if SMBASE=0xa0000).
"movl $0x06060606, %eax"
"movl $0x0, %edx"
"movl $0x259, $ecx"
"wrmsr"


Objection: But wait! Only the data cache is modified, not the instruction cache, so the modification should have no effect.

True, but the instruction caches will probably be flushed during mode transitions as running 16-bit instructions in a 32-bit (or 64-bit) mode should not be advised. In that case, instructions are reloaded from… the L1 data cache.

The SMI handler can flush the cache before exiting!
No SMI handler that I have seen does that.
Anyway if the handler did so it would not be a major problem as cache flushing only ensures SMI handler confidentiality (not integrity).

CPU SMBASE register
(SMI handler base address SMBASE+0x8000)
2009-7-15 20:31
0
雪    币: 186
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
56
回楼上,我也只是看过PPT,没自己做过. 不过准备在QEMU OR BOCHS 下面弄弄SMM. 有兴趣的话 ,多交流下.
2009-7-15 22:16
0
雪    币: 186
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
57
关于切换到SMM的一个帖子:
http://www.linuxsir.org/bbs/showthread.php?t=192951
2009-7-16 01:33
0
雪    币: 296
活跃值: (89)
能力值: ( LV15,RANK:340 )
在线值:
发帖
回帖
粉丝
58
SMM相关的东西我已经有段时间没接触了,自从上次重装了系统,也懒得去装VM6搭建测试环境。而且进入SMM后如何调试也是个问题,要么RSM后无声无息的返回,要么直接卡死重启...一来二去的,我耐心已经被两大VM折磨得差不多了。

不过要是也有“同好”那就再好不过了,我这砖头抛出来这么久总算没白搭
需要相关资料的话我也有一些,我就先说说我的一些理解吧。

读写SMRAM我就不重复了,毕竟这个帖子前面通篇都在讲这个。关键是后面写入指令到SMRAM中如何执行,如何利用...

0. 触发SMI进入SMM方法有很多,最简单的就是向 SMI_CMD端口(0xB2) 写入0x0F。
  我 Virtual PC 2007(6.0.192.0) 里测试时很奇怪,向SMM Handler处写上不可执行的乱码,VPC卡死;但向SMM Handler写上包含RSM指令(退出SMM模式的特权指令)的可执行16位代码,触发SMI后啥事也没发生。此后就算向SMM Handler写入垃圾数据,也无法让VPC死掉(也就说触发SMI也无效了,硬要猜的话:要么之前进入SMM后就没有退出来;要么RSM退出SMM后修改了某些东西,导致无法再次进入SMM,也有可能根本就没有进入过SMM,一切都是幻觉-_-)
  而 VMware Workstation(6.0.4-93057) 里触发SMI后,不管SMM Handler处代码是什么,模拟器都会立刻重启。难道VM6里SMM Handler位置不是 0xA8000

  QEMU 和 BOCHS我都不熟,不清楚他们对SMM模拟的程度如何,你可以试试看能不能成功。

1. 关于SMM Handler
也就是进入SMM后开始执行的位置,该位置默认为 SMBASE+0x8000,即(0xA8000)处。一段对此阐述比较详细的话:
This is how it works:

During the boot process the BIOS places a temporary SMM handler at the
default location, 00038000h. This consists of the default SMBASE value
of 00030000h plus the default (fixed) SMM entry offset of 8000h.

This temporary SMM handler does nothing but placing a new SMBASE value
in the SMBASE field of the state save map, and then it RSMs. As a part
of the RSM this new SMBASE value gets loaded into the processor.

Then the BIOS places the final SMM handler at the final location. With
Intel chipsets that usually is 000A8000h, ie. it uses DRAM which would
have to be remapped otherwise, since it is "underneath" VRAM.

To ensure that this final SMM handler works fine, a BIOS usually would
assert SMI# once more.

Placing such a temporary SMM handler doesn't require anything special.
However, placing the final SMM handler does, since its memory is over-
lapping other memmory for most chipsets. The chipsets provide bits, so
that the programmer can select which memory is visible/accessed, and a
few chipsets even provide the ability to protect the SMM handler until
the next RESET, so that nobody can overwrite it.


2. 关于SMM中执行的指令
SMM模式中执行的是16位指令,所以要给指令前面加上 0x66 前缀,比如:
66:33C0 XOR AX,AX
你要是来段32位的汇编代码,下场肯定是很凄惨的。

退出SMM使用RSM特权指令,硬编码是 0F AA (可以在OD里查到)
0FAA RSM


希望对你有些帮助
2009-7-16 20:44
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
59
强大了!俺水平有限,不能学习,只能收藏了!
2009-7-17 14:49
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
60
学习下,了解一下
2009-8-24 09:54
0
雪    币: 306
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
61
无法学习 只能膜拜
2009-9-12 18:39
0
雪    币: 112
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
62
站在远方观望
2009-9-12 21:26
0
雪    币: 202
活跃值: (11)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
63
楼主知道的多,我想说:“我猜是不是跟SMBUS”有关啊。我看很多这块的都说上了SMBUS,但就是不知道怎么使也不可能去测,一测就挂。
2009-10-1 22:28
0
雪    币: 79
活跃值: (10)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
64
这些都是些什么人写的啊。。。。真的看着瞠目结舌,最强的黑客,还是要搞硬件
2009-10-29 20:10
0
雪    币: 73
活跃值: (70)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
65
收藏收藏 哈哈
2009-11-1 09:04
0
雪    币: 214
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
66
底层啊 牛人
2009-11-1 12:29
0
雪    币: 73
活跃值: (70)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
67
..努力学..争取过些时候能看懂这篇帖..先收藏..
2009-11-2 11:45
0
雪    币: 133
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
68
收藏起来漫漫研究哈
2009-11-15 11:26
0
雪    币: 170
活跃值: (90)
能力值: ( LV12,RANK:210 )
在线值:
发帖
回帖
粉丝
69
俺只能远观不可近看
2009-11-16 12:45
0
雪    币: 219
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
70
楼主辛苦了 谢谢
2009-11-17 20:22
0
雪    币: 186
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
71
回的晚了点,赫赫

QEMU下我已经试过,可以触发SMI,执行一段代码. VMWARE WS 不记得了, 似乎也可以的. VIRTUAL PC 我很少用.
2010-7-23 02:36
0
雪    币: 184
活跃值: (56)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
72
只有膜拜的份。。。。。老师太强大了。。。
2010-7-23 18:04
0
雪    币: 78
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
73
还是过来学习吧!
2010-7-23 18:28
0
雪    币: 200
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
74
膜拜中。。。。请勿打扰。。
2010-7-24 17:47
0
雪    币: 328
活跃值: (34)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
75
0xB2是针对intel芯片的sw SMI port,其他芯片不是这个,可以参考相关手册。
SMM hacking已经领略到了,确实很强大。不过有个小问题,就是如果handler的执行时间稍长,则会引起假死机状态,而且有时从smm状态返回,会导致鼠标暂时不能使用。
2010-8-26 13:34
0
游客
登录 | 注册 方可回帖
返回
//