安全中国首页 > 文章中心 > 脱壳技术
 
安全中国网友投稿专用上传FTP空间:
Ftp服务器:download.anqn.com
Ftp端口:21
用户名:anqn
密 码:anqn.com
 

Armadillo-手动脱变种的壳(图)

更新时间:2008-5-14 0:43:26
责任编辑:果果龙
热 点:

那么User32_API_table当然很类似!

在这一点上,如果你很懒,你可以简单地对dll_handle_table检测部分的代码打补丁,以跳过它。然后我们的 IAT就永远不会被redirected了,我们可以简单地启动Imprec或者Revirgin选择running process re-build IAT。。。 但是我们是在手动地做一切,不是吗:)所以让我们继续trace。如果你按F12 one more time,你将会在Import loading loop之中!

10010E59 83 C0 04                 add eax 4

10010E5C 89 85 80                 FD FF FF mov [ebp+IAT_add] eax

我的注释已经说过,设一个breakpointCall Get_API_Address然后trace around the loop去找它的hang 然后你将会看到[ebp+API_name]存储了pointer to Import ASCIIs 紧接着这个pointer,你将会看到一长窜APIDLL"WOW"这就是我们要找的Import ASCII :)吗,转储整个Table然后你会看到dump看起来如下:

WINMMdll00

ErminateProcess 00 ExitThread 00 HeapReAlloc

研究这张表,我们将会看到它由一个DLL开始,然后RVA of first thunk corresponding with 那个 DLL 然后从那个DLL Import的个数和从那个 DLL 所有Imports ASCII列表。 例如,WIMMdll first thunk001D519C开始, (记住字节是反转的)那儿有一个从这个DLLimport form 它是PlaySoundA Kernel32dll first thunk1D4B74开始,那儿有9Fh Imports from kernel32dll。。。等等

更进一步,如果当你在指令10010E51处通过"d eax"来看first thunk,你将会注意到First Thunk 没有被Armadillo touched !那意味着我们知道了original location of ASCII entries of API 但是看一下those location我们只看到了很多0:(。。。所以Import ASCII被删除了,但是嘿,至少我们知道了each entry of Import ASCII被存储在何处。

所以我们现在要做我们必须得做的?我们需要rebuild Import Table,换句话说就是copy Import ASCII to location where they should be Time for some patching on the fly! 设一个断点"bpm 10010DF3 x" 然后重启程序。 一旦中断。

a eip
mov ecx
[ebp+IAT_add]       ; get the RVA of Import ASCII
add ecx
400002h  ; calculate VA of Import ASCII by adding image base and 2 is size of HINT
push ecx
call lstrcpy
jmp API_add_found

啊哈,我希望你理解了那些补丁代码的作用。下一个任务是阻止Armadillo破坏我们的First Thunk 简单的NOP 10010E51处的指令。最后,按F12Armadillo为你rebuilt IAT。。。 一旦softice再次中断dump整个。idata segment

当然你将会注意到the Import Directory丢失了,所以你的任务就是rebuild this directory 我们应该把它当作留给读者的练习吗。如果你很想知道Import by ordinal因为我们不能复制Import ASCII import by name一样,别担心! Import by ordinal is handled 独立地被 Armadillo (如果你在softice窗口中翻页代码一至两页,你将看到all Get_API_address 都在那儿被called as well to handle ordinal cases 然而,正如我说过的,我们的First Thunk是完整的所以Ordinals 已经被存储在First Thunk中了只要我们NOP10010E51处的代码, 我们的Import by ordinals are preserved!

请注意:Another more generic approach would be coding a small utility that reads the Import ASCII dump and insert Import ASCII into our exe dump file and rebuild the Import Directory。这将会在当前任何Armadillo保护目标上都有用!!!

3。新的 int3 trick

现在启动exe and BOOM 你将会从Windows得到一个消息说int3 occurs 但是没有被 handled 那是最新的trick Armadillo用来阻止被转储。 是时候重新进入softiceIDA去跟随了,仅仅去看Debug loop "server" 你将会看到 int3 handling routine

0044DAAC 8B 85 38 FA FF FF      mov eax [ebp+lpDebugEvent]

0044DAB2 81 78 0C 03 00 00 80   cmp dword ptr [eax+0Ch] 80000003h ; INT 3 exception code

0044DAB9 0F 85 96 03 00 00      jnz loc_44DE55

0044DABF                        INT3_occur:

0044DABF 33 C9                  xor ecx ecx

0044DAC1 8A 0D 6E 9A 45 00      mov cl ds:int3_feature_installed

从这儿开始我们的追求去kill int3。从这个point开始tracing,你将会看到"server""client" memory space读了a of data然后将其分成四块tables然后将这tables 解码到4块独立的虚拟内存空间中去。然后"server"使用GetThreadContext去检测"client"eiplocation。这个eip is one byte after the location int3 exception occurs! Trace on and we’ll see that armadillo performs binary search on Table_1 to find the position of eip 一旦 eip location in Table_1 found 我们到达这里:

005DFDD5 8D 95 28 F7 FF FF      lea edx [ebp+Context]

005DFDDB 52                     push edx

005DFE3B 52                     push edx; lpContext

005DFE3C 8B 85 F4 F9 FF FF      mov eax [ebp+hThread]

005DFE42 50                     push eax; hThread

005DFE43 FF 15 80 80 5E 00      call ds:SetThreadContext; SetThreadContext:

基本上,Armadillo已经在original exe中通过int3replaced一些跳转(条件跳转和无条件跳转) 然后产生4 tables存储了那些跳转的信息包括位置,距离。 所有的都在packing time完成。正如你能看到的, int3"client"进程中发生时,"server"会检查int3发生处的eip值,向上看Table_1 一旦被发现,"server"会在table_2中检查相符合的值,那指的是在这个eip处是何种跳转。然后"server" 会检查eflags register "Client"领空(call Get_Jump_typeroutine)去看是否"client"应该jump或不跳。 如果jump然后 "Client"eip会被移入Table_4中相应(jump distance)的值,如果不跳然后"Client"eip会被移入 table_3中相应(length of jump instruction)的值。看一下Get_Jump_Type routine

005E1046                       jump type 9:

005E1046 B0 01 mov al 1       ;al always 1 => always jump no matter what

005E10B0 1B D2                 sbb edx edx

005E10B2 42                    inc edx ; edx = 0 if O flag set else edx = 1

005E10B3 33 C9                 xor ecx ecx

005E10B5 3B C2                 cmp eax edx; compare eax with edx

005E10B7 0F 95 C1              setnz cl; al = 1 if not equal

005E10BA 8A C1                 mov al cl

005E10BC E9 3B 01 00 00        jmp end ; jump if SF != OF==>> JL

好的,总共那儿有11hjump。最后,fix那些int3就是我们的任务。所以我编了一小段代码去scan through Table_1,检测每一个virtual address entry in table_1 在我们转储的文件中, 如果opcode"CC" 那它就out int3,检测Table_2中相应的值以决定它是那种跳转(JNZ or JZ or JMP等等) 然后它检测table_3 去看how long the jump instruction should be 然后写入指定的正确的jump opcodes到我们的exe dump 文件中。 最后,它检测Table_4中相应的值,那个值是distance how far the jump is 然后再次update exe中的值。因此,运行被保护的程序, dump the 4 tables into 4 separate files (确信 that Table_1 size is same as table_4 size and is 4 times the table_2 and 3 size Why?) 我已经免费附加了这个小程序的masm源代码,以供你做参考。

4The 最后的,决定性的 Touch

fixing int3之后,转储的文件仍旧拒绝运行, 以很吵的beeping 退出。这个使我一时很受挫很迷惑。。。tracing doesn’t seem to get me anywhere 我又重新检查了一遍我的int3 patching routine,和IAT。。。 所有的东西看起来都很正常。我已经想尽办法,突然间我想到, 嘿,那些Beep sound并未在我运行original exe时出现, voila bpx MessageBeep然后按F12我们到了这儿。。。

00438E03 68 C4 0E 5C 00                 push offset strDellatsnisyad ; "DELLATSNISYAD" <==WHAT A STRING!!!

00438E43 6A 01                          push 1 ; uType

00438E45 FF 15 64 50 5D 00              call ds:MessageBeep ; MessageBeep:

00438E4B 53                             push ebx ;<== LAND HERE

所以我们的任务就是去为programconditional jump打补丁, 就像试图去恢复一个download你将会收到另一个beep :)。。。 太好,我们只需要用IDA click on GetEnvironmentalVarableA and 检查所有参考, 什么地方called去检测Armadillo全局变量像DAYSINSTALLED,等等。注意那些检测后面通常紧跟着一个MessageBeep你会很快找到那些check

这是patches的概要

438E3C  ?75?<== EB             DAYSINSTALLED

4720EE?75?<== EB               DAYSINSTALLED

4E6B7F?75?<== EB?      ALTUSERNAME    ?

现在Get Right就像一个婴儿一样运行:)。。。 虽然我发现下载很慢。我个人不推荐你去使用这个下载引擎:),所以一旦你crack它,请立即卸载它!

5 尾声

这就是它, phew 好长的一篇tutorial!我希望你觉得它有帮助。我已经尽我所能详细解释,但是我相信我不可能解释清楚每一个细节问题或者这篇tutorial太长了以至于任何人读它都会觉得很枯躁。 所以你发现任何有不清楚的部分,在fravia board上发一个消息给我,我会作出适当的修正。

针对狂热爱好者:如果你注意到IAT redirection routine是在一些隐藏的memory space 你可以试着scrolling upbeginning of this memory section然后你将会看到一个PE header! Check out the image size in the header,设置一个bpmimage的尾部(以确保整个image被装载到内存) 然后重新运行Get Right,一旦softice中断,检测整个image是否被装载到内存?转储它并重命名为rmadll 你将会得到一个virgin dllexport functions like "LoadProgramInfo" "NukeNow" "CheckNetLicense" "ArmAccess" and "RunUserProgram" 希望无限了:)???

                                                        --------------------------------------------------------

如果离开了Fravia Message Board上人们的帮助,这篇tutorial不可能诞生。 所以感谢飞向Fravia boardmirc上所有的朋友。

特别感谢WoodyMarch^drn (get well soon :)

Cheers,干杯

  原著crUsAdEr**翻译FTBirthda

上一页 1 2 3 4 

 
相关文章
一日一文章
 
一日一软件
一日一动画