Suspicious Script Interpreter Execution from Environment Variable Folders
Malware may execute scripts from suspicious directories accessible via environment variables using script interpreters like cscript, wscript, mshta, and powershell to evade detection.
Attackers may attempt to execute malicious scripts from suspicious directories or folders accessible by environment variables. This technique leverages script interpreters such as cscript.exe, wscript.exe, mshta.exe, and powershell.exe to run scripts from locations like the Temp directory, the Public user folder, or other user profile directories. The use of these locations can help attackers evade detection, as security tools may not thoroughly inspect files executed from these typically benign locations. This activity has been associated with threat actors such as Shuckworm, known to target Ukraine military.
Attack Chain
- The attacker gains initial access, potentially through phishing or exploiting a software vulnerability.
- A malicious script is dropped into a suspicious folder such as
C:\Users\Public\,%TEMP%, orC:\Users\<username>\AppData\Local\Temp. - The attacker uses
cscript.exe,wscript.exe, ormshta.exeto execute the dropped script. The command line may contain flags to bypass execution policies (e.g.,-ExecutionPolicy bypass) or hide the window (e.g.,-w hidden). - Alternatively, PowerShell may be invoked with the
-ep bypassor-ExecutionPolicy Bypassflags, along with a command to execute the script located in the temporary folder. - The script executes, performing malicious actions such as downloading additional payloads, establishing persistence, or exfiltrating data.
- The script may leverage built-in Windows utilities for further malicious activities.
- The attacker achieves their objective, such as data theft or system compromise.
Impact
Successful exploitation can lead to a range of damaging outcomes, including system compromise, data theft, and further propagation of malware within the network. Organizations may experience data breaches, financial losses, and reputational damage. The compromise of systems can also disrupt business operations and require extensive recovery efforts.
Recommendation
- Deploy the Sigma rule
Script Interpreter Execution From Suspicious Folderto your SIEM to detect suspicious script executions. - Monitor process creation events with a focus on script interpreters (
cscript.exe,wscript.exe,mshta.exe,powershell.exe) executing from suspicious directories, using thelogsourceanddetectionsections of the Sigma rule as a guide. - Tune the filters in the Sigma rule based on your environment to reduce false positives, as described in the
falsepositivessection. - Review and block any observed malicious command lines containing flags like
-ep bypass,-ExecutionPolicy bypass, or-w hidden, as detailed in theselection_proc_flagssection of the Sigma rule.
Detection coverage 2
Suspicious Script Execution from Temp Folders
highDetects script interpreters executing from temp folders.
Script Interpreter with Bypass Flags
mediumDetects suspicious script execution using bypass flags.
Detection queries are kept inside the platform. Get full rules →