# T1202: Indirect Command Execution

Adversaries may abuse utilities that allow for command execution to bypass security restrictions that limit the use of command-line interpreters. Various Window utilities may be used to execute commands, possibly without invoking cmd. For example, Forfiles, the Program Compatibility Assistant (pcalua.exe), components of the Windows Subsystem for Linux (WSL), as well as other utilities may invoke the execution of programs and commands from a Command and Scripting Interpreter, Run window, or via scripts.

Adversaries may abuse these features for Defense Evasion, specifically to perform arbitrary execution while subverting detections and/or mitigation controls (such as Group Policy) that limit/prevent the usage of cmd or file extensions more commonly associated with malicious payloads.

**Example**

In this Demo using the forfiles utility which can select multiple files and run a command on them. It is typically used in batch jobs but it could be abused to execute arbitrary command or executable. The parameters "/p" and "/m" are used to perform a search in the windows directory "System32" and on the mask "calc.exe". Anything after "/c" parameter is the actual command that is executed.

![](https://315180959-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRh03Vwd4nuiUi3Oje7%2F-MRhqYKKbMFpgHUEYVmn%2F-MRhqaolOiUB4r0_XhgE%2Fimage.png?alt=media\&token=9ff6bdf8-cf0b-4f64-860b-aa42a8233cd4)

Let's check process Explorer and see what happened.

![](https://315180959-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRh03Vwd4nuiUi3Oje7%2F-MRhqYKKbMFpgHUEYVmn%2F-MRhqaCjBd506ikZMrwQ%2Fimage.png?alt=media\&token=3857fbb3-1726-4561-9e4a-131ebbc3595a)

We see here the our payload is a child process of the forfiles utility we can also use this with the Windows "Run" and eliminate the use of the command prompt

![](https://315180959-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRh03Vwd4nuiUi3Oje7%2F-MRhqYKKbMFpgHUEYVmn%2F-MRhqbiyub3tQtyyWnq5%2Fimage.png?alt=media\&token=a71f5b3b-b16c-41b0-8231-a32db9608fce)

Even though it's still the child process of forfiles it tools different steps to execute. We also have the pcalua utility to execute commands as well

From the samples from pcaula this can execute binaries, DLL files they can be local and remote since the binary is proxy aware meaning we can also use UNC Paths.

**I was searching for information on why the "-a" parameter but couldn't find any.**

The User will receive a prompt to Run

![](https://315180959-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRh03Vwd4nuiUi3Oje7%2F-MRhqYKKbMFpgHUEYVmn%2F-MRhqdS9wqp2e4674s0O%2Fimage.png?alt=media\&token=14009254-6a85-4663-ba78-506522025d44)

Weird thing though is that the payload executes but Defender manages to Delete and Remove the Payload from the REMOTE SHARE!!.

![](https://315180959-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRh03Vwd4nuiUi3Oje7%2F-MRhqYKKbMFpgHUEYVmn%2F-MRhqeXBuovcadE5uWrK%2Fimage.png?alt=media\&token=5f8bb368-5034-4f82-9b0b-fb5316d7c825)

That is the traffic from when the payload is accessed and being DELETED. Even with a normal payload with no obfuscation straight out of the box can give us a connection

PCALUA is nowhere in the Process Explorer since Defender Kills it but our connection is still active as it becomes its own process.

![](https://315180959-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRh03Vwd4nuiUi3Oje7%2F-MRhqYKKbMFpgHUEYVmn%2F-MRhqfTBni64bP_Juphy%2Fimage.png?alt=media\&token=9dfe0dce-0857-434f-a3ae-a3c32c4ceb1a)

Reference:

{% embed url="https://pentestlab.blog/2020/07/06/indirect-command-execution/" %}

> [https://twitter.com/KyleHanslovan/status/912659279806640128\
> ](https://twitter.com/KyleHanslovan/status/912659279806640128)
