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 includecmd.exe /c
to execute a single command, or abusingcmd.exe
interactively with input and output forwarded over a command and control channel.
Creates and executes a simple batch script. Upon execution, CMD will briefly launh to run the batch script then close again.
Supported Platforms: Windows
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 |
Start-Process #{script_path}
Remove-Item #{script_path} -Force -ErrorAction Ignore
if (Test-Path #{script_path}) {exit 0} else {exit 1}
New-Item #{script_path} -Force | Out-Null
Set-Content -Path #{script_path} -Value "#{command_to_execute}"