用OllyDbg手脱RLPack V1.17加壳的DLL
程序员文章站
2022-11-28 08:24:54
一.OEP
通常压缩壳加壳的DLL找OEP是比较简单的
DLL卸载时会再次从EP处运行,几个跳转后就会到OEP了
0094BEA0 807C24 08 01 cmp byte ptr ss:[esp 8],1
//进入Olly... 08-10-08...
一.oep
通常压缩壳加壳的dll找oep是比较简单的
dll卸载时会再次从ep处运行,几个跳转后就会到oep了 0094bea0 807c24 08 01 cmp byte ptr ss:[esp 8],1
//进入ollydbg后暂停在ep
0094bea5 0f85 7e010000 jnz 0094c029
//这里在dll卸载时会跳转,就是去oep的捷径了 0094c029 e9 be3afaff jmp 008efaec
//这里就是跳oep了
_____________________________________________
二.输入表 rlpack v1.1x full edition加壳exe文件会加密某些输入表,而加壳dll则很少加密输入表的
bp getprocaddress
shift f9,中断后取消断点,alt f9返回 0094bf57 56 push esi
0094bf58 ff95 e3090000 call near dword ptr ss:[ebp 9e3] ; kernel32.loadlibrarya
0094bf5e 8985 4e0a0000 mov dword ptr ss:[ebp a4e],eax
0094bf64 85c0 test eax,eax
0094bf66 0f84 c2000000 je 0094c02e
0094bf6c 8bc6 mov eax,esi
0094bf6e eb 5f jmp short 0094bfcf
0094bf70 8b85 520a0000 mov eax,dword ptr ss:[ebp a52]
0094bf76 8b00 mov eax,dword ptr ds:[eax]
0094bf78 a9 00000080 test eax,80000000
0094bf7d 74 14 je short 0094bf93
0094bf7f 35 00000080 xor eax,80000000
0094bf84 50 push eax
0094bf85 8b85 520a0000 mov eax,dword ptr ss:[ebp a52]
0094bf8b c700 20202000 mov dword ptr ds:[eax],202020 ; unicode " hercegovina"
0094bf91 eb 06 jmp short 0094bf99
0094bf93 ffb5 520a0000 push dword ptr ss:[ebp a52]
0094bf99 ffb5 4e0a0000 push dword ptr ss:[ebp a4e]
0094bf9f ff95 e7090000 call near dword ptr ss:[ebp 9e7] ; kernel32.getprocaddress
0094bfa5 85c0 test eax,eax
//返回这里
0094bfa7 0f84 81000000 je 0094c02e
0094bfad 8907 mov dword ptr ds:[edi],eax ; ntdll.rtldeletecriticalsection
//填充系统函数地址
//edi=008f3154 注意观察这个地址
0094bfaf 83c7 04 add edi,4
0094bfb2 8b85 520a0000 mov eax,dword ptr ss:[ebp a52]
0094bfb8 eb 01 jmp short 0094bfbb
0094bfba 40 inc eax
0094bfbb 8038 00 cmp byte ptr ds:[eax],0
0094bfbe 75 fa jnz short 0094bfba
0094bfc0 40 inc eax
0094bfc1 8985 520a0000 mov dword ptr ss:[ebp a52],eax
0094bfc7 66:8178 02 0080 cmp word ptr ds:[eax 2],8000
0094bfcd 74 a1 je short 0094bf70
0094bfcf 8038 00 cmp byte ptr ds:[eax],0
0094bfd2 75 9c jnz short 0094bf70
0094bfd4 eb 01 jmp short 0094bfd7
0094bfd6 46 inc esi
0094bfd7 803e 00 cmp byte ptr ds:[esi],0
0094bfda 75 fa jnz short 0094bfd6
0094bfdc 46 inc esi
0094bfdd 40 inc eax
0094bfde 8b38 mov edi,dword ptr ds:[eax]
0094bfe0 e8 4b000000 call 0094c030
0094bfe5 83c0 04 add eax,4
0094bfe8 8985 520a0000 mov dword ptr ss:[ebp a52],eax
0094bfee 803e 01 cmp byte ptr ds:[esi],1
0094bff1 0f85 60ffffff jnz 0094bf57
//循环处理输入表 现在来手动确定输入表的rva和size
在左下角的数据窗口ctrl g:008f3154,点右键->long->address
008f3150 00000000
008f3154 7c93188a ntdll.rtldeletecriticalsection
008f3158 7c9210ed ntdll.rtlleavecriticalsection
……
008f37e0 7d610ec0 shell32.shellexecutea
008f37e4 00000000
008f37e8 76337cd8
008f37ec 7632311e
008f37f0 00000000 输入表开始rva=008f3154-00870000=00083154
输入表size=008f37f0-008f3154=0000069c 三.重定位表 其实写这篇教程的价值就在于这部分了
经过跟踪发现rlpack没有加密重定位表,这就为我们脱壳减少了麻烦 0094bff7 68 00400000 push 4000
0094bffc 68 54180000 push 1854
0094c001 ffb5 560a0000 push dword ptr ss:[ebp a56]
0094c007 ff95 ef090000 call near dword ptr ss:[ebp 9ef] ; kernel32.virtualfree
0094c00d 68 00400000 push 4000
0094c012 68 00200c00 push 0c2000
0094c017 ffb5 3a0a0000 push dword ptr ss:[ebp a3a]
0094c01d ff95 ef090000 call near dword ptr ss:[ebp 9ef] ; kernel32.virtualfree
//清理战场了
0094c023 e8 55000000 call 0094c07d
//重定位处理[/code][code]0094c07d 60 pushad
0094c07e 8bb5 460a0000 mov esi,dword ptr ss:[ebp a46]
//[ebp a46]=00087000 重定位表rva ★
0094c084 0bf6 or esi,esi
0094c086 74 67 je short 0094c0ef
0094c088 8bbd 3e0a0000 mov edi,dword ptr ss:[ebp a3e]
//[ebp a3e]=00400000 文件基址
0094c08e 8b4424 48 mov eax,dword ptr ss:[esp 48]
//[esp 48]=00870000 映像基址
0094c092 8985 420a0000 mov dword ptr ss:[ebp a42],eax
0094c098 3bc7 cmp eax,edi
//比较是否相同
0094c09a 74 53 je short 0094c0ef
//不同不跳就需要重定位处理了
//注意:此时程序没有重定位,可以现在dump,这样脱壳后就不需要修改dump文件基址了 ★
0094c09c 03f0 add esi,eax
//esi=00087000 00870000=008f7000 重定位表va
0094c09e eb 4a jmp short 0094c0ea
0094c0a0 8b16 mov edx,dword ptr ds:[esi]
0094c0a2 8b46 04 mov eax,dword ptr ds:[esi 4]
0094c0a5 8985 4a0a0000 mov dword ptr ss:[ebp a4a],eax
0094c0ab 01b5 4a0a0000 add dword ptr ss:[ebp a4a],esi
0094c0b1 83c6 08 add esi,8
0094c0b4 eb 2c jmp short 0094c0e2
0094c0b6 0fb706 movzx eax,word ptr ds:[esi]
0094c0b9 8bd8 mov ebx,eax
0094c0bb c1eb 0c shr ebx,0c
0094c0be 8bcb mov ecx,ebx
0094c0c0 69db 00100000 imul ebx,ebx,1000
0094c0c6 2bc3 sub eax,ebx
0094c0c8 03c2 add eax,edx
0094c0ca 0385 420a0000 add eax,dword ptr ss:[ebp a42]
0094c0d0 83f9 03 cmp ecx,3
0094c0d3 75 0a jnz short 0094c0df
0094c0d5 2938 sub dword ptr ds:[eax],edi
0094c0d7 8b8d 420a0000 mov ecx,dword ptr ss:[ebp a42]
0094c0dd 0108 add dword ptr ds:[eax],ecx
0094c0df 83c6 02 add esi,2
0094c0e2 3bb5 4a0a0000 cmp esi,dword ptr ss:[ebp a4a]
0094c0e8 72 cc jb short 0094c0b6
0094c0ea 833e 00 cmp dword ptr ds:[esi],0
0094c0ed 75 b1 jnz short 0094c0a0
//循环重定位处理
0094c0ef 61 popad
//处理完后esi=009000f8
//relocation table size=009000f8-008f7000=000090f8 ★
0094c0f0 c3 retn
_____________________________________________
四.完成脱壳 0094c028 61 popad
0094c029 e9 be3afaff jmp 008efaec
//飞向光明之巅
0094c02e 61 popad
0094c02f c3 retn 008efaec 55 push ebp
//oep rva=008efaec-00870000=0007faec
008efaed 8bec mov ebp,esp
008efaef 83c4 c4 add esp,-3c
008efaf2 b8 04f98e00 mov eax,008ef904
008efaf7 e8 cc6df8ff call 008768c8
008efafc 33c0 xor eax,eax
008efafe a3 442c8f00 mov dword ptr ds:[8f2c44],eax
008efb03 e8 dc4bf8ff call 008746e4 运行importrec,由于此dll加载后已经进行重定位处理,所以去掉“use pe header from disk”选项
选择ollydbg的loaddll.exe进程,pick dll选择ibox.dll
填入oep rva=0007faec,输入表rva=00083154,输入表size=0000069c,get imports
可以新增区段修复,也可以把输入表放在程序无用的空白处。 使用lordpe修改dumped_.dll的relocation table rva=00087000,relocation table size=000090f8
附件中ibox.unpacked.dll只是简单优化,如果想优化的完美点那就要多费时间了。
脱壳完成
dll卸载时会再次从ep处运行,几个跳转后就会到oep了 0094bea0 807c24 08 01 cmp byte ptr ss:[esp 8],1
//进入ollydbg后暂停在ep
0094bea5 0f85 7e010000 jnz 0094c029
//这里在dll卸载时会跳转,就是去oep的捷径了 0094c029 e9 be3afaff jmp 008efaec
//这里就是跳oep了
_____________________________________________
二.输入表 rlpack v1.1x full edition加壳exe文件会加密某些输入表,而加壳dll则很少加密输入表的
bp getprocaddress
shift f9,中断后取消断点,alt f9返回 0094bf57 56 push esi
0094bf58 ff95 e3090000 call near dword ptr ss:[ebp 9e3] ; kernel32.loadlibrarya
0094bf5e 8985 4e0a0000 mov dword ptr ss:[ebp a4e],eax
0094bf64 85c0 test eax,eax
0094bf66 0f84 c2000000 je 0094c02e
0094bf6c 8bc6 mov eax,esi
0094bf6e eb 5f jmp short 0094bfcf
0094bf70 8b85 520a0000 mov eax,dword ptr ss:[ebp a52]
0094bf76 8b00 mov eax,dword ptr ds:[eax]
0094bf78 a9 00000080 test eax,80000000
0094bf7d 74 14 je short 0094bf93
0094bf7f 35 00000080 xor eax,80000000
0094bf84 50 push eax
0094bf85 8b85 520a0000 mov eax,dword ptr ss:[ebp a52]
0094bf8b c700 20202000 mov dword ptr ds:[eax],202020 ; unicode " hercegovina"
0094bf91 eb 06 jmp short 0094bf99
0094bf93 ffb5 520a0000 push dword ptr ss:[ebp a52]
0094bf99 ffb5 4e0a0000 push dword ptr ss:[ebp a4e]
0094bf9f ff95 e7090000 call near dword ptr ss:[ebp 9e7] ; kernel32.getprocaddress
0094bfa5 85c0 test eax,eax
//返回这里
0094bfa7 0f84 81000000 je 0094c02e
0094bfad 8907 mov dword ptr ds:[edi],eax ; ntdll.rtldeletecriticalsection
//填充系统函数地址
//edi=008f3154 注意观察这个地址
0094bfaf 83c7 04 add edi,4
0094bfb2 8b85 520a0000 mov eax,dword ptr ss:[ebp a52]
0094bfb8 eb 01 jmp short 0094bfbb
0094bfba 40 inc eax
0094bfbb 8038 00 cmp byte ptr ds:[eax],0
0094bfbe 75 fa jnz short 0094bfba
0094bfc0 40 inc eax
0094bfc1 8985 520a0000 mov dword ptr ss:[ebp a52],eax
0094bfc7 66:8178 02 0080 cmp word ptr ds:[eax 2],8000
0094bfcd 74 a1 je short 0094bf70
0094bfcf 8038 00 cmp byte ptr ds:[eax],0
0094bfd2 75 9c jnz short 0094bf70
0094bfd4 eb 01 jmp short 0094bfd7
0094bfd6 46 inc esi
0094bfd7 803e 00 cmp byte ptr ds:[esi],0
0094bfda 75 fa jnz short 0094bfd6
0094bfdc 46 inc esi
0094bfdd 40 inc eax
0094bfde 8b38 mov edi,dword ptr ds:[eax]
0094bfe0 e8 4b000000 call 0094c030
0094bfe5 83c0 04 add eax,4
0094bfe8 8985 520a0000 mov dword ptr ss:[ebp a52],eax
0094bfee 803e 01 cmp byte ptr ds:[esi],1
0094bff1 0f85 60ffffff jnz 0094bf57
//循环处理输入表 现在来手动确定输入表的rva和size
在左下角的数据窗口ctrl g:008f3154,点右键->long->address
008f3150 00000000
008f3154 7c93188a ntdll.rtldeletecriticalsection
008f3158 7c9210ed ntdll.rtlleavecriticalsection
……
008f37e0 7d610ec0 shell32.shellexecutea
008f37e4 00000000
008f37e8 76337cd8
008f37ec 7632311e
008f37f0 00000000 输入表开始rva=008f3154-00870000=00083154
输入表size=008f37f0-008f3154=0000069c 三.重定位表 其实写这篇教程的价值就在于这部分了
经过跟踪发现rlpack没有加密重定位表,这就为我们脱壳减少了麻烦 0094bff7 68 00400000 push 4000
0094bffc 68 54180000 push 1854
0094c001 ffb5 560a0000 push dword ptr ss:[ebp a56]
0094c007 ff95 ef090000 call near dword ptr ss:[ebp 9ef] ; kernel32.virtualfree
0094c00d 68 00400000 push 4000
0094c012 68 00200c00 push 0c2000
0094c017 ffb5 3a0a0000 push dword ptr ss:[ebp a3a]
0094c01d ff95 ef090000 call near dword ptr ss:[ebp 9ef] ; kernel32.virtualfree
//清理战场了
0094c023 e8 55000000 call 0094c07d
//重定位处理[/code][code]0094c07d 60 pushad
0094c07e 8bb5 460a0000 mov esi,dword ptr ss:[ebp a46]
//[ebp a46]=00087000 重定位表rva ★
0094c084 0bf6 or esi,esi
0094c086 74 67 je short 0094c0ef
0094c088 8bbd 3e0a0000 mov edi,dword ptr ss:[ebp a3e]
//[ebp a3e]=00400000 文件基址
0094c08e 8b4424 48 mov eax,dword ptr ss:[esp 48]
//[esp 48]=00870000 映像基址
0094c092 8985 420a0000 mov dword ptr ss:[ebp a42],eax
0094c098 3bc7 cmp eax,edi
//比较是否相同
0094c09a 74 53 je short 0094c0ef
//不同不跳就需要重定位处理了
//注意:此时程序没有重定位,可以现在dump,这样脱壳后就不需要修改dump文件基址了 ★
0094c09c 03f0 add esi,eax
//esi=00087000 00870000=008f7000 重定位表va
0094c09e eb 4a jmp short 0094c0ea
0094c0a0 8b16 mov edx,dword ptr ds:[esi]
0094c0a2 8b46 04 mov eax,dword ptr ds:[esi 4]
0094c0a5 8985 4a0a0000 mov dword ptr ss:[ebp a4a],eax
0094c0ab 01b5 4a0a0000 add dword ptr ss:[ebp a4a],esi
0094c0b1 83c6 08 add esi,8
0094c0b4 eb 2c jmp short 0094c0e2
0094c0b6 0fb706 movzx eax,word ptr ds:[esi]
0094c0b9 8bd8 mov ebx,eax
0094c0bb c1eb 0c shr ebx,0c
0094c0be 8bcb mov ecx,ebx
0094c0c0 69db 00100000 imul ebx,ebx,1000
0094c0c6 2bc3 sub eax,ebx
0094c0c8 03c2 add eax,edx
0094c0ca 0385 420a0000 add eax,dword ptr ss:[ebp a42]
0094c0d0 83f9 03 cmp ecx,3
0094c0d3 75 0a jnz short 0094c0df
0094c0d5 2938 sub dword ptr ds:[eax],edi
0094c0d7 8b8d 420a0000 mov ecx,dword ptr ss:[ebp a42]
0094c0dd 0108 add dword ptr ds:[eax],ecx
0094c0df 83c6 02 add esi,2
0094c0e2 3bb5 4a0a0000 cmp esi,dword ptr ss:[ebp a4a]
0094c0e8 72 cc jb short 0094c0b6
0094c0ea 833e 00 cmp dword ptr ds:[esi],0
0094c0ed 75 b1 jnz short 0094c0a0
//循环重定位处理
0094c0ef 61 popad
//处理完后esi=009000f8
//relocation table size=009000f8-008f7000=000090f8 ★
0094c0f0 c3 retn
_____________________________________________
四.完成脱壳 0094c028 61 popad
0094c029 e9 be3afaff jmp 008efaec
//飞向光明之巅
0094c02e 61 popad
0094c02f c3 retn 008efaec 55 push ebp
//oep rva=008efaec-00870000=0007faec
008efaed 8bec mov ebp,esp
008efaef 83c4 c4 add esp,-3c
008efaf2 b8 04f98e00 mov eax,008ef904
008efaf7 e8 cc6df8ff call 008768c8
008efafc 33c0 xor eax,eax
008efafe a3 442c8f00 mov dword ptr ds:[8f2c44],eax
008efb03 e8 dc4bf8ff call 008746e4 运行importrec,由于此dll加载后已经进行重定位处理,所以去掉“use pe header from disk”选项
选择ollydbg的loaddll.exe进程,pick dll选择ibox.dll
填入oep rva=0007faec,输入表rva=00083154,输入表size=0000069c,get imports
可以新增区段修复,也可以把输入表放在程序无用的空白处。 使用lordpe修改dumped_.dll的relocation table rva=00087000,relocation table size=000090f8
附件中ibox.unpacked.dll只是简单优化,如果想优化的完美点那就要多费时间了。
脱壳完成
上一篇: 个人网站的策划的困难和解决之道
下一篇: 中国怀孕网女站长创业历程