SlideShare une entreprise Scribd logo
1  sur  24
www.SecurityXploded.com
Disclaimer
The Content, Demonstration, Source Code and Programs presented here
is "AS IS" without any warranty or conditions of any kind. Also the
views/ideas/knowledge expressed here are solely of the trainer’s only and
nothing to do with the company or the organization in which the trainer is
currently working.

However in no circumstances neither the trainer nor SecurityXploded is
responsible for any damage or loss caused due to use or misuse of the
information presented here.




                              www.SecurityXploded.com
Acknowledgement
 Special thanks to null & Garage4Hackers community for their extended
  support and cooperation.
 Thanks to all the trainers who have devoted their precious time and
  countless hours to make it happen.




                               www.SecurityXploded.com
Reversing & Malware Analysis Training

This presentation is part of our Reverse Engineering & Malware
Analysis Training program. Currently it is delivered only during our local
meet for FREE of cost.




For complete details of this course, visit our Security Training page.


                              www.SecurityXploded.com
Who am I
Nagareshwar Talekar
      Founder of SecurityXploded
      Reverse Engineering, Malware Analysis, Cryptography, Password
       Forensics, Secure Coding etc.
      Email: tnagareshwar at gmail.com




                          www.SecurityXploded.com
Contents
   What is EXE Packing?
   Purpose of Packing EXE
   What is Unpacking?
   Detection of Packer
   Execution of Packed EXE Program
   Standard Process of Unpacking EXE
   Unpacking UPX using OllyDbg
   DEMO - Unpacking UPX
   Anti Anti-Debugging Plugins
   References



                              www.SecurityXploded.com
What is EXE Packing/Protecting?
   EXE Packing:
    Compressing the Executable to a smaller Size


   EXE Protecting:
    Encrypting with Anti-Debugging Techniques to prevent Reversing


   In Reversing world, both Packer & Protector is commonly referred
    as Packer.

Examples of Packers: UPX, AsProtect, Armadillo etc.


                           www.SecurityXploded.com
EXE - Before Packing




      www.SecurityXploded.com
EXE - After Packing




     www.SecurityXploded.com
Purpose of Packing EXE

   Prevent Reverse Engineering [Crack License, Secret Code etc.]
    • Defeat Static Disassembling

    • Make Dynamic Debugging Difficult


   Reduce the size of Executable file

   Bypass Anti-virus Detections with multi-level Packing

   It is used by Software Vendors to prevent Serial Cracking and

    Malware Authors to prevent analysis by AV Researchers.


                              www.SecurityXploded.com
What is Unpacking?

       Extracting the Original Binary from the Packed Executable File.

       Automatic Unpackers available for popular Packers.

    •    May not work with different versions

    •    Not available for Complex packers


       Involves Live Debugging by Defeating Anti-Debugging

        techniques



                                  www.SecurityXploded.com
Detection of Packer

   Packer Detectors like PEiD, RDG, ExeScan etc
     •       Detect the popular Packers

     •       Show the version of Packer also


   PE Viewer Tools like PEditor, PEview
         •   Look at Section Table

         •   Look at Import Table




                                      www.SecurityXploded.com
Packer Detectors




    www.SecurityXploded.com
Structure of Packed EXE




Before Packing                             After Packing

                 www.SecurityXploded.com
Execution of Packed EXE Program

   Execution starts from new OEP


   Saves the Register status using PUSHAD instruction


   All the Packed Sections are Unpacked in memory


   Resolve the import table of original executable file.


   Restore the original Register Status using POPAD instruction


   Finally Jumps to Original Entry point to begin the actual execution


                              www.SecurityXploded.com
Standard Process of Unpacking EXE

   Debug the EXE to find the real OEP (Original Entry Point)


   At OEP, Dump the fully Unpacked Program to Disk


   [?] Fix the Import Table using ImpRec Tool


   [?] Fix the PE Header




                            www.SecurityXploded.com
Unpacking UPX using OllyDbg

   Load the UPX packed EXE file into the OllyDbg

   Start tracing the EXE, until you encounter a PUSHAD instruction.

   At this stage, put the Hardware Breakpoint (type 'hr esp-4' at

    command bar) so as to stop at POPAD instruction.

   Other way is to manually search for POPAD (Opcode 61) instruction

    and then set Breakpoint on it.


                              www.SecurityXploded.com
Unpacking UPX using OllyDbg (contd)

   Next press F9 to continue the Execution.

   You will break on the instruction which is immediately after
    POPAD or on POPAD instruction [based on the method you
    have chosen]
   Now start tracing with F7 and soon you will encounter a JMP
    instruction which will Jump to OEP in the original program.

   At OEP, dump the whole program using OllyDmp plugin.



                           www.SecurityXploded.com
DEMO - Unpacking UPX




      www.SecurityXploded.com
Anti Anti-Debugging Plugins

Here are useful OllyDbg Plugins for Anti Anti-Debugging

      Olly Advanced

      Hide Debugger

      NtGlobalFlag

      Anti Anti BPM




                         www.SecurityXploded.com
Useful Tips

   Always use simple EXE for Unpacking exercises

   Use same EXE for all – You will know the OEP & other magic
    numbers

   Use Windows XP for better (less annoying) debugging experience.

   Have Patience, Its an Art and takes time.

   For best results, do it in the Moon Light 




                           www.SecurityXploded.com
What's Next?

   Try Unpacking AsPack, AsProtect, PESpin, YodaP etc


   Try Unpacking Packed DLL (Google - Neolite       DLL Unpacking)



   Try Advanced Packers: Armadillo 




                           www.SecurityXploded.com
Reference
   Complete Reference Guide for Reversing & Malware
    Analysis Training




                           www.SecurityXploded.com
Thank You !



www.SecurityXploded.com

Contenu connexe

Plus de securityxploded

Fingerprinting healthcare institutions
Fingerprinting healthcare institutionsFingerprinting healthcare institutions
Fingerprinting healthcare institutionssecurityxploded
 
Hollow Process Injection - Reversing and Investigating Malware Evasive Tactics
Hollow Process Injection - Reversing and Investigating Malware Evasive TacticsHollow Process Injection - Reversing and Investigating Malware Evasive Tactics
Hollow Process Injection - Reversing and Investigating Malware Evasive Tacticssecurityxploded
 
Malicious Client Detection Using Machine Learning
Malicious Client Detection Using Machine LearningMalicious Client Detection Using Machine Learning
Malicious Client Detection Using Machine Learningsecurityxploded
 
Understanding CryptoLocker (Ransomware) with a Case Study
Understanding CryptoLocker (Ransomware) with a Case StudyUnderstanding CryptoLocker (Ransomware) with a Case Study
Understanding CryptoLocker (Ransomware) with a Case Studysecurityxploded
 
Linux Malware Analysis using Limon Sandbox
Linux Malware Analysis using Limon SandboxLinux Malware Analysis using Limon Sandbox
Linux Malware Analysis using Limon Sandboxsecurityxploded
 
Automating Malware Analysis
Automating Malware AnalysisAutomating Malware Analysis
Automating Malware Analysissecurityxploded
 
Reverse Engineering Malware
Reverse Engineering MalwareReverse Engineering Malware
Reverse Engineering Malwaresecurityxploded
 
Partial Homomorphic Encryption
Partial Homomorphic EncryptionPartial Homomorphic Encryption
Partial Homomorphic Encryptionsecurityxploded
 
Hunting Rootkit From the Dark Corners Of Memory
Hunting Rootkit From the Dark Corners Of MemoryHunting Rootkit From the Dark Corners Of Memory
Hunting Rootkit From the Dark Corners Of Memorysecurityxploded
 
Return Address – The Silver Bullet
Return Address – The Silver BulletReturn Address – The Silver Bullet
Return Address – The Silver Bulletsecurityxploded
 
Defeating public exploit protections (EMET v5.2 and more)
Defeating public exploit protections (EMET v5.2 and more)Defeating public exploit protections (EMET v5.2 and more)
Defeating public exploit protections (EMET v5.2 and more)securityxploded
 
Hunting Ghost RAT Using Memory Forensics
Hunting Ghost RAT Using Memory ForensicsHunting Ghost RAT Using Memory Forensics
Hunting Ghost RAT Using Memory Forensicssecurityxploded
 
Malicious Url Detection Using Machine Learning
Malicious Url Detection Using Machine LearningMalicious Url Detection Using Machine Learning
Malicious Url Detection Using Machine Learningsecurityxploded
 

Plus de securityxploded (20)

Fingerprinting healthcare institutions
Fingerprinting healthcare institutionsFingerprinting healthcare institutions
Fingerprinting healthcare institutions
 
Hollow Process Injection - Reversing and Investigating Malware Evasive Tactics
Hollow Process Injection - Reversing and Investigating Malware Evasive TacticsHollow Process Injection - Reversing and Investigating Malware Evasive Tactics
Hollow Process Injection - Reversing and Investigating Malware Evasive Tactics
 
Buffer Overflow Attacks
Buffer Overflow AttacksBuffer Overflow Attacks
Buffer Overflow Attacks
 
Malicious Client Detection Using Machine Learning
Malicious Client Detection Using Machine LearningMalicious Client Detection Using Machine Learning
Malicious Client Detection Using Machine Learning
 
Understanding CryptoLocker (Ransomware) with a Case Study
Understanding CryptoLocker (Ransomware) with a Case StudyUnderstanding CryptoLocker (Ransomware) with a Case Study
Understanding CryptoLocker (Ransomware) with a Case Study
 
Linux Malware Analysis using Limon Sandbox
Linux Malware Analysis using Limon SandboxLinux Malware Analysis using Limon Sandbox
Linux Malware Analysis using Limon Sandbox
 
Introduction to SMPC
Introduction to SMPCIntroduction to SMPC
Introduction to SMPC
 
Breaking into hospitals
Breaking into hospitalsBreaking into hospitals
Breaking into hospitals
 
Bluetooth [in]security
Bluetooth [in]securityBluetooth [in]security
Bluetooth [in]security
 
Basic malware analysis
Basic malware analysisBasic malware analysis
Basic malware analysis
 
Automating Malware Analysis
Automating Malware AnalysisAutomating Malware Analysis
Automating Malware Analysis
 
Reverse Engineering Malware
Reverse Engineering MalwareReverse Engineering Malware
Reverse Engineering Malware
 
DLL Preloading Attack
DLL Preloading AttackDLL Preloading Attack
DLL Preloading Attack
 
Partial Homomorphic Encryption
Partial Homomorphic EncryptionPartial Homomorphic Encryption
Partial Homomorphic Encryption
 
Hunting Rootkit From the Dark Corners Of Memory
Hunting Rootkit From the Dark Corners Of MemoryHunting Rootkit From the Dark Corners Of Memory
Hunting Rootkit From the Dark Corners Of Memory
 
Return Address – The Silver Bullet
Return Address – The Silver BulletReturn Address – The Silver Bullet
Return Address – The Silver Bullet
 
Defeating public exploit protections (EMET v5.2 and more)
Defeating public exploit protections (EMET v5.2 and more)Defeating public exploit protections (EMET v5.2 and more)
Defeating public exploit protections (EMET v5.2 and more)
 
Hunting Ghost RAT Using Memory Forensics
Hunting Ghost RAT Using Memory ForensicsHunting Ghost RAT Using Memory Forensics
Hunting Ghost RAT Using Memory Forensics
 
Malicious Url Detection Using Machine Learning
Malicious Url Detection Using Machine LearningMalicious Url Detection Using Machine Learning
Malicious Url Detection Using Machine Learning
 
Anatomy of Exploit Kits
Anatomy of Exploit KitsAnatomy of Exploit Kits
Anatomy of Exploit Kits
 

Dernier

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Dernier (20)

Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Reversing & Malware Analysis Training Part 7 - Unpacking UPX

  • 2. Disclaimer The Content, Demonstration, Source Code and Programs presented here is "AS IS" without any warranty or conditions of any kind. Also the views/ideas/knowledge expressed here are solely of the trainer’s only and nothing to do with the company or the organization in which the trainer is currently working. However in no circumstances neither the trainer nor SecurityXploded is responsible for any damage or loss caused due to use or misuse of the information presented here. www.SecurityXploded.com
  • 3. Acknowledgement  Special thanks to null & Garage4Hackers community for their extended support and cooperation.  Thanks to all the trainers who have devoted their precious time and countless hours to make it happen. www.SecurityXploded.com
  • 4. Reversing & Malware Analysis Training This presentation is part of our Reverse Engineering & Malware Analysis Training program. Currently it is delivered only during our local meet for FREE of cost. For complete details of this course, visit our Security Training page. www.SecurityXploded.com
  • 5. Who am I Nagareshwar Talekar  Founder of SecurityXploded  Reverse Engineering, Malware Analysis, Cryptography, Password Forensics, Secure Coding etc.  Email: tnagareshwar at gmail.com www.SecurityXploded.com
  • 6. Contents  What is EXE Packing?  Purpose of Packing EXE  What is Unpacking?  Detection of Packer  Execution of Packed EXE Program  Standard Process of Unpacking EXE  Unpacking UPX using OllyDbg  DEMO - Unpacking UPX  Anti Anti-Debugging Plugins  References www.SecurityXploded.com
  • 7. What is EXE Packing/Protecting?  EXE Packing: Compressing the Executable to a smaller Size  EXE Protecting: Encrypting with Anti-Debugging Techniques to prevent Reversing  In Reversing world, both Packer & Protector is commonly referred as Packer. Examples of Packers: UPX, AsProtect, Armadillo etc. www.SecurityXploded.com
  • 8. EXE - Before Packing www.SecurityXploded.com
  • 9. EXE - After Packing www.SecurityXploded.com
  • 10. Purpose of Packing EXE  Prevent Reverse Engineering [Crack License, Secret Code etc.] • Defeat Static Disassembling • Make Dynamic Debugging Difficult  Reduce the size of Executable file  Bypass Anti-virus Detections with multi-level Packing  It is used by Software Vendors to prevent Serial Cracking and Malware Authors to prevent analysis by AV Researchers. www.SecurityXploded.com
  • 11. What is Unpacking?  Extracting the Original Binary from the Packed Executable File.  Automatic Unpackers available for popular Packers. • May not work with different versions • Not available for Complex packers  Involves Live Debugging by Defeating Anti-Debugging techniques www.SecurityXploded.com
  • 12. Detection of Packer  Packer Detectors like PEiD, RDG, ExeScan etc • Detect the popular Packers • Show the version of Packer also  PE Viewer Tools like PEditor, PEview • Look at Section Table • Look at Import Table www.SecurityXploded.com
  • 13. Packer Detectors www.SecurityXploded.com
  • 14. Structure of Packed EXE Before Packing After Packing www.SecurityXploded.com
  • 15. Execution of Packed EXE Program  Execution starts from new OEP  Saves the Register status using PUSHAD instruction  All the Packed Sections are Unpacked in memory  Resolve the import table of original executable file.  Restore the original Register Status using POPAD instruction  Finally Jumps to Original Entry point to begin the actual execution www.SecurityXploded.com
  • 16. Standard Process of Unpacking EXE  Debug the EXE to find the real OEP (Original Entry Point)  At OEP, Dump the fully Unpacked Program to Disk  [?] Fix the Import Table using ImpRec Tool  [?] Fix the PE Header www.SecurityXploded.com
  • 17. Unpacking UPX using OllyDbg  Load the UPX packed EXE file into the OllyDbg  Start tracing the EXE, until you encounter a PUSHAD instruction.  At this stage, put the Hardware Breakpoint (type 'hr esp-4' at command bar) so as to stop at POPAD instruction.  Other way is to manually search for POPAD (Opcode 61) instruction and then set Breakpoint on it. www.SecurityXploded.com
  • 18. Unpacking UPX using OllyDbg (contd)  Next press F9 to continue the Execution.  You will break on the instruction which is immediately after POPAD or on POPAD instruction [based on the method you have chosen]  Now start tracing with F7 and soon you will encounter a JMP instruction which will Jump to OEP in the original program.  At OEP, dump the whole program using OllyDmp plugin. www.SecurityXploded.com
  • 19. DEMO - Unpacking UPX www.SecurityXploded.com
  • 20. Anti Anti-Debugging Plugins Here are useful OllyDbg Plugins for Anti Anti-Debugging  Olly Advanced  Hide Debugger  NtGlobalFlag  Anti Anti BPM www.SecurityXploded.com
  • 21. Useful Tips  Always use simple EXE for Unpacking exercises  Use same EXE for all – You will know the OEP & other magic numbers  Use Windows XP for better (less annoying) debugging experience.  Have Patience, Its an Art and takes time.  For best results, do it in the Moon Light  www.SecurityXploded.com
  • 22. What's Next?  Try Unpacking AsPack, AsProtect, PESpin, YodaP etc  Try Unpacking Packed DLL (Google - Neolite DLL Unpacking)  Try Advanced Packers: Armadillo  www.SecurityXploded.com
  • 23. Reference  Complete Reference Guide for Reversing & Malware Analysis Training www.SecurityXploded.com