# ly4k/pwnkit architecture

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

- Interactive diagram: https://gitdiagram.com/ly4k/pwnkit
- Repository: https://github.com/ly4k/pwnkit

## Overview

PwnKit is a self-contained local privilege-escalation exploit for vulnerable pkexec systems. The principal workflow is to run the exploit, stage the gconv files, invoke pkexec, and use the resulting privileged initialization to launch either a command or an interactive shell. The C source also monitors pkexec output and removes staged files when it detects a likely patched target. The README documents both direct execution and a shell-based download-and-run entry point; binary internals were not sampled.

Main entry points: [`PwnKit.c`](https://github.com/ly4k/pwnkit/blob/main/PwnKit.c) (Exploit entry), [`PwnKit`](https://github.com/ly4k/pwnkit/blob/main/PwnKit) (PwnKit executable), [`PwnKit.sh`](https://github.com/ly4k/pwnkit/blob/main/PwnKit.sh) (Shell launcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_delivery["Launch"]
  node_launcher["Shell launcher<br/>[PwnKit.sh]"]
  node_binary64["PwnKit executable"]
  node_binary32["32-bit executable"]
end

subgraph group_exploit["Exploit runtime"]
  node_entry["Exploit entry<br/>[PwnKit.c]"]
  node_staging["Gconv staging<br/>[PwnKit.c]"]
  node_watcher["Failure watcher<br/>[PwnKit.c]"]
  node_initializer["Gconv initializer<br/>[PwnKit.c]"]
  node_artifacts["Staged files<br/>[PwnKit.c]"]
  node_pipe["Output pipe<br/>[PwnKit.c]"]
  node_cleanup["Artifact cleanup<br/>[PwnKit.c]"]
end

subgraph group_result["Privileged result"]
  node_command["Command shell"]
  node_interactive["Interactive shell"]
end

node_user(("Operator"))
node_pkexec["pkexec"]

node_user -->|"runs one-liner"| node_launcher
node_launcher -->|"downloads and runs"| node_binary64
node_user -->|"runs directly"| node_binary64
node_binary64 -.->|"enters"| node_entry
node_entry -->|"creates"| node_staging
node_staging -->|"writes"| node_artifacts
node_entry -->|"forks"| node_watcher
node_entry -->|"creates"| node_pipe
node_watcher -->|"reads"| node_pipe
node_entry -->|"redirects stderr"| node_pipe
node_entry -->|"executes"| node_pkexec
node_pkexec -.->|"loads gconv payload"| node_initializer
node_initializer -->|"removes artifacts"| node_cleanup
node_watcher -->|"cleans on failure"| node_cleanup
node_initializer -->|"executes command"| node_command
node_initializer -->|"starts shell"| node_interactive

click node_launcher "https://github.com/ly4k/pwnkit/blob/main/PwnKit.sh"
click node_binary64 "https://github.com/ly4k/pwnkit/blob/main/PwnKit"
click node_binary32 "https://github.com/ly4k/pwnkit/blob/main/PwnKit32"
click node_entry "https://github.com/ly4k/pwnkit/blob/main/PwnKit.c"
click node_staging "https://github.com/ly4k/pwnkit/blob/main/PwnKit.c"
click node_watcher "https://github.com/ly4k/pwnkit/blob/main/PwnKit.c"
click node_initializer "https://github.com/ly4k/pwnkit/blob/main/PwnKit.c"
click node_artifacts "https://github.com/ly4k/pwnkit/blob/main/PwnKit.c"
click node_pipe "https://github.com/ly4k/pwnkit/blob/main/PwnKit.c"
click node_cleanup "https://github.com/ly4k/pwnkit/blob/main/PwnKit.c"

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_launcher,node_binary64,node_binary32 toneBlue
class node_entry,node_staging,node_watcher,node_initializer,node_artifacts,node_pipe,node_cleanup toneAmber
class node_command,node_interactive toneMint
class node_user,node_pkexec toneIndigo
```

## Components

### Launch

- [Shell launcher](https://github.com/ly4k/pwnkit/blob/main/PwnKit.sh): `PwnKit.sh`
- [PwnKit executable](https://github.com/ly4k/pwnkit/blob/main/PwnKit): `PwnKit`
- [32-bit executable](https://github.com/ly4k/pwnkit/blob/main/PwnKit32): `PwnKit32`

### Exploit runtime

- [Exploit entry](https://github.com/ly4k/pwnkit/blob/main/PwnKit.c): `PwnKit.c`
- [Gconv staging](https://github.com/ly4k/pwnkit/blob/main/PwnKit.c): `PwnKit.c`
- [Failure watcher](https://github.com/ly4k/pwnkit/blob/main/PwnKit.c): `PwnKit.c`
- [Gconv initializer](https://github.com/ly4k/pwnkit/blob/main/PwnKit.c): `PwnKit.c`
- [Staged files](https://github.com/ly4k/pwnkit/blob/main/PwnKit.c): `PwnKit.c`
- [Output pipe](https://github.com/ly4k/pwnkit/blob/main/PwnKit.c): `PwnKit.c`
- [Artifact cleanup](https://github.com/ly4k/pwnkit/blob/main/PwnKit.c): `PwnKit.c`

### Privileged result

- **Command shell**
- **Interactive shell**

### Other components

- **Operator**
- **pkexec**

## Connections

- Operator → Shell launcher: runs one-liner (evidence: `README.md`)
- Shell launcher → PwnKit executable: downloads and runs (evidence: `README.md`)
- Operator → PwnKit executable: runs directly (evidence: `README.md`)
- PwnKit executable → Exploit entry: enters
- Exploit entry → Gconv staging: creates (evidence: `PwnKit.c`)
- Gconv staging → Staged files: writes (evidence: `PwnKit.c`)
- Exploit entry → Failure watcher: forks (evidence: `PwnKit.c`)
- Exploit entry → Output pipe: creates (evidence: `PwnKit.c`)
- Failure watcher → Output pipe: reads (evidence: `PwnKit.c`)
- Exploit entry → Output pipe: redirects stderr (evidence: `PwnKit.c`)
- Exploit entry → pkexec: executes (evidence: `PwnKit.c`)
- pkexec → Gconv initializer: loads gconv payload
- Gconv initializer → Artifact cleanup: removes artifacts (evidence: `PwnKit.c`)
- Failure watcher → Artifact cleanup: cleans on failure (evidence: `PwnKit.c`)
- Gconv initializer → Command shell: executes command (evidence: `PwnKit.c`)
- Gconv initializer → Interactive shell: starts shell (evidence: `PwnKit.c`)
