> For the complete documentation index, see [llms.txt](https://notes.cavementech.com/pentesting-quick-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.cavementech.com/pentesting-quick-reference/web-pentesting/command-injection.md).

# Command Injection

```
system("TZ=`whoami` date")
>>>>>>>>>>>>>>>this leads to these system calls
execve("/bin/sh", ["sh", "-c", "TZ=`whoami` date"], {...})
execve("/usr/bin/whoami", ["whoami"], {...})
```

Backticks make the shell run the input and replace the result within the place of backticks

```
system("TZ=; whoami # date")
execve("/bin/sh", ["sh", "-c", "TZ=; whoami # date"], {...})
execve("/usr/bin/whoami", ["whoami"], {...})
```

pound # sighn makes the rest of the command comment out.
