> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/pt-br/web/command-injection/basic-os-command-injection.md).

# Injeção Básica de Comandos no Sistema Operacional

### Injeção de comandos do sistema operacional

Este laboratório apresenta uma vulnerabilidade de injeção de comandos do sistema na ferramenta de verificação de estoque de um produto. / A aplicação executa um comando de shell que inclui as credenciais do produto e da loja fornecidas pelo usuário e, em seguida, retorna diretamente na resposta a saída bruta desse comando.

O objetivo do laboratório é executar o **whoami** comando para identificar o nome do usuário atual.

Descobrimos que, no Linux, quando você insere um comando como:

```bash
pwd
```

é possível encadear vários comandos usando ponto e vírgula:

```bash
pwd;whoami
```

<figure><img src="/files/0afc4050d5e9b7119a4b4a4aea126e5cdd2c7655" alt="" width="563"><figcaption></figcaption></figure>

Nesse caso, dois parâmetros são transmitidos.

<figure><img src="/files/8e79d2a4112db6b9809a983b6c0b5219a9f77cde" alt="" width="563"><figcaption></figcaption></figure>

Se alguém inserir um **;** em um ou outro, é possível executar um comando arbitrário porque o backend usa uma função do tipo **system**.

Exemplo:

```bash
productId=1&storeId=1;ls -l
```

<figure><img src="/files/0cf160ef07e5a8e1b248f1373b8e2b8bcae0fbfd" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/pt-br/web/command-injection/basic-os-command-injection.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
