命令与脚本解释器

命令与脚本解释器滥用是指攻击者利用系统内置或常见的脚本环境执行恶意代码,其通过混淆代码逻辑、劫持合法进程、规避安全监控等手段实施攻击。传统防御手段侧重于监控异常进程创建、检测已知恶意脚本特征、限制非授权解释器执行等,通过日志审计与行为分析识别可疑的脚本活动。

为对抗日益增强的检测能力,攻击者发展出多维度的匿迹执行技术,通过消除磁盘痕迹、融合合法行为、动态变异特征等策略,将恶意脚本操作隐匿于系统正常活动中,形成"无特征、无驻留、无告警"的新型攻击范式。

当前匿迹技术的共性在于重构脚本执行的时空特征与上下文环境:内存驻留技术彻底规避磁盘审计,通过解释器运行时实现零接触攻击;工具链调用将恶意意图分散至多个合规工具,破坏单点行为关联分析;动态混淆与反射加载形成代码特征的持续变异,突破静态检测的防护边界;低频触发机制则利用系统运维节奏掩盖恶意周期;进程注入技术通过执行环境伪装实现权限隐身。这些技术通过分层隐匿架构,在代码形态、执行载体、行为模式、时序特征等维度构建多重混淆,使得传统基于规则匹配或单一维度异常检测的防御体系面临严峻挑战。

匿迹技术的演进迫使防御体系向多维行为建模转型,需加强内存取证、上下文关联分析、跨进程行为追踪等能力,构建解释器运行时完整性保护机制,并引入AI驱动的异常脚本模式识别技术,实现对隐蔽脚本攻击的全生命周期防护。

ID: T1059
Tactic: 攻击执行
Platforms: IaaS, Identity Provider, Linux, Network, Office Suite, Windows, macOS
Supports Remote:  Yes
Version: 2.5
Created: 31 May 2017
Last Modified: 14 October 2024

匿迹效应

效应类型 是否存在
特征伪装
行为透明
数据遮蔽
时空释痕

特征伪装

攻击者通过动态代码混淆、合法工具滥用等手段,使恶意脚本在语法结构和行为特征上模仿合法管理脚本。例如将恶意PowerShell命令嵌入正常的系统管理流程,或使用常见运维工具链传递攻击载荷,使得恶意操作在日志审计中呈现为合规的系统维护行为。

数据遮蔽

采用内存加密加载和反射注入技术,恶意脚本在传输和执行过程中始终以密文或编码形式存在(如Base64编码的PowerShell命令),关键攻击指令仅在内存中解密执行。这导致基于网络流量分析或磁盘文件扫描的检测手段难以获取可识别的明文特征。

时空释痕

通过低频触发和时序伪装策略,将恶意脚本的执行周期与系统合法任务同步(如每月维护窗口),并将单次攻击动作控制在极短时间内完成。同时利用跨地域代理节点分发执行指令,使得攻击痕迹分散在长时间跨度和多进程环境中,破坏防御系统的关联分析能力。

Procedure Examples

ID Name Description
G0073 APT19

APT19 downloaded and launched code within a SCT file.[1]

G0050 APT32

APT32 has used COM scriptlets to download Cobalt Strike beacons.[2]

G0067 APT37

APT37 has used Ruby scripts to execute payloads.[3]

G0087 APT39

APT39 has utilized custom scripts to perform internal reconnaissance.[4][5]

S0234 Bandook

Bandook can support commands to execute Java-based payloads.[6]

S0486 Bonadan

Bonadan can create bind and reverse shells on the infected system.[7]

S0023 CHOPSTICK

CHOPSTICK is capable of performing remote command execution.[8][9]

C0029 Cutting Edge

During Cutting Edge, threat actors used Perl scripts to enable the deployment of the THINSPOOL shell script dropper and for enumerating host data.[10][11]

S0334 DarkComet

DarkComet can execute various types of scripts on the victim’s machine.[12]

S0695 Donut

Donut can generate shellcode outputs that execute via Ruby.[13]

G0035 Dragonfly

Dragonfly has used the command line for execution.[14]

S0363 Empire

Empire uses a command-line interface to interact with systems.[15]

G0053 FIN5

FIN5 scans processes on all victim systems in the environment and uses automated scripts to pull back the results.[16]

G0037 FIN6

FIN6 has used scripting to iterate through a list of compromised PoS systems, copy data to a log file, and remove the original data files.[17][18]

G0046 FIN7

FIN7 used SQL scripts to help perform tasks on the victim's machine.[19][20][19]

S0618 FIVEHANDS

FIVEHANDS can receive a command line argument to limit file encryption to specified directories.[21][22]

G0117 Fox Kitten

Fox Kitten has used a Perl reverse shell to communicate with C2.[23]

S0460 Get2

Get2 has the ability to run executables with command-line arguments.[24]

S0032 gh0st RAT

gh0st RAT is able to open a remote shell to execute commands.[25][26]

S0434 Imminent Monitor

Imminent Monitor has a CommandPromptPacket and ScriptPacket module(s) for creating a remote shell and executing scripts.[27]

G0004 Ke3chang

Malware used by Ke3chang can run commands on the command-line interface.[28][29]

S0487 Kessel

Kessel can create a reverse shell between the infected host and a specified system.[7]

S0167 Matryoshka

Matryoshka is capable of providing Meterpreter shell access.[30]

G0049 OilRig

OilRig has used various types of scripting for execution.[31][32][33][34][35]

C0005 Operation Spalax

For Operation Spalax, the threat actors used Nullsoft Scriptable Install System (NSIS) scripts to install malware.[36]

S0598 P.A.S. Webshell

P.A.S. Webshell has the ability to create reverse shells with Perl scripts.[37]

S1130 Raspberry Robin

Raspberry Robin variants can be delivered via highly obfuscated Windows Script Files (WSF) for initial execution.[38]

G1031 Saint Bear

Saint Bear has used the Windows Script Host (wscript) to execute intermediate files written to victim machines.[39]

S1110 SLIGHTPULSE

SLIGHTPULSE contains functionality to execute arbitrary commands passed to it.[40]

S0374 SpeakUp

SpeakUp uses Perl scripts.[41]

G0038 Stealth Falcon

Stealth Falcon malware uses WMI to script data collection and command execution on the victim.[42]

S1154 VersaMem

VersaMem was delivered as a Java Archive (JAR) that runs by attaching itself to the Apache Tomcat Java servlet and web server.[43]

G0107 Whitefly

Whitefly has used a simple remote shell tool that will call back to the C2 server and wait for commands.[44]

G0124 Windigo

Windigo has used a Perl script for information gathering.[7]

S0219 WINERACK

WINERACK can create a reverse shell that utilizes statically-linked Wine cmd.exe code to emulate Windows command prompt commands.[45]

G1035 Winter Vivern

Winter Vivern used XLM 4.0 macros for initial code execution for malicious document files.[46]

S1151 ZeroCleare

ZeroCleare can receive command line arguments from an operator to corrupt the file system using the RawDisk driver.[47]

S0330 Zeus Panda

Zeus Panda can launch remote scripts on the victim’s machine.[48]

Mitigations

ID Mitigation Description
M1049 Antivirus/Antimalware

Anti-virus can be used to automatically quarantine suspicious files.

M1047 Audit

Inventory systems for unauthorized command and scripting interpreter installations.

M1040 Behavior Prevention on Endpoint

On Windows 10, enable Attack Surface Reduction (ASR) rules to prevent Visual Basic and JavaScript scripts from executing potentially malicious downloaded content [49].

M1045 Code Signing

Where possible, only permit execution of signed scripts.

M1042 Disable or Remove Feature or Program

Disable or remove any unnecessary or unused shells or interpreters.

M1038 Execution Prevention

Use application control where appropriate. For example, PowerShell Constrained Language mode can be used to restrict access to sensitive or otherwise dangerous language elements such as those used to execute arbitrary Windows APIs or files (e.g., Add-Type).[50]

M1033 Limit Software Installation

Prevent user installation of unrequired command and scripting interpreters.

M1026 Privileged Account Management

When PowerShell is necessary, consider restricting PowerShell execution policy to administrators. Be aware that there are methods of bypassing the PowerShell execution policy, depending on environment configuration.[51]

PowerShell JEA (Just Enough Administration) may also be used to sandbox administration and limit what commands admins/users can execute through remote PowerShell sessions.[52]

M1021 Restrict Web-Based Content

Script blocking extensions can help prevent the execution of scripts and HTA files that may commonly be used during the exploitation process. For malicious code served up through ads, adblockers can help prevent that code from executing in the first place.

Detection

ID Data Source Data Component Detects
DS0017 Command Command Execution

Monitor command-line arguments for script execution and subsequent behavior. Actions may be related to network and system information Discovery, Collection, or other scriptable post-compromise behaviors and could be used as indicators of detection leading back to the source script. Scripts are likely to perform actions with various effects on a system that may generate events, depending on the types of monitoring used.

Analytic 1 - Suspicious script execution

(sourcetype=WinEventLog:Security OR OR sourcetype=sysmon OR sourcetype=linux_secure OR sourcetype=linux_audit OR sourcetype=mac_os_log OR sourcetype=azure:audit OR sourcetype=o365:audit)| search Image IN ("bash", "sh", "cmd", "powershell", "python", "java", "perl", "ruby", "node", "osascript", "wmic")| eval suspicious_cmds=if(like(command_line, "%Invoke-Obfuscation%") OR like(command_line, "%-EncodedCommand%") OR like(command_line, "%IEX%") OR like(command_line, "%wget%") OR like(command_line, "%curl%"), "Yes", "No")

DS0011 Module Module Load

Monitor for events associated with scripting execution, such as the loading of modules associated with scripting languages (ex: JScript.dll or vbscript.dll).

Analytic 1 - Look for unusual module loads associated with scripting languages.

sourcetype=WinEventLog:Microsoft-Windows-Sysmon/Operational| search EventCode=7 ImageLoaded IN ("C:\Windows\System32\JScript.dll", "C:\Windows\System32\vbscript.dll", "System.Management.Automation.dll")

DS0009 Process Process Creation

Monitor log files for process execution through command-line and scripting activities. This information can be useful in gaining additional insight to adversaries' actions through how they use native processes or custom tools. Also monitor for loading of modules associated with specific languages.

Analytic 1 - Look for unusual command and scripting process creation.

(sourcetype=WinEventLog:Security OR sourcetype=sysmon OR sourcetype=linux_secure OR sourcetype=linux_audit OR sourcetype=mac_os_log OR sourcetype=azure:audit OR sourcetype=o365:audit)(EventCode=4688 OR EventID=1 OR _raw=sh OR _raw=python OR _raw=powershell OR _raw=cmd OR _raw=script OR _raw=wscript OR _raw=bash)

Process Metadata

Monitor contextual data about a running process, which may include information such as environment variables, image name, user/owner, or other information that may reveal abuse of system features. For example, consider monitoring for Windows Event ID (EID) 400, which shows the version of PowerShell executing in the EngineVersion field (which may also be relevant to detecting a potential Downgrade Attack) as well as if PowerShell is running locally or remotely in the HostName field. Furthermore, EID 400 may indicate the start time and EID 403 indicates the end time of a PowerShell session.[53]

DS0012 Script Script Execution

Monitor for any attempts to enable scripts running on a system that would be considered suspicious. If scripts are not commonly used on a system, but enabled, scripts running out of cycle from patching or other administrator functions are suspicious. Scripts should be captured from the file system when possible to determine their actions and intent.

Analytic 1 - Look for attempts to enable scripts on the system.

index=windows (EventCode=1 OR EventCode=4688 OR EventCode=4103 OR EventCode=4104) (CommandLine="script")| search script_name IN (".ps1", ".sh", ".py", ".rb", ".js", ".vbs")| eval suspicious_script=if(like(script_name, "%.sh") AND hour(_time) NOT BETWEEN 8 AND 18, "Yes", "No")| where suspicious_script="Yes"

References

  1. Ahl, I. (2017, June 06). Privileges and Credentials: Phished at the Request of Counsel. Retrieved May 17, 2018.
  2. Dahan, A. (2017). Operation Cobalt Kitty. Retrieved December 27, 2018.
  3. Cash, D., Grunzweig, J., Adair, S., Lancaster, T. (2021, August 25). North Korean BLUELIGHT Special: InkySquid Deploys RokRAT. Retrieved October 1, 2021.
  4. Hawley et al. (2019, January 29). APT39: An Iranian Cyber Espionage Group Focused on Personal Information. Retrieved February 19, 2019.
  5. FBI. (2020, September 17). Indicators of Compromise Associated with Rana Intelligence Computing, also known as Advanced Persistent Threat 39, Chafer, Cadelspy, Remexi, and ITG07. Retrieved December 10, 2020.
  6. Check Point. (2020, November 26). Bandook: Signed & Delivered. Retrieved May 31, 2021.
  7. Dumont, R., M.Léveillé, M., Porcher, H. (2018, December 1). THE DARK SIDE OF THE FORSSHE A landscape of OpenSSH backdoors. Retrieved July 16, 2020.
  8. Alperovitch, D.. (2016, June 15). Bears in the Midst: Intrusion into the Democratic National Committee. Retrieved August 3, 2016.
  9. ESET. (2016, October). En Route with Sednit - Part 2: Observing the Comings and Goings. Retrieved November 21, 2016.
  10. Lin, M. et al. (2024, January 31). Cutting Edge, Part 2: Investigating Ivanti Connect Secure VPN Zero-Day Exploitation. Retrieved February 27, 2024.
  11. McLellan, T. et al. (2024, January 12). Cutting Edge: Suspected APT Targets Ivanti Connect Secure VPN in New Zero-Day Exploitation. Retrieved February 27, 2024.
  12. Kujawa, A. (2018, March 27). You dirty RAT! Part 1: DarkComet. Retrieved November 6, 2018.
  13. TheWover. (2019, May 9). donut. Retrieved March 25, 2022.
  14. US-CERT. (2018, March 16). Alert (TA18-074A): Russian Government Cyber Activity Targeting Energy and Other Critical Infrastructure Sectors. Retrieved June 6, 2018.
  15. Schroeder, W., Warner, J., Nelson, M. (n.d.). Github PowerShellEmpire. Retrieved April 28, 2016.
  16. Bromiley, M. and Lewis, P. (2016, October 7). Attacking the Hospitality and Gaming Industries: Tracking an Attacker Around the World in 7 Years. Retrieved October 6, 2017.
  17. FireEye Threat Intelligence. (2016, April). Follow the Money: Dissecting the Operations of the Cyber Crime Group FIN6. Retrieved June 1, 2016.
  18. McKeague, B. et al. (2019, April 5). Pick-Six: Intercepting a FIN6 Intrusion, an Actor Recently Tied to Ryuk and LockerGoga Ransomware. Retrieved April 17, 2019.
  19. Carr, N., et al. (2018, August 01). On the Hunt for FIN7: Pursuing an Enigmatic and Evasive Global Criminal Operation. Retrieved August 23, 2018.
  20. Platt, J. and Reeves, J.. (2019, March). FIN7 Revisited: Inside Astra Panel and SQLRat Malware. Retrieved June 18, 2019.
  21. McLellan, T. and Moore, J. et al. (2021, April 29). UNC2447 SOMBRAT and FIVEHANDS Ransomware: A Sophisticated Financial Threat. Retrieved June 2, 2021.
  22. Matthews, M. and Backhouse, W. (2021, June 15). Handy guide to a new Fivehands ransomware variant. Retrieved June 24, 2021.
  23. ClearSky. (2020, December 17). Pay2Key Ransomware – A New Campaign by Fox Kitten. Retrieved December 21, 2020.
  24. Schwarz, D. et al. (2019, October 16). TA505 Distributes New SDBbot Remote Access Trojan with Get2 Downloader. Retrieved May 29, 2020.
  25. FireEye Threat Intelligence. (2015, July 13). Demonstrating Hustle, Chinese APT Groups Quickly Use Zero-Day Vulnerability (CVE-2015-5119) Following Hacking Team Leak. Retrieved January 25, 2016.
  26. Pantazopoulos, N. (2018, April 17). Decoding network data from a Gh0st RAT variant. Retrieved November 2, 2018.
  27. QiAnXin Threat Intelligence Center. (2019, February 18). APT-C-36: Continuous Attacks Targeting Colombian Government Institutions and Corporations. Retrieved May 5, 2020.
  1. Villeneuve, N., Bennett, J. T., Moran, N., Haq, T., Scott, M., & Geers, K. (2014). OPERATION “KE3CHANG”: Targeted Attacks Against Ministries of Foreign Affairs. Retrieved November 12, 2014.
  2. Smallridge, R. (2018, March 10). APT15 is alive and strong: An analysis of RoyalCli and RoyalDNS. Retrieved April 4, 2018.
  3. ClearSky Cyber Security and Trend Micro. (2017, July). Operation Wilted Tulip: Exposing a cyber espionage apparatus. Retrieved August 21, 2017.
  4. Sardiwal, M, et al. (2017, December 7). New Targeted Attack in the Middle East by APT34, a Suspected Iranian Threat Group, Using CVE-2017-11882 Exploit. Retrieved December 20, 2017.
  5. Falcone, R. and Lee, B. (2017, July 27). OilRig Uses ISMDoor Variant; Possibly Linked to Greenbug Threat Group. Retrieved January 8, 2018.
  6. Lee, B., Falcone, R. (2018, February 23). OopsIE! OilRig Uses ThreeDollars to Deliver New Trojan. Retrieved July 16, 2018.
  7. Lee, B., Falcone, R. (2018, July 25). OilRig Targets Technology Service Provider and Government Agency with QUADAGENT. Retrieved August 9, 2018.
  8. Falcone, R., Wilhoit, K.. (2018, November 16). Analyzing OilRig’s Ops Tempo from Testing to Weaponization to Delivery. Retrieved April 23, 2019.
  9. M. Porolli. (2021, January 21). Operation Spalax: Targeted malware attacks in Colombia. Retrieved September 16, 2022.
  10. ANSSI. (2021, January 27). SANDWORM INTRUSION SET CAMPAIGN TARGETING CENTREON SYSTEMS. Retrieved March 30, 2021.
  11. Patrick Schläpfer . (2024, April 10). Raspberry Robin Now Spreading Through Windows Script Files. Retrieved May 17, 2024.
  12. Unit 42. (2022, February 25). Spear Phishing Attacks Target Organizations in Ukraine, Payloads Include the Document Stealer OutSteel and the Downloader SaintBot. Retrieved June 9, 2022.
  13. Perez, D. et al. (2021, April 20). Check Your Pulse: Suspected APT Actors Leverage Authentication Bypass Techniques and Pulse Secure Zero-Day. Retrieved February 5, 2024.
  14. Check Point Research. (2019, February 4). SpeakUp: A New Undetected Backdoor Linux Trojan. Retrieved April 17, 2019.
  15. Marczak, B. and Scott-Railton, J.. (2016, May 29). Keep Calm and (Don’t) Enable Macros: A New Threat Actor Targets UAE Dissidents. Retrieved June 8, 2016.
  16. Black Lotus Labs. (2024, August 27). Taking The Crossroads: The Versa Director Zero-Day Exploitaiton. Retrieved August 27, 2024.
  17. Symantec. (2019, March 6). Whitefly: Espionage Group has Singapore in Its Sights. Retrieved May 26, 2020.
  18. FireEye. (2018, February 20). APT37 (Reaper): The Overlooked North Korean Actor. Retrieved March 1, 2018.
  19. Chad Anderson. (2021, April 27). Winter Vivern: A Look At Re-Crafted Government MalDocs Targeting Multiple Languages. Retrieved July 29, 2024.
  20. Jenkins, L. at al. (2022, August 4). ROADSWEEP Ransomware - Likely Iranian Threat Actor Conducts Politically Motivated Disruptive Activity Against Albanian Government Organizations. Retrieved August 6, 2024.
  21. Ebach, L. (2017, June 22). Analysis Results of Zeus.Variant.Panda. Retrieved November 5, 2018.
  22. Microsoft. (2021, July 2). Use attack surface reduction rules to prevent malware infection. Retrieved June 24, 2021.
  23. PowerShell Team. (2017, November 2). PowerShell Constrained Language Mode. Retrieved March 27, 2023.
  24. Sutherland, S. (2014, September 9). 15 Ways to Bypass the PowerShell Execution Policy. Retrieved September 12, 2024.
  25. Microsoft. (2022, November 17). Just Enough Administration. Retrieved March 27, 2023.
  26. Hastings, M. (2014, July 16). Investigating PowerShell Attacks. Retrieved December 1, 2021.