pwn 0.5.628 → 0.5.629

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -21
  3. data/bin/pwn +35 -1
  4. data/bin/pwn_setup +64 -0
  5. data/documentation/AI-Integration.md +48 -9
  6. data/documentation/AWS.md +1 -1
  7. data/documentation/Agent-Tool-Registry.md +24 -0
  8. data/documentation/BurpSuite.md +4 -1
  9. data/documentation/CLI-Drivers.md +27 -10
  10. data/documentation/Configuration.md +37 -10
  11. data/documentation/Contributing.md +13 -3
  12. data/documentation/Extrospection.md +108 -98
  13. data/documentation/FFI.md +14 -2
  14. data/documentation/Fuzzing.md +3 -0
  15. data/documentation/General-PWN-Usage.md +12 -0
  16. data/documentation/Hardware.md +4 -0
  17. data/documentation/Home.md +4 -4
  18. data/documentation/How-PWN-Works.md +2 -1
  19. data/documentation/Installation.md +201 -37
  20. data/documentation/Metasploit.md +4 -1
  21. data/documentation/NmapIt.md +3 -0
  22. data/documentation/Persistence.md +5 -2
  23. data/documentation/Reporting.md +3 -0
  24. data/documentation/SDR.md +4 -0
  25. data/documentation/Skills-Memory-Learning.md +24 -11
  26. data/documentation/Swarm.md +20 -0
  27. data/documentation/Transparent-Browser.md +3 -0
  28. data/documentation/Troubleshooting.md +63 -7
  29. data/documentation/What-is-PWN.md +1 -1
  30. data/documentation/diagrams/agent-tool-registry.svg +120 -109
  31. data/documentation/diagrams/ai-integration-tool-calling.svg +76 -65
  32. data/documentation/diagrams/dot/agent-tool-registry.dot +5 -3
  33. data/documentation/diagrams/dot/ai-integration-tool-calling.dot +3 -2
  34. data/documentation/diagrams/dot/memory-skills-detailed.dot +26 -4
  35. data/documentation/diagrams/dot/overall-pwn-architecture.dot +6 -4
  36. data/documentation/diagrams/dot/persistence-filesystem.dot +4 -2
  37. data/documentation/diagrams/dot/pwn-ai-feedback-learning-loop.dot +31 -10
  38. data/documentation/diagrams/dot/swarm-multi-agent.dot +7 -1
  39. data/documentation/diagrams/extrospection-world-awareness.svg +129 -129
  40. data/documentation/diagrams/memory-skills-detailed.svg +268 -137
  41. data/documentation/diagrams/overall-pwn-architecture.svg +188 -171
  42. data/documentation/diagrams/persistence-filesystem.svg +115 -85
  43. data/documentation/diagrams/pwn-ai-feedback-learning-loop.svg +407 -255
  44. data/documentation/diagrams/sdr-radio-flow.svg +51 -51
  45. data/documentation/diagrams/swarm-multi-agent.svg +156 -119
  46. data/documentation/pwn-REPL.md +1 -0
  47. data/documentation/pwn-ai-Agent.md +50 -22
  48. data/lib/pwn/ai/agent/dispatch.rb +1 -1
  49. data/lib/pwn/ai/agent/learning.rb +1 -1
  50. data/lib/pwn/ai/agent/loop.rb +40 -0
  51. data/lib/pwn/ai/agent/metrics.rb +1 -1
  52. data/lib/pwn/config.rb +2 -2
  53. data/lib/pwn/memory_index.rb +1 -1
  54. data/lib/pwn/plugins/repl.rb +26 -2
  55. data/lib/pwn/setup.rb +563 -0
  56. data/lib/pwn/version.rb +1 -1
  57. data/lib/pwn.rb +1 -0
  58. data/spec/lib/pwn/setup_spec.rb +28 -0
  59. data/third_party/pwn_rdoc.jsonl +15 -1
  60. metadata +5 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44fdb9e4897d83ad9ab54d65bc774eed6be14c379eea42b1a7984abab23c03bd
4
- data.tar.gz: ba801dabf738c43b3fe7ce9cf40bdfb38d1cf62f7a0b98b05861626c33d2d008
3
+ metadata.gz: 2f0c536ea0f5b7dbd2c88621241adfa866f7ed726ee4e2109abe83aef13b0385
4
+ data.tar.gz: 7e3bc1436b9ce27c63da25dc609eab317a009b1339a843a6cdfe03469386b195
5
5
  SHA512:
6
- metadata.gz: 205805e3088246b711249ba3b778e9418fb1616ad576dde6c22c0c632409de88b2545fda88ee30316fe7a203a2ff9a46236136e94ba291a7dc27c800d7b8c02c
7
- data.tar.gz: 4e439c01661f7707c9bf79e8e4be656e76f9d57d5bb17cf9778536bd1a8ebbc63aebd4effbcce38d4ed89f4cfdbe188072ab710a7374d0a951fd8a0c7bd7d0fd
6
+ metadata.gz: 572496cd5d2754022fdb35c360db8e5fec65cd91693ea196f8e44666c28141f198b3353146cd658aa07b93d0add52e3808448fe0836b38830c2fb1b553d8dad2
7
+ data.tar.gz: 7dc0f6160402b01d8acb694e72d86daef36743fd9b9f0b84a2f87da0d77367798e8ef429463e25f36747f359c5b621615e61e26df29033de9561a24d926af4a6
data/README.md CHANGED
@@ -33,7 +33,7 @@ hardware / radio exploitation, to reporting and disclosure — and puts a
33
33
  **self-improving, tool-calling, multi-agent AI** on top of it.
34
34
 
35
35
  **In numbers:** 66 `PWN::Plugins` · 48 `PWN::SAST` rules · 90 `PWN::AWS`
36
- service wrappers · 21 `PWN::WWW` site drivers · 52 `bin/pwn_*` CLI drivers ·
36
+ service wrappers · 21 `PWN::WWW` site drivers · 53 `bin/pwn_*` CLI drivers ·
37
37
  5 LLM engines · 10 agent toolsets · 45+ LLM-callable tools.
38
38
 
39
39
  Full page: [What is PWN](documentation/What-is-PWN.md)
@@ -86,7 +86,7 @@ The complete wiki lives in this repo at **[`documentation/Home.md`](documentatio
86
86
  |---|---|---|---|
87
87
  | [What is PWN](documentation/What-is-PWN.md) | [`pwn` REPL](documentation/pwn-REPL.md) | [AI / LLM Integration](documentation/AI-Integration.md) | [Plugins (66)](documentation/Plugins.md) |
88
88
  | [Why PWN](documentation/Why-PWN.md) | [`pwn-ai` Agent](documentation/pwn-ai-Agent.md) | [Agent Tool Registry](documentation/Agent-Tool-Registry.md) | [SAST (48)](documentation/SAST.md) |
89
- | [How PWN Works](documentation/How-PWN-Works.md) | [CLI Drivers (52)](documentation/CLI-Drivers.md) | [Memory · Skills · Learning](documentation/Skills-Memory-Learning.md) | [AWS (90)](documentation/AWS.md) |
89
+ | [How PWN Works](documentation/How-PWN-Works.md) | [CLI Drivers (53)](documentation/CLI-Drivers.md) | [Memory · Skills · Learning](documentation/Skills-Memory-Learning.md) | [AWS (90)](documentation/AWS.md) |
90
90
  | [Installation](documentation/Installation.md) | [Build a Driver](documentation/Drivers.md) | [Mistakes (neg-feedback)](documentation/Mistakes.md) | [WWW (21)](documentation/WWW.md) |
91
91
  | [General Usage](documentation/General-PWN-Usage.md) | | [Extrospection](documentation/Extrospection.md) | [SDR / Radio](documentation/SDR.md) |
92
92
  | [Configuration](documentation/Configuration.md) | | [Swarm (multi-agent)](documentation/Swarm.md) | [Hardware](documentation/Hardware.md) |
@@ -103,18 +103,31 @@ Rebuild every SVG from its Graphviz source:
103
103
 
104
104
  ### **Installation** ###
105
105
 
106
- Tested on Debian-based Linux & macOS, Ruby via RVM.
106
+ PWN is a **single gem** with a built-in post-install doctor/provisioner —
107
+ `pwn setup` — that detects your package manager (`apt` · `dnf` · `pacman` ·
108
+ `brew` · `port`) and installs exactly the OS headers + external tools each
109
+ `PWN::` capability needs. Tested on Kali/Debian/Ubuntu, Fedora, Arch, macOS.
107
110
 
108
111
  ```
109
- $ cd /opt
110
- $ sudo git clone https://github.com/0dayinc/pwn
111
- $ cd /opt/pwn
112
- $ ./install.sh
113
- $ ./install.sh ruby-gem
112
+ $ gem install pwn
113
+ $ pwn setup # read-only doctor: which capabilities are usable?
114
+ $ pwn setup --profile full --yes # provision everything (or: web | net | sdr | vision | …)
114
115
  $ pwn
115
- pwn[v0.5.628]:001 >>> PWN.help
116
+ pwn[v0.5.629]:001 >>> PWN.help
116
117
  ```
117
118
 
119
+ Only need a subset?
120
+
121
+ ```
122
+ $ pwn setup --list-profiles
123
+ $ pwn setup --profile web # TransparentBrowser · Burp · ZAP · Tor · sqlmap
124
+ $ pwn setup --profile sdr --yes # GQRX · rtl-sdr · hackrf · SoapySDR · FFI DSP
125
+ $ pwn setup --profile net --dry-run
126
+ ```
127
+
128
+ Also available as `pwn_setup` (standalone driver) and `pwn --setup[=PROFILE]`.
129
+ The doctor exits non-zero when capabilities are degraded, so CI can gate on it.
130
+
118
131
  [![Installing the pwn Security Automation Framework](https://raw.githubusercontent.com/0dayInc/pwn/master/documentation/pwn_install.png)](https://youtu.be/G7iLUY4FzsI)
119
132
 
120
133
  Full page: [Installation](documentation/Installation.md) ·
@@ -131,20 +144,16 @@ Update PWN frequently — new plugins, agent tools, skills and zero-day tooling
131
144
  land regularly:
132
145
 
133
146
  ```
134
- $ rvm list gemsets
135
- $ rvm use ruby-4.0.5@pwn
136
- $ gem uninstall --all --executables pwn
137
- $ gem install --verbose pwn
147
+ $ gem update pwn
148
+ $ pwn setup # re-doctor — new versions may add capabilities
138
149
  $ pwn
139
- pwn[v0.5.628]:001 >>> PWN.help
150
+ pwn[v0.5.629]:001 >>> PWN.help
140
151
  ```
141
152
 
142
- If using a multi-user RVM install:
153
+ From a git checkout:
143
154
 
144
155
  ```
145
- $ rvm use ruby-4.0.5@pwn
146
- $ rvmsudo gem uninstall --all --executables pwn
147
- $ rvmsudo gem install --verbose pwn
156
+ $ cd /opt/pwn && git pull && rake install && pwn setup
148
157
  ```
149
158
 
150
159
  **Inside the `pwn` REPL:**
@@ -160,11 +169,10 @@ $ echo "$LONG_PROMPT" | pwn --ai -
160
169
  $ pwn -Y ./ci/pwn.yaml --ai 'Run pwn_sast against ./src and summarise HIGH findings' > findings.txt
161
170
  ```
162
171
 
163
- PWN periodically upgrades to the latest Ruby (`/opt/pwn/.ruby-version`).
164
- Easiest upgrade of Ruby + pwn from a previous install:
172
+ **Provision a CI runner / Docker image:**
165
173
 
166
174
  ```
167
- $ /opt/pwn/vagrant/provisioners/pwn.sh
175
+ $ pwn setup --profile web --yes && pwn setup --check # exits 1 if degraded
168
176
  ```
169
177
 
170
178
  ---
data/bin/pwn CHANGED
@@ -3,6 +3,19 @@
3
3
 
4
4
  require 'pwn'
5
5
 
6
+ # ----------------------------------------------------------------------
7
+ # Bare-word subcommand: `pwn setup [...]` → delegate to bin/pwn_setup so
8
+ # `gem install pwn && pwn setup` is the canonical two-step install path.
9
+ # Must be handled BEFORE OptionParser (which would reject `setup`).
10
+ # ----------------------------------------------------------------------
11
+ if ARGV.first == 'setup'
12
+ ARGV.shift
13
+ setup_bin = File.expand_path('pwn_setup', __dir__)
14
+ setup_bin = Gem.bin_path('pwn', 'pwn_setup') unless File.file?(setup_bin)
15
+ load setup_bin
16
+ exit
17
+ end
18
+
6
19
  opts = PWN::Env[:driver_opts]
7
20
  pwn_driver = PWN::Driver::Parser.new do |options|
8
21
  options.on(
@@ -14,6 +27,16 @@ pwn_driver = PWN::Driver::Parser.new do |options|
14
27
  ) do |a|
15
28
  opts[:ai] = a
16
29
  end
30
+
31
+ options.on(
32
+ '-S[PROFILE]',
33
+ '--setup[=PROFILE]',
34
+ '<Optional - Post-install doctor / capability provisioner. With no ' \
35
+ "PROFILE runs a read-only check; with PROFILE (#{PWN::Setup::PROFILES.keys.join('|')}) " \
36
+ 'installs OS deps for that capability set. Same as `pwn setup` / `pwn_setup`>'
37
+ ) do |p|
38
+ opts[:setup] = p || true
39
+ end
17
40
  end
18
41
  pwn_driver.auto_opts_help = false
19
42
  pwn_driver.parse!
@@ -21,7 +44,18 @@ pwn_driver.parse!
21
44
  begin
22
45
  pwn_pid = Process.pid
23
46
 
24
- if opts[:ai]
47
+ if opts[:setup]
48
+ # ------------------------------------------------------------------
49
+ # `pwn --setup` → PWN::Setup.check (read-only doctor)
50
+ # `pwn --setup=web` → PWN::Setup.deps(profile: :web)
51
+ # ------------------------------------------------------------------
52
+ if opts[:setup] == true
53
+ r = PWN::Setup.check
54
+ exit(r[:ok] ? 0 : 1)
55
+ else
56
+ PWN::Setup.deps(profile: opts[:setup])
57
+ end
58
+ elsif opts[:ai]
25
59
  # ------------------------------------------------------------------
26
60
  # Headless pwn-ai: behave as if the user typed PROMPT at the pwn-ai
27
61
  # TUI, but non-interactively — a single agent-loop turn with native
data/bin/pwn_setup ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'pwn'
5
+
6
+ opts = PWN::Env[:driver_opts]
7
+ pwn_driver = PWN::Driver::Parser.new do |options|
8
+ options.banner = "USAGE: #{File.basename($PROGRAM_NAME)} [opts]\n " \
9
+ "Post-install doctor & capability provisioner for the PWN gem.\n " \
10
+ "With no options, runs a read-only capability check.\n"
11
+
12
+ options.on('-c', '--check',
13
+ '<Optional - Read-only doctor: which PWN capabilities are usable on this host? (default action)>') do |o|
14
+ opts[:check] = o
15
+ end
16
+
17
+ options.on('-d', '--deps',
18
+ '<Optional - Install OS headers + external tools + rebuild native gems for --profile (default: full)>') do |o|
19
+ opts[:deps] = o
20
+ end
21
+
22
+ options.on('-pNAME', '--profile=NAME',
23
+ "<Optional - Capability profile: #{PWN::Setup::PROFILES.keys.join(' | ')} (default: full)>") do |o|
24
+ opts[:profile] = o
25
+ end
26
+
27
+ options.on('-l', '--list-profiles',
28
+ '<Optional - List capability profiles and exit>') do |o|
29
+ opts[:list] = o
30
+ end
31
+
32
+ options.on('-y', '--yes',
33
+ '<Optional - Assume yes; non-interactive (CI-friendly)>') do |o|
34
+ opts[:yes] = o
35
+ end
36
+
37
+ options.on('-n', '--dry-run',
38
+ '<Optional - Print the commands that would run, do not execute>') do |o|
39
+ opts[:dry_run] = o
40
+ end
41
+ end
42
+ pwn_driver.auto_opts_help = false
43
+ pwn_driver.parse!
44
+
45
+ begin
46
+ if opts[:list]
47
+ PWN::Setup.list_profiles
48
+ elsif opts[:deps] || opts[:profile]
49
+ PWN::Setup.deps(
50
+ profile: opts[:profile],
51
+ yes: opts[:yes],
52
+ dry_run: opts[:dry_run]
53
+ )
54
+ else
55
+ r = PWN::Setup.check
56
+ exit 1 unless r[:ok]
57
+ end
58
+ rescue Interrupt
59
+ puts "\naborted."
60
+ exit 130
61
+ rescue StandardError => e
62
+ warn "pwn_setup: #{e.class}: #{e.message}"
63
+ exit 1
64
+ end
@@ -1,7 +1,7 @@
1
1
  # AI / LLM Integration — `PWN::AI`
2
2
 
3
3
  One agent loop, five interchangeable engines. Swap providers by changing one
4
- line in `~/.pwn/config.yml`; the tool-calling contract is normalised so the
4
+ line in `~/.pwn/pwn.yaml`; the tool-calling contract is normalised so the
5
5
  agent code never cares which model is behind it.
6
6
 
7
7
  ![Multi-provider integration](diagrams/ai-integration-tool-calling.svg)
@@ -14,23 +14,58 @@ agent code never cares which model is behind it.
14
14
  | `anthropic` | `PWN::AI::Anthropic` | `key:` | tool-use native |
15
15
  | `grok` | `PWN::AI::Grok` | `key:` **or** `oauth: true` | OAuth = RFC-8628 device-code flow using xAI's public Grok-CLI client id (no secret) — see skill `xai_grok_oauth_device_flow` |
16
16
  | `gemini` | `PWN::AI::Gemini` | `key:` | function-calling native |
17
- | `ollama` | `PWN::AI::Ollama` | none | local, `base_url:` + `model:` |
17
+ | `ollama` | `PWN::AI::Ollama` | none | local — native `/api/chat` (`num_ctx`, `keep_alive`, low-temp + `format:'json'` on tool turns) and `/api/embed` for `PWN::MemoryIndex` |
18
+
19
+ > PWN is **model-agnostic**. `ai.<engine>.model` is passed straight through to
20
+ > the provider — the codebase and docs deliberately never name a specific
21
+ > model id so you can point each engine at whatever the vendor currently
22
+ > ships (or whatever `ollama list` shows locally).
18
23
 
19
24
  ## Selecting an engine
20
25
 
21
26
  ```yaml
22
- # ~/.pwn/config.yml
27
+ # ~/.pwn/pwn.yaml
23
28
  ai:
24
- engine: grok
29
+ active: grok
25
30
  grok:
26
- oauth: true # first run opens https://accounts.x.ai/… device page
31
+ oauth:
32
+ enroll: true # first run opens https://accounts.x.ai/… device page
27
33
  ```
28
34
 
29
35
  ```ruby
30
36
  # at runtime
31
- PWN::Env[:ai][:engine] = :ollama
37
+ PWN::Env[:ai][:active] = :ollama
32
38
  ```
33
39
 
40
+ ## Engine-aware behaviour
41
+
42
+ The harness adapts to the *class* of engine, not the model name:
43
+
44
+ | Concern | Frontier (`openai` · `anthropic` · `grok` · `gemini`) | Local (`ollama`) |
45
+ |---|---|---|
46
+ | **PromptBuilder.budget** | full MEMORY / METRICS / MISTAKES / LEARNING / EXTRO blocks | tightened via `ai.ollama.prompt_budget` (extro off by default) |
47
+ | **MEMORY ranking** | relevance-ranked when a local Ollama `embed_model` is reachable, else newest-first | relevance-ranked via `PWN::MemoryIndex` (`~/.pwn/memory.idx`) |
48
+ | **Tool schemas shipped** | all toolsets | `CORE_TOOLS` + top-K keyword matches when `ai.agent.tool_router` is on |
49
+ | **Pre-pass** | none | `plan_first` numbered tool plan before first dispatch |
50
+ | **Few-shot** | none | `Learning.exemplars_for(request)` splices a prior successful trace |
51
+ | **Dispatch parsing** | strict | tolerant — Levenshtein tool-name repair + JSON5-ish arg cleanup, each repair fingerprinted into `Mistakes` |
52
+ | **Post-answer** | `auto_introspect` | `auto_introspect` **+** `fact_check_local_final` (auto `extro_verify` on CVE/version-shaped claims) |
53
+ | **Metrics bucket** | `metrics.json[:tools][name][:engines][:<engine>]` | same — the `TOOL EFFECTIVENESS` block is per-engine so local telemetry never blends with frontier |
54
+
55
+ ## Teacher-student reflection
56
+
57
+ `ai.reflect_engine` decouples *doing* from *learning-about-doing*:
58
+
59
+ ```yaml
60
+ ai:
61
+ active: ollama # the local model executes tools and answers
62
+ reflect_engine: anthropic # a frontier model writes the durable Memory :lesson
63
+ ```
64
+
65
+ `PWN::AI::Agent::Reflect.on` temporarily flips the active engine for the
66
+ introspection call only, so the local model reads back distilled reasoning it
67
+ could not have produced itself.
68
+
34
69
  ## Direct client use (no agent)
35
70
 
36
71
  ```ruby
@@ -43,10 +78,14 @@ puts resp[:content]
43
78
  ## Model diversity in Swarm
44
79
 
45
80
  Because each persona in [`agents.yml`](Swarm.md) can override `engine:`, an
46
- `agent_debate` can literally pit Claude against Grok against a local Llama
47
- real antagonism, not one model role-playing three voices.
81
+ `agent_debate` can pit five *different providers* against each other real
82
+ antagonism, not one model role-playing three voices. The same mechanism backs
83
+ `ai.agent.escalation_persona`: when a local model is stuck, `Loop.run` asks a
84
+ frontier persona for a 3-line corrective hint and injects it as a synthetic
85
+ tool result.
48
86
 
49
87
  **See also:** [pwn-ai Agent](pwn-ai-Agent.md) ·
50
- [Agent Tool Registry](Agent-Tool-Registry.md) · [Swarm](Swarm.md)
88
+ [Agent Tool Registry](Agent-Tool-Registry.md) · [Swarm](Swarm.md) ·
89
+ [Configuration](Configuration.md)
51
90
 
52
91
  [← Home](Home.md)
data/documentation/AWS.md CHANGED
@@ -10,7 +10,7 @@ with the PWN `opts = {}` convention so they compose in the REPL and in
10
10
 
11
11
  Standard AWS SDK chain: `~/.aws/credentials` profile, env vars
12
12
  (`AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `AWS_SESSION_TOKEN`), or
13
- instance profile. Optionally pin in `~/.pwn/config.yml` under `aws:`.
13
+ instance profile. Optionally pin in `~/.pwn/pwn.yaml` under `aws:`.
14
14
 
15
15
  ## Quick enumeration
16
16
 
@@ -21,6 +21,30 @@ toolsets; the JSON-Schema for each tool is what the model actually sees.
21
21
  | `cron` | `cron_list` · `cron_create` · `cron_run` · `cron_enable` · `cron_disable` · `cron_remove` | `PWN::Cron` → `~/.pwn/cron/jobs.yml` |
22
22
  | `swarm` | `agent_list` · `agent_spawn` · `agent_ask` · `agent_debate` · `agent_broadcast` · `swarm_bus` · `swarm_list` | `PWN::AI::Agent::Swarm` → `~/.pwn/agents.yml` + `~/.pwn/swarm/` |
23
23
 
24
+
25
+ ## Dynamic tool-set slimming (`ai.agent.tool_router`)
26
+
27
+ Shipping every schema on every turn overwhelms a small local model — the
28
+ choice space is huge and it mis-routes (e.g. picks an RF tool for a git
29
+ question). When `ai.agent.tool_router: true` **and** `Loop.run` passes the
30
+ user request through as `relevance:`, `Registry.definitions` shrinks the
31
+ pool to:
32
+
33
+ ```text
34
+ CORE_TOOLS = shell · pwn_eval · memory_remember · memory_recall
35
+ mistakes_record · mistakes_resolve · learning_note_outcome
36
+ + top-K keyword-ranked matches for THIS request
37
+ (ties break on Metrics per-engine success_rate → the router
38
+ itself is a learned component)
39
+ ```
40
+
41
+ ```ruby
42
+ PWN::AI::Agent::Registry.definitions(relevance: 'nmap sweep 10.0.0.0/8', top_k: 10)
43
+ PWN::AI::Agent::Registry.rank(query: 'run a shell command') # inspect ranking
44
+ ```
45
+
46
+ Frontier engines leave `tool_router` off and receive the full set.
47
+
24
48
  ## Adding a tool
25
49
 
26
50
  ```ruby
@@ -6,10 +6,13 @@ Professional's headless mode + REST API.
6
6
 
7
7
  ![Web application testing](diagrams/web-application-testing.svg)
8
8
 
9
+ > **Install:** `pwn setup --profile web` — burpsuite · zaproxy · chromium ·
10
+ > geckodriver · sqlmap · tor. See [Installation](Installation.md).
11
+
9
12
  ## Configure
10
13
 
11
14
  ```yaml
12
- # ~/.pwn/config.yml
15
+ # ~/.pwn/pwn.yaml (edit via `pwn-vault`)
13
16
  burp:
14
17
  jar: /opt/burpsuite_pro/burpsuite_pro.jar
15
18
  api_key: <REST-API-KEY>
@@ -1,6 +1,6 @@
1
1
  # CLI Drivers — `bin/pwn_*`
2
2
 
3
- 52 headless executables, each a thin `OptionParser` wrapper over one plugin
3
+ 53 headless executables, each a thin `OptionParser` wrapper over one plugin
4
4
  (or one workflow). They exist so CI/CD can call PWN without a REPL or an LLM.
5
5
 
6
6
  ![Driver anatomy](diagrams/driver-framework.svg)
@@ -26,19 +26,34 @@ pwn_crt_sh pwn_serial_check_voicemail
26
26
  pwn_defectdojo_engagement_create pwn_serial_msr206
27
27
  pwn_defectdojo_importscan pwn_serial_qualcomm_commands
28
28
  pwn_defectdojo_reimportscan pwn_serial_son_micro_sm132_rfid
29
- pwn_diff_csv_files_w_column_exclude pwn_shodan_graphql_introspection
30
- pwn_domain_reversewhois pwn_shodan_search
31
- pwn_fuzz_net_app_proto pwn_simple_http_server
32
- pwn_gqrx_scanner pwn_web_cache_deception
33
- pwn_jenkins_create_job pwn_www_checkip
34
- pwn_jenkins_create_view pwn_www_uri_buster
35
- pwn_jenkins_install_plugin pwn_xss_dom_vectors
36
- pwn_zaproxy_active_rest_api_scan
37
- pwn_zaproxy_active_scan
29
+ pwn_diff_csv_files_w_column_exclude pwn_setup
30
+ pwn_domain_reversewhois pwn_shodan_graphql_introspection
31
+ pwn_fuzz_net_app_proto pwn_shodan_search
32
+ pwn_gqrx_scanner pwn_simple_http_server
33
+ pwn_jenkins_create_job pwn_web_cache_deception
34
+ pwn_jenkins_create_view pwn_www_checkip
35
+ pwn_jenkins_install_plugin pwn_www_uri_buster
38
36
  ```
39
37
 
40
38
  Run any with `--help` for its flags.
41
39
 
40
+ ## `pwn_setup` — post-install doctor & capability provisioner
41
+
42
+ The one driver that isn't a plugin wrapper. It grows a bare `gem install pwn`
43
+ into a fully-armed host by installing OS headers / external tools for whatever
44
+ capability profile you ask for. Also reachable as `pwn setup` and
45
+ `pwn --setup[=PROFILE]`.
46
+
47
+ ```bash
48
+ pwn_setup # read-only doctor; exit 1 if degraded
49
+ pwn_setup --list-profiles
50
+ pwn_setup --profile web --yes # CI-friendly, non-interactive
51
+ pwn_setup --deps --dry-run # print the apt/dnf/pacman/brew/port commands only
52
+ ```
53
+
54
+ See [Installation](Installation.md) for the full profile table and
55
+ `PWN::Setup` API.
56
+
42
57
  ## Typical CI usage
43
58
 
44
59
  ```yaml
@@ -46,6 +61,8 @@ Run any with `--help` for its flags.
46
61
  sast:
47
62
  image: 0dayinc/pwn:latest
48
63
  script:
64
+ - pwn_setup --profile net --yes
65
+ - pwn_setup --check # gate: exit 1 if degraded
49
66
  - pwn_sast -d "$CI_PROJECT_DIR" -o sast_out/
50
67
  - pwn_defectdojo_importscan -f sast_out/report.json -e "$DD_ENGAGEMENT"
51
68
  ```
@@ -16,6 +16,11 @@ writes a fully-commented template with every key below (values set to
16
16
  `'optional - …'` / `'required - …'` placeholder strings), encrypts it, and
17
17
  generates the decryptor.
18
18
 
19
+ > **Before configuring**, run `pwn setup` — the
20
+ > [doctor](Installation.md#pwn-setup--the-post-install-doctor--provisioner)
21
+ > reports whether `~/.pwn/`, `pwn.yaml`, its decryptor, and an AI-engine key
22
+ > are present, and exits non-zero for CI if any are missing.
23
+
19
24
  ---
20
25
 
21
26
  ## Full annotated example
@@ -30,7 +35,7 @@ ai:
30
35
  grok:
31
36
  base_uri: https://api.x.ai/v1 # xAI API base URL. Override for a self-hosted proxy / private endpoint.
32
37
  key: xai-… # xAI API key. If blank AND no oauth.* below, PWN prompts interactively at load.
33
- model: grok-4.5 # Model id sent on every chat / tool-loop request.
38
+ model: <model-id> # Model id sent on every chat / tool-loop request. See provider docs / API for currently-supported ids.
34
39
  system_role_content: 'You are an ethically hacking xAI Grok agent.' # Base system prompt (MEMORY/SKILLS/LEARNING/EXTROSPECTION blocks are appended to this).
35
40
  temp: 1.0 # Sampling temperature passed to the chat endpoint.
36
41
  max_prompt_length: 256000 # Soft input-context ceiling (chars) used for prompt truncation / chunking.
@@ -46,7 +51,7 @@ ai:
46
51
  openai:
47
52
  base_uri: https://api.openai.com/v1 # OpenAI API base URL. Override for Azure OpenAI / VPC gateway / local proxy.
48
53
  key: sk-… # OpenAI API key (`sk-…`). Prompted interactively if blank.
49
- model: gpt-4o # Model id sent on every chat / tool-loop request.
54
+ model: <model-id> # Model id sent on every chat / tool-loop request. See provider docs / API for currently-supported ids.
50
55
  system_role_content: 'You are an ethically hacking OpenAI agent.' # Base system prompt for this engine.
51
56
  temp: 1.0 # Sampling temperature.
52
57
  max_prompt_length: 128000 # Soft input-context ceiling (chars) for truncation / chunking.
@@ -55,7 +60,7 @@ ai:
55
60
  anthropic:
56
61
  base_uri: https://api.anthropic.com/v1 # Anthropic API base URL. Override for Bedrock / private gateway.
57
62
  key: sk-ant-… # Anthropic API key (`sk-ant-…`). Prompted interactively if blank.
58
- model: claude-3-5-sonnet-20240620 # Model id sent on every chat / tool-loop request.
63
+ model: <model-id> # Model id sent on every chat / tool-loop request. See provider docs / API for currently-supported ids.
59
64
  system_role_content: 'You are an ethically hacking Anthropic agent.' # Base system prompt for this engine.
60
65
  temp: 1.0 # Sampling temperature.
61
66
  max_tokens: 8192 # Max OUTPUT tokens per response. Raise if tool-call JSON truncates.
@@ -64,7 +69,7 @@ ai:
64
69
  gemini:
65
70
  base_uri: https://generativelanguage.googleapis.com/v1beta # Google Generative Language API base URL.
66
71
  key: AIza… # Google AI Studio API key (`AIza…`). Prompted interactively if blank.
67
- model: gemini-2.5-pro # Model id sent on every chat / tool-loop request.
72
+ model: <model-id> # Model id sent on every chat / tool-loop request. See provider docs / API for currently-supported ids.
68
73
  system_role_content: 'You are an ethically hacking Gemini agent.' # Base system prompt for this engine.
69
74
  temp: 1.0 # Sampling temperature.
70
75
  max_prompt_length: 1000000 # Soft input-context ceiling (chars) — Gemini supports very large contexts.
@@ -72,17 +77,31 @@ ai:
72
77
  ollama:
73
78
  base_uri: https://ollama.local # REQUIRED for ollama — Open WebUI / ollama-serve base URL (no vendor default).
74
79
  key: eyJ… # Open WebUI JWT (Settings → Account → API Key). Prompted if blank.
75
- model: llama3.1:70b # Local model tag as `ollama list` shows it.
80
+ model: <local-model-tag> # Local model tag exactly as `ollama list` shows it.
81
+ embed_model: <embed-model-tag> # Embedding model for PWN::MemoryIndex (relevance-ranked MEMORY). Must be pulled locally.
76
82
  system_role_content: 'You are an ethically hacking Ollama agent.' # Base system prompt for this engine.
77
- temp: 1.0 # Sampling temperature.
83
+ temp: 1.0 # Sampling temperature (used on the FINAL text-only turn — tool-bearing turns are pinned low for deterministic routing).
84
+ num_ctx: 32768 # Context window passed to /api/chat options.num_ctx. Ollama's default (2048) is too small for the pwn-ai system prompt.
85
+ keep_alive: 30m # How long ollama keeps the model resident between iterations (avoids reload latency mid-turn).
86
+ prompt_budget: # Per-block caps applied by PromptBuilder.budget so a small model spends attention on the request, not the harness.
87
+ memory: 6 # Max MEMORY entries injected (relevance-ranked via PWN::MemoryIndex when available).
88
+ metrics: 3 # Max TOOL EFFECTIVENESS rows.
89
+ mistakes: 3 # Max KNOWN MISTAKES / FIXES rows.
90
+ learning: 2 # Max recent LEARNING outcomes shown.
91
+ extro: false # Gate the (heaviest) EXTROSPECTION block entirely for local models.
78
92
  max_prompt_length: 32000 # Soft input-context ceiling (chars) — tune per local model's real context window.
79
93
 
94
+ reflect_engine: ~ # Teacher-student reflection: EXECUTE on ai.active, but write durable lessons via THIS engine (nil = same as active). Lets a local model act while a frontier model authors the Memory :lesson entries it reads back.
95
+
80
96
  agent:
81
97
  native_tools: true # Use provider-native tool_calls / function-calling. false → legacy text-parsed tool protocol.
82
98
  max_iters: 25 # Hard cap on tool-call rounds per user turn before a forced final answer.
83
99
  max_depth: 3 # Recursion guard: how many levels deep agent_ask/agent_debate sub-agents may spawn sub-agents.
84
100
  auto_introspect: true # Run Learning.auto_introspect (outcome logging + lesson mining) after every final answer.
85
101
  auto_extrospect: false # Optional ambient baseline (host/repo/env ONLY — never launches burpsuite/zaproxy/msf/gqrx). Sense tools (intel/verify/watch/rf_tune/observe) stay on-demand.
102
+ plan_first: ~ # Plan-then-act pre-pass: force the model to externalise a numbered tool plan BEFORE its first dispatch. nil = auto (true when ai.active == ollama).
103
+ tool_router: false # Dynamic tool-set slimming: ship only Registry::CORE_TOOLS + top-K keyword-relevant schemas per turn (helps small models route correctly).
104
+ escalation_persona: ~ # Swarm persona name to ask for a 3-line corrective hint once a local model burns ≥ Loop::ESCALATE_AFTER_FAILS in-turn failures. nil = disabled.
86
105
  toolsets: ~ # Allow-list of toolsets exposed to the agent. nil = all. Valid: cron, extrospection, learning, memory, metrics, pwn, sessions, skills, swarm, terminal.
87
106
  extrospection:
88
107
  web:
@@ -193,12 +212,17 @@ PWN::Config.refresh_env
193
212
  | `ai.module_reflection` | Boolean | `false` | `PWN::AI::Agent::Reflect`, `PWN::SAST::*`, `PWN::Plugins::BurpSuite` | Master gate for LLM-driven self-analysis (SAST triage, Burp finding enrichment, `Learning.llm_reflect`). |
194
213
  | `ai.<engine>.base_uri` | String | provider default | `PWN::AI::<Engine>.rest_call` | Override the API base URL (self-hosted proxy, private endpoint, Azure/VPC gateway). **Required** for `ollama`. |
195
214
  | `ai.<engine>.key` | String | — | `PWN::AI::<Engine>` | API key / bearer token. If blank AND no OAuth is configured, PWN prompts interactively at load. |
196
- | `ai.<engine>.model` | String | provider default | `PWN::AI::<Engine>.chat` / `.chat_tool_loop` | Model id sent on every request (e.g. `grok-4.5`, `gpt-4o`, `claude-3-5-sonnet-20240620`, `gemini-2.5-pro`, `llama3.1:70b`). |
215
+ | `ai.<engine>.model` | String | provider default | `PWN::AI::<Engine>.chat` / `.chat_tool_loop` | Model id sent on every request. Use whatever id the provider / `ollama list` currently exposes — PWN never hard-codes a specific model. |
197
216
  | `ai.<engine>.system_role_content` | String | ethical-hacker persona | `PWN::AI::Agent::PromptBuilder`, `PWN::Plugins::REPL` | Base system prompt prepended to MEMORY / SKILLS / LEARNING / EXTROSPECTION blocks. |
198
217
  | `ai.<engine>.temp` | Float | `1.0` | `PWN::AI::<Engine>.chat` | Sampling temperature. |
199
218
  | `ai.<engine>.max_prompt_length` | Integer | per-engine | `PWN::AI::<Engine>`, `PWN::Plugins::REPL` | Soft input-context ceiling used for prompt truncation / chunking. |
200
219
  | `ai.anthropic.max_tokens` | Integer | `8192` | `PWN::AI::Anthropic.chat_tool_loop` | Max **output** tokens per response. Raise if tool-call JSON truncates. |
201
220
  | `ai.openai.max_tokens` | Integer | `16384` | `PWN::AI::OpenAI.chat` | Max **output** tokens per response. Mapped to OpenAI's wire param `max_completion_tokens` (legacy env key `max_completion_tokens` still accepted). |
221
+ | `ai.ollama.embed_model` | String | provider default | `PWN::MemoryIndex` | Local embedding model tag used to build `~/.pwn/memory.idx` for **relevance-ranked** MEMORY injection. Falls back to substring recall when unset / unreachable. |
222
+ | `ai.ollama.num_ctx` | Integer | `32768` | `PWN::AI::Ollama.chat_with_tools` | Context window sent as `options.num_ctx` on the native `/api/chat` call. Ollama's own default (2048) truncates the pwn-ai system prompt. |
223
+ | `ai.ollama.keep_alive` | String | `30m` | `PWN::AI::Ollama.chat_with_tools` | How long the model stays resident in ollama between iterations of a single turn. |
224
+ | `ai.ollama.prompt_budget` | Hash | `{memory:6, metrics:3, mistakes:3, learning:2, extro:false}` | `PWN::AI::Agent::PromptBuilder.budget` | Per-block caps on injected context so a small local model spends its attention on the request, not the harness. Any engine may set this. |
225
+ | `ai.reflect_engine` | Symbol \| `nil` | `nil` (= `ai.active`) | `PWN::AI::Agent::Reflect.on`, `Learning.reflect` | **Teacher-student** override: run the task on `ai.active`, but generate durable lessons via *this* engine. Lets a local model execute while a frontier model writes the Memory it reads back. |
202
226
  | `ai.grok.oauth.refresh_token` | String | — | `PWN::AI::Grok.resolve_auth` | Durable OAuth refresh token (from `PWN::AI::Grok.obtain_oauth_bearer_token` device flow). Enables silent re-auth without an API key. |
203
227
  | `ai.grok.oauth.bearer_token` | String | — | `PWN::AI::Grok.resolve_auth` | Short-lived OAuth access JWT. Auto-refreshed each run when `refresh_token` is present; live-cached back into this hash. |
204
228
  | `ai.grok.oauth.client_id` | String | Grok-CLI public id | `PWN::AI::Grok` | Override the public OAuth client id used for device-flow / refresh. |
@@ -217,6 +241,9 @@ PWN::Config.refresh_env
217
241
  | `ai.agent.auto_introspect` | Boolean | `true` | `PWN::AI::Agent::Learning.auto_introspect` | Run outcome logging + lesson mining after every final answer. Toggle live via `learning_auto_introspect_toggle`. |
218
242
  | `ai.agent.auto_extrospect` | Boolean | `false` | `PWN::AI::Agent::Extrospection.auto_extrospect` | Optional ambient baseline after every final answer (`AUTO_SECTIONS` = host/repo/env only; never spawns GUI/JVM tools). Prefer on-demand sense tools (`intel`/`verify`/`watch`/`rf_tune`/`observe`). Toggle live via `extro_auto_toggle`. |
219
243
  | `ai.agent.toolsets` | Array\<String\> \| `nil` | `nil` (all) | `bin/pwn`, `PWN::Plugins::REPL`, `PWN::AI::Agent::Registry` | Allow-list of toolsets exposed to the agent. Valid: `cron`, `extrospection`, `learning`, `memory`, `metrics`, `pwn`, `sessions`, `skills`, `swarm`, `terminal`. |
244
+ | `ai.agent.plan_first` | Boolean \| `nil` | `nil` (auto: `true` when `ai.active == ollama`) | `PWN::AI::Agent::Loop.plan_first` | Plan-then-act pre-pass: the model must emit a numbered tool plan (as an assistant message) *before* it may dispatch anything. Cheap chain-of-thought scaffolding for local models. |
245
+ | `ai.agent.tool_router` | Boolean | `false` | `PWN::AI::Agent::Registry.definitions` | Dynamic tool-set slimming: expose only `Registry::CORE_TOOLS` + the top-K keyword-relevant schemas for *this* request. Ties break on historical `Metrics` success rate so the router itself is a learned component. |
246
+ | `ai.agent.escalation_persona` | String \| `nil` | `nil` | `PWN::AI::Agent::Loop.escalate` → `Swarm.ask` | Circuit-breaker: once a local model accumulates ≥ `Loop::ESCALATE_AFTER_FAILS` in-turn failures, ask this Swarm persona for a 3-line corrective hint (injected as a synthetic tool result). The local model still authors the final answer so Learning/Metrics stay attributed. |
220
247
  | `ai.agent.extrospection.web.anchors` | Array\<String\> | `DEFAULT_WEB_ANCHORS` | `PWN::AI::Agent::Extrospection.probe_web` | URLs the headless browser fingerprints on `extro_snapshot(sections:[:web])`. Alias: `web_anchors`. |
221
248
  | `ai.agent.extrospection.web.proxy` | String | — | `Extrospection.probe_web` / `.verify` / `.watch` | Upstream proxy for `PWN::Plugins::TransparentBrowser` (e.g. `tor`, `http://127.0.0.1:8080`). |
222
249
  | `ai.agent.extrospection.web.max_anchors` | Integer | `8` | `Extrospection.probe_web` | Cap on anchors rendered per snapshot. |
@@ -309,9 +336,9 @@ agent system prompt.
309
336
 
310
337
  `pwn.yaml` is the only file you edit; everything else is machine-written
311
338
  state. See **[Persistence](Persistence.md)** for the full map
312
- (`memory.json`, `learning.jsonl`, `mistakes.json`, `metrics.json`,
313
- `extrospection.json`, `sessions/`, `skills/`, `cron/`, `agents.yml`,
314
- `swarm/`).
339
+ (`memory.json`, `memory.idx`, `learning.jsonl`, `mistakes.json`,
340
+ `metrics.json`, `extrospection.json`, `sessions/`, `skills/`,
341
+ `finetune/`, `cron/`, `agents.yml`, `swarm/`).
315
342
 
316
343
  Multi-agent personas are **not** configured here — they live in
317
344
  `~/.pwn/agents.yml` and are managed with `agent_spawn` / `agent_list`
@@ -4,10 +4,11 @@
4
4
 
5
5
  ```text
6
6
  lib/pwn/ # all namespaces
7
+ lib/pwn/setup.rb # PWN::Setup — doctor/provisioner data tables
7
8
  lib/pwn/plugins/ # 66 plugin modules
8
9
  lib/pwn/ai/agent/ # agent core
9
10
  lib/pwn/ai/agent/tools/ # LLM tool registrations
10
- bin/ # 52 pwn_* drivers
11
+ bin/ # 53 pwn_* drivers (incl. pwn_setup)
11
12
  spec/ # RSpec (incl. conventions_spec)
12
13
  documentation/ # this wiki + diagrams
13
14
  ```
@@ -23,9 +24,11 @@ documentation/ # this wiki + diagrams
23
24
  ## Quality gates
24
25
 
25
26
  ```bash
26
- rvmsudo rake # rubocop + rspec — must be zero offenses
27
+ rake # rubocop + rspec — must be zero offenses
27
28
  ```
28
29
 
30
+ (`rvmsudo rake` on multi-user RVM installs.)
31
+
29
32
  ## Adding a plugin
30
33
 
31
34
  1. `lib/pwn/plugins/my_thing.rb` following the conventions above.
@@ -34,7 +37,14 @@ rvmsudo rake # rubocop + rspec — must be zero offenses
34
37
  4. Optional `bin/pwn_my_thing` driver (see [Drivers](Drivers.md)).
35
38
  5. Optional agent tool in `lib/pwn/ai/agent/tools/` (see
36
39
  [Agent Tool Registry](Agent-Tool-Registry.md)).
37
- 6. Update [Plugins.md](Plugins.md) and, if it changes a data flow, the
40
+ 6. **If it needs a native gem or external binary**, add **one row** to
41
+ `PWN::Setup::NATIVE_GEMS` or `PWN::Setup::TOOLCHAIN` in
42
+ `lib/pwn/setup.rb` (with `apt:`/`dnf:`/`pacman:`/`brew:`/`port:` package
43
+ names + the `plugins:` it unlocks) and, if it belongs in a capability
44
+ set, reference it from `PWN::Setup::PROFILES`. That single edit makes
45
+ `pwn setup` install it on every OS and every install path (gem, git,
46
+ Docker, Packer, Vagrant, CI). **Do not** add a new bash provisioner.
47
+ 7. Update [Plugins.md](Plugins.md) and, if it changes a data flow, the
38
48
  relevant `.dot` in `documentation/diagrams/dot/` → `./build.sh`.
39
49
 
40
50
  ## Commit / release