SlideShare a Scribd company logo
DLLInjection
Static Linking
• Code libraries (.lib) include lots of functions to be copied to
your program when required.
• So, there is no need to reinvent the wheel and rewrite these
functions again.
• This is done by a program called a linker, which basically
copies the needed functions into a program and generates
the executable file with all the needed functions inside.
• This process is called the static linking.
Dynamic Linking
• Statically linked libraries lead to having the same code
copied repeatedly inside each program.
• That might lead to the loss of hard disk space and
increases the size of the executable files.
• Dynamic linking allows programs to expand more and
become more functionality-rich.
• Instead of storing the code inside each executable, any
needed library is loaded beside each application in the
same virtual memory.
• These libraries are named Dynamic Link Libraries (DLLs).
Dynamic link libraries
• Not all library functions are exported as some of them are for internal use.
• But the functions that are exported can be accessed through its name or its ordinal
number (index number).
• They are called Application Programming Interfaces (APIs).
• APIs are those exported functions in any library that any application can call or
interact with
• Some of known Windows DLLs:
• kernel32.dll
• ntdll.dll
• user32.dll
• advapi32.dll
Dynamic API Loading
• It's very common in malware code to obscure the name of the libraries
and the APIs that they are using to hide their functionality from static
analysis using what's called dynamic API loading.
• Dynamic API loading is supported by Windows using two very well-known
APIs :
• LoadLibraryA: This API loads a dynamic link library into the virtual
memory of the calling program and returns its address (variations
include LoadLibraryW, LoadLibraryExA, and LoadLibraryExW).
• GetProcAddress: This API gets the address of an API given its name
and the address of the library that contains this API.
• By calling these two APIs, the malware is able to access APIs that are not
written in the import table and are totally hidden from the eyes of the
reverse engineer.
DLL Injection
• The Windows operating system allows processes to load dynamic link libraries
into other processes for security reasons, sandboxing, or even graphics.
• DLL injection is used to manipulate the execution of a running process.
• DLL injection primarily tricks an application to call a malicious DLL file which
then gets executed as part of the target process.
• DLL injection can be divided into 4 steps:
• 1. Attach to the process
• 2. Allocate Memory within the process
• 3. Copy the DLL or the DLL Path into the processes memory and determine
appropriate memory addresses
• 4. Instruct the process to Execute your DLL
Windows Supported DLL Injection
• Windows has created registry entries for DLLs so that they can be loaded in every process that meets
certain criteria.
• Many of them allow the malware DLL to be injected into multiple processes, including browsers and
other legitimate processes.
• Most common ones:
HKEY_LOCAL_MACHINESOFTWARE
MicrosoftWindowsNTCurrentVers
ionWindowsAppInit_DLLs
• The libraries included in
this path are loaded
together with every
process that loads
user32.dll.
Windows Supported DLL Injection (Cont.)
• Other commonly misused registry key:
• HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSessionManagerAppCertDlls
• The libraries in this registry entry are loaded in each process that calls at least one of the following
Win32 API functions:
• CreateProcess
• CreateProcessAsUser
• CreateProcessWithLogonW
• CreateProcessWithTokenW
• WinExec
• This allows the malware to be injected into most browsers as many of them create child processes to
manage different tabs and other applications as well.
Windows Supported DLL Injection (Cont.)
Autoruns from Sysinternals, allows you to see whether any of these registry entries have
been exploited for malicious use on the current system.
https://docs.microsoft.com/en-us/sysinternals/downloads/autoruns
Another DLL Injection Technique
• This technique uses the LoadLibrary API to load a
malicious library using Windows PE loader and execute its
EntryPoint.
• The main goal is to inject the path of the malicious DLL
into the process using the VirtualAllocEx API and
WriteProcessMemory.
• Then, it creates a thread into that process using
CreateRemoteThread, with the address of the LoadLibrary
API as the thread start address.
• When passing the DLL path as an argument to that thread
(which is passed to the LoadLibrary API), the Windows PE
loader will load that DLL into the process and execute its
code flawlessly.
Another DLL Injection Technique (Cont.)
• The exact steps the malware generally follows are like so:
1. Get the targeted process handle via its PID using the OpenProcess API. This
handle will be used to access, read, and write to this process.
2. Allocate a space in that process virtual memory using the VirtualAllocEx API.
This space will be used to write the full path of the malicious DLL file.
3. Write to the process using the WriteProcessMemory API. Write the path of
the malware DLL.
4. Load and execute this DLL using CreateRemoteThread and give
the LoadLibraryA address as the start address and the address of the DLL path
as an argument.
References
• http://blog.opensecurityresearch.com/2013/01/windows-dllinjection-basics.html
• https://www.packtpub.com/product/mastering-malware-analysis/9781789610789

More Related Content

What's hot

Malware Static Analysis
Malware Static AnalysisMalware Static Analysis
Malware Static Analysis
Hossein Yavari
 
CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)
Sam Bowne
 
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
Sam Bowne
 
Codes malveillants
Codes malveillantsCodes malveillants
Codes malveillants
Christophe Casalegno
 
ORM2Pwn: Exploiting injections in Hibernate ORM
ORM2Pwn: Exploiting injections in Hibernate ORMORM2Pwn: Exploiting injections in Hibernate ORM
ORM2Pwn: Exploiting injections in Hibernate ORM
Mikhail Egorov
 
CNIT 126: Ch 2 & 3
CNIT 126: Ch 2 & 3CNIT 126: Ch 2 & 3
CNIT 126: Ch 2 & 3
Sam Bowne
 
Exploiting Deserialization Vulnerabilities in Java
Exploiting Deserialization Vulnerabilities in JavaExploiting Deserialization Vulnerabilities in Java
Exploiting Deserialization Vulnerabilities in Java
CODE WHITE GmbH
 
Secure Coding in C/C++
Secure Coding in C/C++Secure Coding in C/C++
Secure Coding in C/C++
Dan-Claudiu Dragoș
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
قصي نسور
 
Windows Operating System Archaeology
Windows Operating System ArchaeologyWindows Operating System Archaeology
Windows Operating System Archaeology
enigma0x3
 
OWASP Secure Coding
OWASP Secure CodingOWASP Secure Coding
OWASP Secure Coding
bilcorry
 
iOS Application Pentesting
iOS Application PentestingiOS Application Pentesting
iOS Application Pentesting
n|u - The Open Security Community
 
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
Sam Bowne
 
iOS Application Penetration Testing
iOS Application Penetration TestingiOS Application Penetration Testing
iOS Application Penetration Testing
n|u - The Open Security Community
 
Practical Malware Analysis: Ch 5: IDA Pro
Practical Malware Analysis: Ch 5: IDA ProPractical Malware Analysis: Ch 5: IDA Pro
Practical Malware Analysis: Ch 5: IDA Pro
Sam Bowne
 
6 buffer overflows
6   buffer overflows6   buffer overflows
6 buffer overflows
drewz lin
 
The OWASP Zed Attack Proxy
The OWASP Zed Attack ProxyThe OWASP Zed Attack Proxy
The OWASP Zed Attack Proxy
Aditya Gupta
 
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSFAppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
Ajin Abraham
 
Clang: More than just a C/C++ Compiler
Clang: More than just a C/C++ CompilerClang: More than just a C/C++ Compiler
Clang: More than just a C/C++ Compiler
Samsung Open Source Group
 
Injection on Steroids: Codeless code injection and 0-day techniques
Injection on Steroids: Codeless code injection and 0-day techniquesInjection on Steroids: Codeless code injection and 0-day techniques
Injection on Steroids: Codeless code injection and 0-day techniques
enSilo
 

What's hot (20)

Malware Static Analysis
Malware Static AnalysisMalware Static Analysis
Malware Static Analysis
 
CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)
 
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
Practical Malware Analysis: Ch 7: Analyzing Malicious Windows Programs
 
Codes malveillants
Codes malveillantsCodes malveillants
Codes malveillants
 
ORM2Pwn: Exploiting injections in Hibernate ORM
ORM2Pwn: Exploiting injections in Hibernate ORMORM2Pwn: Exploiting injections in Hibernate ORM
ORM2Pwn: Exploiting injections in Hibernate ORM
 
CNIT 126: Ch 2 & 3
CNIT 126: Ch 2 & 3CNIT 126: Ch 2 & 3
CNIT 126: Ch 2 & 3
 
Exploiting Deserialization Vulnerabilities in Java
Exploiting Deserialization Vulnerabilities in JavaExploiting Deserialization Vulnerabilities in Java
Exploiting Deserialization Vulnerabilities in Java
 
Secure Coding in C/C++
Secure Coding in C/C++Secure Coding in C/C++
Secure Coding in C/C++
 
Buffer overflow
Buffer overflowBuffer overflow
Buffer overflow
 
Windows Operating System Archaeology
Windows Operating System ArchaeologyWindows Operating System Archaeology
Windows Operating System Archaeology
 
OWASP Secure Coding
OWASP Secure CodingOWASP Secure Coding
OWASP Secure Coding
 
iOS Application Pentesting
iOS Application PentestingiOS Application Pentesting
iOS Application Pentesting
 
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
Practical Malware Analysis: Ch 2 Malware Analysis in Virtual Machines & 3: Ba...
 
iOS Application Penetration Testing
iOS Application Penetration TestingiOS Application Penetration Testing
iOS Application Penetration Testing
 
Practical Malware Analysis: Ch 5: IDA Pro
Practical Malware Analysis: Ch 5: IDA ProPractical Malware Analysis: Ch 5: IDA Pro
Practical Malware Analysis: Ch 5: IDA Pro
 
6 buffer overflows
6   buffer overflows6   buffer overflows
6 buffer overflows
 
The OWASP Zed Attack Proxy
The OWASP Zed Attack ProxyThe OWASP Zed Attack Proxy
The OWASP Zed Attack Proxy
 
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSFAppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
 
Clang: More than just a C/C++ Compiler
Clang: More than just a C/C++ CompilerClang: More than just a C/C++ Compiler
Clang: More than just a C/C++ Compiler
 
Injection on Steroids: Codeless code injection and 0-day techniques
Injection on Steroids: Codeless code injection and 0-day techniquesInjection on Steroids: Codeless code injection and 0-day techniques
Injection on Steroids: Codeless code injection and 0-day techniques
 

Similar to DLL Injection

Ch 6: The Wild World of Windows
Ch 6: The Wild World of WindowsCh 6: The Wild World of Windows
Ch 6: The Wild World of Windows
Sam Bowne
 
Windows internals
Windows internalsWindows internals
Windows internals
Piyush Jain
 
CNIT 127 Ch 6: The Wild World of Windows
CNIT 127 Ch 6: The Wild World of WindowsCNIT 127 Ch 6: The Wild World of Windows
CNIT 127 Ch 6: The Wild World of Windows
Sam Bowne
 
Sp group7 27_53_65_66_68_ppt_dynamic linking library
Sp group7 27_53_65_66_68_ppt_dynamic linking librarySp group7 27_53_65_66_68_ppt_dynamic linking library
Sp group7 27_53_65_66_68_ppt_dynamic linking library
SagarSikchi1
 
Computer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptxComputer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptx
fatahozil
 
CNIT 126 Ch 7: Analyzing Malicious Windows Programs
CNIT 126 Ch 7: Analyzing Malicious Windows ProgramsCNIT 126 Ch 7: Analyzing Malicious Windows Programs
CNIT 126 Ch 7: Analyzing Malicious Windows Programs
Sam Bowne
 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologies
prakashk453625
 
CNIT 126 7: Analyzing Malicious Windows Programs
CNIT 126 7: Analyzing Malicious Windows ProgramsCNIT 126 7: Analyzing Malicious Windows Programs
CNIT 126 7: Analyzing Malicious Windows Programs
Sam Bowne
 
E.s unit 6
E.s unit 6E.s unit 6
E.s unit 6
Sneha Chopra
 
Hm system programming class 1
Hm system programming class 1Hm system programming class 1
Hm system programming class 1
Hitesh Mohapatra
 
CNIT 126 12: Covert Malware Launching
CNIT 126 12: Covert Malware LaunchingCNIT 126 12: Covert Malware Launching
CNIT 126 12: Covert Malware Launching
Sam Bowne
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
SubashiniRathinavel
 
Lecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfLecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdf
ShaimaaMohamedGalal
 
iOS Application Exploitation
iOS Application ExploitationiOS Application Exploitation
iOS Application Exploitation
Positive Hack Days
 
Dotnet framework
Dotnet frameworkDotnet framework
Dotnet framework
Nitu Pandey
 
SOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class LibrariesSOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class Libraries
Vagif Abilov
 
Loaders complete
Loaders completeLoaders complete
Loaders complete
Faisal Shah
 
Microservices: How loose is loosely coupled?
Microservices: How loose is loosely coupled?Microservices: How loose is loosely coupled?
Microservices: How loose is loosely coupled?
John Rofrano
 
Tech presentation (part 1)
Tech presentation (part 1)Tech presentation (part 1)
Tech presentation (part 1)
Abhijit Roy
 
CNIT 126 Ch 11: Malware Behavior
CNIT 126 Ch 11: Malware BehaviorCNIT 126 Ch 11: Malware Behavior
CNIT 126 Ch 11: Malware Behavior
Sam Bowne
 

Similar to DLL Injection (20)

Ch 6: The Wild World of Windows
Ch 6: The Wild World of WindowsCh 6: The Wild World of Windows
Ch 6: The Wild World of Windows
 
Windows internals
Windows internalsWindows internals
Windows internals
 
CNIT 127 Ch 6: The Wild World of Windows
CNIT 127 Ch 6: The Wild World of WindowsCNIT 127 Ch 6: The Wild World of Windows
CNIT 127 Ch 6: The Wild World of Windows
 
Sp group7 27_53_65_66_68_ppt_dynamic linking library
Sp group7 27_53_65_66_68_ppt_dynamic linking librarySp group7 27_53_65_66_68_ppt_dynamic linking library
Sp group7 27_53_65_66_68_ppt_dynamic linking library
 
Computer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptxComputer and multimedia Week 1 Windows Architecture.pptx
Computer and multimedia Week 1 Windows Architecture.pptx
 
CNIT 126 Ch 7: Analyzing Malicious Windows Programs
CNIT 126 Ch 7: Analyzing Malicious Windows ProgramsCNIT 126 Ch 7: Analyzing Malicious Windows Programs
CNIT 126 Ch 7: Analyzing Malicious Windows Programs
 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologies
 
CNIT 126 7: Analyzing Malicious Windows Programs
CNIT 126 7: Analyzing Malicious Windows ProgramsCNIT 126 7: Analyzing Malicious Windows Programs
CNIT 126 7: Analyzing Malicious Windows Programs
 
E.s unit 6
E.s unit 6E.s unit 6
E.s unit 6
 
Hm system programming class 1
Hm system programming class 1Hm system programming class 1
Hm system programming class 1
 
CNIT 126 12: Covert Malware Launching
CNIT 126 12: Covert Malware LaunchingCNIT 126 12: Covert Malware Launching
CNIT 126 12: Covert Malware Launching
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.pptx
 
Lecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfLecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdf
 
iOS Application Exploitation
iOS Application ExploitationiOS Application Exploitation
iOS Application Exploitation
 
Dotnet framework
Dotnet frameworkDotnet framework
Dotnet framework
 
SOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class LibrariesSOLID Programming with Portable Class Libraries
SOLID Programming with Portable Class Libraries
 
Loaders complete
Loaders completeLoaders complete
Loaders complete
 
Microservices: How loose is loosely coupled?
Microservices: How loose is loosely coupled?Microservices: How loose is loosely coupled?
Microservices: How loose is loosely coupled?
 
Tech presentation (part 1)
Tech presentation (part 1)Tech presentation (part 1)
Tech presentation (part 1)
 
CNIT 126 Ch 11: Malware Behavior
CNIT 126 Ch 11: Malware BehaviorCNIT 126 Ch 11: Malware Behavior
CNIT 126 Ch 11: Malware Behavior
 

More from Hossein Yavari

What is Matroska?
What is Matroska?What is Matroska?
What is Matroska?
Hossein Yavari
 
SIPREC RTPEngine Media Forking
SIPREC RTPEngine Media ForkingSIPREC RTPEngine Media Forking
SIPREC RTPEngine Media Forking
Hossein Yavari
 
Windows Forensics
Windows ForensicsWindows Forensics
Windows Forensics
Hossein Yavari
 
SIP over TLS
SIP over TLSSIP over TLS
SIP over TLS
Hossein Yavari
 
Desjardins Data Breach
Desjardins Data BreachDesjardins Data Breach
Desjardins Data Breach
Hossein Yavari
 
Introduction to Metasploit
Introduction to MetasploitIntroduction to Metasploit
Introduction to Metasploit
Hossein Yavari
 
Which IT Certification is Better for You?
Which IT Certification is Better for You?Which IT Certification is Better for You?
Which IT Certification is Better for You?
Hossein Yavari
 
Disassembly Using IDA
Disassembly Using IDADisassembly Using IDA
Disassembly Using IDA
Hossein Yavari
 
Introduction to Snort
Introduction to SnortIntroduction to Snort
Introduction to Snort
Hossein Yavari
 
SQL Injection in JAVA
SQL Injection in JAVASQL Injection in JAVA
SQL Injection in JAVA
Hossein Yavari
 
Creativity and Role of the Leaders
Creativity and Role of the LeadersCreativity and Role of the Leaders
Creativity and Role of the Leaders
Hossein Yavari
 
IPsec for IMS
IPsec for IMSIPsec for IMS
IPsec for IMS
Hossein Yavari
 
eSIM Deep Dive
eSIM Deep DiveeSIM Deep Dive
eSIM Deep Dive
Hossein Yavari
 
Yeastar Technical Training Course
Yeastar Technical Training CourseYeastar Technical Training Course
Yeastar Technical Training Course
Hossein Yavari
 
SENA Cloud UC
SENA Cloud UCSENA Cloud UC
SENA Cloud UC
Hossein Yavari
 
FreePBX Disaster Recovery
FreePBX Disaster RecoveryFreePBX Disaster Recovery
FreePBX Disaster Recovery
Hossein Yavari
 
eSIM Overview
eSIM OvervieweSIM Overview
eSIM Overview
Hossein Yavari
 
LTE Architecture Overview
LTE Architecture OverviewLTE Architecture Overview
LTE Architecture Overview
Hossein Yavari
 
Introduction to DIAMETER
Introduction to DIAMETERIntroduction to DIAMETER
Introduction to DIAMETER
Hossein Yavari
 
Introduction to SS7- Part 2
Introduction to SS7- Part 2Introduction to SS7- Part 2
Introduction to SS7- Part 2
Hossein Yavari
 

More from Hossein Yavari (20)

What is Matroska?
What is Matroska?What is Matroska?
What is Matroska?
 
SIPREC RTPEngine Media Forking
SIPREC RTPEngine Media ForkingSIPREC RTPEngine Media Forking
SIPREC RTPEngine Media Forking
 
Windows Forensics
Windows ForensicsWindows Forensics
Windows Forensics
 
SIP over TLS
SIP over TLSSIP over TLS
SIP over TLS
 
Desjardins Data Breach
Desjardins Data BreachDesjardins Data Breach
Desjardins Data Breach
 
Introduction to Metasploit
Introduction to MetasploitIntroduction to Metasploit
Introduction to Metasploit
 
Which IT Certification is Better for You?
Which IT Certification is Better for You?Which IT Certification is Better for You?
Which IT Certification is Better for You?
 
Disassembly Using IDA
Disassembly Using IDADisassembly Using IDA
Disassembly Using IDA
 
Introduction to Snort
Introduction to SnortIntroduction to Snort
Introduction to Snort
 
SQL Injection in JAVA
SQL Injection in JAVASQL Injection in JAVA
SQL Injection in JAVA
 
Creativity and Role of the Leaders
Creativity and Role of the LeadersCreativity and Role of the Leaders
Creativity and Role of the Leaders
 
IPsec for IMS
IPsec for IMSIPsec for IMS
IPsec for IMS
 
eSIM Deep Dive
eSIM Deep DiveeSIM Deep Dive
eSIM Deep Dive
 
Yeastar Technical Training Course
Yeastar Technical Training CourseYeastar Technical Training Course
Yeastar Technical Training Course
 
SENA Cloud UC
SENA Cloud UCSENA Cloud UC
SENA Cloud UC
 
FreePBX Disaster Recovery
FreePBX Disaster RecoveryFreePBX Disaster Recovery
FreePBX Disaster Recovery
 
eSIM Overview
eSIM OvervieweSIM Overview
eSIM Overview
 
LTE Architecture Overview
LTE Architecture OverviewLTE Architecture Overview
LTE Architecture Overview
 
Introduction to DIAMETER
Introduction to DIAMETERIntroduction to DIAMETER
Introduction to DIAMETER
 
Introduction to SS7- Part 2
Introduction to SS7- Part 2Introduction to SS7- Part 2
Introduction to SS7- Part 2
 

Recently uploaded

14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
XfilesPro
 
Benefits of Artificial Intelligence in Healthcare!
Benefits of  Artificial Intelligence in Healthcare!Benefits of  Artificial Intelligence in Healthcare!
Benefits of Artificial Intelligence in Healthcare!
Prestware
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
ervikas4
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
Marcin Chrost
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
kgyxske
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
Maitrey Patel
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
Reetu63
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 

Recently uploaded (20)

14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...
 
Benefits of Artificial Intelligence in Healthcare!
Benefits of  Artificial Intelligence in Healthcare!Benefits of  Artificial Intelligence in Healthcare!
Benefits of Artificial Intelligence in Healthcare!
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptxMigration From CH 1.0 to CH 2.0 and  Mule 4.6 & Java 17 Upgrade.pptx
Migration From CH 1.0 to CH 2.0 and Mule 4.6 & Java 17 Upgrade.pptx
 
Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !Enums On Steroids - let's look at sealed classes !
Enums On Steroids - let's look at sealed classes !
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptxLiberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
一比一原版(sdsu毕业证书)圣地亚哥州立大学毕业证如何办理
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.ACE - Team 24 Wrapup event at ahmedabad.
ACE - Team 24 Wrapup event at ahmedabad.
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 
ppt on the brain chip neuralink.pptx
ppt  on   the brain  chip neuralink.pptxppt  on   the brain  chip neuralink.pptx
ppt on the brain chip neuralink.pptx
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 

DLL Injection

  • 2. Static Linking • Code libraries (.lib) include lots of functions to be copied to your program when required. • So, there is no need to reinvent the wheel and rewrite these functions again. • This is done by a program called a linker, which basically copies the needed functions into a program and generates the executable file with all the needed functions inside. • This process is called the static linking.
  • 3. Dynamic Linking • Statically linked libraries lead to having the same code copied repeatedly inside each program. • That might lead to the loss of hard disk space and increases the size of the executable files. • Dynamic linking allows programs to expand more and become more functionality-rich. • Instead of storing the code inside each executable, any needed library is loaded beside each application in the same virtual memory. • These libraries are named Dynamic Link Libraries (DLLs).
  • 4. Dynamic link libraries • Not all library functions are exported as some of them are for internal use. • But the functions that are exported can be accessed through its name or its ordinal number (index number). • They are called Application Programming Interfaces (APIs). • APIs are those exported functions in any library that any application can call or interact with • Some of known Windows DLLs: • kernel32.dll • ntdll.dll • user32.dll • advapi32.dll
  • 5. Dynamic API Loading • It's very common in malware code to obscure the name of the libraries and the APIs that they are using to hide their functionality from static analysis using what's called dynamic API loading. • Dynamic API loading is supported by Windows using two very well-known APIs : • LoadLibraryA: This API loads a dynamic link library into the virtual memory of the calling program and returns its address (variations include LoadLibraryW, LoadLibraryExA, and LoadLibraryExW). • GetProcAddress: This API gets the address of an API given its name and the address of the library that contains this API. • By calling these two APIs, the malware is able to access APIs that are not written in the import table and are totally hidden from the eyes of the reverse engineer.
  • 6. DLL Injection • The Windows operating system allows processes to load dynamic link libraries into other processes for security reasons, sandboxing, or even graphics. • DLL injection is used to manipulate the execution of a running process. • DLL injection primarily tricks an application to call a malicious DLL file which then gets executed as part of the target process. • DLL injection can be divided into 4 steps: • 1. Attach to the process • 2. Allocate Memory within the process • 3. Copy the DLL or the DLL Path into the processes memory and determine appropriate memory addresses • 4. Instruct the process to Execute your DLL
  • 7. Windows Supported DLL Injection • Windows has created registry entries for DLLs so that they can be loaded in every process that meets certain criteria. • Many of them allow the malware DLL to be injected into multiple processes, including browsers and other legitimate processes. • Most common ones: HKEY_LOCAL_MACHINESOFTWARE MicrosoftWindowsNTCurrentVers ionWindowsAppInit_DLLs • The libraries included in this path are loaded together with every process that loads user32.dll.
  • 8. Windows Supported DLL Injection (Cont.) • Other commonly misused registry key: • HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSessionManagerAppCertDlls • The libraries in this registry entry are loaded in each process that calls at least one of the following Win32 API functions: • CreateProcess • CreateProcessAsUser • CreateProcessWithLogonW • CreateProcessWithTokenW • WinExec • This allows the malware to be injected into most browsers as many of them create child processes to manage different tabs and other applications as well.
  • 9. Windows Supported DLL Injection (Cont.) Autoruns from Sysinternals, allows you to see whether any of these registry entries have been exploited for malicious use on the current system. https://docs.microsoft.com/en-us/sysinternals/downloads/autoruns
  • 10. Another DLL Injection Technique • This technique uses the LoadLibrary API to load a malicious library using Windows PE loader and execute its EntryPoint. • The main goal is to inject the path of the malicious DLL into the process using the VirtualAllocEx API and WriteProcessMemory. • Then, it creates a thread into that process using CreateRemoteThread, with the address of the LoadLibrary API as the thread start address. • When passing the DLL path as an argument to that thread (which is passed to the LoadLibrary API), the Windows PE loader will load that DLL into the process and execute its code flawlessly.
  • 11. Another DLL Injection Technique (Cont.) • The exact steps the malware generally follows are like so: 1. Get the targeted process handle via its PID using the OpenProcess API. This handle will be used to access, read, and write to this process. 2. Allocate a space in that process virtual memory using the VirtualAllocEx API. This space will be used to write the full path of the malicious DLL file. 3. Write to the process using the WriteProcessMemory API. Write the path of the malware DLL. 4. Load and execute this DLL using CreateRemoteThread and give the LoadLibraryA address as the start address and the address of the DLL path as an argument.