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

# Low

Di bawah ini adalah *source-code* dari *command injection* level low di DVWA.

```php
vulnerabilities/xss_d/source/low.php

<?php
​
# No protections, anything goes
​
?> 
```

## Mencari Informasi <a href="#mencari-informasi" id="mencari-informasi"></a>

​[`shell_exec()`](https://www.php.net/manual/en/function.shell-exec.php) adalah fungsi bawaan PHP yang berfungsi untuk menjalankan perintah melalui shell dan mengembalikan output yang lengkap sebagai string.

Terlihat bahwa pada baris ke-10 dan 14 program ini menjalankan perintah **ping** ke target yang diinputkan oleh user.

Contoh dari penggunaan program ini adalah seperti berikut:

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-LzLzMX7uh3MhnDx4FrW%2F-LzMZcaWddMMtWx7vQGN%2Fimage.png?alt=media\&token=3ecba17e-4333-4ca9-bbcf-791db9e99992)

Jika kita perhatikan *source code*-nya, tidak ada validasi inputan. Pada Unix/Linux, tanda `;` memungkinkan user bisa menjalankan beberapa perintah sekaligus pada satu baris yang sama.

## Melakukan Serangan <a href="#melakukan-serangan" id="melakukan-serangan"></a>

Setelah mengetahui bahwa tidak ada validasi input, kita bisa memanfaatkan `;` untuk menjalankan perintah lainnya. Seperti contohnya `8.8.8.8; whoami` yang digunakan untuk mengetahui user yang sedang digunakan.

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-LzNB8sTkF__Fy92pViR%2F-LzNDloML-tU1ULxjvPD%2Fimage.png?alt=media\&token=f78554f5-b2bf-43e5-b675-f8a17a8f5e03)

Kita juga bisa melihat isi dari file **/etc/passwd** dengan memasukkan `8.8.8.8; cat /etc/passwd`, membuat *backdoor*, dll. Maka dari itu, *command injection* ini sangatlah berbahaya.

Selanjutnya, anda bisa melakukan *back connect*, dengan cara reverse shell atau bind shell. Penjelasan tentang *back connect* bisa anda baca [di sini](https://medium.com/@nairpaa/post-exploitation-with-netcat-fb63a03703e7).

### Alternatif `;` <a href="#alternatif" id="alternatif"></a>

Selain menggunakan `;` kita juga memiliki alternatif lain seperti berikut yang bisa digunakan di shell bash.

* `&&` — AND Operator
* `|` — PIPE Operator (menghapus hasil ping dari output)

Selamat! Kita telah berhasil melakukan *command injection*. Silahkan anda bisa mencoba melakukan eskalasi lebih lanjut.😆


---

# 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://notes.anggipradana.com/tutorial/dvwa/command-injection/low.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.
