Malware and the Windows API Windows API Conventions
- Slides: 16
Malware and the Windows API
Windows API Conventions
Windows API Hungarian Notation § WORD (w) - 16 -bit unsigned value (w. Val) § DWORD (dw) - Double-WORD, 32 -bit unsigned value (dw. Val) § Handle (H) – Reference to an object (Hmodule) § Long Pointer (LP) – Pointer to another type (LPByte) 3
Windows API Function Suffixes § A – ANSI strings for params / return values (Copy. File. A) q ANSI – 8 -bit characters § W – WIDE strings for params / return values (Shell. Execute. W) q WIDE – 16 -bit characters § Ex – Extended, has added functionality over normal version of function (Reg. Set. Value. Ex. A) 4
Common Windows API Combinations in Malware
Guessing Behavior from API Functions § Investigating functions in the IAT can imply malware behavior § Can be even more confident about likely behavior if certain Windows API calls occur sequentially in disassembly 6
Runtime Linking § Load. Library - Load a DLL into a process’s memory § Get. Proc. Address – Gets the address of a function from a DLL in memory § In combination, can get the address of any function in any DLL on the system q Don’t need to list desired functions in the IAT 7
Privilege Escalation § Open. Process. Token – Opens a process’s access token (which describes its security context) § Lookup. Privilege. Value – Retrieves a locally unique identifier (LUID), which is a struct that represents a specific privilege § Adjust. Token. Privileges – Modifies privileges of an access token § Usually getting Se. Debug. Privilege, which is pretty much admin 8
Anti-Debugging Timing Checks § Query. Performance. Counter – Called twice, difference between processor’s performance counter at each call is calculated § Get. Tick. Count – Called twice, difference between number of milliseconds since computer boot is calculated 9
Other Anti-Debugging API Functions § Is. Debugger. Present – Checks the current process’s Process Environment Block (PEB) for the status of Is. Debugged field § Check. Remote. Debugger. Present – Checks the PEB of any process on the machine for the status of the Is. Debugged field 10
Even More Anti-Debugging API Functions § Nt. Query. Information. Process – Gets information about a process given its handle. When passed the Process. Debug. Port parameter, returns the debug status. § Set. Last. Error, Output. Debug. String, Get. Last. Error – Sends a string for a debugger to display. If no debugger is present, the current error code has changed. 11
Process Injection § Virtual. Alloc – Allocate space in an external process’s memory § Write. Process. Memory – Write data (executable code to be executed as a thread) to the allocated space § Create. Remote. Thread – Execute the injected code as a thread belonging to the victim process 12
Download + Execute § URLDownload. To. File – Download a file from the internet and save it to disk § Win. Exec / Shell. Execute – Execute the downloaded file 13
Polling Keylogger § Find. Window + Show. Window / Get. Foreground. Window – Gets a handle to a specific window / the window in the foreground § Get. Key. State / Get. Async. Key. State – Gets whether a key is being pressed § Usually found in a nested loop. The outer loop gets a window and the inner polls the state of each key 14
Hooking Keylogger § Set. Windows. Hook – Creates a Windows hook that gets notified when a keyboard event happens. § Get. Message – Called in a loop to retrieve keyboard event messages 15
Taking Screenshots § Get. Desktop. Window – Get a handle to the desktop window, which contains the entire screen § Bit. Blt, Get. DIBits – Given a handle to a window, copy pixels to a destination buffer § Often seen with other functions, such as Create. File (to save the screenshot) 16
- Cuckoo
- Si te mbrohemi nga viruset kompjuterike
- Feature vectors
- Malware radar
- Ddos tabletop exercise
- Bad guys mdl
- Advanced malware analysis course
- Misp malware
- Wat is malware
- Pihole adlist
- Malware, nella sicurezza informatica indica
- Rdg packer detector
- Oligomorphic malware
- Malware analysis
- Unlabel
- Type de malware
- Malwr sandbox