SlideShare a Scribd company logo
Advanced Malware Analysis Training Series




        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 community for their extended support and co-operation.


 Special thanks to ThoughtWorks for the beautiful venue.


 Thanks to all the trainers who have devoted their precious time and countless hours to make it
  happen.




                                        www.SecurityXploded.com
Advanced Malware Analysis Training

This presentation is part of our Advanced Malware Analysis Training program. Currently it
is delivered only during our local meets for FREE of cost.




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

                                          www.SecurityXploded.com
Who am I?
Harsimran Walia
     Member, SecurityXploded
     Research Scientist, McAfee Labs
     Reversing, Malware Analysis, Exploit Analysis/Development etc.
     Personal site: http://harsimranwalia.info
     E-mail: walia.harsimran@gmail.com
     Twitter: b44nz0r




                                        www.SecurityXploded.com
Content
   Automation
     Python scripts

     Use of modules

   Tools/Modules discussed
     PEfile

     PyDbg

     IDAPython




                                www.SecurityXploded.com
PEfile
   Python module to read and work with Portable Executable (PE) files

   pefile requires understanding of the layout of a PE file (already covered)

   Tasks that pefile makes possible are:
     Modifying and writing back to the PE image
     Header Inspection
     Sections analysis
     Retrieving data
     Warnings for suspicious and malformed values
     Packer detection with PEiD’s signatures




                                            www.SecurityXploded.com
Pefile (hands-on)
    Load a PE (create an instance)




    Reading important PE header attributes




    Modifying values
All PE instance values support assignment followed by a call to write function to write the modified exe to system




                                                           www.SecurityXploded.com
Pefile (hands-on)
   PE sections – fetching detail about sections



                                                                      Output
   File Info




                                                                               Output




                                            www.SecurityXploded.com
Pefile (hands-on)
   Type of file (exe/dll/driver)




   List of imported dlls and imported functions




                                           www.SecurityXploded.com
Pydbg
   Open Source Python debugger

   Developed by Pedram Amini as the main component of PaiMei framework

   It uses user-defined callback functions

   These functions can implement actions to take on hitting a breakpoint, exception
    etc

   Upon execution of the callback function the control is passed back to pydbg to
    execute the program normally




                                         www.SecurityXploded.com
Pydbg installation
 Download or git clone: https://github.com/OpenRCE/pydbg
 Pre-reqs
     Python 2.7
     c-types python library
   Copy the pydbg files to Python-2.7Libsite-packagespydbg
 pydasm.pyd is compiled for Python 2.6, lets fix this!
 Open pydasm.pyd in any hex-editor(010 etc) and search python
     Change python26.dll to python27.dll
     Save and replace with original


                                       www.SecurityXploded.com
Pydbg (hands-on)
                          Import required pydbg modules and struct




                            Breakpoint handler for CreateFileA
                            Extract the parameter from the stack = filename



                            Breakpoint handler for CreateFileW




                            •    Look for process to debug
                            •    Attach debugger to process
                            •    Set breakpoint on function entry address
                            •    Attach a breakpoint handler

www.SecurityXploded.com
IDA Python
   An IDA Pro plugin

   Integrates Python, allowing scripts to run in IDA Pro

   IDAPython Scripts have access to
     IDA Plugin API,

     IDC and all modules available for Python




                                             www.SecurityXploded.com
Installation
   Download the plugin from https://code.google.com/p/idapython

   Match the IDAPro and python version before downloading

   Copy the ''python'' directory from the extracted plugin to the IDA Pro install
    directory (%IDADIR%)

   Copy the plugin executable to ''%IDADIR%plugins''




                                        www.SecurityXploded.com
Hands-on
   Utility functions
     ScreenEA()
       ○   Obtains the address of where your cursor is currently positioned on the IDA screen.
     GetInputFileMD5()
       ○   Returns the MD5 hash of the binary loaded in IDA, which is useful for tracking changes in the binary



   Functions
     Functions( long StartAddress, long EndAddress )
       ○   Returns a list of all function start addresses contained between StartAddress and EndAddress.
     LocByName( string FunctionName )
       ○   Returns the address of a function based on its name.
     GetFunctionName( long Address )
       ○   Given an address, returns the name of the function the address belongs to.



                                                      www.SecurityXploded.com
Hands-on




   Try running on war-ftpd.exe


                                     www.SecurityXploded.com
Demo..
   ExeScan

     http://www.securityxploded.com/exe-scan.php



   Malpimp

     http://www.securityxploded.com/malpimp.php




                                  www.SecurityXploded.com
Reference
Complete Reference Guide for Advanced Malware Analysis Training
[Include links for all the Demos & Tools]




                                            www.SecurityXploded.com
Thank You !



www.SecurityXploded.com




       www.SecurityXploded.com

More Related Content

PPTX
Reversing & malware analysis training part 2 introduction to windows internals
PPTX
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
PPTX
Advanced Malware Analysis Training Session 6 - Malware Sandbox Analysis
PPTX
Advanced Malware Analysis Training Session 3 - Botnet Analysis Part 2
PPTX
Advanced Malware Analysis Training Session 1 - Detection and Removal of Malwares
PPTX
Reversing & malware analysis training part 3 windows pe file format basics
PPTX
Primer on password security
PPTX
Reversing & malware analysis training part 1 lab setup guide
Reversing & malware analysis training part 2 introduction to windows internals
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 6 - Malware Sandbox Analysis
Advanced Malware Analysis Training Session 3 - Botnet Analysis Part 2
Advanced Malware Analysis Training Session 1 - Detection and Removal of Malwares
Reversing & malware analysis training part 3 windows pe file format basics
Primer on password security
Reversing & malware analysis training part 1 lab setup guide

What's hot (20)

PPTX
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
PPTX
Anti-Virus Evasion Techniques and Countermeasures
PPTX
Reversing & Malware Analysis Training Part 9 - Advanced Malware Analysis
PPTX
Advanced Malware Analysis Training Session 7 - Malware Memory Forensics
PPTX
Advanced Malware Analysis Training Session 4 - Anti-Analysis Techniques
PPTX
Reversing & Malware Analysis Training Part 13 - Future Roadmap
PPTX
Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...
PPTX
Advanced Malware Analysis Training Session 8 - Introduction to Android
PPTX
Anatomy of Exploit Kits
PPTX
Hunting Rootkit From the Dark Corners Of Memory
PPTX
Advanced malwareanalysis training session2 botnet analysis part1
PPTX
Application Virtualization
PPTX
Advanced malware analysis training session5 reversing automation
PPTX
Advanced malware analysis training session 7 malware memory forensics
PPTX
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
PPTX
Reversing malware analysis training part6 practical reversing
PPTX
Reversing malware analysis training part11 exploit development advanced
PPTX
Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)
PPTX
Advanced malware analysis training session8 introduction to android
PPTX
Dissecting Android APK
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
Anti-Virus Evasion Techniques and Countermeasures
Reversing & Malware Analysis Training Part 9 - Advanced Malware Analysis
Advanced Malware Analysis Training Session 7 - Malware Memory Forensics
Advanced Malware Analysis Training Session 4 - Anti-Analysis Techniques
Reversing & Malware Analysis Training Part 13 - Future Roadmap
Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...
Advanced Malware Analysis Training Session 8 - Introduction to Android
Anatomy of Exploit Kits
Hunting Rootkit From the Dark Corners Of Memory
Advanced malwareanalysis training session2 botnet analysis part1
Application Virtualization
Advanced malware analysis training session5 reversing automation
Advanced malware analysis training session 7 malware memory forensics
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Reversing malware analysis training part6 practical reversing
Reversing malware analysis training part11 exploit development advanced
Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)
Advanced malware analysis training session8 introduction to android
Dissecting Android APK
Ad

Similar to Advanced Malware Analysis Training Session 5 - Reversing Automation (20)

PDF
Reversing & malware analysis training part 5 reverse engineering tools basics
PPTX
Malware 101 by saurabh chaudhary
PDF
Security Challenges of Antivirus Engines, Products and Systems
PPTX
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
PPTX
Introduction to Malware Analysis
PDF
CNIT 126 Ch 0: Malware Analysis Primer & 1: Basic Static Techniques
PPTX
Malware Static Analysis
PPTX
PPTX
Malware Analysis Techniques &Incident Response.pptx
PPTX
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
PDF
Cyber Defense Forensic Analyst - Real World Hands-on Examples
PDF
Reversing & malware analysis training part 1 lab setup guide
PDF
Reversing & malware analysis training part 12 rootkit analysis
PDF
MODERN MALWARE THREAT: HANDLING OBFUSCATED CODE -- CONFIDENCE CONFERENCE (2019)
PPTX
Vulnerability, exploit to metasploit
PDF
Malware Analysis -an overview by PP Singh
PDF
'Malware Analysis' by PP Singh
PPTX
Let's Talk Technical: Malware Evasion and Detection
PDF
Reversing & malware analysis training part 9 advanced malware analysis
PDF
Malware Analysis Tips and Tricks.pdf
Reversing & malware analysis training part 5 reverse engineering tools basics
Malware 101 by saurabh chaudhary
Security Challenges of Antivirus Engines, Products and Systems
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
Introduction to Malware Analysis
CNIT 126 Ch 0: Malware Analysis Primer & 1: Basic Static Techniques
Malware Static Analysis
Malware Analysis Techniques &Incident Response.pptx
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Cyber Defense Forensic Analyst - Real World Hands-on Examples
Reversing & malware analysis training part 1 lab setup guide
Reversing & malware analysis training part 12 rootkit analysis
MODERN MALWARE THREAT: HANDLING OBFUSCATED CODE -- CONFIDENCE CONFERENCE (2019)
Vulnerability, exploit to metasploit
Malware Analysis -an overview by PP Singh
'Malware Analysis' by PP Singh
Let's Talk Technical: Malware Evasion and Detection
Reversing & malware analysis training part 9 advanced malware analysis
Malware Analysis Tips and Tricks.pdf
Ad

More from securityxploded (20)

PPTX
Fingerprinting healthcare institutions
PDF
Hollow Process Injection - Reversing and Investigating Malware Evasive Tactics
PDF
Buffer Overflow Attacks
PPTX
Malicious Client Detection Using Machine Learning
PDF
Understanding CryptoLocker (Ransomware) with a Case Study
PDF
Linux Malware Analysis using Limon Sandbox
PPT
Introduction to SMPC
PPTX
Breaking into hospitals
PPTX
Bluetooth [in]security
PPTX
Basic malware analysis
PPTX
Automating Malware Analysis
PPTX
Reverse Engineering Malware
PPTX
DLL Preloading Attack
PPTX
Partial Homomorphic Encryption
PPTX
Return Address – The Silver Bullet
PPTX
Defeating public exploit protections (EMET v5.2 and more)
PPTX
Hunting Ghost RAT Using Memory Forensics
PPTX
Malicious Url Detection Using Machine Learning
PPTX
MalwareNet Project
PPTX
Reversing and Decrypting the Communications of APT Malware (Etumbot)
Fingerprinting healthcare institutions
Hollow Process Injection - Reversing and Investigating Malware Evasive Tactics
Buffer Overflow Attacks
Malicious Client Detection Using Machine Learning
Understanding CryptoLocker (Ransomware) with a Case Study
Linux Malware Analysis using Limon Sandbox
Introduction to SMPC
Breaking into hospitals
Bluetooth [in]security
Basic malware analysis
Automating Malware Analysis
Reverse Engineering Malware
DLL Preloading Attack
Partial Homomorphic Encryption
Return Address – The Silver Bullet
Defeating public exploit protections (EMET v5.2 and more)
Hunting Ghost RAT Using Memory Forensics
Malicious Url Detection Using Machine Learning
MalwareNet Project
Reversing and Decrypting the Communications of APT Malware (Etumbot)

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
A Presentation on Artificial Intelligence
PPTX
Machine Learning_overview_presentation.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
Getting Started with Data Integration: FME Form 101
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
August Patch Tuesday
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Tartificialntelligence_presentation.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
Spectroscopy.pptx food analysis technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
1. Introduction to Computer Programming.pptx
PPTX
OMC Textile Division Presentation 2021.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
A Presentation on Artificial Intelligence
Machine Learning_overview_presentation.pptx
Encapsulation theory and applications.pdf
Mobile App Security Testing_ A Comprehensive Guide.pdf
A comparative study of natural language inference in Swahili using monolingua...
Univ-Connecticut-ChatGPT-Presentaion.pdf
Getting Started with Data Integration: FME Form 101
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Accuracy of neural networks in brain wave diagnosis of schizophrenia
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
August Patch Tuesday
Assigned Numbers - 2025 - Bluetooth® Document
Tartificialntelligence_presentation.pptx
Programs and apps: productivity, graphics, security and other tools
cloud_computing_Infrastucture_as_cloud_p
Spectroscopy.pptx food analysis technology
Building Integrated photovoltaic BIPV_UPV.pdf
1. Introduction to Computer Programming.pptx
OMC Textile Division Presentation 2021.pptx

Advanced Malware Analysis Training Session 5 - Reversing Automation

  • 1. Advanced Malware Analysis Training Series www.SecurityXploded.com
  • 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 community for their extended support and co-operation.  Special thanks to ThoughtWorks for the beautiful venue.  Thanks to all the trainers who have devoted their precious time and countless hours to make it happen. www.SecurityXploded.com
  • 4. Advanced Malware Analysis Training This presentation is part of our Advanced Malware Analysis Training program. Currently it is delivered only during our local meets for FREE of cost. For complete details of this course, visit our Security Training page. www.SecurityXploded.com
  • 5. Who am I? Harsimran Walia  Member, SecurityXploded  Research Scientist, McAfee Labs  Reversing, Malware Analysis, Exploit Analysis/Development etc.  Personal site: http://harsimranwalia.info  E-mail: [email protected]  Twitter: b44nz0r www.SecurityXploded.com
  • 6. Content  Automation  Python scripts  Use of modules  Tools/Modules discussed  PEfile  PyDbg  IDAPython www.SecurityXploded.com
  • 7. PEfile  Python module to read and work with Portable Executable (PE) files  pefile requires understanding of the layout of a PE file (already covered)  Tasks that pefile makes possible are:  Modifying and writing back to the PE image  Header Inspection  Sections analysis  Retrieving data  Warnings for suspicious and malformed values  Packer detection with PEiD’s signatures www.SecurityXploded.com
  • 8. Pefile (hands-on)  Load a PE (create an instance)  Reading important PE header attributes  Modifying values All PE instance values support assignment followed by a call to write function to write the modified exe to system www.SecurityXploded.com
  • 9. Pefile (hands-on)  PE sections – fetching detail about sections Output  File Info Output www.SecurityXploded.com
  • 10. Pefile (hands-on)  Type of file (exe/dll/driver)  List of imported dlls and imported functions www.SecurityXploded.com
  • 11. Pydbg  Open Source Python debugger  Developed by Pedram Amini as the main component of PaiMei framework  It uses user-defined callback functions  These functions can implement actions to take on hitting a breakpoint, exception etc  Upon execution of the callback function the control is passed back to pydbg to execute the program normally www.SecurityXploded.com
  • 12. Pydbg installation  Download or git clone: https://github.com/OpenRCE/pydbg  Pre-reqs  Python 2.7  c-types python library  Copy the pydbg files to Python-2.7Libsite-packagespydbg  pydasm.pyd is compiled for Python 2.6, lets fix this!  Open pydasm.pyd in any hex-editor(010 etc) and search python  Change python26.dll to python27.dll  Save and replace with original www.SecurityXploded.com
  • 13. Pydbg (hands-on) Import required pydbg modules and struct Breakpoint handler for CreateFileA Extract the parameter from the stack = filename Breakpoint handler for CreateFileW • Look for process to debug • Attach debugger to process • Set breakpoint on function entry address • Attach a breakpoint handler www.SecurityXploded.com
  • 14. IDA Python  An IDA Pro plugin  Integrates Python, allowing scripts to run in IDA Pro  IDAPython Scripts have access to  IDA Plugin API,  IDC and all modules available for Python www.SecurityXploded.com
  • 15. Installation  Download the plugin from https://code.google.com/p/idapython  Match the IDAPro and python version before downloading  Copy the ''python'' directory from the extracted plugin to the IDA Pro install directory (%IDADIR%)  Copy the plugin executable to ''%IDADIR%plugins'' www.SecurityXploded.com
  • 16. Hands-on  Utility functions  ScreenEA() ○ Obtains the address of where your cursor is currently positioned on the IDA screen.  GetInputFileMD5() ○ Returns the MD5 hash of the binary loaded in IDA, which is useful for tracking changes in the binary  Functions  Functions( long StartAddress, long EndAddress ) ○ Returns a list of all function start addresses contained between StartAddress and EndAddress.  LocByName( string FunctionName ) ○ Returns the address of a function based on its name.  GetFunctionName( long Address ) ○ Given an address, returns the name of the function the address belongs to. www.SecurityXploded.com
  • 17. Hands-on  Try running on war-ftpd.exe www.SecurityXploded.com
  • 18. Demo..  ExeScan  http://www.securityxploded.com/exe-scan.php  Malpimp  http://www.securityxploded.com/malpimp.php www.SecurityXploded.com
  • 19. Reference Complete Reference Guide for Advanced Malware Analysis Training [Include links for all the Demos & Tools] www.SecurityXploded.com
  • 20. Thank You ! www.SecurityXploded.com www.SecurityXploded.com