SlideShare une entreprise Scribd logo
1  sur  20
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

Contenu connexe

Tendances

Tendances (20)

Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
Reversing & Malware Analysis Training Part 11 - Exploit Development [Advanced]
 
Anti-Virus Evasion Techniques and Countermeasures
Anti-Virus Evasion Techniques and CountermeasuresAnti-Virus Evasion Techniques and Countermeasures
Anti-Virus Evasion Techniques and Countermeasures
 
Reversing & Malware Analysis Training Part 9 - Advanced Malware Analysis
Reversing & Malware Analysis Training Part 9 -  Advanced Malware AnalysisReversing & Malware Analysis Training Part 9 -  Advanced Malware Analysis
Reversing & Malware Analysis Training Part 9 - Advanced Malware Analysis
 
Advanced Malware Analysis Training Session 7 - Malware Memory Forensics
Advanced Malware Analysis Training Session 7  - Malware Memory ForensicsAdvanced Malware Analysis Training Session 7  - Malware Memory Forensics
Advanced Malware Analysis Training Session 7 - Malware Memory Forensics
 
Advanced Malware Analysis Training Session 4 - Anti-Analysis Techniques
Advanced Malware Analysis Training Session 4 - Anti-Analysis TechniquesAdvanced Malware Analysis Training Session 4 - Anti-Analysis Techniques
Advanced Malware Analysis Training Session 4 - Anti-Analysis Techniques
 
Reversing & Malware Analysis Training Part 13 - Future Roadmap
Reversing & Malware Analysis Training Part 13 - Future RoadmapReversing & Malware Analysis Training Part 13 - Future Roadmap
Reversing & Malware Analysis Training Part 13 - Future Roadmap
 
Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...
Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...
Advanced Malware Analysis Training Session 11 - (Part 2) Dissecting the Heart...
 
Advanced Malware Analysis Training Session 8 - Introduction to Android
Advanced Malware Analysis Training Session 8 - Introduction to AndroidAdvanced Malware Analysis Training Session 8 - Introduction to Android
Advanced Malware Analysis Training Session 8 - Introduction to Android
 
Anatomy of Exploit Kits
Anatomy of Exploit KitsAnatomy of Exploit Kits
Anatomy of Exploit Kits
 
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
 
Advanced malwareanalysis training session2 botnet analysis part1
Advanced malwareanalysis training session2 botnet analysis part1Advanced malwareanalysis training session2 botnet analysis part1
Advanced malwareanalysis training session2 botnet analysis part1
 
Application Virtualization
Application VirtualizationApplication Virtualization
Application Virtualization
 
Advanced malware analysis training session5 reversing automation
Advanced malware analysis training session5 reversing automationAdvanced malware analysis training session5 reversing automation
Advanced malware analysis training session5 reversing automation
 
Advanced malware analysis training session 7 malware memory forensics
Advanced malware analysis training session 7 malware memory forensicsAdvanced malware analysis training session 7 malware memory forensics
Advanced malware analysis training session 7 malware memory forensics
 
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Reversing & Malware Analysis Training Part 4 - Assembly Programming BasicsReversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
 
Reversing malware analysis training part6 practical reversing
Reversing malware analysis training part6 practical reversingReversing malware analysis training part6 practical reversing
Reversing malware analysis training part6 practical reversing
 
Reversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advancedReversing malware analysis training part11 exploit development advanced
Reversing malware analysis training part11 exploit development advanced
 
Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)
Reversing & Malware Analysis Training Part 6 -  Practical Reversing (I)Reversing & Malware Analysis Training Part 6 -  Practical Reversing (I)
Reversing & Malware Analysis Training Part 6 - Practical Reversing (I)
 
Advanced malware analysis training session8 introduction to android
Advanced malware analysis training session8 introduction to androidAdvanced malware analysis training session8 introduction to android
Advanced malware analysis training session8 introduction to android
 
Dissecting Android APK
Dissecting Android APKDissecting Android APK
Dissecting Android APK
 

Similaire à Advanced Malware Analysis Training Session 5 - Reversing Automation

Reversing & malware analysis training part 3 windows pe file format basics
Reversing & malware analysis training part 3   windows pe file format basicsReversing & malware analysis training part 3   windows pe file format basics
Reversing & malware analysis training part 3 windows pe file format basics
Abdulrahman Bassam
 
Reversing & malware analysis training part 10 exploit development basics
Reversing & malware analysis training part 10   exploit development basicsReversing & malware analysis training part 10   exploit development basics
Reversing & malware analysis training part 10 exploit development basics
Abdulrahman Bassam
 
Reversing & malware analysis training part 5 reverse engineering tools basics
Reversing & malware analysis training part 5   reverse engineering tools basics Reversing & malware analysis training part 5   reverse engineering tools basics
Reversing & malware analysis training part 5 reverse engineering tools basics
Abdulrahman Bassam
 
Reversing & malware analysis training part 12 rootkit analysis
Reversing & malware analysis training part 12   rootkit analysisReversing & malware analysis training part 12   rootkit analysis
Reversing & malware analysis training part 12 rootkit analysis
Abdulrahman Bassam
 
Introduction to Dynamic Analysis of Android Application
Introduction to Dynamic Analysis of Android ApplicationIntroduction to Dynamic Analysis of Android Application
Introduction to Dynamic Analysis of Android Application
Kelwin Yang
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical Memento
Odoo
 

Similaire à Advanced Malware Analysis Training Session 5 - Reversing Automation (20)

VB2013 - Security Research and Development Framework
VB2013 - Security Research and Development FrameworkVB2013 - Security Research and Development Framework
VB2013 - Security Research and Development Framework
 
Reversing & malware analysis training part 3 windows pe file format basics
Reversing & malware analysis training part 3   windows pe file format basicsReversing & malware analysis training part 3   windows pe file format basics
Reversing & malware analysis training part 3 windows pe file format basics
 
Reversing & malware analysis training part 10 exploit development basics
Reversing & malware analysis training part 10   exploit development basicsReversing & malware analysis training part 10   exploit development basics
Reversing & malware analysis training part 10 exploit development basics
 
Reversing & malware analysis training part 5 reverse engineering tools basics
Reversing & malware analysis training part 5   reverse engineering tools basics Reversing & malware analysis training part 5   reverse engineering tools basics
Reversing & malware analysis training part 5 reverse engineering tools basics
 
Reversing & malware analysis training part 12 rootkit analysis
Reversing & malware analysis training part 12   rootkit analysisReversing & malware analysis training part 12   rootkit analysis
Reversing & malware analysis training part 12 rootkit analysis
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
R sharing 101
R sharing 101R sharing 101
R sharing 101
 
Php Development Stack
Php Development StackPhp Development Stack
Php Development Stack
 
Php Development Stack
Php Development StackPhp Development Stack
Php Development Stack
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
Introduction to Dynamic Analysis of Android Application
Introduction to Dynamic Analysis of Android ApplicationIntroduction to Dynamic Analysis of Android Application
Introduction to Dynamic Analysis of Android Application
 
Understanding and extending p2 for fun and profit
Understanding and extending p2 for fun and profitUnderstanding and extending p2 for fun and profit
Understanding and extending p2 for fun and profit
 
Flash Camp Chennai - Build automation of Flex and AIR applications
Flash Camp Chennai - Build automation of Flex and AIR applicationsFlash Camp Chennai - Build automation of Flex and AIR applications
Flash Camp Chennai - Build automation of Flex and AIR applications
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Introduction to Software Development
Introduction to Software DevelopmentIntroduction to Software Development
Introduction to Software Development
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
IDAPRO
IDAPROIDAPRO
IDAPRO
 
OpenERP Technical Memento
OpenERP Technical MementoOpenERP Technical Memento
OpenERP Technical Memento
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 

Plus de securityxploded

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
 
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
 
MalwareNet Project
MalwareNet ProjectMalwareNet Project
MalwareNet Project
 
Reversing and Decrypting the Communications of APT Malware (Etumbot)
Reversing and Decrypting the Communications of APT Malware (Etumbot)Reversing and Decrypting the Communications of APT Malware (Etumbot)
Reversing and Decrypting the Communications of APT Malware (Etumbot)
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

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: walia.harsimran@gmail.com  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