# bayazid-bit/pyrat-ctf-exploit architecture

> Architecture diagram of the GitHub repository bayazid-bit/pyrat-ctf-exploit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bayazid-bit/pyrat-ctf-exploit
- Repository: https://github.com/bayazid-bit/pyrat-ctf-exploit

## Overview

This is a single-file PyRAT CTF exploit, not a general-purpose RAT or a multi-service application. Its workflow accepts a target, opens two connections, reverses socket metadata, injects guessed admin socket strings, and attempts an interactive shell. The graph reflects the calls shown in exploit.py; the target server is external and its internal behavior is not represented.

Main entry points: [`exploit.py`](https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py) (Dual connections)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_exploit["Exploit runtime"]
  node_cli["Argument parsing<br/>[exploit.py]"]
  node_connections["Dual connections<br/>[exploit.py]"]
  node_socket_metadata["Socket reversal<br/>[exploit.py]"]
  node_fd_injection["FD guesses<br/>[exploit.py]"]
  node_shell["Shell upgrade<br/>[exploit.py]"]
  node_shell_io["Interactive I/O<br/>[exploit.py]"]
end

node_operator(("Operator"))
node_target["Vulnerable PyRAT"]

node_operator -->|"provides target"| node_cli
node_cli -->|"starts exploit"| node_connections
node_connections -->|"opens sockets"| node_target
node_connections -->|"reads metadata"| node_socket_metadata
node_socket_metadata -->|"supplies template"| node_fd_injection
node_fd_injection -->|"sends guesses"| node_target
node_connections -->|"attempts shell"| node_shell
node_shell -->|"sends shell command"| node_target
node_shell -->|"starts on success"| node_shell_io
node_shell_io -->|"exchanges commands"| node_target

click node_cli "https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py"
click node_connections "https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py"
click node_socket_metadata "https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py"
click node_fd_injection "https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py"
click node_shell "https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py"
click node_shell_io "https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_connections,node_socket_metadata,node_fd_injection,node_shell,node_shell_io toneBlue
class node_operator,node_target toneIndigo
```

## Components

### Exploit runtime

- [Argument parsing](https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py): `exploit.py`
- [Dual connections](https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py): `exploit.py`
- [Socket reversal](https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py): `exploit.py`
- [FD guesses](https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py): `exploit.py`
- [Shell upgrade](https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py): `exploit.py`
- [Interactive I/O](https://github.com/bayazid-bit/pyrat-ctf-exploit/blob/main/exploit.py): `exploit.py`

### Other components

- **Operator**
- **Vulnerable PyRAT**

## Connections

- Operator → Argument parsing: provides target (evidence: `README.md`)
- Argument parsing → Dual connections: starts exploit (evidence: `exploit.py`)
- Dual connections → Vulnerable PyRAT: opens sockets (evidence: `exploit.py`)
- Dual connections → Socket reversal: reads metadata (evidence: `exploit.py`)
- Socket reversal → FD guesses: supplies template (evidence: `exploit.py`)
- FD guesses → Vulnerable PyRAT: sends guesses (evidence: `exploit.py`)
- Dual connections → Shell upgrade: attempts shell (evidence: `exploit.py`)
- Shell upgrade → Vulnerable PyRAT: sends shell command (evidence: `exploit.py`)
- Shell upgrade → Interactive I/O: starts on success (evidence: `exploit.py`)
- Interactive I/O → Vulnerable PyRAT: exchanges commands (evidence: `exploit.py`)
