Unpacking UPX | |||
Theory | |||
What is UPX? UPX is a portable, extendable, high-performance executable packer for several different executable formats. It achieves an excellent compression ratio and offers **very** fast decompression. Your executables suffer no memory overhead or other drawbacks for most of the formats supported. And for all reversers out there, it includes a nice feature :) All UPX supported file formats can be unpacked using the -d switch, eg. upx -d yourfile.exe will uncompress the file you've just compressed. So, before trying anything else, try to unpack it with the -d switch. If that doesn't work...read on :) Every packer needs to unpack the wrapped program in memory, and this
works in the following way : Let's dig in! |
|||
Tracing the loader | |||
TOOLS : SoftIce,
Procdump, FileScanner If we examine the packed file (with a Fileanalyser :), we see only 4 functions in the ImportTable. Among them GetProcAddress, a very useful function. Loadlibrary, or Getmodulehandle can do the trick too :) We can use it to break. Put a 'bpx GetProcAdress' in SoftIce. Now what are we looking for? We need to find the point in the code where
the entire program is unpacked, and when the loader jumps to the OEP (Original
Entry Point). Let's find out ! Run the packed program... We land here : |
|||
:004209C9
|
8A07
|
mov al, byte ptr [edi]
|
- - -^ - - -
unpacking routine... |
Dumping the program | |||
Search for the crackme in the Process list, right-click it, and choose full dump. Save the file, but don't run it yet.
All we have to do is change the OEP to the entry point of the original
program. (Which we found already : 406EFF) Fire up your favorite PEeditor (or use the one in Procdump) and change the Entry Point to : OEP - Image Base = 406EFF - 400000 = 6EFF Put the value 6EFF as Entry point. Save it, and run the program... It works ! Detten |
|||
|