pentesting 0.7.49 → 0.8.2

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.
package/README.md CHANGED
@@ -12,337 +12,71 @@
12
12
  **Autonomous AI Penetration Testing Agent**
13
13
 
14
14
  [![npm version](https://badge.fury.io/js/pentesting.svg)](https://www.npmjs.com/package/pentesting)
15
- [![Docker](https://img.shields.io/badge/Docker-pentesting--tools-blue)](https://hub.docker.com/r/agnusdei1207/pentesting-tools)
15
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
16
16
 
17
17
  </div>
18
18
 
19
19
  ---
20
20
 
21
- ## 🚀 Quick Start
21
+ ## Quick Start
22
22
 
23
23
  ```bash
24
- # Install
25
24
  npm install -g pentesting
26
25
 
27
- # Configure
28
- export PENTEST_API_KEY=your_api_key
29
- export PENTEST_BASE_URL=https://your-api-endpoint.com/v1
30
- export PENTEST_MODEL=your-model-name
26
+ # GLM example
27
+ export PENTEST_API_KEY="your_api_key"
28
+ export PENTEST_BASE_URL="https://api.z.ai/api/anthropic"
29
+ export PENTEST_MODEL="glm-4.7"
31
30
 
32
- # Run
33
31
  pentesting
34
32
  ```
35
33
 
36
34
  ---
37
35
 
38
- ## 🧠 Philosophy: Think Like a Hacker
36
+ ## Environment Variables
39
37
 
40
- **Pentesting is not a brute-force tool.** It's an intelligent agent that thinks strategically.
41
-
42
- ### Strategic Decision Framework
43
-
44
- Every action is evaluated using:
45
-
46
- ```
47
- Value = (Probability × CVSS Impact) / Time Cost
48
- ```
49
-
50
- The agent only executes actions with **confidence >50%**. Below that, it finds a better approach.
51
-
52
- ### Self-Reflection Before Every Action
53
-
54
- Before running any tool, the agent asks:
55
- - "What exactly am I trying to learn?"
56
- - "Is this the FASTEST way to get that information?"
57
- - "Have I already tried this? What happened?"
58
- - "Is there a simpler approach?"
59
-
60
- ### Mandatory Fallback Strategy
61
-
62
- When a tool fails, the agent immediately tries alternatives:
63
-
64
- | Task | Primary | Fallback 1 | Fallback 2 |
65
- |------|---------|------------|------------|
66
- | Subdomain | subfinder | ffuf | amass |
67
- | Directory | gobuster | ffuf | dirsearch |
68
- | Port Scan | rustscan | nmap | masscan |
38
+ | Variable | Required | Default | Description |
39
+ |----------|----------|---------|-------------|
40
+ | `PENTEST_API_KEY` | ✅ | - | API key (`ANTHROPIC_API_KEY` also works) |
41
+ | `PENTEST_BASE_URL` | | - | Custom API endpoint URL |
42
+ | `PENTEST_MODEL` | | `claude-sonnet-4-20250514` | LLM model name |
43
+ | `PENTEST_MAX_TOKENS` | | `16384` | Max response tokens |
69
44
 
70
45
  ---
71
46
 
72
- ## 🔥 Why Pentesting?
73
-
74
- | Feature | Traditional Tools | Pentesting Agent |
75
- |---------|-------------------|------------------|
76
- | Decision Making | Manual | AI-driven with confidence scoring |
77
- | Tool Selection | You choose | Auto-selects based on context |
78
- | Failure Handling | You retry | Auto-fallback to alternatives |
79
- | Attack Planning | Manual prioritization | CVSS-based priority matrix |
80
- | Context Awareness | None | Remembers all findings |
81
- | Reporting | Manual | Auto-generated findings |
82
-
83
- ---
84
-
85
- ## ✨ Core Capabilities
86
-
87
- - **10-Phase Attack Workflow**: Recon → Scan → Enum → Vuln Analysis → Exploitation → PrivEsc → Pivot → Persist → Exfil → Report
88
- - **Auto Docker Management**: Pulls and starts tool container automatically
89
- - **Multi-Target Attack**: Attack multiple targets sequentially
90
- - **Real-time Feedback**: See thinking process, tool calls, results live
91
- - **Session Persistence**: Save/resume attack sessions
92
- - **Context Compaction**: Automatic history summarization
93
-
94
- ---
95
-
96
- ## 📖 CLI Commands
97
-
98
- ### Target Management
99
- ```bash
100
- /target <domain|ip> Set primary target
101
- /target add <t> Add target to list
102
- /target list Show all targets (★ = primary)
103
- /target rm <t> Remove target from list
104
- /target set <t> Set as primary target
105
- /target clear Remove ALL targets
106
- ```
107
-
108
- ### Attack Execution
109
- ```bash
110
- /start [objective] Start pentest on primary target
111
- /start all Attack ALL registered targets sequentially
112
- /stop Stop current operation
113
- /status Show status report
114
- ```
115
-
116
- ### Session Management
117
- ```bash
118
- /checkpoint [desc] Create checkpoint with optional description
119
- /checkpoints List all checkpoints
120
- /undo Undo to last checkpoint
121
- /revert <id> Revert to specific checkpoint
122
- /compact Compact context (keep last 3 messages)
123
- /sessions List saved sessions
124
- /resume [id] Resume a session
125
- /replay Show session recordings
126
- ```
47
+ ## Features
127
48
 
128
- ### Skills & Extras
129
- ```bash
130
- /skills List available skills
131
- /update Check for updates
132
- /update now Install update
133
- ```
134
-
135
- ### Findings & Reports
136
- ```bash
137
- /findings Show discovered findings
138
- /report Generate pentest report
139
- ```
140
-
141
- ### Utility
142
- ```bash
143
- /paste Paste from clipboard (text or image)
144
- /yolo Toggle auto-approve mode
145
- /clear Clear screen
146
- /exit Exit
147
- /y /n /ya Approve/Deny/Always approve (for pending tools)
148
- ```
49
+ - **Soul Architecture** - ReAct pattern: Think → Act → Observe → Reflect
50
+ - **9 Specialized Agents** - Recon, Exploit, PrivEsc, Web, Crypto...
51
+ - **80%+ Confidence Filter** - Only high-confidence findings
52
+ - **D-Mail Time Travel** - Auto-recovery from dead ends
53
+ - **50+ Security Tools** - nmap, sqlmap, gobuster, hydra...
149
54
 
150
55
  ---
151
56
 
152
- ## Multi-Target Workflow
57
+ ## Commands
153
58
 
154
- ```bash
155
- # Start pentesting CLI
156
- pentesting
157
-
158
- # Register multiple targets
159
- /target add example1.com
160
- /target add example2.com
161
- /target add 192.168.1.1
162
- /target add internal.corp
163
-
164
- # View registered targets
165
- /target list
166
- Targets (4):
167
- 1. * example1.com (primary)
168
- 2. example2.com
169
- 3. 192.168.1.1
170
- 4. internal.corp
171
-
172
- # Attack all targets sequentially
173
- /start all
174
-
175
- Starting multi-target attack on 4 targets
176
-
177
- --- [1/4] example1.com ---
178
- Session: session-1707325423
179
- ... reconnaissance & exploitation ...
180
-
181
- --- [2/4] example2.com ---
182
- ...
183
-
184
- # Press ESC to stop between targets
185
- Stopped at target 2/4
186
-
187
- Complete
188
- ```
59
+ | Command | Description |
60
+ |---------|-------------|
61
+ | `/target <ip>` | Set target |
62
+ | `/start [objective]` | Start autonomous pentest |
63
+ | `/findings` | Show findings |
64
+ | `/status` | Status |
65
+ | `/yolo` | Toggle auto-approve |
66
+ | `/help` | Help |
189
67
 
190
68
  ---
191
69
 
192
- ## 🤖 AI Agents
193
-
194
- Pentesting automatically switches between specialized AI agents based on the current attack phase:
195
-
196
- | Phase | Agent | What it does |
197
- |-------|-------|--------------|
198
- | Reconnaissance | **Recon Agent** | Discovers hosts, ports, services, subdomains |
199
- | Web Scanning | **Web Agent** | Tests for OWASP Top 10, SQLi, XSS, SSRF |
200
- | Exploitation | **Exploit Agent** | Researches CVEs, selects and runs exploits |
201
- | Privilege Escalation | **PrivEsc Agent** | Finds SUID, sudo misconfigs, kernel exploits |
202
- | Data Extraction | **Crypto Agent** | Cracks hashes, analyzes encryption |
203
-
204
- ### How it works
205
-
206
- 1. **You set a target** → Agent starts in Recon mode
207
- 2. **Finds web services** → Automatically switches to Web Agent
208
- 3. **Discovers vulnerability** → Switches to Exploit Agent
209
- 4. **Gets shell access** → Switches to PrivEsc Agent
210
- 5. **Finds password hashes** → Crypto Agent takes over
211
-
212
- > No manual agent switching needed. The system automatically picks the best agent for each situation.
213
-
214
- ---
215
-
216
- ## ⚙️ Configuration
217
-
218
- ### Environment Variables
219
-
220
- | Variable | Description | Default |
221
- |----------|-------------|---------|
222
- | `PENTEST_API_KEY` | LLM API key | Required |
223
- | `PENTEST_BASE_URL` | API endpoint URL | - |
224
- | `PENTEST_MODEL` | Model name | claude-sonnet-4-20250514 |
225
- | `PENTEST_MAX_TOKENS` | Max response tokens | 16384 |
226
- | `PENTESTING_DOCKER` | Force Docker execution | 0 |
227
- | `PENTESTING_CONTAINER` | Docker container name | pentesting-tools |
228
-
229
- > **Note**: `ANTHROPIC_API_KEY` is also accepted as fallback for `PENTEST_API_KEY`.
230
-
231
-
232
- ---
233
-
234
- ## 💻 For Developers
235
-
236
- Pentesting can be used as a library in your own projects. See [Architecture Docs](./docs/architecture.md) for:
237
- - API Reference
238
- - Event System
239
- - Custom Agent Integration
240
-
241
- ---
242
-
243
- ## 🐳 Docker Toolkit (Auto-Managed)
244
-
245
- Pentesting automatically manages a Docker container with 50+ pre-installed tools.
246
-
247
- ### Automatic Setup
248
-
249
- **No manual Docker setup required!** When you run a command that needs tools like `nmap` or `rustscan`:
250
-
251
- 1. Pentesting checks if tool exists locally
252
- 2. If not, it automatically pulls `agnusdei1207/pentesting-tools:latest`
253
- 3. Starts container `pentesting-tools` with host network
254
- 4. Executes command via `docker exec`
255
-
256
- ### Manual Docker Control
257
-
258
- ```bash
259
- # Force all commands through Docker
260
- export PENTESTING_DOCKER=1
261
-
262
- # Use custom container name
263
- export PENTESTING_CONTAINER=my-pentest-container
264
-
265
- # Manual pull (optional - auto-pulled on first use)
266
- docker pull agnusdei1207/pentesting-tools:latest
267
- ```
268
-
269
- ### Included Tools (50+)
270
-
271
- | Category | Tools |
272
- |----------|-------|
273
- | **Network** | nmap, rustscan, masscan, netcat, tcpdump |
274
- | **Web** | ffuf, nikto, sqlmap, httpx, whatweb |
275
- | **Discovery** | subfinder, amass, nuclei, dnsrecon |
276
- | **Bruteforce** | hydra, hashcat, john |
277
- | **AD/Windows** | impacket, crackmapexec, smbclient |
278
- | **Database** | mysql-client, postgresql-client, redis-tools |
279
- | **Utilities** | curl, wget, jq, python3, go |
280
-
281
- ---
282
-
283
- ## 🔌 MCP Integration
284
-
285
- Pentesting supports MCP (Model Context Protocol) for extending capabilities with additional tools and servers. See [Architecture Docs](./docs/architecture.md) for integration details.
286
-
287
- ---
288
-
289
- ## 🏗️ How It Works
290
-
291
- ```
292
- ┌──────────────────────────────────────────────┐
293
- │ Your Terminal │
294
- │ ┌────────────────────────────────────────┐ │
295
- │ │ pentesting CLI (Interactive TUI) │ │
296
- │ │ - Target management │ │
297
- │ │ - Session recording │ │
298
- │ │ - Real-time output │ │
299
- │ └────────────────────────────────────────┘ │
300
- └─────────────────────┬────────────────────────┘
301
-
302
- ┌──────────────────────────────────────────────┐
303
- │ AI Agent Core │
304
- │ ┌────────────────────────────────────────┐ │
305
- │ │ 5 Specialized Agents (auto-switching) │ │
306
- │ │ Recon → Web → Exploit → PrivEsc → Crypto│
307
- │ └────────────────────────────────────────┘ │
308
- └─────────────────────┬────────────────────────┘
309
-
310
- ┌──────────────────────────────────────────────┐
311
- │ Tool Execution │
312
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
313
- │ │ Docker │ │ Local │ │ MCP │ │
314
- │ │ (50+ │ │ Tools │ │ Servers │ │
315
- │ │ tools) │ │ │ │ │ │
316
- │ └──────────┘ └──────────┘ └──────────┘ │
317
- └──────────────────────────────────────────────┘
318
- ```
319
-
320
- ---
321
-
322
- ## 🛠️ Development
323
-
324
- ```bash
325
- # Clone
326
- git clone https://github.com/agnusdei1207/pentesting.git
327
- cd pentesting
328
-
329
- # Install
330
- npm install
331
-
332
- # Build
333
- npm run build
334
-
335
- # Dev mode
336
- npm run dev
337
- ```
338
-
339
70
  ## Documentation
340
71
 
341
- - [Architecture](./docs/ARCHITECTURE.md) - System design and components
342
- - [Docker Image](https://hub.docker.com/r/agnusdei1207/pentesting-tools) - Pre-built security tools
72
+ - [Architecture](docs/architecture.md)
73
+ - [API Reference](docs/api-reference.md)
74
+ - [Troubleshooting](docs/troubleshooting.md)
343
75
 
344
76
  ---
345
77
 
346
- ## 📄 License
78
+ ## License
347
79
 
348
80
  MIT
81
+
82
+ ⚠️ **For authorized security testing only.**
@@ -8,8 +8,8 @@ import {
8
8
  readVersionCache,
9
9
  semverTuple,
10
10
  writeVersionCache
11
- } from "./chunk-AIBIXGJI.js";
12
- import "./chunk-5QWIIPHH.js";
11
+ } from "./chunk-N27ISRFF.js";
12
+ import "./chunk-IYELGZKK.js";
13
13
  import "./chunk-3RG5ZIWI.js";
14
14
  export {
15
15
  checkForUpdate,
@@ -186,7 +186,7 @@ var SENSITIVE_TOOLS = [
186
186
 
187
187
  // src/config/constants.ts
188
188
  import { createRequire } from "module";
189
- var pkgVersion = "0.7.48";
189
+ var pkgVersion = "0.8.0";
190
190
  try {
191
191
  const require2 = createRequire(import.meta.url);
192
192
  const pkg = require2("../../package.json");
@@ -200,6 +200,14 @@ var LLM_API_KEY = process.env.PENTEST_API_KEY || process.env.ANTHROPIC_API_KEY |
200
200
  var LLM_BASE_URL = process.env.PENTEST_BASE_URL || void 0;
201
201
  var LLM_MODEL = process.env.PENTEST_MODEL || "claude-sonnet-4-20250514";
202
202
  var LLM_MAX_TOKENS = parseInt(process.env.PENTEST_MAX_TOKENS || "16384", 10);
203
+ var CONTEXT_WINDOW = {
204
+ maxTokens: 2e5,
205
+ // Claude's context window size
206
+ compactionThreshold: 15e4,
207
+ // Trigger compaction at 75% usage
208
+ reservedTokens: 4e3
209
+ // Reserved for system prompt
210
+ };
203
211
  var AGENT_CONFIG = {
204
212
  maxIterations: 200,
205
213
  maxToolCallsPerIteration: 10,
@@ -240,5 +248,6 @@ export {
240
248
  LLM_BASE_URL,
241
249
  LLM_MODEL,
242
250
  LLM_MAX_TOKENS,
251
+ CONTEXT_WINDOW,
243
252
  AGENT_CONFIG
244
253
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  APP_NAME,
3
3
  APP_VERSION
4
- } from "./chunk-5QWIIPHH.js";
4
+ } from "./chunk-IYELGZKK.js";
5
5
 
6
6
  // src/core/update/auto-update.ts
7
7
  import { execSync } from "child_process";
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  APP_DESCRIPTION,
7
7
  APP_VERSION,
8
8
  CLI_COMMAND,
9
+ CONTEXT_WINDOW,
9
10
  LLM_API_KEY,
10
11
  LLM_BASE_URL,
11
12
  LLM_MAX_TOKENS,
@@ -15,7 +16,7 @@ import {
15
16
  PHASE_STATUS,
16
17
  THOUGHT_TYPE,
17
18
  TOOL_NAME
18
- } from "./chunk-5QWIIPHH.js";
19
+ } from "./chunk-IYELGZKK.js";
19
20
  import {
20
21
  __require
21
22
  } from "./chunk-3RG5ZIWI.js";
@@ -3162,7 +3163,7 @@ function getHistoryTokens(messages) {
3162
3163
  return total + estimateTokens(content);
3163
3164
  }, 0);
3164
3165
  }
3165
- function needsCompaction(messages, maxTokens = 15e4, minMessages = 10) {
3166
+ function needsCompaction(messages, maxTokens = CONTEXT_WINDOW.compactionThreshold, minMessages = 10) {
3166
3167
  if (messages.length < minMessages) return false;
3167
3168
  return getHistoryTokens(messages) > maxTokens;
3168
3169
  }
@@ -3218,7 +3219,7 @@ var ContextManager = class {
3218
3219
  client;
3219
3220
  constructor(client, options) {
3220
3221
  this.client = client;
3221
- this.maxTokens = options?.maxTokens ?? 15e4;
3222
+ this.maxTokens = options?.maxTokens ?? CONTEXT_WINDOW.compactionThreshold;
3222
3223
  this.warningThreshold = options?.warningThreshold ?? 12e4;
3223
3224
  }
3224
3225
  /**
@@ -6983,7 +6984,7 @@ var App = ({ autoApprove = false, target }) => {
6983
6984
  setCheckpointCount(contextManagerRef.current?.getCheckpoints().length || 0);
6984
6985
  }
6985
6986
  });
6986
- import("./auto-update-FWXZGK5Z.js").then(({ checkForUpdateAsync, formatUpdateNotification }) => {
6987
+ import("./auto-update-NUVK35LG.js").then(({ checkForUpdateAsync, formatUpdateNotification }) => {
6987
6988
  checkForUpdateAsync().then((result) => {
6988
6989
  if (result.hasUpdate) {
6989
6990
  const notification = formatUpdateNotification(result);
@@ -7686,7 +7687,7 @@ ${list}`);
7686
7687
  return;
7687
7688
  case "update":
7688
7689
  try {
7689
- const { checkForUpdate, formatUpdateNotification, doUpdate } = await import("./update-OD3N757W.js");
7690
+ const { checkForUpdate, formatUpdateNotification, doUpdate } = await import("./update-VGGUNUWQ.js");
7690
7691
  const result = checkForUpdate(true);
7691
7692
  if (result.hasUpdate) {
7692
7693
  const notification = formatUpdateNotification(result);
@@ -8,8 +8,8 @@ import {
8
8
  readVersionCache,
9
9
  semverTuple,
10
10
  writeVersionCache
11
- } from "./chunk-AIBIXGJI.js";
12
- import "./chunk-5QWIIPHH.js";
11
+ } from "./chunk-N27ISRFF.js";
12
+ import "./chunk-IYELGZKK.js";
13
13
  import "./chunk-3RG5ZIWI.js";
14
14
  export {
15
15
  checkForUpdate,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pentesting",
3
- "version": "0.7.49",
3
+ "version": "0.8.2",
4
4
  "description": "Autonomous Penetration Testing AI Agent",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -18,6 +18,8 @@
18
18
  "dev": "tsx src/index.tsx",
19
19
  "build": "tsup src/index.tsx --format esm --dts --clean",
20
20
  "start": "node dist/index.js",
21
+ "test": "vitest run",
22
+ "test:watch": "vitest",
21
23
  "lint": "tsc --noEmit",
22
24
  "prepublishOnly": "npm run build",
23
25
  "release:patch": "npm version patch && npm run build && npm publish",
@@ -78,6 +80,7 @@
78
80
  "@types/react": "^18.3.18",
79
81
  "tsup": "^8.3.6",
80
82
  "tsx": "^4.19.2",
81
- "typescript": "^5.7.3"
83
+ "typescript": "^5.7.3",
84
+ "vitest": "^4.0.18"
82
85
  }
83
86
  }