SlideShare uma empresa Scribd logo
1 de 25
Code/DLL Injection


   ECE4112 – Internetwork Security
    Georgia Institute of Technology

     By Andrei Bersatti and Brandon Harrington



                                                 1
Agenda

•Background: Processes and DLLs
•Code Injection
   •Static Injection
   •Dynamic Injection
• Trojans and Firewall Evasion
• Defenses

                                  2
Processes and DLLs (1)

• What are processes?
• What are DLL files?
    More on this later
• Processes are running tasks that are managed by the
  Operating System. Processes may load DLL files
  (Dynamic Link Libraries, in Windows).
• Dynamic Link Libraries are executable code that can
  only be executed when called by a process.

                                                        3
Processes and DLLs (2)

• At the Lab:
   We will have a brief review of Processes.
   Use Windows Task Managers to Observe
    Processes.
   Use Sysinternals Process Explorer (view processes
    and .dll files loaded by processes).
   Process Name, Process User, Process Description,
    Process ID, Process DLL’s.

                                                    4
Code Injection

  • Code Injection: ‘Injecting’ code (putting
    executable code within) into another program.
  • Two Kinds:
     • Static Injection: Occurs prior to program execution.
     • Dynamic Injection: Occurs on or after program
       execution.

  • Original Program/Process + Injected Code =
    Malicious Program/Process
                                                              5
Code Injection – Static
Injection (1)

  • Occurs prior to execution of a program.
  • Example:
     • A program innocent.exe is modified so that
       prior to executing itself it executes code that
       has been injected to do some nasty thing.
     • Then the program is delivered to the victim
       who thinks the program is innocent (a virus? A
       trojan? A technique!).
                                                         6
Code Injection – Static Injection
                (2)

• How is it done?
  • Programs have a memory space.
  • Not all of the memory space is used, some parts of
    the memory space (usually at the end) is full of
    NOOPs. This area is known as a “cave.”
  • A cave can be overwritten without corrupting
    (other than by adding a desired functionality) the
    victim program.
                                                         7
Code Injection – Static Injection
 (3)
•In order to execute the code in the cave, the program has to
be able to reach the code.
•How?
•Every program has an Entry Point. By changing the first
instruction in the Entry Point into a JUMP to our added code,
as soon as the program starts our code executes.
•At the end of our code we add any instructions overwritten
by the JUMP and then enter a JUMP back to the 2nd
Instruction of the Entry Point.
•Program execution continues normally.
                                                                8
Code Injection – Static Injection
(4)
• In the Lab:
   •We will use OllyDbg (a debugger or decompiler) to
   modify the memory space of winmine.exe
   (Minesweeper) so that it displays a Message Box prior to
   executing.
• Need some basic ASM:
   •JMP -> A jump to an address (to an instruction).
   •PUSH -> Pushes a variable into the stack.
   •CALL -> Calls a Function, our function,
   user32.MessageBoxA, will pop the stack and take those      9
   variables as parameters.
Code Injection – Static Injection
 (5)

• Static Code Injection is not widely exploited
by Trojans.
• Understanding how Static Code Injection
works helps to understand Dynamic Code
Injection.
• Static Code Injection is harder to detect since it
may have occurred before the victim program
arrived at a particular location.
                                                  10
Dynamic Code Injection

• Used by rootkits, trojans, viruses, spyware

• Inserting code into the program’s memory
  space.

• No signs of tampering in the executable
  file. Changes done on-the-fly while the
  process is running.
                                            11
Dynamic Link Libraries (DLL)

• DLLs are shared libraries used across
  many programs.
   Instead of including the shared code in every
    executable, common functions are stored in a
    separate file accessible by the programs.
     – Reduces executable size
     – Increases code re-use
   Accessed by memory location
     – Import/Export Look-up table
                                                12
API Hooking

• Closely related to functional overloading in
  programming

• Common practice in programming mainly
  for debugging purposes.

• Uses DLL injection to implant its hook DLL

                                             13
API Hooking (continued)

• Malicious uses
   Override functions in programs to intercept
    data
   Maintain functionality but add “bad features”
   Examples:
     – An encryption algorithm in a DLL could be
       overwritten to output the data before encrypted.
     – A send web data function could be overwritten to
       send duplicate data to another server.

                                                          14
Lab Procedures
(Dynamic Injection)

• Inject DLLs into running processes using
   APM
   Aphex’s DLL Injector


• Use Process Explorer (PE) to show the
  new DLL loaded


                                             15
Trojans and Firewall Evasion (1)
•What is the relevance of Code Injection to an
Internetwork Security class?
•Trojans often use code/dll injection in an attempt
to evade the Firewall and communicate with the
Internet.
•Reverse Connection: Attacker’s computer does not
contact you; your computer contacts the attacker’s
computer!
•Access to data prior to encryption!
                                                      16
Trojans and Firewall Evasion (2)
• Static code injection scenario:
    Install.exe was downloaded from Kazaa. (Assume
     Install.exe is your favorite videogame).
    Install.exe is in reality MultiPlayerGame.exe wrapped with
     invisible Keylogger.exe.
    MultiPlayerGame.exe was injected with code to connect to
     the Internet and deliver Keylog.txt to an attacker’s IP
     address.
    Because you willingly ran a Multiplayer Game, you will
     tell your Firewall “Yes, allow MultiPlayerGame.exe to go
     outbound.”

                                                             17
Trojans and Firewall Evasion (3)
   •But like we said before, while harder to detect, Static
   Code Injection is not commonly used by trojans.
   •Dynamic Code/DLL Injection is far more common
   and far more dangerous!
   •Dynamic Code/DLL Injection scenario:
      •warningIamAtrojanServer.exe was somehow executed by
      some irresponsible person.
      •This installed in the Run registry a program that runs upon
      startup for 1 second and injects a trojan.dll into iexplore.exe.
      Trojan was a Remote Administration Tool and because
      iexplore.exe has Firewall privileges, this RAT does too!

                                                                         18
Trojans and Firewall Evasion (4)

•At the lab:
   •We will install a firewall (Sygate Personal
   Firewall)
   •We will test a firewall using Atelier Web
   Firewall Tester (tests Firewalls by trying to
   inject different processes that should already
   have privileges in the Firewall.
   •Atelier claims that most firewalls fail these
   tests!!                                          19
Trojans and Firewall Evasion (5)
• Some Trojans that use injection:
   Assassin 2.0 – Uses dynamic DLL injection for
    reverse connection.
   Beast 2.0 – Uses dynamic DLL injection for reverse
    connection.
   Nuclear Uploader – Uses dynamic DLL injection for
    reverse connection.
   Flux – Uses dynamic code injection for reverse
    connection.
   Institution 2004 – Claims to use DLL injection for
    reverse connection. Allows to remotely patch a
    process.

                                                     20
Trojans and Firewall Evasion (6)
• In the lab:

• We will play with Assassin 2.0; show the loaded .dll using Process
  Explorer.

• We will play with Institution 2004; show ability to patch processes
  remotely.

• We will play with Flux; show that it does indeed use Internet
  Explorer to evade the Firewall and yet no loaded .dll is detected.

• Tools: Process Explorer, Sygate Personal Firewall logs.



                                                                        21
Protection

• How can you protect yourself from this
  attack?

• Anti-Hook
   Essentially a firewall for DLL’s
   Rule-based
     – Allow only “trusted” dll’s to be loaded by programs


                                                        22
Detection

• Static Injection
   File Fingerprinting


• Dynamic Injection
   Scan memory for rogue DLL currently loaded

   Check import/export addresses of linked
    functions and compare with known addresses

                                             23
Lab Procedures (Defenses)

• Use Advanced Process Manipulation (APM)
  to unload DLL injected into current
  processes



• Use TDS-3 to scan memory for rogue
  DLLs

                                       24
Conclusions

• This is a common technique.

• Comparable to buffer overflows.

• If you know how the technique works,
  you can defend yourself against various
  malware that uses it

                                            25

Mais conteúdo relacionado

Mais procurados

Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
Tech_MX
 

Mais procurados (20)

Sql injection
Sql injectionSql injection
Sql injection
 
Java package
Java packageJava package
Java package
 
Java Serialization
Java SerializationJava Serialization
Java Serialization
 
CNIT 126 Ch 0: Malware Analysis Primer & 1: Basic Static Techniques
CNIT 126 Ch 0: Malware Analysis Primer & 1: Basic Static TechniquesCNIT 126 Ch 0: Malware Analysis Primer & 1: Basic Static Techniques
CNIT 126 Ch 0: Malware Analysis Primer & 1: Basic Static Techniques
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
QSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and JitQSpiders - Jdk Jvm Jre and Jit
QSpiders - Jdk Jvm Jre and Jit
 
Basic Dynamic Analysis of Malware
Basic Dynamic Analysis of MalwareBasic Dynamic Analysis of Malware
Basic Dynamic Analysis of Malware
 
java Features
java Featuresjava Features
java Features
 
Exception Handling in JAVA
Exception Handling in JAVAException Handling in JAVA
Exception Handling in JAVA
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Interface in java
Interface in javaInterface in java
Interface in java
 
9: OllyDbg
9: OllyDbg9: OllyDbg
9: OllyDbg
 
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
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unit
 
Sql injection
Sql injectionSql injection
Sql injection
 
Deadlock
DeadlockDeadlock
Deadlock
 
Java Networking
Java NetworkingJava Networking
Java Networking
 
Java program structure
Java program structureJava program structure
Java program structure
 

Destaque

Had You Got It ponywang
Had You Got It ponywangHad You Got It ponywang
Had You Got It ponywang
VERABLOG
 
Eic2008munich1
Eic2008munich1Eic2008munich1
Eic2008munich1
Doc Searls
 
網路拍賣
網路拍賣網路拍賣
網路拍賣
future20
 
Trial For Blog 2003
Trial For Blog 2003Trial For Blog 2003
Trial For Blog 2003
guestcd6f00
 
2008 06 02_scopenl-a
2008 06 02_scopenl-a2008 06 02_scopenl-a
2008 06 02_scopenl-a
Doc Searls
 

Destaque (20)

2011 03 22_kynetx1
2011 03 22_kynetx12011 03 22_kynetx1
2011 03 22_kynetx1
 
The
TheThe
The
 
1runit4
1runit41runit4
1runit4
 
Applebee’S
Applebee’SApplebee’S
Applebee’S
 
Maps, Maps, Maps
Maps, Maps, MapsMaps, Maps, Maps
Maps, Maps, Maps
 
Had You Got It ponywang
Had You Got It ponywangHad You Got It ponywang
Had You Got It ponywang
 
Unit3segon
Unit3segonUnit3segon
Unit3segon
 
Umpc
UmpcUmpc
Umpc
 
2009 03 24 Lunchtalk
2009 03 24 Lunchtalk2009 03 24 Lunchtalk
2009 03 24 Lunchtalk
 
Dsohowto
DsohowtoDsohowto
Dsohowto
 
Eic2008munich1
Eic2008munich1Eic2008munich1
Eic2008munich1
 
網路拍賣
網路拍賣網路拍賣
網路拍賣
 
Birr
BirrBirr
Birr
 
Introduction to Web 2.0 & Free Culture
Introduction to Web 2.0 & Free CultureIntroduction to Web 2.0 & Free Culture
Introduction to Web 2.0 & Free Culture
 
Trial For Blog 2003
Trial For Blog 2003Trial For Blog 2003
Trial For Blog 2003
 
2008 06 02_scopenl-a
2008 06 02_scopenl-a2008 06 02_scopenl-a
2008 06 02_scopenl-a
 
InMemoriam
InMemoriamInMemoriam
InMemoriam
 
1ststory3
1ststory31ststory3
1ststory3
 
20100522 bv d66 wat betekene onze plannen voor u
20100522 bv d66 wat betekene onze plannen voor u20100522 bv d66 wat betekene onze plannen voor u
20100522 bv d66 wat betekene onze plannen voor u
 
Fridgend Silde
Fridgend SildeFridgend Silde
Fridgend Silde
 

Semelhante a Dll injection

Volatile IOCs for Fast Incident Response
Volatile IOCs for Fast Incident ResponseVolatile IOCs for Fast Incident Response
Volatile IOCs for Fast Incident Response
Takahiro Haruyama
 
Project Malware AnalysisCS 6262 Project 3Agenda.docx
Project Malware AnalysisCS 6262 Project 3Agenda.docxProject Malware AnalysisCS 6262 Project 3Agenda.docx
Project Malware AnalysisCS 6262 Project 3Agenda.docx
briancrawford30935
 

Semelhante a Dll injection (20)

Captain Hook: Pirating AVs to Bypass Exploit Mitigations
Captain Hook: Pirating AVs to Bypass Exploit MitigationsCaptain Hook: Pirating AVs to Bypass Exploit Mitigations
Captain Hook: Pirating AVs to Bypass Exploit Mitigations
 
Piratng Avs to bypass exploit mitigation
Piratng Avs to bypass exploit mitigationPiratng Avs to bypass exploit mitigation
Piratng Avs to bypass exploit mitigation
 
Fileless Malware Infections
Fileless Malware InfectionsFileless Malware Infections
Fileless Malware Infections
 
Botnets Attacks.pptx
Botnets Attacks.pptxBotnets Attacks.pptx
Botnets Attacks.pptx
 
Lecture 12 malicious software
Lecture 12 malicious software Lecture 12 malicious software
Lecture 12 malicious software
 
how-to-bypass-AM-PPL
how-to-bypass-AM-PPLhow-to-bypass-AM-PPL
how-to-bypass-AM-PPL
 
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
 
CNIT 126 Ch 11: Malware Behavior
CNIT 126 Ch 11: Malware BehaviorCNIT 126 Ch 11: Malware Behavior
CNIT 126 Ch 11: Malware Behavior
 
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
 
Yow connected developing secure i os applications
Yow connected   developing secure i os applicationsYow connected   developing secure i os applications
Yow connected developing secure i os applications
 
6unit1 virus and their types
6unit1 virus and their types6unit1 virus and their types
6unit1 virus and their types
 
openioc_scan - IOC scanner for memory forensics
openioc_scan - IOC scanner for memory forensicsopenioc_scan - IOC scanner for memory forensics
openioc_scan - IOC scanner for memory forensics
 
Finfisher- Nguyễn Chấn Việt
Finfisher- Nguyễn Chấn ViệtFinfisher- Nguyễn Chấn Việt
Finfisher- Nguyễn Chấn Việt
 
Volatile IOCs for Fast Incident Response
Volatile IOCs for Fast Incident ResponseVolatile IOCs for Fast Incident Response
Volatile IOCs for Fast Incident Response
 
CNIT 126 12: Covert Malware Launching
CNIT 126 12: Covert Malware LaunchingCNIT 126 12: Covert Malware Launching
CNIT 126 12: Covert Malware Launching
 
Bypass_AV-EDR.pdf
Bypass_AV-EDR.pdfBypass_AV-EDR.pdf
Bypass_AV-EDR.pdf
 
Cyber attacks 101
Cyber attacks 101Cyber attacks 101
Cyber attacks 101
 
CNIT 126 11. Malware Behavior
CNIT 126 11. Malware BehaviorCNIT 126 11. Malware Behavior
CNIT 126 11. Malware Behavior
 
Project Malware AnalysisCS 6262 Project 3Agenda.docx
Project Malware AnalysisCS 6262 Project 3Agenda.docxProject Malware AnalysisCS 6262 Project 3Agenda.docx
Project Malware AnalysisCS 6262 Project 3Agenda.docx
 
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan BalazsHacking Highly Secured Enterprise Environments by Zoltan Balazs
Hacking Highly Secured Enterprise Environments by Zoltan Balazs
 

Mais de KarlFrank99

Hs P005 Reflective Dll Injection
Hs P005 Reflective Dll InjectionHs P005 Reflective Dll Injection
Hs P005 Reflective Dll Injection
KarlFrank99
 
Atomic Bomb Tutorial En
Atomic Bomb Tutorial EnAtomic Bomb Tutorial En
Atomic Bomb Tutorial En
KarlFrank99
 
Bh Usa 07 Butler And Kendall
Bh Usa 07 Butler And KendallBh Usa 07 Butler And Kendall
Bh Usa 07 Butler And Kendall
KarlFrank99
 

Mais de KarlFrank99 (20)

Sandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooksSandboxie process isolation with kernel hooks
Sandboxie process isolation with kernel hooks
 
Comodo q1 2018
Comodo q1 2018Comodo q1 2018
Comodo q1 2018
 
Double agent zero-day code injection and persistence technique
Double agent  zero-day code injection and persistence techniqueDouble agent  zero-day code injection and persistence technique
Double agent zero-day code injection and persistence technique
 
Process Doppelgänging
Process Doppelgänging Process Doppelgänging
Process Doppelgänging
 
Osteoblast-Osteoclast Interactions
Osteoblast-Osteoclast InteractionsOsteoblast-Osteoclast Interactions
Osteoblast-Osteoclast Interactions
 
Role of autophagy in tumor necrosis factor-α- induced apoptosis of osteoblast...
Role of autophagy in tumor necrosis factor-α- induced apoptosis of osteoblast...Role of autophagy in tumor necrosis factor-α- induced apoptosis of osteoblast...
Role of autophagy in tumor necrosis factor-α- induced apoptosis of osteoblast...
 
Osteoblast and Osteoclast Crosstalks: From OAF to Ephrin
Osteoblast and Osteoclast Crosstalks: From OAF to EphrinOsteoblast and Osteoclast Crosstalks: From OAF to Ephrin
Osteoblast and Osteoclast Crosstalks: From OAF to Ephrin
 
The Tight Relationship Between Osteoclasts and the Immune System
The Tight Relationship Between Osteoclasts and the Immune SystemThe Tight Relationship Between Osteoclasts and the Immune System
The Tight Relationship Between Osteoclasts and the Immune System
 
No association between circulating concentrations of vitamin D and risk of lu...
No association between circulating concentrations of vitamin D and risk of lu...No association between circulating concentrations of vitamin D and risk of lu...
No association between circulating concentrations of vitamin D and risk of lu...
 
20180426_EcbMeeting_DiffStatement
20180426_EcbMeeting_DiffStatement20180426_EcbMeeting_DiffStatement
20180426_EcbMeeting_DiffStatement
 
20180420__DanskeResearch_ECBPreview
20180420__DanskeResearch_ECBPreview20180420__DanskeResearch_ECBPreview
20180420__DanskeResearch_ECBPreview
 
20180420__DanskeResearcch_WeeklyFocus
20180420__DanskeResearcch_WeeklyFocus20180420__DanskeResearcch_WeeklyFocus
20180420__DanskeResearcch_WeeklyFocus
 
20180417_DanskeResearch_FX_Forecast_Update
20180417_DanskeResearch_FX_Forecast_Update20180417_DanskeResearch_FX_Forecast_Update
20180417_DanskeResearch_FX_Forecast_Update
 
20180418_NordeaResearch_EAInfl_n_ECB
20180418_NordeaResearch_EAInfl_n_ECB20180418_NordeaResearch_EAInfl_n_ECB
20180418_NordeaResearch_EAInfl_n_ECB
 
NordeaResearch_EcbWatch_20180423
NordeaResearch_EcbWatch_20180423NordeaResearch_EcbWatch_20180423
NordeaResearch_EcbWatch_20180423
 
20170426_CommerzbankResearch__BullionWeeklyTechnicals
20170426_CommerzbankResearch__BullionWeeklyTechnicals20170426_CommerzbankResearch__BullionWeeklyTechnicals
20170426_CommerzbankResearch__BullionWeeklyTechnicals
 
Tesi Laurea
Tesi LaureaTesi Laurea
Tesi Laurea
 
Hs P005 Reflective Dll Injection
Hs P005 Reflective Dll InjectionHs P005 Reflective Dll Injection
Hs P005 Reflective Dll Injection
 
Atomic Bomb Tutorial En
Atomic Bomb Tutorial EnAtomic Bomb Tutorial En
Atomic Bomb Tutorial En
 
Bh Usa 07 Butler And Kendall
Bh Usa 07 Butler And KendallBh Usa 07 Butler And Kendall
Bh Usa 07 Butler And Kendall
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
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
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
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
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 

Dll injection

  • 1. Code/DLL Injection ECE4112 – Internetwork Security Georgia Institute of Technology By Andrei Bersatti and Brandon Harrington 1
  • 2. Agenda •Background: Processes and DLLs •Code Injection •Static Injection •Dynamic Injection • Trojans and Firewall Evasion • Defenses 2
  • 3. Processes and DLLs (1) • What are processes? • What are DLL files?  More on this later • Processes are running tasks that are managed by the Operating System. Processes may load DLL files (Dynamic Link Libraries, in Windows). • Dynamic Link Libraries are executable code that can only be executed when called by a process. 3
  • 4. Processes and DLLs (2) • At the Lab:  We will have a brief review of Processes.  Use Windows Task Managers to Observe Processes.  Use Sysinternals Process Explorer (view processes and .dll files loaded by processes).  Process Name, Process User, Process Description, Process ID, Process DLL’s. 4
  • 5. Code Injection • Code Injection: ‘Injecting’ code (putting executable code within) into another program. • Two Kinds: • Static Injection: Occurs prior to program execution. • Dynamic Injection: Occurs on or after program execution. • Original Program/Process + Injected Code = Malicious Program/Process 5
  • 6. Code Injection – Static Injection (1) • Occurs prior to execution of a program. • Example: • A program innocent.exe is modified so that prior to executing itself it executes code that has been injected to do some nasty thing. • Then the program is delivered to the victim who thinks the program is innocent (a virus? A trojan? A technique!). 6
  • 7. Code Injection – Static Injection (2) • How is it done? • Programs have a memory space. • Not all of the memory space is used, some parts of the memory space (usually at the end) is full of NOOPs. This area is known as a “cave.” • A cave can be overwritten without corrupting (other than by adding a desired functionality) the victim program. 7
  • 8. Code Injection – Static Injection (3) •In order to execute the code in the cave, the program has to be able to reach the code. •How? •Every program has an Entry Point. By changing the first instruction in the Entry Point into a JUMP to our added code, as soon as the program starts our code executes. •At the end of our code we add any instructions overwritten by the JUMP and then enter a JUMP back to the 2nd Instruction of the Entry Point. •Program execution continues normally. 8
  • 9. Code Injection – Static Injection (4) • In the Lab: •We will use OllyDbg (a debugger or decompiler) to modify the memory space of winmine.exe (Minesweeper) so that it displays a Message Box prior to executing. • Need some basic ASM: •JMP -> A jump to an address (to an instruction). •PUSH -> Pushes a variable into the stack. •CALL -> Calls a Function, our function, user32.MessageBoxA, will pop the stack and take those 9 variables as parameters.
  • 10. Code Injection – Static Injection (5) • Static Code Injection is not widely exploited by Trojans. • Understanding how Static Code Injection works helps to understand Dynamic Code Injection. • Static Code Injection is harder to detect since it may have occurred before the victim program arrived at a particular location. 10
  • 11. Dynamic Code Injection • Used by rootkits, trojans, viruses, spyware • Inserting code into the program’s memory space. • No signs of tampering in the executable file. Changes done on-the-fly while the process is running. 11
  • 12. Dynamic Link Libraries (DLL) • DLLs are shared libraries used across many programs.  Instead of including the shared code in every executable, common functions are stored in a separate file accessible by the programs. – Reduces executable size – Increases code re-use  Accessed by memory location – Import/Export Look-up table 12
  • 13. API Hooking • Closely related to functional overloading in programming • Common practice in programming mainly for debugging purposes. • Uses DLL injection to implant its hook DLL 13
  • 14. API Hooking (continued) • Malicious uses  Override functions in programs to intercept data  Maintain functionality but add “bad features”  Examples: – An encryption algorithm in a DLL could be overwritten to output the data before encrypted. – A send web data function could be overwritten to send duplicate data to another server. 14
  • 15. Lab Procedures (Dynamic Injection) • Inject DLLs into running processes using  APM  Aphex’s DLL Injector • Use Process Explorer (PE) to show the new DLL loaded 15
  • 16. Trojans and Firewall Evasion (1) •What is the relevance of Code Injection to an Internetwork Security class? •Trojans often use code/dll injection in an attempt to evade the Firewall and communicate with the Internet. •Reverse Connection: Attacker’s computer does not contact you; your computer contacts the attacker’s computer! •Access to data prior to encryption! 16
  • 17. Trojans and Firewall Evasion (2) • Static code injection scenario:  Install.exe was downloaded from Kazaa. (Assume Install.exe is your favorite videogame).  Install.exe is in reality MultiPlayerGame.exe wrapped with invisible Keylogger.exe.  MultiPlayerGame.exe was injected with code to connect to the Internet and deliver Keylog.txt to an attacker’s IP address.  Because you willingly ran a Multiplayer Game, you will tell your Firewall “Yes, allow MultiPlayerGame.exe to go outbound.” 17
  • 18. Trojans and Firewall Evasion (3) •But like we said before, while harder to detect, Static Code Injection is not commonly used by trojans. •Dynamic Code/DLL Injection is far more common and far more dangerous! •Dynamic Code/DLL Injection scenario: •warningIamAtrojanServer.exe was somehow executed by some irresponsible person. •This installed in the Run registry a program that runs upon startup for 1 second and injects a trojan.dll into iexplore.exe. Trojan was a Remote Administration Tool and because iexplore.exe has Firewall privileges, this RAT does too! 18
  • 19. Trojans and Firewall Evasion (4) •At the lab: •We will install a firewall (Sygate Personal Firewall) •We will test a firewall using Atelier Web Firewall Tester (tests Firewalls by trying to inject different processes that should already have privileges in the Firewall. •Atelier claims that most firewalls fail these tests!! 19
  • 20. Trojans and Firewall Evasion (5) • Some Trojans that use injection:  Assassin 2.0 – Uses dynamic DLL injection for reverse connection.  Beast 2.0 – Uses dynamic DLL injection for reverse connection.  Nuclear Uploader – Uses dynamic DLL injection for reverse connection.  Flux – Uses dynamic code injection for reverse connection.  Institution 2004 – Claims to use DLL injection for reverse connection. Allows to remotely patch a process. 20
  • 21. Trojans and Firewall Evasion (6) • In the lab: • We will play with Assassin 2.0; show the loaded .dll using Process Explorer. • We will play with Institution 2004; show ability to patch processes remotely. • We will play with Flux; show that it does indeed use Internet Explorer to evade the Firewall and yet no loaded .dll is detected. • Tools: Process Explorer, Sygate Personal Firewall logs. 21
  • 22. Protection • How can you protect yourself from this attack? • Anti-Hook  Essentially a firewall for DLL’s  Rule-based – Allow only “trusted” dll’s to be loaded by programs 22
  • 23. Detection • Static Injection  File Fingerprinting • Dynamic Injection  Scan memory for rogue DLL currently loaded  Check import/export addresses of linked functions and compare with known addresses 23
  • 24. Lab Procedures (Defenses) • Use Advanced Process Manipulation (APM) to unload DLL injected into current processes • Use TDS-3 to scan memory for rogue DLLs 24
  • 25. Conclusions • This is a common technique. • Comparable to buffer overflows. • If you know how the technique works, you can defend yourself against various malware that uses it 25