Execution through API
|Execution through API|
|Permissions Required||User, Administrator, SYSTEM|
|Data Sources||API monitoring, Process monitoring|
Adversary tools may directly use the Windows application programming interface (API) to execute binaries. Functions such as the Windows API CreateProcess will allow programs and scripts to start other processes with proper path and argument parameters.1
Additional Windows API calls that can be used to execute binaries include:2
- CreateProcessA() and CreateProcessW(),
- CreateProcessAsUserA() and CreateProcessAsUserW(),
- CreateProcessInternalA() and CreateProcessInternalW(),
- CreateProcessWithLogonW(), CreateProcessWithTokenW(),
- LoadLibraryA() and LoadLibraryW(),
- LoadLibraryExA() and LoadLibraryExW(),
- ShellExecuteA() and ShellExecuteW(),
- ShellExecuteExA() and ShellExecuteExW()
- ADVSTORESHELL is capable of starting a process using CreateProcess.3
- BADNEWS has a command to download an .exe and execute it via CreateProcess API.4
- Cobalt Strike's "beacon" payload is capable of running shell commands without
cmd.exeand PowerShell commands without
- PlugX can use the Windows API function CreateProcess to execute another process.6
- XAgentOSX contains the execFile function to execute a specified file on the system using the NSTask:launch method.7
Mitigating specific API calls will likely have unintended side effects, such as preventing legitimate software from operating properly. Efforts should be focused on preventing adversary tools from running earlier in the chain of activity and on identifying subsequent malicious behavior. Audit and/or block potentially malicious software by using whitelisting8 tools, like AppLocker,910 or Software Restriction Policies11 where appropriate.12
Monitoring API calls may generate a significant amount of data and may not be directly useful for defense unless collected under specific circumstances, since benign use of Windows API functions such as CreateProcess are common and difficult to distinguish from malicious behavior. Correlation of other events with behavior surrounding API function calls using API monitoring will provide additional context to an event that may assist in determining if it is due to malicious behavior. Correlation of activity by process lineage by process ID may be sufficient.
- Microsoft. (n.d.). CreateProcess function. Retrieved December 5, 2014.
- Kanthak, S. (2017). Application Verifier Provider. Retrieved February 13, 2017.
- Bitdefender. (2015, December). APT28 Under the Scope. Retrieved February 23, 2017.
- Settle, A., et al. (2016, August 8). MONSOON - Analysis Of An APT Campaign. Retrieved September 22, 2016.
- Strategic Cyber LLC. (2017, March 14). Cobalt Strike Manual. Retrieved May 24, 2017.
- Vasilenko, R. (2013, December 17). An Analysis of PlugX Malware. Retrieved November 24, 2015.
- Robert Falcone. (2017, February 14). XAgentOSX: Sofacy's Xagent macOS Tool. Retrieved July 12, 2017.
- Beechey, J. (2010, December). Application Whitelisting: Panacea or Propaganda?. Retrieved November 18, 2014.
- Tomonaga, S. (2016, January 26). Windows Commands Abused by Attackers. Retrieved February 2, 2016.
- NSA Information Assurance Directorate. (2014, August). Application Whitelisting Using Microsoft AppLocker. Retrieved March 31, 2016.
- Corio, C., & Sayana, D. P. (2008, June). Application Lockdown with Software Restriction Policies. Retrieved November 18, 2014.
- Microsoft. (2012, June 27). Using Software Restriction Policies and AppLocker Policies. Retrieved April 7, 2016.