SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
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 #1
Amit Malik (sometimes DouBle_Zer0,DZZ)
 Member SecurityXploded
 Security Researcher @ McAfee Labs
 RE, Exploit Analysis/Development, Malware Analysis
 Email: m.amit30@gmail.com
www.SecurityXploded.com
Who am I #2
Swapnil Pathak
 Member SecurityXploded
 Security Researcher @ McAfee Labs
 RE, Malware Analysis, Network Security
 Email: swapnilpathak101@gmail.com
www.SecurityXploded.com
Course Q&A
 Keep yourself up to date with latest security news
 http://www.securityphresh.com
 For Q&A, join our mailing list.
 http://groups.google.com/group/securityxploded
www.SecurityXploded.com
PE File Format
 PE – Portable Executable
 PE is the native Win32 file format.
 32-bit DLL, COM, OCX, Control Panel Applets(.CPL), .NET, NT kernel
mode drivers are all PE File Format.
www.SecurityXploded.com
Why PE File Format
 How windowsloaderloads theexecutablein memory.
 How loaderbuild theimport and export tablefor a modulein memory
 Fromwhere to start the executionorAddress ofentry point
 Answerofthe question “how binary compiled on a version of windowsworks
on anotherversion of windows?”
 Whereshould attackerattack 
 Also today’smalwares aregenerally encrypted, packed. In order to rebuild the
original binarywe need to know how the binary is structured.
www.SecurityXploded.com
Basic Structure
www.SecurityXploded.com
Basic Structure Cont.
 Most common sections found in executable are
 Executable Code section (.text , CODE)
 Data Sections (.data, .rdata, .bss, DATA)
 Resources section (.rsrc)
 Export Section (.edata)
 Import Section (.idata)
 Debug Information Section (.debug)
www.SecurityXploded.com
Headers – DOS Header
 All PE files start with DOS header
 First 64 bytes of the file.
 Run program in DOS.
 Runs the DOS stub
 Usually the string
“This program must be run under Microsoft Windows”
 e_lfanew is the pointer to PE or NT header
 Structure defined in windows.inc or winnt.h
www.SecurityXploded.com
Header- DOS header cont.
e_magic = 4D, 5A (MZ)
e_lfanew is a DWORD which contains the offset of the PE header
www.SecurityXploded.com
Headers – PE header
 Begins with signature (DWORD) 50h, 45h, 00h, 00h
 Letters “PE” followed by two terminating zeros
 File Header- 20 Bytes – contains info about physical layout and properties of the
file
 Optional Header- 224 Bytes – contains info about the logical layout of the PE
file – size given by member of File header
www.SecurityXploded.com
Headers – PE –> File header
 Machine
 NumberOfSections
 SizeOfOptionalHeader
 Characteristics
www.SecurityXploded.com
Header – PE –> Optional Header
www.SecurityXploded.com
Optional Header Cont.
 AddressOfEntryPoint
 ImageBase
 SectionAlignment
 FileAlignment
 SizeOfImage
 SizeOfHeaders
 Subsystem
 DataDirectory
www.SecurityXploded.com
Header – PE –> Optional –> Data
Directory
 Last 128 bytes of OptionalHeader
 Array of 16 Image_Data_Directory structures
 Each relating to an important data structure like the Import Table
 Members
 Virtual Address : RVA of the data structure
 iSize : size in bytes of the data structure
www.SecurityXploded.com
Data Directories
www.SecurityXploded.com
 IMAGE_DIRECTORY_ENTRY_EXPORT
 IMAGE_DIRECTORY_ENTRY_IMPORT
 IMAGE_DIRECTORY_ENTRY_RESOURCE
 IMAGE_DIRECTORY_ENTRY_TLS
 IMAGE_DIRECTORY_ENTRY_IAT
www.SecurityXploded.com
Headers - Section Header
 Array of IMAGE_SECTION_HEADER
 Equal to the numberofsections – FileHeader member.
 Each structure size = 40 bytes
www.SecurityXploded.com
Section Header cont.
 Name – Virtually can be anything in text
 VirtualSize – Size of section in memory
 VirtualAddress – section entry offset in memory (RVA)
 SizeOfRawData – Size of section on disk
 PointerToRawData – section entry offset on disk
 Characteristics – Type of section (execuatble, data etc.)
 Section Alignment and File Alignment are two important values from
optional header that control the entry point of next section.
www.SecurityXploded.com
 The structure of PE file on disk is exactly the same as when it is loaded into
memory.
 The windows loader maps the required sections in memory.
 When sections are loaded into memory they are aligned to fit 4KB memory pages
(Section Alignment), each section starting on a new page.
www.SecurityXploded.com
Type of PE file sections
 Executable code
 Data
 Resources
 Export section
 Import section
 Thread Local Storage (TLS)
 Base Relocations (reloc.)
www.SecurityXploded.com
Export Section
 Relevant to DLLs
 Export functions in two ways
- By name
- By ordinal only
 Ordinal – 16 bit value that uniquely defines a function in particular DLL
www.SecurityXploded.com
nName
nBase
NumberOfFunctions
NumberOfNames
AddressOfFunctions
AddressOfNames
AddressOfNameOrdinals
www.SecurityXploded.com
Export by Ordinal only
Export Forwarding
www.SecurityXploded.com
Import Section
 Contains information about all functions imported by executable from
DLLs
 Loader maps all the DLLs used by the application into its address space
 Finds the addresses of all the imported functions and makes them
available to the executable being loaded.
www.SecurityXploded.com
Import Directory
 20 byte structure IMAGE_IMPORT_DESCRIPTOR
 Number of structures = Number of DLLs imported
 Last structure filed with zeros
www.SecurityXploded.com
 OriginalFirstThunk
 Name1
 FirstThunk
Hint
Name1
www.SecurityXploded.com
 Each IMAGE_THUNK_DATA str corresponds to one imported function from
the dll.
 Arrays pointed by OriginalFirstThunk and FirstThunk run parallelly.
 OriginalFirstThunk – Import Name Table – Never modified
 FirstThunk – Import Address Table – Contain actual function addresses
www.SecurityXploded.com
Functions exported by ordinal only
- No IMAGE_IMPORT_BY_NAME structure
-IMAGE_THUNK_DATA contains the ordinal of the function
-MSB used to identify the same
- MSB is set, rest 31 bits are treated as an ordinal value.
-Bound Imports
www.SecurityXploded.com
DEMO
www.SecurityXploded.com
Reference
 Complete Reference Guide for Reversing & Malware Analysis Training
www.SecurityXploded.com
PE file format test
 Write a program in “C” or “ASM” that will modify the Address of Entry point of
an Executable (.exe) file with any random address.
 Write a program in “C” or “ASM” that will add a new section into an executable
(.exe)
 For hints shoot us an email 
www.SecurityXploded.com
Thank You !
www.SecurityXploded.com

Más contenido relacionado

La actualidad más candente

Things to keep in mind while creating a word press plugin from scratch
Things to keep in mind while creating a word press plugin from scratchThings to keep in mind while creating a word press plugin from scratch
Things to keep in mind while creating a word press plugin from scratchElsner Technologies Pvt Ltd
 
I Know You Want Me - Unplugging PlugX
I Know You Want Me - Unplugging PlugXI Know You Want Me - Unplugging PlugX
I Know You Want Me - Unplugging PlugXTakahiro Haruyama
 
Reverse Engineering iOS apps
Reverse Engineering iOS appsReverse Engineering iOS apps
Reverse Engineering iOS appsMax Bazaliy
 
Oracle database error with solution
Oracle database error with solutionOracle database error with solution
Oracle database error with solutionRavi Kumar Lanke
 
Securing Your Web Server
Securing Your Web ServerSecuring Your Web Server
Securing Your Web Servermanugoel2003
 

La actualidad más candente (7)

Things to keep in mind while creating a word press plugin from scratch
Things to keep in mind while creating a word press plugin from scratchThings to keep in mind while creating a word press plugin from scratch
Things to keep in mind while creating a word press plugin from scratch
 
Local File Inclusion to Remote Code Execution
Local File Inclusion to Remote Code ExecutionLocal File Inclusion to Remote Code Execution
Local File Inclusion to Remote Code Execution
 
I Know You Want Me - Unplugging PlugX
I Know You Want Me - Unplugging PlugXI Know You Want Me - Unplugging PlugX
I Know You Want Me - Unplugging PlugX
 
Reverse Engineering iOS apps
Reverse Engineering iOS appsReverse Engineering iOS apps
Reverse Engineering iOS apps
 
LFI to RCE Exploit with Perl Script
LFI to RCE Exploit with Perl ScriptLFI to RCE Exploit with Perl Script
LFI to RCE Exploit with Perl Script
 
Oracle database error with solution
Oracle database error with solutionOracle database error with solution
Oracle database error with solution
 
Securing Your Web Server
Securing Your Web ServerSecuring Your Web Server
Securing Your Web Server
 

Destacado

Family Business Australia Economic Update 28 August 2015 FBA format
Family Business Australia Economic Update 28 August 2015 FBA formatFamily Business Australia Economic Update 28 August 2015 FBA format
Family Business Australia Economic Update 28 August 2015 FBA formatDarryl Gobbett
 
Joachim von Haenisch, CEO of KYC-Exchange
Joachim von Haenisch, CEO of KYC-ExchangeJoachim von Haenisch, CEO of KYC-Exchange
Joachim von Haenisch, CEO of KYC-ExchangeChris Skinner
 
The New Preparation of Financial Statements Standard (SSARS 21)
The New Preparation of Financial Statements Standard (SSARS 21)The New Preparation of Financial Statements Standard (SSARS 21)
The New Preparation of Financial Statements Standard (SSARS 21)Charles B. Hall, CPA, CFE
 
Startup pitch deck template
Startup pitch deck templateStartup pitch deck template
Startup pitch deck templateDaniele Beccari
 
Copy Of Investment Proposal The Bophut Building Boutique Hotel
Copy Of Investment Proposal   The Bophut Building Boutique HotelCopy Of Investment Proposal   The Bophut Building Boutique Hotel
Copy Of Investment Proposal The Bophut Building Boutique HotelRuss Blumenthal
 
Building an Integrated Marketing Plan
Building an Integrated Marketing PlanBuilding an Integrated Marketing Plan
Building an Integrated Marketing PlanMargaret Dawson
 

Destacado (6)

Family Business Australia Economic Update 28 August 2015 FBA format
Family Business Australia Economic Update 28 August 2015 FBA formatFamily Business Australia Economic Update 28 August 2015 FBA format
Family Business Australia Economic Update 28 August 2015 FBA format
 
Joachim von Haenisch, CEO of KYC-Exchange
Joachim von Haenisch, CEO of KYC-ExchangeJoachim von Haenisch, CEO of KYC-Exchange
Joachim von Haenisch, CEO of KYC-Exchange
 
The New Preparation of Financial Statements Standard (SSARS 21)
The New Preparation of Financial Statements Standard (SSARS 21)The New Preparation of Financial Statements Standard (SSARS 21)
The New Preparation of Financial Statements Standard (SSARS 21)
 
Startup pitch deck template
Startup pitch deck templateStartup pitch deck template
Startup pitch deck template
 
Copy Of Investment Proposal The Bophut Building Boutique Hotel
Copy Of Investment Proposal   The Bophut Building Boutique HotelCopy Of Investment Proposal   The Bophut Building Boutique Hotel
Copy Of Investment Proposal The Bophut Building Boutique Hotel
 
Building an Integrated Marketing Plan
Building an Integrated Marketing PlanBuilding an Integrated Marketing Plan
Building an Integrated Marketing Plan
 

Similar a Discover how malware hides in PE files

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 basicssecurityxploded
 
Advanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing AutomationAdvanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing Automationsecurityxploded
 
Reversing & malware analysis training part 2 introduction to windows internals
Reversing & malware analysis training part 2   introduction to windows internalsReversing & malware analysis training part 2   introduction to windows internals
Reversing & malware analysis training part 2 introduction to windows internalssecurityxploded
 
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1  Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1 securityxploded
 
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 analysisAbdulrahman Bassam
 
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 automationCysinfo Cyber Security Community
 
Reversing & malware analysis training part 1 lab setup guide
Reversing & malware analysis training part 1   lab setup guideReversing & malware analysis training part 1   lab setup guide
Reversing & malware analysis training part 1 lab setup guidesecurityxploded
 
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)Abdulrahman Bassam
 
VB2013 - Security Research and Development Framework
VB2013 - Security Research and Development FrameworkVB2013 - Security Research and Development Framework
VB2013 - Security Research and Development FrameworkAmr Thabet
 
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 basicsAbdulrahman Bassam
 
Reversing & malware analysis training part 2 introduction to windows internals
Reversing & malware analysis training part 2   introduction to windows internalsReversing & malware analysis training part 2   introduction to windows internals
Reversing & malware analysis training part 2 introduction to windows internalsAbdulrahman Bassam
 
Oracle_Retail_Xstore_Suite_Install.pdf
Oracle_Retail_Xstore_Suite_Install.pdfOracle_Retail_Xstore_Suite_Install.pdf
Oracle_Retail_Xstore_Suite_Install.pdfvamshikkrishna1
 
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 Forensicssecurityxploded
 
Bruh! Do you even diff?—Diffing Microsoft Patches to Find Vulnerabilities
Bruh! Do you even diff?—Diffing Microsoft Patches to Find VulnerabilitiesBruh! Do you even diff?—Diffing Microsoft Patches to Find Vulnerabilities
Bruh! Do you even diff?—Diffing Microsoft Patches to Find VulnerabilitiesPriyanka Aash
 
Anant kochhar _revealing_the_secrets - ClubHack2009
Anant kochhar _revealing_the_secrets - ClubHack2009Anant kochhar _revealing_the_secrets - ClubHack2009
Anant kochhar _revealing_the_secrets - ClubHack2009ClubHack
 
Advanced Malware Analysis Training Session 6 - Malware Sandbox Analysis
Advanced Malware Analysis Training Session 6  - Malware Sandbox AnalysisAdvanced Malware Analysis Training Session 6  - Malware Sandbox Analysis
Advanced Malware Analysis Training Session 6 - Malware Sandbox Analysissecurityxploded
 
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 Analysissecurityxploded
 
Reverse Engineering: Protecting and Breaking the Software
Reverse Engineering: Protecting and Breaking the SoftwareReverse Engineering: Protecting and Breaking the Software
Reverse Engineering: Protecting and Breaking the SoftwareSatria Ady Pradana
 

Similar a Discover how malware hides in PE files (20)

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
 
Advanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing AutomationAdvanced Malware Analysis Training Session 5 - Reversing Automation
Advanced Malware Analysis Training Session 5 - Reversing Automation
 
Reversing & malware analysis training part 2 introduction to windows internals
Reversing & malware analysis training part 2   introduction to windows internalsReversing & malware analysis training part 2   introduction to windows internals
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 2 - Botnet Analysis Part 1  Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
Advanced Malware Analysis Training Session 2 - Botnet Analysis Part 1
 
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
 
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
 
Reversing & malware analysis training part 1 lab setup guide
Reversing & malware analysis training part 1   lab setup guideReversing & malware analysis training part 1   lab setup guide
Reversing & malware analysis training part 1 lab setup guide
 
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)
 
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 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 2 introduction to windows internals
Reversing & malware analysis training part 2   introduction to windows internalsReversing & malware analysis training part 2   introduction to windows internals
Reversing & malware analysis training part 2 introduction to windows internals
 
Oracle_Retail_Xstore_Suite_Install.pdf
Oracle_Retail_Xstore_Suite_Install.pdfOracle_Retail_Xstore_Suite_Install.pdf
Oracle_Retail_Xstore_Suite_Install.pdf
 
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
 
Bruh! Do you even diff?—Diffing Microsoft Patches to Find Vulnerabilities
Bruh! Do you even diff?—Diffing Microsoft Patches to Find VulnerabilitiesBruh! Do you even diff?—Diffing Microsoft Patches to Find Vulnerabilities
Bruh! Do you even diff?—Diffing Microsoft Patches to Find Vulnerabilities
 
Anant kochhar _revealing_the_secrets - ClubHack2009
Anant kochhar _revealing_the_secrets - ClubHack2009Anant kochhar _revealing_the_secrets - ClubHack2009
Anant kochhar _revealing_the_secrets - ClubHack2009
 
IDAPRO
IDAPROIDAPRO
IDAPRO
 
Advanced Malware Analysis Training Session 6 - Malware Sandbox Analysis
Advanced Malware Analysis Training Session 6  - Malware Sandbox AnalysisAdvanced Malware Analysis Training Session 6  - Malware Sandbox Analysis
Advanced Malware Analysis Training Session 6 - Malware Sandbox Analysis
 
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
 
Reverse Engineering: Protecting and Breaking the Software
Reverse Engineering: Protecting and Breaking the SoftwareReverse Engineering: Protecting and Breaking the Software
Reverse Engineering: Protecting and Breaking the Software
 

Más de Abdulrahman Bassam

Reversing & malware analysis training part 11 exploit development advanced
Reversing & malware analysis training part 11   exploit development advancedReversing & malware analysis training part 11   exploit development advanced
Reversing & malware analysis training part 11 exploit development advancedAbdulrahman Bassam
 
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 analysisAbdulrahman Bassam
 
Reversing & malware analysis training part 8 malware memory forensics
Reversing & malware analysis training part 8   malware memory forensicsReversing & malware analysis training part 8   malware memory forensics
Reversing & malware analysis training part 8 malware memory forensicsAbdulrahman Bassam
 
Reversing & malware analysis training part 7 unpacking upx
Reversing & malware analysis training part 7   unpacking upxReversing & malware analysis training part 7   unpacking upx
Reversing & malware analysis training part 7 unpacking upxAbdulrahman Bassam
 
Reversing & malware analysis training part 4 assembly programming basics
Reversing & malware analysis training part 4   assembly programming basics Reversing & malware analysis training part 4   assembly programming basics
Reversing & malware analysis training part 4 assembly programming basics Abdulrahman Bassam
 
Reversing & malware analysis training part 1 lab setup guide
Reversing & malware analysis training part 1   lab setup guideReversing & malware analysis training part 1   lab setup guide
Reversing & malware analysis training part 1 lab setup guideAbdulrahman Bassam
 
The apache software foundation
The apache software foundationThe apache software foundation
The apache software foundationAbdulrahman Bassam
 

Más de Abdulrahman Bassam (7)

Reversing & malware analysis training part 11 exploit development advanced
Reversing & malware analysis training part 11   exploit development advancedReversing & malware analysis training part 11   exploit development advanced
Reversing & malware analysis training part 11 exploit development advanced
 
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
 
Reversing & malware analysis training part 8 malware memory forensics
Reversing & malware analysis training part 8   malware memory forensicsReversing & malware analysis training part 8   malware memory forensics
Reversing & malware analysis training part 8 malware memory forensics
 
Reversing & malware analysis training part 7 unpacking upx
Reversing & malware analysis training part 7   unpacking upxReversing & malware analysis training part 7   unpacking upx
Reversing & malware analysis training part 7 unpacking upx
 
Reversing & malware analysis training part 4 assembly programming basics
Reversing & malware analysis training part 4   assembly programming basics Reversing & malware analysis training part 4   assembly programming basics
Reversing & malware analysis training part 4 assembly programming basics
 
Reversing & malware analysis training part 1 lab setup guide
Reversing & malware analysis training part 1   lab setup guideReversing & malware analysis training part 1   lab setup guide
Reversing & malware analysis training part 1 lab setup guide
 
The apache software foundation
The apache software foundationThe apache software foundation
The apache software foundation
 

Último

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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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 BrazilV3cube
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
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...Martijn de Jong
 
🐬 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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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 AutomationSafe Software
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
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.pptxHampshireHUG
 
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 DevelopmentsTrustArc
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - 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
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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
 
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 productivityPrincipled Technologies
 

Último (20)

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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
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...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
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
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - 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
 
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...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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
 
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
 

Discover how malware hides in PE files

  • 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 #1 Amit Malik (sometimes DouBle_Zer0,DZZ)  Member SecurityXploded  Security Researcher @ McAfee Labs  RE, Exploit Analysis/Development, Malware Analysis  Email: m.amit30@gmail.com www.SecurityXploded.com
  • 6. Who am I #2 Swapnil Pathak  Member SecurityXploded  Security Researcher @ McAfee Labs  RE, Malware Analysis, Network Security  Email: swapnilpathak101@gmail.com www.SecurityXploded.com
  • 7. Course Q&A  Keep yourself up to date with latest security news  http://www.securityphresh.com  For Q&A, join our mailing list.  http://groups.google.com/group/securityxploded www.SecurityXploded.com
  • 8. PE File Format  PE – Portable Executable  PE is the native Win32 file format.  32-bit DLL, COM, OCX, Control Panel Applets(.CPL), .NET, NT kernel mode drivers are all PE File Format. www.SecurityXploded.com
  • 9. Why PE File Format  How windowsloaderloads theexecutablein memory.  How loaderbuild theimport and export tablefor a modulein memory  Fromwhere to start the executionorAddress ofentry point  Answerofthe question “how binary compiled on a version of windowsworks on anotherversion of windows?”  Whereshould attackerattack   Also today’smalwares aregenerally encrypted, packed. In order to rebuild the original binarywe need to know how the binary is structured. www.SecurityXploded.com
  • 11. Basic Structure Cont.  Most common sections found in executable are  Executable Code section (.text , CODE)  Data Sections (.data, .rdata, .bss, DATA)  Resources section (.rsrc)  Export Section (.edata)  Import Section (.idata)  Debug Information Section (.debug) www.SecurityXploded.com
  • 12. Headers – DOS Header  All PE files start with DOS header  First 64 bytes of the file.  Run program in DOS.  Runs the DOS stub  Usually the string “This program must be run under Microsoft Windows”  e_lfanew is the pointer to PE or NT header  Structure defined in windows.inc or winnt.h www.SecurityXploded.com
  • 13. Header- DOS header cont. e_magic = 4D, 5A (MZ) e_lfanew is a DWORD which contains the offset of the PE header www.SecurityXploded.com
  • 14. Headers – PE header  Begins with signature (DWORD) 50h, 45h, 00h, 00h  Letters “PE” followed by two terminating zeros  File Header- 20 Bytes – contains info about physical layout and properties of the file  Optional Header- 224 Bytes – contains info about the logical layout of the PE file – size given by member of File header www.SecurityXploded.com
  • 15. Headers – PE –> File header  Machine  NumberOfSections  SizeOfOptionalHeader  Characteristics www.SecurityXploded.com
  • 16. Header – PE –> Optional Header www.SecurityXploded.com
  • 17. Optional Header Cont.  AddressOfEntryPoint  ImageBase  SectionAlignment  FileAlignment  SizeOfImage  SizeOfHeaders  Subsystem  DataDirectory www.SecurityXploded.com
  • 18. Header – PE –> Optional –> Data Directory  Last 128 bytes of OptionalHeader  Array of 16 Image_Data_Directory structures  Each relating to an important data structure like the Import Table  Members  Virtual Address : RVA of the data structure  iSize : size in bytes of the data structure www.SecurityXploded.com
  • 20.  IMAGE_DIRECTORY_ENTRY_EXPORT  IMAGE_DIRECTORY_ENTRY_IMPORT  IMAGE_DIRECTORY_ENTRY_RESOURCE  IMAGE_DIRECTORY_ENTRY_TLS  IMAGE_DIRECTORY_ENTRY_IAT www.SecurityXploded.com
  • 21. Headers - Section Header  Array of IMAGE_SECTION_HEADER  Equal to the numberofsections – FileHeader member.  Each structure size = 40 bytes www.SecurityXploded.com
  • 22. Section Header cont.  Name – Virtually can be anything in text  VirtualSize – Size of section in memory  VirtualAddress – section entry offset in memory (RVA)  SizeOfRawData – Size of section on disk  PointerToRawData – section entry offset on disk  Characteristics – Type of section (execuatble, data etc.)  Section Alignment and File Alignment are two important values from optional header that control the entry point of next section. www.SecurityXploded.com
  • 23.  The structure of PE file on disk is exactly the same as when it is loaded into memory.  The windows loader maps the required sections in memory.  When sections are loaded into memory they are aligned to fit 4KB memory pages (Section Alignment), each section starting on a new page. www.SecurityXploded.com
  • 24. Type of PE file sections  Executable code  Data  Resources  Export section  Import section  Thread Local Storage (TLS)  Base Relocations (reloc.) www.SecurityXploded.com
  • 25. Export Section  Relevant to DLLs  Export functions in two ways - By name - By ordinal only  Ordinal – 16 bit value that uniquely defines a function in particular DLL www.SecurityXploded.com
  • 27. Export by Ordinal only Export Forwarding www.SecurityXploded.com
  • 28. Import Section  Contains information about all functions imported by executable from DLLs  Loader maps all the DLLs used by the application into its address space  Finds the addresses of all the imported functions and makes them available to the executable being loaded. www.SecurityXploded.com
  • 29. Import Directory  20 byte structure IMAGE_IMPORT_DESCRIPTOR  Number of structures = Number of DLLs imported  Last structure filed with zeros www.SecurityXploded.com
  • 30.  OriginalFirstThunk  Name1  FirstThunk Hint Name1 www.SecurityXploded.com
  • 31.  Each IMAGE_THUNK_DATA str corresponds to one imported function from the dll.  Arrays pointed by OriginalFirstThunk and FirstThunk run parallelly.  OriginalFirstThunk – Import Name Table – Never modified  FirstThunk – Import Address Table – Contain actual function addresses www.SecurityXploded.com
  • 32. Functions exported by ordinal only - No IMAGE_IMPORT_BY_NAME structure -IMAGE_THUNK_DATA contains the ordinal of the function -MSB used to identify the same - MSB is set, rest 31 bits are treated as an ordinal value. -Bound Imports www.SecurityXploded.com
  • 34. Reference  Complete Reference Guide for Reversing & Malware Analysis Training www.SecurityXploded.com
  • 35. PE file format test  Write a program in “C” or “ASM” that will modify the Address of Entry point of an Executable (.exe) file with any random address.  Write a program in “C” or “ASM” that will add a new section into an executable (.exe)  For hints shoot us an email  www.SecurityXploded.com