4

recently i got my hands on one sample that self-modifies its .text section. So, I placed a breakpoint on .text section on write operation and then continued. I found out that it zeroes out the .text section and then writes the decrypted code to that section and then makes a call to the decrypted OEP. I used Scylla to correct the OEP and dump the .exe file.

Scylla_output

When i get the imports it shows that the program only imports kernel32.dll.

PEBear_output

This is the assembly of the dumped .exe file in the PEBear.

ImmunityDBG_output

This is what I get when i try to open the dumped file in ImmunityDbg.

The imports i get are also very different from what Scylla gave me + The dumped program does not run it crashes right away. What am i doing wrong?

Thanks.

rustam Shirinov
  • 395
  • 1
  • 3
  • 16

2 Answers2

5

Start by placing a breakpoint on the entrypoint itself, which is probably not in the .text section at all, but in another section entirely. You will see that the program resolves its own imports dynamically, probably by searching within kernel32.dll for LoadLibrary and GetProcAddress.

By tracing through the top layer, you will also find when the decryption is complete and the transfer of control occurs to the decrypted code. If you dump the file at that moment, and then disassemble the result, you might be able to see the cause of the crash - it is likely to be anti-debugging mechanisms, of which there are too many possibilities to list here (but see http://pferrie.host22.com/papers/antidebug.pdf for a selection of commonly-used ones).

peter ferrie
  • 4,709
  • 4
  • 19
  • 33
2

Thanks everyone who responded. The IAT was the problem. The OEP I found was the real OEP pointing to the unpacked code. But the dumped executable was not runnable because IAT was corrupt. After Fixing IAT in Scylla. It is now runnable.

rustam Shirinov
  • 395
  • 1
  • 3
  • 16