【ChinaBeta.Cn 网盟学院】
Anti Soft ICE : Blue Screen of Death and no Chocolate: The NumberOfRvaAndSizes field has been modified in order to reboot any computer running a recent version of Soft ICE. While Disassembling the PE Loader of Soft ICE, i found a very critical vulnerability in Soft ICE that allows one binary to crash any computer running Soft ICE without any code execution. This vulnerability (bug) has been reported to Compuware and should be fixed in the next version. Apparently it didn't happen on some of the authors of the submissions for some reasons. Oh well. Here is the disassembly of Soft ICE PE loader to find out why it reboots your computer: .text:000A79FE .text:000A79FE loc_A79FE: ; CODE XREF: sub_A79B9+31j .text:000A79FE ; sub_A79B9+3Cj .text:000A79FE ; DATA XREF: .text:00012F9Bo .text:000A79FE sti .text:000A79FF mov esi, ecx .text:000A7A01 mov ax, [esi] .text:000A7A04 cmp ax, 'ZM' .text:000A7A08 jnz not_PE_file .text:000A7A08 .text:000A7A0E mov edi, [esi+_IMAGE_DOS_HEADER.e_lfanew] .text:000A7A11 add edi, esi .text:000A7A13 mov ax, [edi] .text:000A7A16 cmp ax, 'EP' .text:000A7A1A jnz not_PE_file .text:000A7A1A .text:000A7A20 movzx ecx, [edi+IMAGE_NT_HEADERS.FileHeader.NumberOfSections] .text:000A7A24 or ecx, ecx .text:000A7A26 jz not_PE_file .text:000A7A26 .text:000A7A2C mov eax, [edi+IMAGE_NT_HEADERS.OptionalHeader.NumberOfRvaAndSizes] .text:000A7A2F lea edi, [edi+eax*8+IMAGE_NT_HEADERS.OptionalHeader.DataDirectory] .text:000A7A33 mov eax, ecx .text:000A7A35 imul eax, 28h .text:000A7A38 mov al, [eax+edi] ; CRITICAL BUG! One can force EAX+EDI to be equal to zero. Reading at [0] in ring 0 isn't nice eh ;-) .text:000A7A3B .text:000A7A3B loc_A7A3B: ; DATA XREF: .text:00012FA5o .text:000A7A3B cli
.text:000A7A3C call sub_15C08 .text:000A7A3C .text:000A7A41 mov byte_FA259, 0 .text:000A7A48 push eax ; Save EAX .text:000A7A49 mov eax, dword_16B56F ; EAX is modified by a saved dword .text:000A7A4E mov dr7, eax ; Debug Register 7 take the value in EAX .text:000A7A51 pop eax ; EAX is restored .text:000A7A52 mov dword_FC6CC, esp .text:000A7A58 mov esp, offset unk_FBABC .text:000A7A5D and esp, 0FFFFFFFCh .text:000A7A60 xor al, al ; AL is zeroed? Why this mov al, [eax+edi] then ? .text:000A7A60 ; I don't see the point. old code? .text:000A7A62 call sub_4D2EB .text:000A7A62 .text:000A7A67 call sub_36AC1 .text:000A7A67 .text:000A7A6C xor edx, edx .text:000A7A6E .text:000A7A6E loc_A7A6E: ; CODE XREF: sub_A79B9+124j .text:000A7A6E call sub_74916 .text:000A7A6E
反SoftIce:蓝屏死机花屏: 修改NumberOfRvaAndSizes会令含SoftIce的系统重起。通过反汇编SoftIce装载器,我发现:无需代码执行,一个二进位的变动就可使一台含SoftIce的电脑立刻崩溃。不过此漏洞已上报COMPUWARE并将在下一版本中改进。但是,由于某种原因,一些系统却运行正常。让我们来看一下反汇编后的SoftICE装载器里到底有什么:
.text:000A79FE .text:000A79FE loc_A79FE: ; CODE XREF: sub_A79B9+31j .text:000A79FE ; sub_A79B9+3Cj .text:000A79FE ; DATA XREF: .text:00012F9Bo .text:000A79FE sti .text:000A79FF mov esi, ecx .text:000A7A01 mov ax, [esi] .text:000A7A04 cmp ax, 'ZM' .text:000A7A08 jnz not_PE_file .text:000A7A08 .text:000A7A0E mov edi, [esi+_IMAGE_DOS_HEADER.e_lfanew] .text:000A7A11 add edi, esi .text:000A7A13 mov ax, [edi] .text:000A7A16 cmp ax, 'EP' .text:000A7A1A jnz not_PE_file .text:000A7A1A .text:000A7A20 movzx ecx, [edi+IMAGE_NT_HEADERS.FileHeader.NumberOfSections] .text:000A7A24 or ecx, ecx .text:000A7A26 jz not_PE_file .text:000A7A26 .text:000A7A2C mov eax, [edi+IMAGE_NT_HEADERS.OptionalHeader.NumberOfRvaAndSizes] .text:000A7A2F lea edi, [edi+eax*8+IMAGE_NT_HEADERS.OptionalHeader.DataDirectory] .text:000A7A33 mov eax, ecx .text:000A7A35 imul eax, 28h .text:000A7A38 mov al, [eax+edi] ; EAX+EDI=0则崩溃。权限0中读取[0]地址可不妙。 .text:000A7A3B .text:000A7A3B loc_A7A3B: ; DATA XREF: .text:00012FA5o .text:000A7A3B cli .text:000A7A3C call sub_15C08 .text:000A7A3C .text:000A7A41 mov byte_FA259, 0 .text:000A7A48 push eax ; Save EAX .text:000A7A49 mov eax, dword_16B56F ; 用双字修改EAX中值 .text:000A7A4E mov dr7, eax ; 寄存器7从EAX中取值 .text:000A7A51 pop eax ; 恢复EAX .text:000A7A52 mov dword_FC6CC, esp .text:000A7A58 mov esp, offset unk_FBABC .text:000A7A5D and esp, 0FFFFFFFCh .text:000A7A60 xor al, al ; AL取0?为什么要mov al, [eax+edi]? .text:000A7A60 ; 不明白.原始代码? .text:000A7A62 call sub_4D2EB .text:000A7A62 .text:000A7A67 call sub_36AC1 .text:000A7A67 .text:000A7A6C xor edx, edx .text:000A7A6E .text:000A7A6E loc_A7A6E: ; CODE XREF: sub_A79B9+124j .text:000A7A6E call sub_74916 .text:000A7A6E
As you can see from the code above, we can force Soft ICE to read at memory location [0] or something similar using a special value inside the PE header. For this binary i didn't bother calculating the exact value to read at address [0], that's may explain why it didn't crash for some people.I won't explain how to calculate this special value because it is trivial and i don't want Dark lords to use that trick without a little brainstorming. To fix this problems, one needs to patch the value in the PE Header. The standard value for NumberOfRvaAndSizes is 0x10. Just patch this value in the PE Header and the Soft ICE wrecking will be gone. The OllyDBG problem as well, because it is based on BOTH fields modifications. You can also nullify the other field if you want.
如你所见,我们可以令SoftIce读取[0]地址或其它特殊值。但我并不知道这时确切的数值,这可能与系统是否崩溃有关。我不想讨论怎样计算这一特殊值,因为它与主题无关,另外也给大家留下讨论的空间。你可以通过值的修改来修正这一问题。NumberOfRvaAndSizes的一般值为0x10。修改它。另外因为Olly和SoftIce都基于这种技术,因此你都可以通过改变NumberOfRvaAndSizes的值或归0来搞定。上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] 下一页
(责任编辑:hahack)
|