SlideShare a Scribd company logo
1 of 24
Unpacking Malicious Binaries InfraGard September 2008
- In Windows, all executables use a common  format known as a portable executable - PEs are based off the Common Object File  Format (COFF) used in UNIX - The PE format is also used for .dll, .obj, and .sys files in Windows  Portable Executables (PEs)‏
PE Format - All PE files will follow this same format, regardless of the version of Windows
- Packing an executable essentially  encapsulates one PE inside of another PE - The inner PE is our original code (in our case,  the malicious code) and the outer PE is the newly packed executable that is produced - There are two categories of packers, generic packers and custom packers Packing
- Custom packers are unique packing algorithms  invented by the malware author for that specific  piece (or group) of malware - Can be more difficult to unpack, because no  documentation, information, or tutorials about the  packer can be found, because it was custom made - Custom packers may not be as robust, or contain  all of the extra features that a generic packer might  include, and once you figure out how to unpack one  custom packed binary, you can usually unpack all of  its related binaries (ie different versions of Storm)‏ Custom vs Generic packers
- Generic packers can be easier to unpack than  custom made packers, because information and  tutorials can be found online where people have  already reverse engineered these packers - Methods of unpacking stay consistent with the  packer used, in other words, all malware packed  with UPX can be unpacked the same way - However, many contain extra features such as antidebugging (won't run in a debugger) or anti VMware (won't run in a virtual machine)‏ Custom vs Generic packers
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Examples of generic packers: ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
- Obfuscation of the malicious code. The  original executable can't be analyzed or  reverse engineered until it has been  unpacked - Makes the malware harder to detect for AV  products - Makes the executable compressed/smaller  in size - Can make the same (or similar) pieces of  malware appear to be different Why bother packing?
- Peid, a program used to detect which packer was used on an executable  - Ollydbg, with the Ollydump plugin, for  disassembling and debugging the executable - ImpRec, for reconstructing the IAT - Strings, to pull strings from the unpacked  binary - Procexplorer, to tell when you've accidentally  infected yourself  Tools used for unpacking
- Unpacking allows analysis and reverse engineering of a piece of malware - Allows us to find information that we  otherwise might not find, for example what compiler was used, strings that hint at what the malware does, IP addresses, etc. - Allows us to show that 2 pieces of malware are related, when they otherwise don't appear  to be Advantages of unpacking
- In order to unpack a PE, we must use a  disassembler and debugger to step through the outer PE, until we reach the original entry point  (OEP) of the inner binary (our malware)‏ - From there, we can dump the binary starting at that OEP, which now gives us an unpacked version of that inner PE - If we want to execute the PE, we must repair its import address table (IAT)‏ - A lot of unpacking is Trial and Error The unpacking process
- Using PEID, this is a good place to start, but this  method is fairly unreliable, and doesn't ID custom  packers - Looking at the section headers of a PE can also give hints about which packer was used Identifying the Packer
- Running strings on an executable, some strings can give  hints about which packer was used - Ollydbg is pretty reliable on determining if a binary is  packed, though not what it was packed with Identifying the Packer
-  Refers to a trick commonly used by unpackers. Can be used to unpack many generic packers - Many generic packers start with the instruction “ PUSHAD”, this pushes all information in  the  processor's registers onto the stack, thus allowing the packer to use the registers without risk of  overwriting important information in those registers  (if for example, the unpacked binary will later need to reference those values)‏ The ESP trick
The ESP trick - ESP refers to the register that holds the  stack pointer
- After executing the PUSHAD, the next time the  executable references the stack pointer (ESP) is when it is popping everything off the stack - The executable isn't going to pop everything off the stack until it is done using the registers, or in other  words, when it is finished unpacking The ESP trick - The next JMP after the POPAD will be our OEP
- Execute the PUSHAD at the start of the  packed executable - Set a breakpoint on the stack pointer ESP - Let the program run until it hits the breakpoint - Execute the program one line at a time until you hit the next JMP statement, this will be the unpacked executable's OEP The ESP trick
- Live demo of video.exe
Video.exe screens
Video.exe screens
- Live demo of Colonial Digital Certificates
Digital cert spam screens
Digital cert spam screens
Questions?

More Related Content

What's hot

ovs-2.3.1 on debian 8.1
ovs-2.3.1 on debian 8.1ovs-2.3.1 on debian 8.1
ovs-2.3.1 on debian 8.1
Clive Peng
 

What's hot (10)

Gambit for Geiser
Gambit for GeiserGambit for Geiser
Gambit for Geiser
 
Volatility101
Volatility101Volatility101
Volatility101
 
Apparmor
ApparmorApparmor
Apparmor
 
Using strace
Using straceUsing strace
Using strace
 
ovs-2.3.1 on debian 8.1
ovs-2.3.1 on debian 8.1ovs-2.3.1 on debian 8.1
ovs-2.3.1 on debian 8.1
 
Desktop Application In Linux
Desktop Application In LinuxDesktop Application In Linux
Desktop Application In Linux
 
Lab so-abertos-unidade1
Lab so-abertos-unidade1Lab so-abertos-unidade1
Lab so-abertos-unidade1
 
Composer Tutorial (PHP Hampshire Sept 2013)
Composer Tutorial (PHP Hampshire Sept 2013)Composer Tutorial (PHP Hampshire Sept 2013)
Composer Tutorial (PHP Hampshire Sept 2013)
 
maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming maXbox Starter 42 Multiprocessing Programming
maXbox Starter 42 Multiprocessing Programming
 
VerneMQ @ Paris Erlang User Group June 29th 2015
VerneMQ @ Paris Erlang User Group June 29th 2015VerneMQ @ Paris Erlang User Group June 29th 2015
VerneMQ @ Paris Erlang User Group June 29th 2015
 

Viewers also liked

Hybrid Rice -- Alternative for Professional Farmers
Hybrid Rice -- Alternative for Professional FarmersHybrid Rice -- Alternative for Professional Farmers
Hybrid Rice -- Alternative for Professional Farmers
NSTDA THAILAND
 
Metra Prostasias Gia Tin Gripi H1 N1
Metra Prostasias Gia Tin Gripi H1 N1Metra Prostasias Gia Tin Gripi H1 N1
Metra Prostasias Gia Tin Gripi H1 N1
Kostas Tampakis
 
La bella roma[1][1]._tno
La bella roma[1][1]._tnoLa bella roma[1][1]._tno
La bella roma[1][1]._tno
Kostas Tampakis
 
Air Quality
Air QualityAir Quality
Air Quality
ekhouri
 
Semana Santa 2010
Semana Santa 2010Semana Santa 2010
Semana Santa 2010
mgcanu
 
20120512 robots en verzekeraar
20120512 robots en verzekeraar20120512 robots en verzekeraar
20120512 robots en verzekeraar
JGB de Groot
 
ANDREA, SARA AND LUCÍA IN MADRID
ANDREA, SARA AND LUCÍA IN MADRIDANDREA, SARA AND LUCÍA IN MADRID
ANDREA, SARA AND LUCÍA IN MADRID
ceipcruceiro
 

Viewers also liked (20)

Animals
AnimalsAnimals
Animals
 
BCS Selenium Workshop
BCS Selenium WorkshopBCS Selenium Workshop
BCS Selenium Workshop
 
Hybrid Rice -- Alternative for Professional Farmers
Hybrid Rice -- Alternative for Professional FarmersHybrid Rice -- Alternative for Professional Farmers
Hybrid Rice -- Alternative for Professional Farmers
 
Giants
GiantsGiants
Giants
 
Activism Reader
Activism ReaderActivism Reader
Activism Reader
 
Metra Prostasias Gia Tin Gripi H1 N1
Metra Prostasias Gia Tin Gripi H1 N1Metra Prostasias Gia Tin Gripi H1 N1
Metra Prostasias Gia Tin Gripi H1 N1
 
Regulacja otwartej edukacji i nauki
Regulacja otwartej edukacji i naukiRegulacja otwartej edukacji i nauki
Regulacja otwartej edukacji i nauki
 
РИФ 2016, Киберпреступность в России и еѐ влияние на экономику страны
РИФ 2016, Киберпреступность в России и еѐ влияние на экономику страныРИФ 2016, Киберпреступность в России и еѐ влияние на экономику страны
РИФ 2016, Киберпреступность в России и еѐ влияние на экономику страны
 
La bella roma[1][1]._tno
La bella roma[1][1]._tnoLa bella roma[1][1]._tno
La bella roma[1][1]._tno
 
120 маркетинговых диаграмм
120 маркетинговых диаграмм120 маркетинговых диаграмм
120 маркетинговых диаграмм
 
SRIVIROJ FARM NO. 1 IN THE NORTHEAST
SRIVIROJ FARM NO. 1 IN THE NORTHEASTSRIVIROJ FARM NO. 1 IN THE NORTHEAST
SRIVIROJ FARM NO. 1 IN THE NORTHEAST
 
Vegan Infants
Vegan InfantsVegan Infants
Vegan Infants
 
THAI KIDS WIN 3 AWARDS AT IDC RoBoCON 2009 IN JAPAN
THAI KIDS WIN 3 AWARDS AT IDC RoBoCON 2009 IN JAPANTHAI KIDS WIN 3 AWARDS AT IDC RoBoCON 2009 IN JAPAN
THAI KIDS WIN 3 AWARDS AT IDC RoBoCON 2009 IN JAPAN
 
Air Quality
Air QualityAir Quality
Air Quality
 
Digitized Isan Krungthep Turakij 211009
Digitized Isan  Krungthep Turakij 211009Digitized Isan  Krungthep Turakij 211009
Digitized Isan Krungthep Turakij 211009
 
Semana Santa 2010
Semana Santa 2010Semana Santa 2010
Semana Santa 2010
 
Alimentazione Aiurvedjca
Alimentazione AiurvedjcaAlimentazione Aiurvedjca
Alimentazione Aiurvedjca
 
20120512 robots en verzekeraar
20120512 robots en verzekeraar20120512 robots en verzekeraar
20120512 robots en verzekeraar
 
Продвижение электротехнической продукции на высококонкурентном рынке
Продвижение электротехнической продукции на высококонкурентном рынкеПродвижение электротехнической продукции на высококонкурентном рынке
Продвижение электротехнической продукции на высококонкурентном рынке
 
ANDREA, SARA AND LUCÍA IN MADRID
ANDREA, SARA AND LUCÍA IN MADRIDANDREA, SARA AND LUCÍA IN MADRID
ANDREA, SARA AND LUCÍA IN MADRID
 

Similar to Infragard Sept08

Bypassing anti virus scanners
Bypassing anti virus scannersBypassing anti virus scanners
Bypassing anti virus scanners
martacax
 
How to Make a Honeypot Stickier (SSH*)
How to Make a Honeypot Stickier (SSH*)How to Make a Honeypot Stickier (SSH*)
How to Make a Honeypot Stickier (SSH*)
Jose Hernandez
 
Bypassing anti virus scanners
Bypassing anti virus scannersBypassing anti virus scanners
Bypassing anti virus scanners
martacax
 
How to Make a Honeypot Stickier (SSH*)
How to Make a Honeypot Stickier (SSH*)How to Make a Honeypot Stickier (SSH*)
How to Make a Honeypot Stickier (SSH*)
Jose Hernandez
 
Making%20R%20Packages%20Under%20Windows
Making%20R%20Packages%20Under%20WindowsMaking%20R%20Packages%20Under%20Windows
Making%20R%20Packages%20Under%20Windows
tutorialsruby
 
Making%20R%20Packages%20Under%20Windows
Making%20R%20Packages%20Under%20WindowsMaking%20R%20Packages%20Under%20Windows
Making%20R%20Packages%20Under%20Windows
tutorialsruby
 

Similar to Infragard Sept08 (20)

Bypassing anti virus scanners
Bypassing anti virus scannersBypassing anti virus scanners
Bypassing anti virus scanners
 
Learning Puppet Chapter 1
Learning Puppet Chapter 1Learning Puppet Chapter 1
Learning Puppet Chapter 1
 
Parrot tutorial
Parrot tutorialParrot tutorial
Parrot tutorial
 
How to Make a Honeypot Stickier (SSH*)
How to Make a Honeypot Stickier (SSH*)How to Make a Honeypot Stickier (SSH*)
How to Make a Honeypot Stickier (SSH*)
 
Bypassing anti virus scanners
Bypassing anti virus scannersBypassing anti virus scanners
Bypassing anti virus scanners
 
Reversing malware analysis training part7 unpackingupx
Reversing malware analysis training part7 unpackingupxReversing malware analysis training part7 unpackingupx
Reversing malware analysis training part7 unpackingupx
 
Installing application in ubuntu [autosaved]
Installing application in ubuntu [autosaved]Installing application in ubuntu [autosaved]
Installing application in ubuntu [autosaved]
 
HowTo Install openMPI on Ubuntu
HowTo Install openMPI on UbuntuHowTo Install openMPI on Ubuntu
HowTo Install openMPI on Ubuntu
 
Perl_Part7
Perl_Part7Perl_Part7
Perl_Part7
 
FPM at the Ruby Drink-up of Sophia, September 2011
FPM at the Ruby Drink-up of Sophia, September 2011FPM at the Ruby Drink-up of Sophia, September 2011
FPM at the Ruby Drink-up of Sophia, September 2011
 
How to Make a Honeypot Stickier (SSH*)
How to Make a Honeypot Stickier (SSH*)How to Make a Honeypot Stickier (SSH*)
How to Make a Honeypot Stickier (SSH*)
 
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
 
Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015
 
Instruction: dev environment
Instruction: dev environmentInstruction: dev environment
Instruction: dev environment
 
Pwnstaller
PwnstallerPwnstaller
Pwnstaller
 
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
 
DevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration managementDevOps Series: Extending vagrant with Puppet for configuration management
DevOps Series: Extending vagrant with Puppet for configuration management
 
Linux Troubleshooting
Linux TroubleshootingLinux Troubleshooting
Linux Troubleshooting
 
Making%20R%20Packages%20Under%20Windows
Making%20R%20Packages%20Under%20WindowsMaking%20R%20Packages%20Under%20Windows
Making%20R%20Packages%20Under%20Windows
 
Making%20R%20Packages%20Under%20Windows
Making%20R%20Packages%20Under%20WindowsMaking%20R%20Packages%20Under%20Windows
Making%20R%20Packages%20Under%20Windows
 

Infragard Sept08

  • 1. Unpacking Malicious Binaries InfraGard September 2008
  • 2. - In Windows, all executables use a common format known as a portable executable - PEs are based off the Common Object File Format (COFF) used in UNIX - The PE format is also used for .dll, .obj, and .sys files in Windows Portable Executables (PEs)‏
  • 3. PE Format - All PE files will follow this same format, regardless of the version of Windows
  • 4. - Packing an executable essentially encapsulates one PE inside of another PE - The inner PE is our original code (in our case, the malicious code) and the outer PE is the newly packed executable that is produced - There are two categories of packers, generic packers and custom packers Packing
  • 5. - Custom packers are unique packing algorithms invented by the malware author for that specific piece (or group) of malware - Can be more difficult to unpack, because no documentation, information, or tutorials about the packer can be found, because it was custom made - Custom packers may not be as robust, or contain all of the extra features that a generic packer might include, and once you figure out how to unpack one custom packed binary, you can usually unpack all of its related binaries (ie different versions of Storm)‏ Custom vs Generic packers
  • 6. - Generic packers can be easier to unpack than custom made packers, because information and tutorials can be found online where people have already reverse engineered these packers - Methods of unpacking stay consistent with the packer used, in other words, all malware packed with UPX can be unpacked the same way - However, many contain extra features such as antidebugging (won't run in a debugger) or anti VMware (won't run in a virtual machine)‏ Custom vs Generic packers
  • 7.
  • 8. - Obfuscation of the malicious code. The original executable can't be analyzed or reverse engineered until it has been unpacked - Makes the malware harder to detect for AV products - Makes the executable compressed/smaller in size - Can make the same (or similar) pieces of malware appear to be different Why bother packing?
  • 9. - Peid, a program used to detect which packer was used on an executable - Ollydbg, with the Ollydump plugin, for disassembling and debugging the executable - ImpRec, for reconstructing the IAT - Strings, to pull strings from the unpacked binary - Procexplorer, to tell when you've accidentally infected yourself Tools used for unpacking
  • 10. - Unpacking allows analysis and reverse engineering of a piece of malware - Allows us to find information that we otherwise might not find, for example what compiler was used, strings that hint at what the malware does, IP addresses, etc. - Allows us to show that 2 pieces of malware are related, when they otherwise don't appear to be Advantages of unpacking
  • 11. - In order to unpack a PE, we must use a disassembler and debugger to step through the outer PE, until we reach the original entry point (OEP) of the inner binary (our malware)‏ - From there, we can dump the binary starting at that OEP, which now gives us an unpacked version of that inner PE - If we want to execute the PE, we must repair its import address table (IAT)‏ - A lot of unpacking is Trial and Error The unpacking process
  • 12. - Using PEID, this is a good place to start, but this method is fairly unreliable, and doesn't ID custom packers - Looking at the section headers of a PE can also give hints about which packer was used Identifying the Packer
  • 13. - Running strings on an executable, some strings can give hints about which packer was used - Ollydbg is pretty reliable on determining if a binary is packed, though not what it was packed with Identifying the Packer
  • 14. - Refers to a trick commonly used by unpackers. Can be used to unpack many generic packers - Many generic packers start with the instruction “ PUSHAD”, this pushes all information in the processor's registers onto the stack, thus allowing the packer to use the registers without risk of overwriting important information in those registers (if for example, the unpacked binary will later need to reference those values)‏ The ESP trick
  • 15. The ESP trick - ESP refers to the register that holds the stack pointer
  • 16. - After executing the PUSHAD, the next time the executable references the stack pointer (ESP) is when it is popping everything off the stack - The executable isn't going to pop everything off the stack until it is done using the registers, or in other words, when it is finished unpacking The ESP trick - The next JMP after the POPAD will be our OEP
  • 17. - Execute the PUSHAD at the start of the packed executable - Set a breakpoint on the stack pointer ESP - Let the program run until it hits the breakpoint - Execute the program one line at a time until you hit the next JMP statement, this will be the unpacked executable's OEP The ESP trick
  • 18. - Live demo of video.exe
  • 21. - Live demo of Colonial Digital Certificates
  • 22. Digital cert spam screens
  • 23. Digital cert spam screens