pentesting 0.7.6 → 0.7.8

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 (3) hide show
  1. package/README.md +145 -98
  2. package/dist/index.js +63 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  ```
2
- ██████╗ ███████╗███╗ ██╗████████╗███████╗███████╗████████╗
3
- ██╔══██╗██╔════╝████╗ ██║╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝
4
- ██████╔╝█████╗ ██╔██╗ ██║ ██║ █████╗ ███████╗ ██║
5
- ██╔═══╝ ██╔══╝ ██║╚██╗██║ ██║ ██╔══╝ ╚════██║ ██║
6
- ██║ ███████╗██║ ╚████║ ██║ ███████╗███████║ ██║
7
- ╚═╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚══════╝ ╚═╝
2
+ ██████╗ ███████╗███╗ ██╗████████╗███████╗███████╗████████╗██╗███╗ ██╗ ██████╗
3
+ ██╔══██╗██╔════╝████╗ ██║╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝██║████╗ ██║██╔════╝
4
+ ██████╔╝█████╗ ██╔██╗ ██║ ██║ █████╗ ███████╗ ██║ ██║██╔██╗ ██║██║ ███╗
5
+ ██╔═══╝ ██╔══╝ ██║╚██╗██║ ██║ ██╔══╝ ╚════██║ ██║ ██║██║╚██╗██║██║ ██║
6
+ ██║ ███████╗██║ ╚████║ ██║ ███████╗███████║ ██║ ██║██║ ╚████║╚██████╔╝
7
+ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝
8
8
  ```
9
9
 
10
- ⚠️ **For authorized penetration testing only. Unauthorized use is illegal.**
10
+ **Autonomous AI Penetration Testing Agent**
11
11
 
12
12
  [![npm version](https://badge.fury.io/js/pentesting.svg)](https://www.npmjs.com/package/pentesting)
13
13
  [![Docker](https://img.shields.io/badge/Docker-pentesting--tools-blue)](https://hub.docker.com/r/agnusdei1207/pentesting-tools)
@@ -36,67 +36,116 @@ pentesting
36
36
  ### Core Capabilities
37
37
  - **10-Phase Attack Workflow**: Recon → Scan → Enum → Vuln Analysis → Exploitation → PrivEsc → Pivot → Persist → Exfil → Report
38
38
  - **9 Specialized Agents**: Built-in domain experts for security testing
39
- - **Ralph Loop**: Autonomous iteration until objective is achieved
39
+ - **Multi-Target Attack**: Register multiple targets and attack them sequentially
40
+ - **Auto-Target Detection**: Automatically sets targets from user input
40
41
  - **Streaming Responses**: Real-time LLM output display
41
42
  - **Session Persistence**: Save/resume pentesting sessions
42
- - **Tool Approval**: Manual confirmation for dangerous commands
43
+ - **ESC Interrupt**: Stop execution anytime with ESC key
43
44
  - **MCP Integration**: Extend with Model Context Protocol tools
44
45
  - **Docker Toolkit**: 50+ pre-installed pentesting tools
45
46
  - **Provider Agnostic**: Works with any OpenAI-compatible API
46
47
 
47
- ### v0.4+ New Features (kimi-cli inspired)
48
- - **Context Checkpoints**: Save/restore conversation states with `/checkpoint`, `/undo`, `/revert`
49
- - **Flow Skills**: Mermaid/D2 diagram-based workflow automation
50
- - **Session Replay**: Review past sessions from wire recordings
51
- - **Auto-Update**: Background version checking with update notifications
52
- - **Vision Analysis**: Analyze images from clipboard with `/paste`
53
- - **Wire Logging**: Detailed session recording in JSONL format
54
- - **Rich TUI**: Premium ASCII banner, organized help, status reports
48
+ ### v0.7+ New Features
49
+ - **Multi-Target Management**: `/target add`, `/target list`, `/target clear`
50
+ - **Batch Attack**: `/start all` to attack all registered targets
51
+ - **set_target Tool**: Agent can set targets directly via tool call
52
+ - **Enhanced ESC**: Properly interrupts even during tool execution
53
+ - **UI State Sync**: Real-time status bar updates for findings/creds/targets
55
54
 
56
55
  ---
57
56
 
58
57
  ## 📖 CLI Commands
59
58
 
60
- ### Core
59
+ ### Target Management
61
60
  ```bash
62
- /target <ip> Set target IP/hostname
63
- /start [objective] Start autonomous pentest
64
- /stop Stop current operation
65
- /status Show status report
61
+ /target <domain|ip> Set primary target
62
+ /target add <t> Add target to list
63
+ /target list Show all targets (★ = primary)
64
+ /target rm <t> Remove target from list
65
+ /target set <t> Set as primary target
66
+ /target clear Remove ALL targets
67
+ ```
68
+
69
+ ### Attack Execution
70
+ ```bash
71
+ /start [objective] Start pentest on primary target
72
+ /start all Attack ALL registered targets sequentially
73
+ /stop Stop current operation
74
+ /status Show status report
66
75
  ```
67
76
 
68
77
  ### Session Management
69
78
  ```bash
70
- /checkpoint [desc] Create checkpoint with optional description
71
- /checkpoints List all checkpoints
72
- /undo Undo to last checkpoint
73
- /revert <id> Revert to specific checkpoint
74
- /compact Compact context (keep last 3 messages)
75
- /sessions List saved sessions
76
- /resume [id] Resume a session
77
- /replay Show session recordings
79
+ /checkpoint [desc] Create checkpoint with optional description
80
+ /checkpoints List all checkpoints
81
+ /undo Undo to last checkpoint
82
+ /revert <id> Revert to specific checkpoint
83
+ /compact Compact context (keep last 3 messages)
84
+ /sessions List saved sessions
85
+ /resume [id] Resume a session
86
+ /replay Show session recordings
78
87
  ```
79
88
 
80
89
  ### Skills & Extras
81
90
  ```bash
82
- /skills List available skills
83
- /update Check for updates
84
- /update now Install update
91
+ /skills List available skills
92
+ /update Check for updates
93
+ /update now Install update
85
94
  ```
86
95
 
87
96
  ### Findings & Reports
88
97
  ```bash
89
- /findings Show discovered findings
90
- /report Generate pentest report
98
+ /findings Show discovered findings
99
+ /report Generate pentest report
91
100
  ```
92
101
 
93
102
  ### Utility
94
103
  ```bash
95
- /paste Paste from clipboard (text or image)
96
- /yolo Toggle auto-approve mode
97
- /clear Clear screen
98
- /exit Exit
99
- /y /n /ya Approve/Deny/Always approve (for pending tools)
104
+ /paste Paste from clipboard (text or image)
105
+ /yolo Toggle auto-approve mode
106
+ /clear Clear screen
107
+ /exit Exit
108
+ /y /n /ya Approve/Deny/Always approve (for pending tools)
109
+ ```
110
+
111
+ ---
112
+
113
+ ## 🎯 Multi-Target Workflow
114
+
115
+ ```bash
116
+ # Start pentesting CLI
117
+ pentesting
118
+
119
+ # Register multiple targets
120
+ /target add example1.com
121
+ /target add example2.com
122
+ /target add 192.168.1.1
123
+ /target add internal.corp
124
+
125
+ # View registered targets
126
+ /target list
127
+ 🎯 Targets (4):
128
+ 1. ★ example1.com
129
+ 2. example2.com
130
+ 3. 192.168.1.1
131
+ 4. internal.corp
132
+
133
+ # Attack all targets sequentially
134
+ /start all
135
+
136
+ 🚀 Starting multi-target attack on 4 targets
137
+
138
+ ━━━ [1/4] example1.com ━━━
139
+ 📁 Session: session-1707325423
140
+ ... reconnaissance & exploitation ...
141
+
142
+ ━━━ [2/4] example2.com ━━━
143
+ ...
144
+
145
+ # Press ESC to stop between targets
146
+ ⏸ Stopped at target 2/4
147
+
148
+ ✓ Multi-target attack complete
100
149
  ```
101
150
 
102
151
  ---
@@ -137,35 +186,38 @@ pentesting
137
186
  ## 💻 Programmatic Usage
138
187
 
139
188
  ```typescript
140
- import { PentestingAgent, PENTEST_EVENT } from 'pentesting';
189
+ import { AutonomousHackingAgent, AGENT_EVENT } from 'pentesting';
141
190
 
142
- const agent = new PentestingAgent({
143
- yoloMode: false, // Require approval for dangerous tools
144
- useStreaming: true, // Enable streaming responses
145
- maxIterations: 100, // Max Ralph loop iterations
146
- autoSave: true, // Auto-save session state
191
+ const agent = new AutonomousHackingAgent(undefined, {
192
+ autoApprove: false, // Require approval for dangerous tools
193
+ maxIterations: 100, // Max loop iterations
147
194
  });
148
195
 
196
+ // Multi-target setup
197
+ agent.addTarget('example1.com');
198
+ agent.addTarget('example2.com');
199
+ agent.setTarget('example1.com');
200
+
149
201
  // Listen for events
150
- agent.on(PENTEST_EVENT.FINDING, (finding) => {
202
+ agent.on(AGENT_EVENT.FINDING, (finding) => {
151
203
  console.log(`Found: ${finding.title} (${finding.severity})`);
152
204
  });
153
205
 
154
- agent.on(PENTEST_EVENT.APPROVAL_NEEDED, (request) => {
155
- console.log(`Approval needed for: ${request.toolName}`);
156
- agent.approveToolCall(request.id, 'approve');
206
+ agent.on(AGENT_EVENT.TARGET_SET, (target) => {
207
+ console.log(`Target set: ${target}`);
157
208
  });
158
209
 
159
- agent.on(PENTEST_EVENT.TEXT_DELTA, (text) => {
160
- process.stdout.write(text);
210
+ agent.on(AGENT_EVENT.TOOL_CALL, ({ name, input }) => {
211
+ console.log(`Tool: ${name}`);
161
212
  });
162
213
 
163
214
  // Start pentesting
164
- await agent.start('Get root access', '192.168.1.100');
215
+ await agent.runAutonomous('Get root access');
165
216
 
166
- // Or use individual commands
167
- const scanResult = await agent.chat('/scan 10.10.10.1');
168
- const exploitResult = await agent.chat('/exploit Apache 2.4.49');
217
+ // Control execution
218
+ agent.pause(); // Pause (ESC key equivalent)
219
+ agent.resume(); // Resume
220
+ agent.abort(); // Complete stop
169
221
  ```
170
222
 
171
223
  ---
@@ -185,6 +237,15 @@ docker run -d --name pentesting-tools --network host \
185
237
  docker exec -it pentesting-tools nmap -sCV 10.0.0.1
186
238
  ```
187
239
 
240
+ ### Included Tools
241
+ - **Network**: nmap, rustscan, masscan, netcat
242
+ - **Web**: ffuf, nikto, sqlmap, httpx
243
+ - **Discovery**: subfinder, amass, nuclei
244
+ - **Service**: snmpwalk, nbtscan, hydra, smbclient
245
+ - **AD/Windows**: impacket, crackmapexec
246
+ - **Database**: mysql-client, postgresql-client, redis-tools
247
+ - **Utilities**: curl, wget, jq, python3
248
+
188
249
  ---
189
250
 
190
251
  ## 🔌 MCP Integration
@@ -192,7 +253,7 @@ docker exec -it pentesting-tools nmap -sCV 10.0.0.1
192
253
  Extend with additional MCP servers:
193
254
 
194
255
  ```typescript
195
- const agent = new PentestingAgent();
256
+ const agent = new AutonomousHackingAgent();
196
257
 
197
258
  // Add filesystem access
198
259
  await agent.addMCPServer('filesystem', 'npx', [
@@ -213,8 +274,12 @@ await agent.addMCPServer('security-tools', 'docker', [
213
274
  ┌─────────────────────────────────────────────────────────────────┐
214
275
  │ TUI (app.tsx) │
215
276
  │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────────┐ │
216
- │ │ WireLogger │ │ContextMgr │ │ SlashCommandRegistry │ │
217
- │ │ (Recording) │ │(Checkpoints)│ │ (Command Handling) │ │
277
+ │ │ WireLogger │ │ContextMgr │ │ Multi-Target Handler │ │
278
+ │ │ (Recording) │ │(Checkpoints)│ │ (add/list/rm/clear/all) │ │
279
+ │ └──────────────┘ └──────────────┘ └──────────────────────────┘ │
280
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────────┐ │
281
+ │ │ KeyboardLstn │ │ ForceUpdate │ │ SlashCommandRegistry │ │
282
+ │ │ (ESC/Ctrl+C) │ │ (UI Refresh) │ │ (Command Handling) │ │
218
283
  │ └──────────────┘ └──────────────┘ └──────────────────────────┘ │
219
284
  └────────────────────────────┬────────────────────────────────────┘
220
285
  │ Events
@@ -224,6 +289,10 @@ await agent.addMCPServer('security-tools', 'docker', [
224
289
  │ │ HookExecutor │ │ MCPManager │ │ApprovalMgr │ │
225
290
  │ │ (Lifecycle) │ │ (Extensions) │ │(Tool Safety) │ │
226
291
  │ └──────────────┘ └──────────────┘ └──────────────┘ │
292
+ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
293
+ │ │ TargetMgr │ │ PauseMgr │ │ContextMgr │ │
294
+ │ │ (Multi-Tgt) │ │ (ESC/Abort) │ │ (Compaction) │ │
295
+ │ └──────────────┘ └──────────────┘ └──────────────┘ │
227
296
  │ │
228
297
  │ ┌────────────────────────────────────────────────────────────┐ │
229
298
  │ │ 9 Built-in Specialized Agents │ │
@@ -240,34 +309,6 @@ await agent.addMCPServer('security-tools', 'docker', [
240
309
  └─────────┘ └─────────┘ └─────────┘
241
310
  ```
242
311
 
243
- ### Module Connectivity
244
-
245
- ```
246
- Core Modules (src/core/):
247
- ├── agent/ AutonomousHackingAgent, PentestingAgent, AgentOrchestrator
248
- ├── approval/ ApprovalManager - tool execution safety
249
- ├── commands/ SlashCommandRegistry - command handling
250
- ├── context/ ContextManager (checkpoints) + Compaction (tokens)
251
- ├── display/ DisplayBlocks - rich output formatting
252
- ├── hooks/ HookExecutor - lifecycle events
253
- ├── loop/ RalphLoop - autonomous iteration
254
- ├── prompts/ System prompts for agents
255
- ├── replay/ SessionReplay - wire file parsing
256
- ├── session/ SessionManager - persistence
257
- ├── skill/ SkillManager + FlowExecutor - workflow automation
258
- ├── streaming/ StreamingAgent - real-time output
259
- ├── tools/ Tool definitions, executor, registry
260
- └── update/ AutoUpdate - version management
261
-
262
- Support Modules:
263
- ├── wire/ WireLogger (JSONL recording) + Wire Protocol
264
- ├── mcp/ MCPManager, MCPClient - extensions
265
- ├── utils/ Clipboard, Retry utilities
266
- ├── agents/ 9 built-in specialized agents
267
- ├── commands/ Built-in slash commands
268
- └── config/ Constants, Theme, Agent configuration
269
- ```
270
-
271
312
  ---
272
313
 
273
314
  ## 📁 Project Structure
@@ -276,8 +317,9 @@ Support Modules:
276
317
  src/
277
318
  ├── index.tsx # CLI entry point
278
319
  ├── cli/
279
- │ ├── app.tsx # TUI with streaming, approval, sessions
280
- └── components/ # Rich display components
320
+ │ ├── app.tsx # TUI with streaming, multi-target, approval
321
+ ├── components/ # Rich display components
322
+ │ └── utils/ # Keyboard listener
281
323
  ├── core/
282
324
  │ ├── agent/ # Agent implementations
283
325
  │ ├── approval/ # Tool approval system
@@ -322,19 +364,24 @@ npm run dev
322
364
 
323
365
  ---
324
366
 
325
- ## 📚 Documentation
326
-
327
- - [Architecture](docs/architecture.md) - System design and components
328
- - [API Reference](docs/api-reference.md) - Full API documentation
329
- - [Troubleshooting](docs/troubleshooting.md) - Common issues
367
+ ## 📚 Changelog
330
368
 
331
- ---
369
+ ### v0.7.7
370
+ - Multi-target management (`/target add/list/rm/clear`)
371
+ - Batch attack (`/start all`)
372
+ - `set_target` tool for agent
332
373
 
333
- ## ⚠️ Legal
374
+ ### v0.7.6
375
+ - ESC interrupt improvements
376
+ - UI state sync for findings/creds/phase
334
377
 
335
- **Only use on systems you own or have explicit permission to test.**
378
+ ### v0.7.5
379
+ - `set_target` tool integration
380
+ - `forceUpdate` mechanism for React state
336
381
 
337
- This tool is for authorized penetration testing and CTF competitions only. Unauthorized access to computer systems is illegal.
382
+ ### v0.7.4
383
+ - Removed all legal/permission prompts
384
+ - Auto-target detection from user input
338
385
 
339
386
  ---
340
387
 
package/dist/index.js CHANGED
@@ -4501,6 +4501,20 @@ ${prompt}`
4501
4501
  }
4502
4502
  return targets;
4503
4503
  }
4504
+ /**
4505
+ * Clear all targets
4506
+ */
4507
+ clearTargets() {
4508
+ this.state.target.primary = "";
4509
+ this.state.target.discovered = [];
4510
+ this.emit(AGENT_EVENT.TARGET_SET, { action: "cleared" });
4511
+ }
4512
+ /**
4513
+ * Get target count
4514
+ */
4515
+ getTargetCount() {
4516
+ return this.getAllTargets().length;
4517
+ }
4504
4518
  // ===== Phase Management =====
4505
4519
  getCurrentPhase() {
4506
4520
  return this.state.phases.find((p) => p.id === this.state.currentPhase);
@@ -6761,9 +6775,12 @@ var App = ({ autoApprove = false, target }) => {
6761
6775
  addMessage(
6762
6776
  MESSAGE_TYPE.SYSTEM,
6763
6777
  `\u2500\u2500 Core \u2500\u2500
6764
- /target [domain|ip] Set/show targets
6765
- add <t> list rm <t> set <t>
6766
- /start [goal] Start autonomous pentest
6778
+ /target [domain|ip] Set primary target
6779
+ add <t> Add to list rm <t> Remove
6780
+ list Show all set <t> Set primary
6781
+ clear Remove all targets
6782
+ /start [goal] Pentest primary target
6783
+ /start all Attack ALL targets
6767
6784
  /stop Stop operation
6768
6785
  /status Show status report
6769
6786
 
@@ -6861,10 +6878,17 @@ ${list}`);
6861
6878
  if (args[1]) {
6862
6879
  agent.setTarget(args[1]);
6863
6880
  addMessage(MESSAGE_TYPE.SYSTEM, `\u2605 Primary target \u2192 ${args[1]}`);
6881
+ forceUpdate((n) => n + 1);
6864
6882
  } else {
6865
6883
  addMessage(MESSAGE_TYPE.ERROR, "Usage: /target set <domain|ip>");
6866
6884
  }
6867
6885
  break;
6886
+ case "clear":
6887
+ case "reset":
6888
+ agent.clearTargets();
6889
+ addMessage(MESSAGE_TYPE.SYSTEM, "\u2713 All targets cleared");
6890
+ forceUpdate((n) => n + 1);
6891
+ break;
6868
6892
  default:
6869
6893
  agent.setTarget(subCmd);
6870
6894
  addMessage(MESSAGE_TYPE.SYSTEM, `\u{1F3AF} Target \u2192 ${subCmd}`);
@@ -6872,6 +6896,41 @@ ${list}`);
6872
6896
  return;
6873
6897
  case CLI_COMMAND.START:
6874
6898
  case "s":
6899
+ if (args[0]?.toLowerCase() === "all") {
6900
+ const allTargets = agent.getAllTargets();
6901
+ if (allTargets.length === 0) {
6902
+ addMessage(MESSAGE_TYPE.ERROR, "No targets registered. Use /target add <domain|ip> first");
6903
+ return;
6904
+ }
6905
+ setIsProcessing(true);
6906
+ startTimer();
6907
+ const allObjective = args.slice(1).join(" ") || "Perform comprehensive penetration testing";
6908
+ addMessage(MESSAGE_TYPE.SYSTEM, `\u{1F680} Starting multi-target attack on ${allTargets.length} targets`);
6909
+ for (let i = 0; i < allTargets.length; i++) {
6910
+ const currentTarget = allTargets[i];
6911
+ if (agent.shouldStop()) {
6912
+ addMessage(MESSAGE_TYPE.SYSTEM, `\u23F8 Stopped at target ${i + 1}/${allTargets.length}`);
6913
+ break;
6914
+ }
6915
+ agent.setTarget(currentTarget);
6916
+ addMessage(MESSAGE_TYPE.SYSTEM, `
6917
+ \u2501\u2501\u2501 [${i + 1}/${allTargets.length}] ${currentTarget} \u2501\u2501\u2501`);
6918
+ forceUpdate((n) => n + 1);
6919
+ try {
6920
+ const session = await sessionManager2.createSession(allObjective, currentTarget);
6921
+ addMessage(MESSAGE_TYPE.SYSTEM, `\u{1F4C1} Session: ${session.id}`);
6922
+ agent.resume();
6923
+ await agent.runAutonomous(allObjective);
6924
+ } catch (e) {
6925
+ addMessage(MESSAGE_TYPE.ERROR, `${currentTarget}: ${e instanceof Error ? e.message : String(e)}`);
6926
+ }
6927
+ }
6928
+ stopTimer();
6929
+ setIsProcessing(false);
6930
+ setCurrentStatus("");
6931
+ addMessage(MESSAGE_TYPE.SYSTEM, `\u2713 Multi-target attack complete`);
6932
+ return;
6933
+ }
6875
6934
  let startObjective = args.join(" ");
6876
6935
  const firstArg = args[0];
6877
6936
  if (firstArg && (firstArg.includes(".") || /^\d+\.\d+\.\d+\.\d+$/.test(firstArg))) {
@@ -7251,7 +7310,7 @@ ${list}`);
7251
7310
  if (key.ctrl && input2 === "x") {
7252
7311
  const newMode = mode === "agent" ? "shell" : "agent";
7253
7312
  setMode(newMode);
7254
- addMessage(MESSAGE_TYPE.SYSTEM, `Mode: ${newMode === "agent" ? "\u{1F916} Agent" : "$ Shell"}`);
7313
+ addMessage(MESSAGE_TYPE.SYSTEM, `Mode: ${newMode === "agent" ? "Agent" : "Shell"}`);
7255
7314
  }
7256
7315
  });
7257
7316
  const getStyle = (type) => {
@@ -7350,8 +7409,6 @@ ${list}`);
7350
7409
  ] }),
7351
7410
  /* @__PURE__ */ jsxs2(Box2, { marginTop: 1, justifyContent: "space-between", children: [
7352
7411
  /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
7353
- mode === "agent" ? "\u{1F916}" : "$",
7354
- " ",
7355
7412
  state.target.primary || "No target",
7356
7413
  state.target.discovered.length > 1 && ` (+${state.target.discovered.length - 1})`,
7357
7414
  " \u2502",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pentesting",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "description": "Autonomous Penetration Testing AI Agent",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",