崩溃转储的!chkimg错误的含义

时间:2014-09-22 19:00:39

标签: windows security debugging windbg malware

我有一个奇怪的崩溃转储我的应用程序,我无法弄清楚崩溃的原因。我注意到!chkimg命令在转储中显示了一些错误:

0:013> !chkimg
824985 errors : @eip (77230010-7731016b)

地址范围77230010-7731016b属于ntdll.dll模块。 这是恶意软件影响我的计划的明确迹象吗?我可以以某种方式确认或消除这一假设吗?

编辑: 根据blabb的回答添加了一些内容:

  

范围大小是917851,其中824985在ntdll中被更改(默认情况下!chkimg不检查可写部分,因此输出看起来很可疑

我在最新版本的windbg中执行了该命令,它发现了8219而不是824985错误。

  

你不能假设某台机器是基于可能可能已损坏的转储而被恶意软件

我的应用程序由几个不同的进程/可执行文件组成,我几乎为每个进程转储。并且!chkimg为所有这些错误返回相同的错误。

  

dumpwrite路径在bsod期间可能会出现问题,并且可以写入损坏的转储

所有转储都是用户模式而不是内核。

重新加载符号时,我也收到以下警告:

* 警告:符号时间戳错误0x521ea8e7 0x4ce7ba58 for ntdll.dll

1 个答案:

答案 0 :(得分:1)

范围大小为917851,其中824985在ntdll中被更改(默认情况下!chkimg不检查可写部分,因此输出看起来很可疑

使用chkimg -d它应该显示原始文件与内存文件不同的地方 或强制命令使用chkimg -d ntdll

扫描模块ntdll

你不能假设机器是基于可能可能腐败的转储的恶意软件 dumpwrite路径在bsod期间可能会出现问题,并且可以写入损坏的转储 检查chkimg -db,它可能会显示正在检查的区域中的所有零 我假设你有一个内核完全转储

orginal file address xxxxxxxx 60 90 cc 
memory file                   00 00 00   

以上可以在chkimg输出中显示如此巨大的差异

lkd> !chkimg nt -d
    80501bc8-80501bcb  4 bytes - nt!KiServiceTable+24
    [ ec cb 60 80:a0 9a 3e a9 ]
    80501bf0-80501bf3  4 bytes - nt!KiServiceTable+4c (+0x28)
    [ 44 c9 5c 80:7e a5 3e a9 ]
    80501c08-80501c0b  4 bytes - nt!KiServiceTable+64 (+0x18)
    [ ba 1c 5b 80:5d e8 42 a9 ]

可以仅覆盖标记为IMAGE_SCN_MEM_WRITE的二进制部分,写入任何其他部分将生成访问冲突 和chkimg除非被强制不将这些部分与pe标头中的IMAGE_SCN_MEM_WRITE属性进行比较,否则查询中显示的内容将出现在不允许或不允许修改的地方。

这是一个示例代码,它采用dll名称并尝试写入.data部分

#include <windows.h>
#include <stdio.h>
int main (int argc,char *argv[]) {
    UNREFERENCED_PARAMETER(argc);
    HMODULE hMod = LoadLibrary(argv[1]);
    if (hMod)   {
        PIMAGE_DOS_HEADER doshead = ( PIMAGE_DOS_HEADER ) hMod;
        DWORD ntoffset = doshead->e_lfanew + (DWORD)hMod;
        DWORD datsecoffset = ntoffset + sizeof(IMAGE_NT_HEADERS);
        PIMAGE_NT_HEADERS nthead = ( PIMAGE_NT_HEADERS )( ntoffset );
        DWORD totsections = nthead->FileHeader.NumberOfSections;
        for (DWORD i = 0 ; i< totsections ; i++) {
            PIMAGE_SECTION_HEADER sechead = (PIMAGE_SECTION_HEADER ) 
                (datsecoffset + i * sizeof(IMAGE_SECTION_HEADER));
            if( ( sechead->Characteristics & IMAGE_SCN_MEM_WRITE ) == 
                IMAGE_SCN_MEM_WRITE ) {
                    CONSOLE_SCREEN_BUFFER_INFO csbiInfo; 
                    HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
                    GetConsoleScreenBufferInfo(out, &csbiInfo);
                    WORD oldcolor = csbiInfo.wAttributes;
                    SetConsoleTextAttribute(out,10);
                    printf(
                        "Module %p Section %s is writable trying to write\n",
                        hMod,sechead->Name);
                    for( DWORD j = sechead->VirtualAddress ; 
                        j < sechead->VirtualAddress + sechead->SizeOfRawData ; 
                        j++)  {
                            BYTE Inbyte = *(BYTE *) ( (BYTE *)hMod + j);
                            *(BYTE *) ( (BYTE *)hMod + j) = Inbyte;
                    }
                    printf(
                        "Module %p Section %s is written to successfully\n",
                        hMod,sechead->Name);
                    SetConsoleTextAttribute(
                        GetStdHandle(STD_OUTPUT_HANDLE),oldcolor);
            } else {
                printf(
                    "Module %p Section %s is not writable skipping\n",
                    hMod,sechead->Name);
            }
        }
        return 0;
    }
}

在hexedited dll和ntdll

下输出
:\>xxd -s +0x3c -l 4 -g 4 sec_attr_mod_dll.dll
000003c: b0000000                             ....    
:\>set /a 0xb0 + 0xf8 + 0x24
460
:\>xxd -s +460 -l 4 -g 4 sec_attr_mod_dll.dll & xxd -s +500 -l 4 -g 4 sec_attr_m
od_dll.dll & xxd -s +540 -l 4 -g 4 sec_attr_mod_dll.dll & xxd -s +580 -l 4 -g 4
sec_attr_mod_dll.dll
00001cc: 400000c0                             @...
00001f4: 400000c0                             @...
000021c: 400000c0                             @...
0000244: 400000c2                             @...

:\>w2dl.exe sec_attr_mod_dll.dll
Module 10000000 Section .text is writable trying to write
Module 10000000 Section .text is written to successfully
Module 10000000 Section .rdata is writable trying to write
Module 10000000 Section .rdata is written to successfully
Module 10000000 Section .data is writable trying to write
Module 10000000 Section .data is written to successfully
Module 10000000 Section .reloc is writable trying to write
Module 10000000 Section .reloc is written to successfully

:\>w2dl.exe ntdll.dll
Module 7C900000 Section .text is not writable skipping
Module 7C900000 Section .data is writable trying to write
Module 7C900000 Section .data is written to successfully
Module 7C900000 Section .rsrc is not writable skipping
Module 7C900000 Section .reloc is not writable skipping

:\>