LLXX
August 27th, 2005, 03:14
This target which I am trying to reverse is packed with Armadillo 3.00 - 3.61 according to PEid. However, it is not exactly a "normal" target, since it is supposed to be executed by another program - when simply run alone, it just exits as if the only code it contained was an ExitProcess call. Thus for various reasons I cannot have the the target running long enough to dump it, but I figure with Olly it should be only necessary to get to OEP and then dump it. Here is what I've done:
1. Tracing through the Armadillo code with F7 - takes too long, I did it for nearly three hours and still haven't reached anything resembling an OEP. It is apparent the code is hand-made, consisting of self-modifying parts, convoluted jumping sequences, garbage code, and tricky stack manipulations.
2. Identifying the exact species of Armadillo. In all the tutorials I've found there are references to "Standard Protection", "Debug Blocker", "CopyMem II", etc. From what I understand, Standard Protection is like a standard packer, i.e. Unpack then Execute; Debug Blocker is two-process but the second process is completely unpacked and dumpable from the memory; CopyMem II has two process but only unpacks around where the current IP is - correct me if I'm wrong. My target has two processes, that's all I can gather. I reckon either Debug Blocker or CopyMem II.
3. Follow the advice of the Tutorial (ARTeam and others) which describe detaching the second process and then dumping it:
Start Olly, load the program. (My Olly is properly hidden, that is not a problem here.)
Break on WriteProcessMemory - according to tutorial it's the second one which needs to have their byte changed to eb fe to loop infinitely. It breaks, I change these bytes. Strangely enough, in the tutorial the original bytes were 60 e8, which are exactly the same as the ones in my target, even though the target used in the tutorial was completely different from mine.
Next, break on WaitForDebugEvent. After breaking there the tutorial tells to find the Pid of the newly created process then detach it by running a DebugActiveProcessStop call. I manage to detach it successfully, and open a second Olly and Attach there. Now my whole machine slows down severely. Inspection of Task Manager reveals CPU usage is still less than 10%. Not mentioned in Tutorial, this slowing down.
Eventually I see the infinite jump and change it back to the 60 e8 it used to be, after several minutes of waiting due to the slowness. But here I see something familiar - is it the exact same appearance of the entrypoint at the original target (father process)? If so, have I basically done nothing? Or is it the nature of the Armadillo to create a duplicate of itself? At this point I use the LordPE and dump the entire process. I open with a hex editor, and see the entire .text section (which is supposed to be where the unpacked code goes, I think) is filled with the null. Following that is a section containing the same code as the original file, and then the packed data.
After closing both Ollies and then opening the dump in the new one the speed is back to normal, so I decide to trace through it. It is the same code that was in the original file. I then try to break on WriteProcessMemory, and it does, in other words doing the exact same thing the original file was doing. If I just try to executed the dumped thing directly, it displays message like "This program is corrupted please reinstall".
General observations (open target file with hex editor and look around):
Armadillo's body contains (in order of encounterance) the extremely obfuscated first code section which looks like it's been packed (I obtained an Armadillo'd crackme and can verify that this section is identical to it, and should be similar for all the 3.xx versions), a "padding" of "É"s (NOP), a space of nulls, a piece of an import table, some interesting strings (including "Cannot locate protected program data"
, a table-like structure (8-byte entries) which purpose I'm not sure of, more strings which relate to data compression (e.g. "invalid distance code"
, and then some unknown binary with the interesting string "deflate 1.1.4 Copyright 1995-2002 Jean-loup Gailly" (occurred in all the Armadillo'd programs I could find), more strange data, "inflate 1.1.4 Copyright 1995-2002 Mark Adler", and a section of strings resembling that of M$'s C++ runtime library. Then follows some empty space, more imports, and finally the most interesting part, a chunk of compressed data beginning with the string "PDATA000" which occurred earlier in the file. This coincides with the .pdata section. The thought happened that this data is compressed with the common "flate" algorithm, maybe I should just use decompressor on it and yield the virgin? But it is probably encrypted too, unfortunately. I tried to breakpoint on access to that section but it never hit the breakpoint (terminate with error code 128 or something like that).
1. Tracing through the Armadillo code with F7 - takes too long, I did it for nearly three hours and still haven't reached anything resembling an OEP. It is apparent the code is hand-made, consisting of self-modifying parts, convoluted jumping sequences, garbage code, and tricky stack manipulations.
2. Identifying the exact species of Armadillo. In all the tutorials I've found there are references to "Standard Protection", "Debug Blocker", "CopyMem II", etc. From what I understand, Standard Protection is like a standard packer, i.e. Unpack then Execute; Debug Blocker is two-process but the second process is completely unpacked and dumpable from the memory; CopyMem II has two process but only unpacks around where the current IP is - correct me if I'm wrong. My target has two processes, that's all I can gather. I reckon either Debug Blocker or CopyMem II.
3. Follow the advice of the Tutorial (ARTeam and others) which describe detaching the second process and then dumping it:
Start Olly, load the program. (My Olly is properly hidden, that is not a problem here.)
Break on WriteProcessMemory - according to tutorial it's the second one which needs to have their byte changed to eb fe to loop infinitely. It breaks, I change these bytes. Strangely enough, in the tutorial the original bytes were 60 e8, which are exactly the same as the ones in my target, even though the target used in the tutorial was completely different from mine.
Next, break on WaitForDebugEvent. After breaking there the tutorial tells to find the Pid of the newly created process then detach it by running a DebugActiveProcessStop call. I manage to detach it successfully, and open a second Olly and Attach there. Now my whole machine slows down severely. Inspection of Task Manager reveals CPU usage is still less than 10%. Not mentioned in Tutorial, this slowing down.
Eventually I see the infinite jump and change it back to the 60 e8 it used to be, after several minutes of waiting due to the slowness. But here I see something familiar - is it the exact same appearance of the entrypoint at the original target (father process)? If so, have I basically done nothing? Or is it the nature of the Armadillo to create a duplicate of itself? At this point I use the LordPE and dump the entire process. I open with a hex editor, and see the entire .text section (which is supposed to be where the unpacked code goes, I think) is filled with the null. Following that is a section containing the same code as the original file, and then the packed data.
After closing both Ollies and then opening the dump in the new one the speed is back to normal, so I decide to trace through it. It is the same code that was in the original file. I then try to break on WriteProcessMemory, and it does, in other words doing the exact same thing the original file was doing. If I just try to executed the dumped thing directly, it displays message like "This program is corrupted please reinstall".
General observations (open target file with hex editor and look around):
Armadillo's body contains (in order of encounterance) the extremely obfuscated first code section which looks like it's been packed (I obtained an Armadillo'd crackme and can verify that this section is identical to it, and should be similar for all the 3.xx versions), a "padding" of "É"s (NOP), a space of nulls, a piece of an import table, some interesting strings (including "Cannot locate protected program data"

