> 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/cross-site-scripting-xss/dom/high.md).

# High

Di bawah ini adalah *source-code* dari XSS (DOM) level high di DVWA.

```php
vulnerabilities/xss_d/source/high.php
<?php
​
// Is there any input?
if ( array_key_exists( "default", $_GET ) && !is_null ($_GET[ 'default' ]) ) {
​
    # White list the allowable languages
    switch ($_GET['default']) {
        case "French":
        case "English":
        case "German":
        case "Spanish":
            # ok
            break;
        default:
            header ("location: ?default=English");
            exit;
    }
}
​
?> 
```

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

Pada level ini, developer sekarang menentukan *whitelist* untuk nilai dari parameter **default**.

Setelah mencoba berbagai cara, akhirnya saya mencoba untuk membuat parameter baru (di sini diberi nama **test**), dan hasilnya seperti berikut:

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-Lzjw2vnbgz2EXMb1Jkv%2F-Lzjz_rYSa4d9-id-XXR%2Fimage.png?alt=media\&token=e326c3f3-d102-44e2-a7d4-31664e14e051)

Terlihat bahwa parameter baru tersebut akan ter-*print* ke halaman web tersebut. Ini bisa kita manfaatkan untuk melakukan *injection*.

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

Hasil dari pengamatan di atas adalah kita bisa menyisipkan script seperti berikut:

```markup
?default=English&<script>alert("Hacked")</script>
```

Jika dijalankan akan tampil hasil *injection* seperti berikut:

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-Lzjw2vnbgz2EXMb1Jkv%2F-Lzk-hqFbY88Nv1iTPen%2Fimage.png?alt=media\&token=1fedf275-5823-4fb6-aa84-31267f656689)

Seperti biasa, kita juga bisa mengambil *cookie*-nya.

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-Lzjw2vnbgz2EXMb1Jkv%2F-Lzk-uu41EmkH38-BR5l%2Fimage.png?alt=media\&token=06f20f90-957e-4a6a-b0d7-683489a02dc9)

Selain menggunakan *payload* seperti di atas, saya juga menemukan cara baru dengan menggunakan *payload* berikut:

```markup
?default=English#<script>alert(123)</script>
```

**Alhamdulillah!** Kita telah menyelesaikan semua level dari XSS (DOM) di DVWA.😁​

Happy Hacking! 🍻


---

# 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/cross-site-scripting-xss/dom/high.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.
