SlideShare a Scribd company logo
1 of 41
Download to read offline
Practical Malware Analysis
Ch 12: Covert Malware Launching
Last revised: 4-10-17
Hiding Malware
• Malware used to be visible in Windows
Task Manager
• But users often know how to look there
• So malware authors now try to blend their
malware into the normal Windows
landscape
• Covert lanching techniques
Launchers
Purpose of a Launcher
• Sets itself or another piece of malware
• For immediate or future covert execution
• Conceals malicious behavior from the user
• Usually contain the malware they're loading
– An executable or DLL in its own resource
section
• Normal items in the resource section
– Icons, images, menus, strings
– Not considered part of the executable
Encryption or Compression
• The resource section may be encrypted or
compressed
• Resource extraction will use APIs like
– FindResource
– LoadResource
– SizeofResource
• Malware also often contains privilege
escalation code
Process Injection
Process Injection
• The most popular covert launching technique
• Two types: DLL Injection and Direct Injection
• Injects code into a running process
• Conceals malicious behavior
• May bypass firewalls and other process-specific
security mechanisms
• Common API calls:
– VirtualAllocEx to allocate space in another
process's memory
– WriteProcessMemory to write to it
DLL Injection
• The most commonly used covert launching
technique
• Inject code into a remote process that calls
LoadLibrary
• Forces the DLL to load in the context of
that process
• On load, the OS automatically calls
DLLMain which contains the malicious
code
Example
• Launcher wants Internet access
• To download more code
• But a process-specific firewall won't let
the launcher's process access the Internet
• Solution: inject malicious code into
Internet Explorer process
• Which already has Internet access
Gaining Privileges
• Malware code has the same privileges as
the code it is injected into
• CreateRemoteThread uses 3
parameters
– Process handle hProcess
– Starting point lpStartAddress
(LoadLibrary)
– Argument lpParameter Malicious DLL name
Analyzing DLL Injection
• Once you find DLL injection activity in
disassembly
• Look for strings containing the name of
the malicious DLL and the victim
process
• Or put a breakpoint in the injection
code and examine the stack to find
them
Direct Injection
• Injects code directly into the remote
process
• Without using a DLL
• More flexible than DLL injection
• Requires a lot of customized code
• To run without negatively impacting the host
process
• Difficult to write
Process Replacement
Process Replacement
• Overwrites the memory space of a running
object with malicious code
• Disguises malware as a legitimate process
• Avoids risk of crashing a process with
process injection
• Malware gains the privileges of the
process it replaces
• Commonly replaces svchost.exe
Suspended State
• In a suspended state, the process is
loaded into memory but the primary
thread is suspended
– So malware can overwrite its code before it
runs
• This uses the CREATE_SUSPENDED value
• in the dwCreationFlags parameter
• In a call to the CreateProcess function
• ZwUnmapViewOfSection releases all
memory pointed to by a section
• VirtualAllocEx allocates new memory
• WriteProcessMemory puts malware in it
• SetThreadContext restores the victim
process's environment and sets the entry
point
• ResumeThread runs the malicious code
Hook Injection
Hooks
• Windows hooks intercept messages
destined for applications
• Malicious hooks
– Ensure that malicious code will run whenever
a particular message is intercepted
– Ensure that a DLL will be loaded in a victim
process's memory space
Local and Remote Hooks
• Local hooks observe or manipulate
messages destined for an internal process
• Remote hooks observe or manipulate
messages destined for a remote process
(another process on the computer)
High-Level and Low-Level 

Remote Hooks
• High-level remote hooks
– Require that the hook procedure is an
exported function contained in a DLL
– Mapped by the OS into the process space of a
hooked thread or all threads
• Low-level remote hooks
– Require that the hook procedure be contained
in the process that installed the hook
Keyloggers Using Hooks
• Keystrokes can be captured by high-level
or low-level hooks using these procedure
types
– WH_KEYBOARD
– or
– WH_KEYBOARD_LL
Using SetWindowsHookEx 

for Remote Windows Hooking
• Parameters
– idHook – type of hook to install
– lpfn – points to hook procedure
– hMod – handle to DLL, or local module, in which the
lpfn procedure is defined
– dwThreadId– thread to associate the hook with.
Zero = all threads
• The hook procedure must call CallNextHookEx
to pass execution to the next hook procedure so
the system continues to run properly
Thread Targeting
• Loading into all threads can degrade system
performance
• May also trigger an IPS
• Keyloggers load into all threads, to get all
the keystrokes
• Other malware targets a single thread
• Often targets a Windows message that is
rarely used, such as WH_CBT (a computer-
based training message)
Explanation of Next Slide
• Malicious DLL hook.dll is loaded
• Malicious hook procedure address
MalwareProc obtained
• The hook procedure calls only
CallNextHookEx
• A WH_CBT message is sent to a Notepad
thread
• Forces hook.dll to be loaded by Notepad
• It runs in the Notepad process space
Detours
A Microsoft Product
• Detours makes it easy for application
developers to modify applications and the
OS
• Used in malware to add new DLLs to
existing binaries on disk
• Modifies the PE structure to create
a .detour section
• Containing original PE header with a new
import address table
• setdll is the Microsoft tool used to point
the PE to the new import table
• There are other ways to add a .detour
section
APC Injection
Asynchronous Procedure Call

(APC)
• Directs a thread to execute other code prior to
executing its regular path
• Every thread has a queue of APCs attached to it
• These are processed when the thread is in an
alterable state, such as when these functions
are called
– WaitForSingleObjectEx
– WaitForMultipleObjectsEx
– Sleep
Two Forms of APCs
• Kernel-Mode APC
– Generated for the system or a driver
• User-Mode APC
– Generated for an application
• APC Injection is used in both cases
APC Injection from User Space
• Uses API function QueueUserAPC
• Thread must be in an alterable state
• WaitForSingleObjectEx is the most
common call in the Windows API
• Many threads are usually in the alterable
state
QueueUserAPC Parameters
• hThread handle to thread
• pfnAPC defines the function to run
• dwData parameter for function
• 1: Opens a handle to the thread
• 2: QueueUserAPC is called with pfnAPC set
to LoadLibraryA (loads a DLL)
• dwData contains the DLL name (dbnet.dll)
• Svchost.exe is often targeted for APC injection
APC Injection from Kernel Space
• Malware drivers and rootkits often want to
execute code in user space
• This is difficult to do
• One method is APC injection to get to user
space
• Most often to svchost.exe
• Functions used:
– KeInitializeApc
– KeInsertQueueApc
CNIT 126 12: Covert Malware Launching

More Related Content

What's hot

CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgSam Bowne
 
CNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 DisassemblyCNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 DisassemblySam Bowne
 
Practical Malware Analysis Ch 14: Malware-Focused Network Signatures
Practical Malware Analysis Ch 14: Malware-Focused Network SignaturesPractical Malware Analysis Ch 14: Malware-Focused Network Signatures
Practical Malware Analysis Ch 14: Malware-Focused Network SignaturesSam 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
 
Introduction Linux Device Drivers
Introduction Linux Device DriversIntroduction Linux Device Drivers
Introduction Linux Device DriversNEEVEE Technologies
 
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 ProSam Bowne
 
Course 102: Lecture 25: Devices and Device Drivers
Course 102: Lecture 25: Devices and Device Drivers Course 102: Lecture 25: Devices and Device Drivers
Course 102: Lecture 25: Devices and Device Drivers Ahmed El-Arabawy
 
Linux device drivers
Linux device driversLinux device drivers
Linux device driversAbhishek Sagar
 
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 TechniquesSam Bowne
 
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly Sam Bowne
 
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...Sam Bowne
 
Processes in unix
Processes in unixProcesses in unix
Processes in unixmiau_max
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingTushar B Kute
 
Character drivers
Character driversCharacter drivers
Character driverspradeep_tewani
 
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbgPractical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbgSam Bowne
 
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
 
CNIT 126 2: Malware Analysis in Virtual Machines & 3: Basic Dynamic Analysis
CNIT 126 2: Malware Analysis in Virtual Machines & 3: Basic Dynamic AnalysisCNIT 126 2: Malware Analysis in Virtual Machines & 3: Basic Dynamic Analysis
CNIT 126 2: Malware Analysis in Virtual Machines & 3: Basic Dynamic AnalysisSam Bowne
 
Linux architecture
Linux architectureLinux architecture
Linux architecturemcganesh
 

What's hot (20)

CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
 
CNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 DisassemblyCNIT 126 4: A Crash Course in x86 Disassembly
CNIT 126 4: A Crash Course in x86 Disassembly
 
Practical Malware Analysis Ch 14: Malware-Focused Network Signatures
Practical Malware Analysis Ch 14: Malware-Focused Network SignaturesPractical Malware Analysis Ch 14: Malware-Focused Network Signatures
Practical Malware Analysis Ch 14: Malware-Focused Network Signatures
 
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
 
Introduction Linux Device Drivers
Introduction Linux Device DriversIntroduction Linux Device Drivers
Introduction Linux Device Drivers
 
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
 
Course 102: Lecture 25: Devices and Device Drivers
Course 102: Lecture 25: Devices and Device Drivers Course 102: Lecture 25: Devices and Device Drivers
Course 102: Lecture 25: Devices and Device Drivers
 
Linux device drivers
Linux device driversLinux device drivers
Linux device drivers
 
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
 
Linux device drivers
Linux device drivers Linux device drivers
Linux device drivers
 
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
Practical Malware Analysis: Ch 4 A Crash Course in x86 Disassembly
 
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
Practical Malware Analysis: Ch 0: Malware Analysis Primer & 1: Basic Static T...
 
Processes in unix
Processes in unixProcesses in unix
Processes in unix
 
Part 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module ProgrammingPart 02 Linux Kernel Module Programming
Part 02 Linux Kernel Module Programming
 
Character drivers
Character driversCharacter drivers
Character drivers
 
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbgPractical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
Practical Malware Analysis: Ch 10: Kernel Debugging with WinDbg
 
I2c drivers
I2c driversI2c drivers
I2c drivers
 
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...
 
CNIT 126 2: Malware Analysis in Virtual Machines & 3: Basic Dynamic Analysis
CNIT 126 2: Malware Analysis in Virtual Machines & 3: Basic Dynamic AnalysisCNIT 126 2: Malware Analysis in Virtual Machines & 3: Basic Dynamic Analysis
CNIT 126 2: Malware Analysis in Virtual Machines & 3: Basic Dynamic Analysis
 
Linux architecture
Linux architectureLinux architecture
Linux architecture
 

Similar to CNIT 126 12: Covert Malware Launching

Practical Malware Analysis Ch12
Practical Malware Analysis Ch12Practical Malware Analysis Ch12
Practical Malware Analysis Ch12Sam Bowne
 
CNIT 126 Ch 11: Malware Behavior
CNIT 126 Ch 11: Malware BehaviorCNIT 126 Ch 11: Malware Behavior
CNIT 126 Ch 11: Malware BehaviorSam Bowne
 
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 ProgramsSam Bowne
 
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 techniquesenSilo
 
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 MitigationsenSilo
 
Piratng Avs to bypass exploit mitigation
Piratng Avs to bypass exploit mitigationPiratng Avs to bypass exploit mitigation
Piratng Avs to bypass exploit mitigationPriyanka Aash
 
Defending Your "Gold"
Defending Your "Gold"Defending Your "Gold"
Defending Your "Gold"Will Schroeder
 
Windows internals
Windows internalsWindows internals
Windows internalsPiyush Jain
 
CNIT 152 12. Investigating Windows Systems (Part 3)
CNIT 152 12. Investigating Windows Systems (Part 3)CNIT 152 12. Investigating Windows Systems (Part 3)
CNIT 152 12. Investigating Windows Systems (Part 3)Sam Bowne
 
CNIT 121: 12 Investigating Windows Systems (Part 3)
CNIT 121: 12 Investigating Windows Systems (Part 3)CNIT 121: 12 Investigating Windows Systems (Part 3)
CNIT 121: 12 Investigating Windows Systems (Part 3)Sam Bowne
 
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 WindowsSam Bowne
 
Owning computers without shell access 2
Owning computers without shell access 2Owning computers without shell access 2
Owning computers without shell access 2Royce Davis
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgSam Bowne
 
Process injection - Malware style
Process injection - Malware styleProcess injection - Malware style
Process injection - Malware styleSander Demeester
 
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 WindowsSam Bowne
 
Performance analysis and troubleshooting using DTrace
Performance analysis and troubleshooting using DTracePerformance analysis and troubleshooting using DTrace
Performance analysis and troubleshooting using DTraceGraeme Jenkinson
 
Introduction to Malware Analysis
Introduction to Malware AnalysisIntroduction to Malware Analysis
Introduction to Malware AnalysisAndrew McNicol
 
Practical Malware Analysis: Ch 9: OllyDbg
Practical Malware Analysis: Ch 9: OllyDbgPractical Malware Analysis: Ch 9: OllyDbg
Practical Malware Analysis: Ch 9: OllyDbgSam Bowne
 

Similar to CNIT 126 12: Covert Malware Launching (20)

Practical Malware Analysis Ch12
Practical Malware Analysis Ch12Practical Malware Analysis Ch12
Practical Malware Analysis Ch12
 
CNIT 126 Ch 11: Malware Behavior
CNIT 126 Ch 11: Malware BehaviorCNIT 126 Ch 11: Malware Behavior
CNIT 126 Ch 11: Malware Behavior
 
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
 
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
 
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
 
Ch0 1
Ch0 1Ch0 1
Ch0 1
 
Defending Your "Gold"
Defending Your "Gold"Defending Your "Gold"
Defending Your "Gold"
 
Windows internals
Windows internalsWindows internals
Windows internals
 
CNIT 152 12. Investigating Windows Systems (Part 3)
CNIT 152 12. Investigating Windows Systems (Part 3)CNIT 152 12. Investigating Windows Systems (Part 3)
CNIT 152 12. Investigating Windows Systems (Part 3)
 
CNIT 121: 12 Investigating Windows Systems (Part 3)
CNIT 121: 12 Investigating Windows Systems (Part 3)CNIT 121: 12 Investigating Windows Systems (Part 3)
CNIT 121: 12 Investigating Windows Systems (Part 3)
 
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
 
Owning computers without shell access 2
Owning computers without shell access 2Owning computers without shell access 2
Owning computers without shell access 2
 
CNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbgCNIT 126: 10: Kernel Debugging with WinDbg
CNIT 126: 10: Kernel Debugging with WinDbg
 
Process injection - Malware style
Process injection - Malware styleProcess injection - Malware style
Process injection - Malware style
 
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
 
Performance analysis and troubleshooting using DTrace
Performance analysis and troubleshooting using DTracePerformance analysis and troubleshooting using DTrace
Performance analysis and troubleshooting using DTrace
 
Introduction to Malware Analysis
Introduction to Malware AnalysisIntroduction to Malware Analysis
Introduction to Malware Analysis
 
Practical Malware Analysis: Ch 9: OllyDbg
Practical Malware Analysis: Ch 9: OllyDbgPractical Malware Analysis: Ch 9: OllyDbg
Practical Malware Analysis: Ch 9: OllyDbg
 
DLL Injection
DLL InjectionDLL Injection
DLL Injection
 

More from Sam Bowne

Cyberwar
CyberwarCyberwar
CyberwarSam Bowne
 
3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities Sam Bowne
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development SecuritySam Bowne
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the ApplicationSam Bowne
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)Sam Bowne
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic CurvesSam Bowne
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-HellmanSam Bowne
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1Sam Bowne
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android ApplicationsSam Bowne
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)Sam Bowne
 
10 RSA
10 RSA10 RSA
10 RSASam Bowne
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3Sam Bowne
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard ProblemsSam Bowne
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)Sam Bowne
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis MethodologySam Bowne
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated EncryptionSam Bowne
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)Sam Bowne
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)Sam Bowne
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream CiphersSam Bowne
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data CollectionSam Bowne
 

More from Sam Bowne (20)

Cyberwar
CyberwarCyberwar
Cyberwar
 
3: DNS vulnerabilities
3: DNS vulnerabilities 3: DNS vulnerabilities
3: DNS vulnerabilities
 
8. Software Development Security
8. Software Development Security8. Software Development Security
8. Software Development Security
 
4 Mapping the Application
4 Mapping the Application4 Mapping the Application
4 Mapping the Application
 
3. Attacking iOS Applications (Part 2)
 3. Attacking iOS Applications (Part 2) 3. Attacking iOS Applications (Part 2)
3. Attacking iOS Applications (Part 2)
 
12 Elliptic Curves
12 Elliptic Curves12 Elliptic Curves
12 Elliptic Curves
 
11. Diffie-Hellman
11. Diffie-Hellman11. Diffie-Hellman
11. Diffie-Hellman
 
2a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 12a Analyzing iOS Apps Part 1
2a Analyzing iOS Apps Part 1
 
9 Writing Secure Android Applications
9 Writing Secure Android Applications9 Writing Secure Android Applications
9 Writing Secure Android Applications
 
12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)12 Investigating Windows Systems (Part 2 of 3)
12 Investigating Windows Systems (Part 2 of 3)
 
10 RSA
10 RSA10 RSA
10 RSA
 
12 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 312 Investigating Windows Systems (Part 1 of 3
12 Investigating Windows Systems (Part 1 of 3
 
9. Hard Problems
9. Hard Problems9. Hard Problems
9. Hard Problems
 
8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)8 Android Implementation Issues (Part 1)
8 Android Implementation Issues (Part 1)
 
11 Analysis Methodology
11 Analysis Methodology11 Analysis Methodology
11 Analysis Methodology
 
8. Authenticated Encryption
8. Authenticated Encryption8. Authenticated Encryption
8. Authenticated Encryption
 
7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)7. Attacking Android Applications (Part 2)
7. Attacking Android Applications (Part 2)
 
7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)7. Attacking Android Applications (Part 1)
7. Attacking Android Applications (Part 1)
 
5. Stream Ciphers
5. Stream Ciphers5. Stream Ciphers
5. Stream Ciphers
 
6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection6 Scope & 7 Live Data Collection
6 Scope & 7 Live Data Collection
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 

CNIT 126 12: Covert Malware Launching

  • 1. Practical Malware Analysis Ch 12: Covert Malware Launching Last revised: 4-10-17
  • 2. Hiding Malware • Malware used to be visible in Windows Task Manager • But users often know how to look there • So malware authors now try to blend their malware into the normal Windows landscape • Covert lanching techniques
  • 4. Purpose of a Launcher • Sets itself or another piece of malware • For immediate or future covert execution • Conceals malicious behavior from the user • Usually contain the malware they're loading – An executable or DLL in its own resource section • Normal items in the resource section – Icons, images, menus, strings – Not considered part of the executable
  • 5. Encryption or Compression • The resource section may be encrypted or compressed • Resource extraction will use APIs like – FindResource – LoadResource – SizeofResource • Malware also often contains privilege escalation code
  • 7. Process Injection • The most popular covert launching technique • Two types: DLL Injection and Direct Injection • Injects code into a running process • Conceals malicious behavior • May bypass firewalls and other process-specific security mechanisms • Common API calls: – VirtualAllocEx to allocate space in another process's memory – WriteProcessMemory to write to it
  • 8. DLL Injection • The most commonly used covert launching technique • Inject code into a remote process that calls LoadLibrary • Forces the DLL to load in the context of that process • On load, the OS automatically calls DLLMain which contains the malicious code
  • 9. Example • Launcher wants Internet access • To download more code • But a process-specific firewall won't let the launcher's process access the Internet • Solution: inject malicious code into Internet Explorer process • Which already has Internet access
  • 10. Gaining Privileges • Malware code has the same privileges as the code it is injected into
  • 11. • CreateRemoteThread uses 3 parameters – Process handle hProcess – Starting point lpStartAddress (LoadLibrary) – Argument lpParameter Malicious DLL name
  • 12.
  • 13. Analyzing DLL Injection • Once you find DLL injection activity in disassembly • Look for strings containing the name of the malicious DLL and the victim process • Or put a breakpoint in the injection code and examine the stack to find them
  • 14. Direct Injection • Injects code directly into the remote process • Without using a DLL • More flexible than DLL injection • Requires a lot of customized code • To run without negatively impacting the host process • Difficult to write
  • 16. Process Replacement • Overwrites the memory space of a running object with malicious code • Disguises malware as a legitimate process • Avoids risk of crashing a process with process injection • Malware gains the privileges of the process it replaces • Commonly replaces svchost.exe
  • 17. Suspended State • In a suspended state, the process is loaded into memory but the primary thread is suspended – So malware can overwrite its code before it runs • This uses the CREATE_SUSPENDED value • in the dwCreationFlags parameter • In a call to the CreateProcess function
  • 18.
  • 19. • ZwUnmapViewOfSection releases all memory pointed to by a section • VirtualAllocEx allocates new memory • WriteProcessMemory puts malware in it
  • 20. • SetThreadContext restores the victim process's environment and sets the entry point • ResumeThread runs the malicious code
  • 22. Hooks • Windows hooks intercept messages destined for applications • Malicious hooks – Ensure that malicious code will run whenever a particular message is intercepted – Ensure that a DLL will be loaded in a victim process's memory space
  • 23.
  • 24. Local and Remote Hooks • Local hooks observe or manipulate messages destined for an internal process • Remote hooks observe or manipulate messages destined for a remote process (another process on the computer)
  • 25. High-Level and Low-Level 
 Remote Hooks • High-level remote hooks – Require that the hook procedure is an exported function contained in a DLL – Mapped by the OS into the process space of a hooked thread or all threads • Low-level remote hooks – Require that the hook procedure be contained in the process that installed the hook
  • 26. Keyloggers Using Hooks • Keystrokes can be captured by high-level or low-level hooks using these procedure types – WH_KEYBOARD – or – WH_KEYBOARD_LL
  • 27. Using SetWindowsHookEx 
 for Remote Windows Hooking • Parameters – idHook – type of hook to install – lpfn – points to hook procedure – hMod – handle to DLL, or local module, in which the lpfn procedure is defined – dwThreadId– thread to associate the hook with. Zero = all threads • The hook procedure must call CallNextHookEx to pass execution to the next hook procedure so the system continues to run properly
  • 28. Thread Targeting • Loading into all threads can degrade system performance • May also trigger an IPS • Keyloggers load into all threads, to get all the keystrokes • Other malware targets a single thread • Often targets a Windows message that is rarely used, such as WH_CBT (a computer- based training message)
  • 29. Explanation of Next Slide • Malicious DLL hook.dll is loaded • Malicious hook procedure address MalwareProc obtained • The hook procedure calls only CallNextHookEx • A WH_CBT message is sent to a Notepad thread • Forces hook.dll to be loaded by Notepad • It runs in the Notepad process space
  • 30.
  • 32. A Microsoft Product • Detours makes it easy for application developers to modify applications and the OS • Used in malware to add new DLLs to existing binaries on disk • Modifies the PE structure to create a .detour section • Containing original PE header with a new import address table
  • 33. • setdll is the Microsoft tool used to point the PE to the new import table • There are other ways to add a .detour section
  • 35. Asynchronous Procedure Call
 (APC) • Directs a thread to execute other code prior to executing its regular path • Every thread has a queue of APCs attached to it • These are processed when the thread is in an alterable state, such as when these functions are called – WaitForSingleObjectEx – WaitForMultipleObjectsEx – Sleep
  • 36. Two Forms of APCs • Kernel-Mode APC – Generated for the system or a driver • User-Mode APC – Generated for an application • APC Injection is used in both cases
  • 37. APC Injection from User Space • Uses API function QueueUserAPC • Thread must be in an alterable state • WaitForSingleObjectEx is the most common call in the Windows API • Many threads are usually in the alterable state
  • 38. QueueUserAPC Parameters • hThread handle to thread • pfnAPC defines the function to run • dwData parameter for function
  • 39. • 1: Opens a handle to the thread • 2: QueueUserAPC is called with pfnAPC set to LoadLibraryA (loads a DLL) • dwData contains the DLL name (dbnet.dll) • Svchost.exe is often targeted for APC injection
  • 40. APC Injection from Kernel Space • Malware drivers and rootkits often want to execute code in user space • This is difficult to do • One method is APC injection to get to user space • Most often to svchost.exe • Functions used: – KeInitializeApc – KeInsertQueueApc