7 2 Malware Behavior
7 2 Malware Behavior
Chapter 11
Common Malware Functionalities
Downloaders
Backdoors
Credential stealers
Persistence mechanisms
Privilege escalation
Covering tracks (rootkits)
Downloaders and Launchers
Retrieve an additional piece of malware from the Internet
and execute
Often packaged with an exploit
Use Windows API URLDownloadtoFileA -> a call to
WinExec
Launchers
Install malware for immediate or future covert execution
Backdoors
Provides remote access to the attackers on the victim’s
machine
Mostly common malware
Often use port 80 (HTTP protocol) to blend in with other traffic
Learn their network signatures (discussed later)
Operations: manipulate registry keys, enumerate display windows,
create directories, search files.
Always use reverse shell
Allow attackers to execute commands like local machine
Examples: Netcat, cmd.exe
Bypass Firewall Shoveling Shell
Connection
Firewall
Attempt X
Or
Attacker NAT Victim
Connection shovel
Firewall
Attacker “Synchronize the two shells” Victim
Similar to Man-in-the-middle
Winlogon process
winlogon executes
fsgina.dll requests credentials
fsgina.dll passes credentials to msgina.dll (it must
contain all DLL exports required by GINA, begins with Wlx – good
indicator it is a GINA interceptor)
Hash Dumping
Password storage
Typically, only hashes of passwords stored
Users with forgotten passwords issued new ones
Hash function well-known
Dumping hashes allows dictionary attacks since users with weak
passwords subject to brute-force dictionary attacks off-line
Pass-the-Hash Attack
No need to crack the hashes to obtain the plaintext. – Reuse
captured hash.
Pwdump/Pass-the-Hash (PSH) Toolkit – opensource
Pwdump – programs that outputs the LM/NTLM password
hashes from Security Account Manager (SAM)
Pwdump performs DLL injection on lsass.exe (Local
Security Authority Subsystem Service)
Pwdump calls GetHash (Hash Extraction)-Can be
easily changed to avoid signatures
Keystroke Logging
Classic form of credential stealing - records keystrokes so
attacker can observe typed data
Kernel-based Keyloggers
Difficult to detect with user-mode applications
Act as keyboard drivers to capture keystrokes
User-space Keyloggers
Use the Windows API to hook – notify the malware each time a key
is pressed (SetWindowsHookEx)
Poll the state of the keys - (GetForegroundWindow and
GetAsyncKeyState)
User-Space Keyloggers
1. Call GetForegroundWindow
logs the active window
3. Calls GetAsyncKeyState
check if a key pressed
Listing 11-4
Notice – Loop: Call sleep function to avoid eating up resources Disassembly
examples
Persistence Mechanism
Methods to ensure survival of malware on a system for a long
time
Windows Registry persistence
Trojaning
DLL load-order hijacking
Windows Registry
Common malware targets
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Win
dows\CurrentVersion\Run + and more
AppInit_DLLs
Loaded into every process that loads User32.dll
Stored in:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Windows
Winlogon Notify
Hooking logged events (logon, logoff, startup, shutdown, lock screen)
Registry entry: \HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon\
When winlogon.exe generates an event, Windows checks the Notify
registry key above for a DLL that will handle it
SvcHost DLL
SvcHost DLLs
All services persist via registry,
removing, won’t start
svchost.exe – generic host
process for services that run
from DLLs
Many instance of svchost
running at once
Each instance contains a group of
services
Group determined at
\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost
jmp InternetConnect
jmp InternetAutodial
jmp InternetErrorDlg
…
IAT Hooking
Modify IAT to hijack a DLL call
Load rootkit hook function into memory
Replace target function’s address in the IAT with address of hook function
x
jmp InternetConnect
jmp InternetAutodial
Rootkit Code
jmp InternetErrorDlg
…
IAT Hooking (Ex. From Book)