T1059.007
Command and Scripting Interpreter: JavaScript
Description from ATT&CK
Adversaries may abuse various implementations of JavaScript for execution. JavaScript (JS) is a platform-independent scripting language (compiled just-in-time at runtime) commonly associated with scripts in webpages, though JS can be executed in runtime environments outside the browser.(Citation: NodeJS)
JScript is the Microsoft implementation of the same scripting standard. JScript is interpreted via the Windows Script engine and thus integrated with many components of Windows such as the Component Object Model and Internet Explorer HTML Application (HTA) pages.(Citation: JScrip May 2018)(Citation: Microsoft JScript 2007)(Citation: Microsoft Windows Scripts)
JavaScript for Automation (JXA) is a macOS scripting language based on JavaScript, included as part of Apple’s Open Scripting Architecture (OSA), that was introduced in OSX 10.10. Apple’s OSA provides scripting capabilities to control applications, interface with the operating system, and bridge access into the rest of Apple’s internal APIs. As of OSX 10.10, OSA only supports two languages, JXA and AppleScript. Scripts can be executed via the command line utility
osascript, they can be compiled into applications or script files viaosacompile, and they can be compiled and executed in memory of other programs by leveraging the OSAKit Framework.(Citation: Apple About Mac Scripting 2016)(Citation: SpecterOps JXA 2020)(Citation: SentinelOne macOS Red Team)(Citation: Red Canary Silver Sparrow Feb2021)(Citation: MDSec macOS JXA and VSCode)Adversaries may abuse various implementations of JavaScript to execute various behaviors. Common uses include hosting malicious scripts on websites as part of a Drive-by Compromise or downloading and executing these script files as secondary payloads. Since these payloads are text-based, it is also very common for adversaries to obfuscate their content as part of Obfuscated Files or Information.
Atomic Tests
- Atomic Test #1: JScript execution to gather local computer information via cscript
- Atomic Test #2: JScript execution to gather local computer information via wscript
- Atomic Test #3: Turla Kopiluwak Windows Enumeration
- Atomic Test #4: Turla KopiLuwak RC4 Decryption Stager
- Atomic Test #5: Turla KopiLuwak Registry JavaScript Payload Execution
Atomic Test #1: JScript execution to gather local computer information via cscript
JScript execution test, execute JScript via cscript command. When successful, system information will be written to $env:TEMP\T1059.007.out.txt
Supported Platforms: Windows
auto_generated_guid: 01d75adf-ca1b-4dd1-ac96-7c9550ad1035
Inputs
| Name | Description | Type | Default Value |
|---|---|---|---|
| jscript | Path to sample script | string | PathToAtomicsFolder\T1059.007\src\sys_info.js |
Attack Commands: Run with command_prompt!
cscript "#{jscript}" > %tmp%\T1059.007.out.txtCleanup Commands
del %tmp%\T1059.007.out.txt >nul 2>&1Dependencies: Run with powershell!
Description: Sample script must exist on disk at specified location (#{jscript})
Check Prereq Commands
if (Test-Path "#{jscript}") {exit 0} else {exit 1}Get Prereq Commands
New-Item -ItemType Directory (Split-Path "#{jscript}") -Force | Out-Null
Invoke-WebRequest "https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1059.007/src/sys_info.js" -OutFile "#{jscript}" -UseBasicParsingAtomic Test #2: JScript execution to gather local computer information via wscript
JScript execution test, execute JScript via wscript command. When successful, system information will be shown with four message boxes.
Supported Platforms: Windows
auto_generated_guid: 0709945e-4fec-4c49-9faf-c3c292a74484
Inputs
| Name | Description | Type | Default Value |
|---|---|---|---|
| jscript | Path to sample script | string | PathToAtomicsFolder\T1059.007\src\sys_info.js |
Attack Commands: Run with command_prompt!
wscript "#{jscript}"Dependencies: Run with powershell!
Description: Sample script must exist on disk at specified location (#{jscript})
Check Prereq Commands
if (Test-Path "#{jscript}") {exit 0} else {exit 1}Get Prereq Commands
New-Item -ItemType Directory (Split-Path "#{jscript}") -Force | Out-Null
Invoke-WebRequest "https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1059.007/src/sys_info.js" -OutFile "#{jscript}" -UseBasicParsingAtomic Test #3: Turla Kopiluwak Windows Enumeration
Executes a JScript file via wscript.exe that runs a series of reconnaissance commands (net use, ipconfig, systeminfo, whoami, tasklist, netstat, arp, dir, etc.) and appends all output to a single staging file at c:\windows\temp\result2.dat. Output file name, wscript.exe execution, and reconnaisance commands run mirror the behaviors of Turla's Javascript trojan Kopiluwak
Reference: https://unit42.paloaltonetworks.com/turla-pensive-ursa-threat-assessment/
Supported Platforms: Windows
auto_generated_guid: e65e6772-bfd3-4f25-934b-861d5caa34db
Inputs
| Name | Description | Type | Default Value |
|---|---|---|---|
| jscript | Path to the reconnaissance JScript file | path | PathToAtomicsFolder\T1059.007\src\xpexplore.js |
Attack Commands: Run with command_prompt!
wscript.exe /b "#{jscript}"Cleanup Commands
del c:\windows\temp\result2.dat >nul 2>&1Dependencies: Run with powershell!
Description: Reconnaissance JScript must exist on disk
Check Prereq Commands
if (Test-Path "#{jscript}") {exit 0} else {exit 1}Get Prereq Commands
New-Item -ItemType Directory (Split-Path "#{jscript}") -Force | Out-Null
Invoke-WebRequest "https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1059.007/src/xpexplore.js" -OutFile "#{jscript}" -UseBasicParsingAtomic Test #4: Turla KopiLuwak RC4 Decryption Stager
Emulates KopiLuwak's next-stage JavaScript loader named Chkdsk.js. The script accepts an RC4 decryption key via the -scan parameter and decrypts hardcoded ciphertext bytes, which are then run as script. In this atomic, the decrypted bytes generate and display a random number instead of performing malicious behavior. In the real attack chain, a scheduled task (ProactiveScan) invokes this script with the key every 30 minutes.
Reference: https://securelist.com/turla-renews-its-arsenal-with-topinambour/91687/
Supported Platforms: Windows
auto_generated_guid: 02428cbe-c230-4353-b31d-61c9d328b153
Inputs
| Name | Description | Type | Default Value |
|---|---|---|---|
| chkdsk_path | Path to the KopiLuwak Chkdsk.js stager script | path | PathToAtomicsFolder\T1059.007\src\Chkdsk.js |
Attack Commands: Run with command_prompt!
wscript.exe /b "#{chkdsk_path}" -scan Kdw6gG7cpOSZsBeHDependencies: Run with powershell!
Description: Chkdsk.js must exist on disk
Check Prereq Commands
if (Test-Path "#{chkdsk_path}") {exit 0} else {exit 1}Get Prereq Commands
New-Item -ItemType Directory (Split-Path "#{chkdsk_path}") -Force | Out-Null
Invoke-WebRequest "https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1059.007/src/Chkdsk.js" -OutFile "#{chkdsk_path}" -UseBasicParsingAtomic Test #5: Turla KopiLuwak Registry JavaScript Payload Execution
Emulates KopiLuwak's technique of storing a JavaScript payload as REG_BINARY data in the Windows registry and executing it. The script uses WMI StdRegProv to read binary data from HKCU\Software\Microsoft\Windows\CurrentVersion\Maintenance\MOfficeMaintenance, converts the bytes to a string with String.fromCharCode, and runs it with eval(). The registry path, value name, and WMI access pattern mirror the real malware.
Reference: https://securelist.com/turla-renews-its-arsenal-with-topinambour/91687/
Supported Platforms: Windows
auto_generated_guid: 9be739ec-b1ba-4950-94d0-e62444b23645
Inputs
| Name | Description | Type | Default Value |
|---|---|---|---|
| payload | JavaScript code to store in the registry as binary and execute via eval | string | var shell = new ActiveXObject('WScript.Shell');shell.Exec('cmd.exe /c whoami'); |
| registry_script | Path to the registry payload JScript file | path | PathToAtomicsFolder\T1059.007\src\registry_payload.js |
Attack Commands: Run with powershell!
Start-Process wscript.exe -ArgumentList '/b', "#{registry_script}" -WaitCleanup Commands
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Maintenance" /v MOfficeMaintenance /f 2>$null
$bak = "$env:TEMP\T1059.007_Maintenance.reg"
if (Test-Path $bak) { reg import $bak 2>$null; Remove-Item $bak -Force -ErrorAction SilentlyContinue }Dependencies: Run with powershell!
Description: Registry payload JScript must exist on disk
Check Prereq Commands
if (Test-Path "#{registry_script}") {exit 0} else {exit 1}Get Prereq Commands
New-Item -ItemType Directory (Split-Path "#{registry_script}") -Force | Out-Null
Invoke-WebRequest "https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1059.007/src/registry_payload.js" -OutFile "#{registry_script}" -UseBasicParsingDescription: Backup existing Maintenance registry key if present
Check Prereq Commands
if (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Maintenance") -or (Test-Path "$env:TEMP\T1059.007_Maintenance.reg")) {exit 0} else {exit 1}Get Prereq Commands
reg export "HKCU\Software\Microsoft\Windows\CurrentVersion\Maintenance" "$env:TEMP\T1059.007_Maintenance.reg" /y 2>$nullDescription: Payload must be written to registry as REG_BINARY
Check Prereq Commands
if ((Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Maintenance" -Name "MOfficeMaintenance" -ErrorAction SilentlyContinue).MOfficeMaintenance) {exit 0} else {exit 1}Get Prereq Commands
$bytes = [System.Text.Encoding]::ASCII.GetBytes("#{payload}")
$regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Maintenance"
if (!(Test-Path $regPath)) { New-Item -Path $regPath -Force | Out-Null }
Set-ItemProperty -Path $regPath -Name "MOfficeMaintenance" -Value $bytes -Type BinaryAtomic test(s) for this technique last updated: 2026-10-20 23:56:26 UTC