# High

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

```php
vulnerabilities/xss_s/source/high.php
<?php
​
if( isset( $_POST[ 'btnSign' ] ) ) {
    // Get input
    $message = trim( $_POST[ 'mtxMessage' ] );
    $name    = trim( $_POST[ 'txtName' ] );
​
    // Sanitize message input
    $message = strip_tags( addslashes( $message ) );
    $message = ((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"],  $message ) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : ""));
    $message = htmlspecialchars( $message );
​
    // Sanitize name input
    $name = preg_replace( '/<(.*)s(.*)c(.*)r(.*)i(.*)p(.*)t/i', '', $name );
    $name = ((isset($GLOBALS["___mysqli_ston"]) && is_object($GLOBALS["___mysqli_ston"])) ? mysqli_real_escape_string($GLOBALS["___mysqli_ston"],  $name ) : ((trigger_error("[MySQLConverterToo] Fix the mysql_escape_string() call! This code does not work.", E_USER_ERROR)) ? "" : ""));
​
    // Update database
    $query  = "INSERT INTO guestbook ( comment, name ) VALUES ( '$message', '$name' );";
    $result = mysqli_query($GLOBALS["___mysqli_ston"],  $query ) or die( '<pre>' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) . '</pre>' );
​
    //mysql_close();
}
​
?> 
```

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

Pada *source code* di atas terlihat bahwa *pattern* **"\<s\*c\*r\*i\*p\*t"** tidak diizinkan pada form **Name**. Tetapi, pada level medium pun kita tidak menggunakannya, sehingga kita bisa menggunakan cara seperti sebelumnya.

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

Kita akan coba seperti pada level sebelumnya, yaitu dengan membuat form **Name** bisa diisi banyak karakter, lalu diinputkan dengan *payload* yang sama.

```markup
<body onload="alert(document.cookie)">
```

![](https://gblobscdn.gitbook.com/assets%2F-LzH5Vfe8_AlGL8KPrs2%2F-LzpgZF_KC4sPanQSj0r%2F-Lzqof55NrkqqbXjmywW%2Fimage.png?alt=media\&token=15a8eab5-3527-439e-9828-2a5a56d1b439)

Mudah bukan? Kita harus teliti dan sering mencoba.

**Alhamdulillah!** Materi Stored XSS akhirnya selesai juga kita pelajari. Tetap semangat dan lanjut ke materi selanjutnya! 🔥


---

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