> 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/dom-xss-document-write-with-location-search.md).

# XSS-DOM document.write mit location.search

Notizen zu XSS-DOM document.write mit location.search für Labs der PortSwigger Web Security Academy, einschließlich Ausnutzungs-Workflow, Payload-Tests, Burp-Suite-Validierung und Behebungskontext.

### DOM-XSS in document.write-Sink unter Verwendung der Quelle location.search

Dieses Labor enthält eine XSS-seitige DOM-Schwachstelle in der Tracking-Funktion der Suchanfrage. Die Seite verwendet `document.write` um Daten aus `location.search` in das DOM zu schreiben, das über die URL gesteuert werden kann.

**Beschreibung der Schwachstelle**/ `document.write` wird mit dem `location.search` String ohne Bereinigung aufgerufen. Da die Eingabe direkt aus der URL kommt, kann ein Angreifer HTML/JS in die Seite einschleusen, indem er `location.search`.

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-285c95883d25e18b3fd57703bb9cbfd4fadf1dfb%2F%7B71C2914B-1181-4283-97D9-BE369005ECA2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Lösungsziel** Führen Sie einen XSS-Angriff auf der DOM-Seite durch, der die `alert()` Funktion aufruft, wenn die Seite geladen wird.

**Kommentare/Indizes**/ Der Code erzeugt etwas wie ein `<img>` Tag, das einen `searchTerms` Parameter in Anführungszeichen enthält, zum Beispiel:

```html
<img src="/resources/images/tracker.gif?searchTerms=Jordan">
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7015f343e74f8f00a9f988ac5d97d58733c3fbff%2F%7BD88B1544-A14A-483D-843A-87C3D304FE97%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Wenn Sie das `<img>` Tag und die Anführungszeichen schließen, können Sie beliebigen HTML-/JS-Inhalt einfügen.

**Beispiele für getestete Payloads (bereitgestellt)**/ Tag schließen und HTML einschleusen:

```html
"><h1>hack</h1>
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-e990723f01026088e065e95c8ed8315f4f9d9273%2F%7B69F16E73-C94E-482E-B6AE-BAC849952B9E%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

Tag schließen und ein Skript einschleusen, um `alert`:

```javascript
"><script>alert("xss")</script>
```

<figure><img src="https://2955439919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c1cb6a560a846ee995ffcdfa9f704d0c2e4fc1c2%2F%7B6656AD8C-DF1B-4935-AE99-1203574875DC%7D.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/de/web/xss/dom-xss-document-write-with-location-search.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
