# flozz/p0wny-shell architecture

> Architecture diagram of the GitHub repository flozz/p0wny-shell, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flozz/p0wny-shell
- Repository: https://github.com/flozz/p0wny-shell

## Overview

p0wny@shell is a single-file PHP web shell for interactive command execution and remote file operations. A user enters commands in a browser terminal; the client sends requests to the PHP endpoint, which executes commands or handles filesystem actions and returns output and working-directory state. The interface also documents command history, autocomplete, and file transfer. The excerpts show the client request flows and some backend behavior, but omit portions of the PHP dispatch and completion implementation, so uncertain internal connections are left out.

Main entry points: [`shell.php`](https://github.com/flozz/p0wny-shell/blob/master/shell.php) (Terminal UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_terminal["Browser terminal"]
  node_terminal_ui["Terminal UI<br/>[shell.php]"]
  node_history["Command history<br/>[shell.php]"]
  node_autocomplete["Autocomplete<br/>[shell.php]"]
  node_request_client["Request client<br/>[shell.php]"]
end

subgraph group_backend["PHP request handling"]
  node_shell_endpoint["Shell endpoint<br/>[shell.php]"]
  node_command_execution["Command execution<br/>[shell.php]"]
  node_completion_handler["Completion handler<br/>[shell.php]"]
  node_upload_handler["Upload handler<br/>[shell.php]"]
  node_download_handler["Download handler<br/>[shell.php]"]
end

subgraph group_host["Server resources"]
  node_server_shell["Server command environment"]
  node_server_files[("Server filesystem")]
end

node_user(("User"))

node_user -->|"enters commands"| node_terminal_ui
node_terminal_ui -->|"records commands"| node_history
node_terminal_ui -->|"requests hints"| node_autocomplete
node_terminal_ui -->|"submits commands"| node_request_client
node_request_client -->|"posts shell request"| node_shell_endpoint
node_shell_endpoint -->|"runs commands"| node_command_execution
node_command_execution -->|"executes on"| node_server_shell
node_terminal_ui -->|"uploads file data"| node_request_client
node_request_client -->|"posts upload request"| node_upload_handler
node_upload_handler -->|"writes file"| node_server_files
node_shell_endpoint -->|"handles download"| node_download_handler
node_download_handler -->|"reads file"| node_server_files
node_terminal_ui -->|"downloads result"| node_download_handler
node_autocomplete -.->|"requests completion"| node_request_client
node_completion_handler -->|"queries commands"| node_server_shell

click node_terminal_ui "https://github.com/flozz/p0wny-shell/blob/master/shell.php"
click node_history "https://github.com/flozz/p0wny-shell/blob/master/shell.php"
click node_autocomplete "https://github.com/flozz/p0wny-shell/blob/master/shell.php"
click node_request_client "https://github.com/flozz/p0wny-shell/blob/master/shell.php"
click node_shell_endpoint "https://github.com/flozz/p0wny-shell/blob/master/shell.php"
click node_command_execution "https://github.com/flozz/p0wny-shell/blob/master/shell.php"
click node_completion_handler "https://github.com/flozz/p0wny-shell/blob/master/shell.php"
click node_upload_handler "https://github.com/flozz/p0wny-shell/blob/master/shell.php"
click node_download_handler "https://github.com/flozz/p0wny-shell/blob/master/shell.php"

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_terminal_ui,node_history,node_autocomplete,node_request_client,node_user toneBlue
class node_shell_endpoint,node_command_execution,node_completion_handler,node_upload_handler,node_download_handler toneAmber
class node_server_shell,node_server_files toneMint
```

## Components

### Browser terminal

- [Terminal UI](https://github.com/flozz/p0wny-shell/blob/master/shell.php): `shell.php`
- [Command history](https://github.com/flozz/p0wny-shell/blob/master/shell.php): `shell.php`
- [Autocomplete](https://github.com/flozz/p0wny-shell/blob/master/shell.php): `shell.php`
- [Request client](https://github.com/flozz/p0wny-shell/blob/master/shell.php): `shell.php`

### PHP request handling

- [Shell endpoint](https://github.com/flozz/p0wny-shell/blob/master/shell.php): `shell.php`
- [Command execution](https://github.com/flozz/p0wny-shell/blob/master/shell.php): `shell.php`
- [Completion handler](https://github.com/flozz/p0wny-shell/blob/master/shell.php): `shell.php`
- [Upload handler](https://github.com/flozz/p0wny-shell/blob/master/shell.php): `shell.php`
- [Download handler](https://github.com/flozz/p0wny-shell/blob/master/shell.php): `shell.php`

### Server resources

- **Server command environment**
- **Server filesystem**

### Other components

- **User**

## Connections

- User → Terminal UI: enters commands (evidence: `README.md`)
- Terminal UI → Command history: records commands (evidence: `shell.php`)
- Terminal UI → Autocomplete: requests hints (evidence: `README.md`)
- Terminal UI → Request client: submits commands (evidence: `shell.php`)
- Request client → Shell endpoint: posts shell request (evidence: `shell.php`)
- Shell endpoint → Command execution: runs commands (evidence: `shell.php`)
- Command execution → Server command environment: executes on (evidence: `shell.php`)
- Terminal UI → Request client: uploads file data (evidence: `shell.php`)
- Request client → Upload handler: posts upload request (evidence: `shell.php`)
- Upload handler → Server filesystem: writes file (evidence: `shell.php`)
- Shell endpoint → Download handler: handles download (evidence: `shell.php`)
- Download handler → Server filesystem: reads file (evidence: `shell.php`)
- Terminal UI → Download handler: downloads result (evidence: `README.md`)
- Autocomplete → Request client: requests completion (evidence: `shell.php`)
- Completion handler → Server command environment: queries commands (evidence: `shell.php`)
