Skip to content

Latest commit

 

History

History
60 lines (36 loc) · 2.16 KB

T1059.003.md

File metadata and controls

60 lines (36 loc) · 2.16 KB

T1059.003 - Windows Command Shell

Adversaries may abuse the Windows command shell for execution. The Windows command shell (cmd.exe) is the primary command prompt on Windows systems. The Windows command prompt can be used to control almost any aspect of a system, with various permission levels required for different subsets of commands.

Batch files (ex: .bat or .cmd) also provide the shell with a list of sequential commands to run, as well as normal scripting operations such as conditionals and loops. Common uses of batch files include long or repetitive tasks, or the need to run the same set of commands on multiple systems.

Adversaries may leverage cmd.exe to execute various commands and payloads. Common uses include cmd.exe /c to execute a single command, or abusing cmd.exe interactively with input and output forwarded over a command and control channel.

Atomic Tests


Atomic Test #1 - Create and Execute Batch Script

Creates and executes a simple batch script. Upon execution, CMD will briefly launh to run the batch script then close again.

Supported Platforms: Windows

Inputs:

Name Description Type Default Value
command_to_execute Command to execute within script. string dir
script_path Script path. path $env:TEMP\T1059.003_script.bat

Attack Commands: Run with powershell!

Start-Process #{script_path}

Cleanup Commands:

Remove-Item #{script_path} -Force -ErrorAction Ignore

Dependencies: Run with powershell!

Description: Batch file must exist on disk at specified location (#{script_path})
Check Prereq Commands:
if (Test-Path #{script_path}) {exit 0} else {exit 1} 
Get Prereq Commands:
New-Item #{script_path} -Force | Out-Null
Set-Content -Path #{script_path} -Value "#{command_to_execute}"