unUPX v1.06
A Manual Unpacking Essay!
Written by McCodEMaN


Introduction

Greetings and welcome to the noble art of reverse engineering!

A few days ago I downloaded a file from Internet that was packed with 'The Ultimate Packer for eXecutables' (UPX).
I was just about to use ProcDump when it hit me, why not do a manual unpacking and perhaps write an essay. So I downloaded the latest version of UPX, so that the essay would be up-to-date!
ProcDump is a great tool no doubt about that, but when it comes to unpacking/decryption your goal should be to learn how to do this on your own.
ProcDump v1.6.2 is the final version so now the unpacking and decryption is up to you, so I consider this essay to be a step in the right direction!



Tools required


Numega SoftIce
ProcDump v1.6
UPX v1.06

Target's URL

My target was notepad.exe



Essay



Don't mind the addresses!


Open up the packed target in SoftIce symbol loader.
Yes...you're absolutely right, softice won't break! OK, lets fix this minor problem....

Run ProcDump and open the target with the PE Editor, then click Sections. Edit UPX0 section and change:


                     E0000080  into:  E0000060


Now, when you load the file you'll end up here......


:0040F9F0     60                     PUSHAD   <--Push registers to stack!
:0040F9F1     BEAEC04000                MOV    ESI, 0040C0AE  <--Start!
:0040F9F6     8DBE524FFFF               LEA    EDI, [ESI+FFFF4F52]
:0040F9FC     57                       PUSH    EDI
:0040F9FD     83CDFF                     OR    EBP, -01
:0040FA00     EB10                      JMP    0040FA12
 
 
 


If we keep on tracing down through the code we'll loop...loop...loop and so on!
So, here is what we'll do.....


Scroll down the window until you see this:


:0040FB31     8903                   MOV    [EBX], EAX
:0040FB33     83C304                 ADD    EBX, 04
:0040FB36     EBE1                   JMP    0040FB19
:0040FB38     FF96ACFC0000          CALL    [ESI+0000FCAC]
:0040FB3E     61                   POPAD          <---Bpx here!
:0040FB3F     E98815FFFF             JMP    004010CC <--Jump to entry point!
:0040FB44     0000                   ADD    [EAX], AL
:0040FB46     0000                   ADD    [EAX], AL
:0040FB48     0000                   ADD    [EAX], AL
 


Set a bpx on POPAD and press F5!
When softice breaks again go down to the JMP after POPAD and write down the entry point.
The PE Entry point that you'll need later on is:   JMP 004010CC  -   400000 (ImageBase)  =  10CC (In this case).

Now create a infinite loop, like this:


               a eip [ENTER]  and  jmp eip [ENTER] and [Esc]!


Clear your breakpoint and leave softice (F5).



Run ProcDump and set options like this:


Under Structure:

-Recompute Object Size
-Optimize PE Structure (If you like to see Imports and Refs in W32Dasm, don't check this option!)

Under Import:

-Rebuild new import table



You can now select your task and make a full dump, then name it and save.

Run the PE Editor and open your dumped file, then enter the correct PE Entry point (10CC).


-ALL DONE-



Final Notes



I would like to thank:

attiTude, tKC, Razzia, MrX, members of TRES2000 and my beloved Jen!




When ever there is a door,
there is an entrance.
And behind an entrance can no secret hide,
when a cracker takes his knowledge for a ride



ObDuh

The information in this essay is for educational purpose only!
You are only allow to crack, reverse engineer, modify code and debugg programs that you legaly bought and then for personal use only!!
To ignore this warning is a criminell act and can result in lawful actions!

So please note!
I take no responebility for how you use the information in this essay, i take NO responebility for what might happen to you or your computer!
You use this information on your own risk!!

What i mean is: Please buy the software!








Essay written by McCodEMaN ŠTRES2000. All Rights Reserved.