11 1 Packing and Unpacking
11 1 Packing and Unpacking
Chapter 18
Packer
• Used to shrink and encrypt malware to thwart detection by
antivirus
• When packed, only access to the packed file
Prevents static analysis since malware must be unpacked and
decrypted before analysis
Original executable transformed to a unique self-extracting one via
compression, encryption, and obfuscation
Difficult to reverse-engineer
Employs anti-disassembly, anti-debugging, and anti-VM techniques
to make analysis difficult
Packer Anatomy
• Unpacking Stub
Small piece of code loaded by the OS just as a normal program
Unpacking stub loads original program
Can be viewed by the analyst
Steps
Unpacking original executable into memory
Loader reads PE header and copies packed sections into allocated memory normally
Unpacking stub unpacks code and copies it into the space allocated
Resolving imports of original executable
Windows loader cannot read packed info –resolve imports by unpacking stub
Loader reads PE header to find library functions to import and their addresses
Unless packed code's imports included in unpacking code's import section, unpacker must resolve imports manually using
LoadLibrary and GetProcAddress
Other approaches also available – discussed in Chapter 19 (no import is needed, stealthier)
Transfer of execution to original execution point
Tail jump to entry point – use ret or call function to obscure
Unpacking Illustrated
Packed executable