pentesting 0.3.1 → 0.4.0

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.
@@ -0,0 +1,24 @@
1
+ import {
2
+ checkForUpdate,
3
+ checkForUpdateAsync,
4
+ compareSemver,
5
+ doUpdate,
6
+ fetchLatestVersion,
7
+ formatUpdateNotification,
8
+ readVersionCache,
9
+ semverTuple,
10
+ writeVersionCache
11
+ } from "./chunk-LZGHM27D.js";
12
+ import "./chunk-IU6YJKJT.js";
13
+ import "./chunk-3RG5ZIWI.js";
14
+ export {
15
+ checkForUpdate,
16
+ checkForUpdateAsync,
17
+ compareSemver,
18
+ doUpdate,
19
+ fetchLatestVersion,
20
+ formatUpdateNotification,
21
+ readVersionCache,
22
+ semverTuple,
23
+ writeVersionCache
24
+ };
@@ -0,0 +1,10 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ export {
9
+ __require
10
+ };
@@ -0,0 +1,182 @@
1
+ // src/config/agent-constants.ts
2
+ var AGENT_STATUS = {
3
+ IDLE: "idle",
4
+ RUNNING: "running",
5
+ PAUSED: "paused",
6
+ STUCK: "stuck",
7
+ WAITING_INPUT: "waiting_input",
8
+ COMPLETED: "completed"
9
+ };
10
+ var PHASE_ID = {
11
+ RECON: "recon",
12
+ SCAN: "scan",
13
+ ENUM: "enum",
14
+ VULN: "vuln",
15
+ EXPLOIT: "exploit",
16
+ PRIVESC: "privesc",
17
+ PIVOT: "pivot",
18
+ PERSIST: "persist",
19
+ EXFIL: "exfil",
20
+ REPORT: "report"
21
+ };
22
+ var PHASE_STATUS = {
23
+ PENDING: "pending",
24
+ IN_PROGRESS: "in_progress",
25
+ COMPLETED: "completed",
26
+ FAILED: "failed",
27
+ SKIPPED: "skipped"
28
+ };
29
+ var THOUGHT_TYPE = {
30
+ OBSERVATION: "observation",
31
+ HYPOTHESIS: "hypothesis",
32
+ PLAN: "plan",
33
+ ACTION: "action",
34
+ RESULT: "result",
35
+ REFLECTION: "reflection",
36
+ STUCK: "stuck",
37
+ BREAKTHROUGH: "breakthrough"
38
+ };
39
+ var AGENT_EVENT = {
40
+ // Lifecycle
41
+ PLUGINS_LOADED: "plugins_loaded",
42
+ HOOKS_LOADED: "hooks_loaded",
43
+ COMMANDS_LOADED: "commands_loaded",
44
+ MCP_SERVER_ADDED: "mcp_server_added",
45
+ // Execution
46
+ ITERATION: "iteration",
47
+ THOUGHT: "thought",
48
+ RESPONSE: "response",
49
+ TOOL_CALL: "tool_call",
50
+ TOOL_RESULT: "tool_result",
51
+ COMMAND_EXECUTE: "command_execute",
52
+ APPROVAL_NEEDED: "approval_needed",
53
+ TOKEN_USAGE: "token_usage",
54
+ // State changes
55
+ TARGET_SET: "target_set",
56
+ PHASE_CHANGE: "phase_change",
57
+ AGENT_SWITCH: "agent_switch",
58
+ PAUSED: "paused",
59
+ RESUMED: "resumed",
60
+ RESET: "reset",
61
+ // Discoveries
62
+ FINDING: "finding",
63
+ CREDENTIAL: "credential",
64
+ COMPROMISED: "compromised",
65
+ // Completion
66
+ COMPLETE: "complete",
67
+ REPORT: "report",
68
+ ERROR: "error",
69
+ HINT_RECEIVED: "hint_received",
70
+ CONTEXT_COMPACTED: "context_compacted"
71
+ };
72
+ var CLI_COMMAND = {
73
+ HELP: "help",
74
+ TARGET: "target",
75
+ START: "start",
76
+ STOP: "stop",
77
+ FINDINGS: "findings",
78
+ CLEAR: "clear",
79
+ EXIT: "exit"
80
+ };
81
+ var MESSAGE_TYPE = {
82
+ USER: "user",
83
+ ASSISTANT: "assistant",
84
+ TOOL: "tool",
85
+ THINKING: "thinking",
86
+ ERROR: "error",
87
+ SYSTEM: "system",
88
+ RESULT: "result"
89
+ };
90
+ var TOOL_NAME = {
91
+ // System
92
+ BASH: "bash",
93
+ READ_FILE: "read_file",
94
+ WRITE_FILE: "write_file",
95
+ LIST_DIRECTORY: "list_directory",
96
+ // Network
97
+ NMAP_SCAN: "nmap_scan",
98
+ TCPDUMP_CAPTURE: "tcpdump_capture",
99
+ // Web
100
+ WEB_REQUEST: "web_request",
101
+ DIRECTORY_BRUTEFORCE: "directory_bruteforce",
102
+ SQL_INJECTION: "sql_injection",
103
+ BROWSER_AUTOMATION: "browser_automation",
104
+ // Exploit
105
+ SEARCHSPLOIT: "searchsploit",
106
+ METASPLOIT: "metasploit",
107
+ GENERATE_PAYLOAD: "generate_payload",
108
+ // Credential
109
+ BRUTEFORCE_LOGIN: "bruteforce_login",
110
+ CRACK_HASH: "crack_hash",
111
+ DUMP_CREDENTIALS: "dump_credentials",
112
+ // Privilege Escalation
113
+ CHECK_SUDO: "check_sudo",
114
+ FIND_SUID: "find_suid",
115
+ RUN_PRIVESC_ENUM: "run_privesc_enum",
116
+ // Post-Exploitation
117
+ SETUP_TUNNEL: "setup_tunnel",
118
+ LATERAL_MOVEMENT: "lateral_movement",
119
+ // Reporting
120
+ REPORT_FINDING: "report_finding",
121
+ TAKE_SCREENSHOT: "take_screenshot"
122
+ };
123
+ var SENSITIVE_TOOLS = [
124
+ TOOL_NAME.WRITE_FILE,
125
+ TOOL_NAME.BRUTEFORCE_LOGIN,
126
+ TOOL_NAME.METASPLOIT,
127
+ TOOL_NAME.SQL_INJECTION,
128
+ TOOL_NAME.DUMP_CREDENTIALS,
129
+ TOOL_NAME.GENERATE_PAYLOAD,
130
+ TOOL_NAME.LATERAL_MOVEMENT
131
+ ];
132
+
133
+ // src/config/constants.ts
134
+ var APP_NAME = "pentesting";
135
+ var APP_VERSION = "0.4.0";
136
+ var APP_DESCRIPTION = "Autonomous Penetration Testing AI Agent";
137
+ var LLM_API_KEY = process.env.PENTEST_API_KEY || process.env.ANTHROPIC_API_KEY || "";
138
+ var LLM_BASE_URL = process.env.PENTEST_BASE_URL || void 0;
139
+ var LLM_MODEL = process.env.PENTEST_MODEL || "claude-sonnet-4-20250514";
140
+ var LLM_MAX_TOKENS = parseInt(process.env.PENTEST_MAX_TOKENS || "16384", 10);
141
+ var AGENT_CONFIG = {
142
+ maxIterations: 200,
143
+ maxToolCallsPerIteration: 10,
144
+ autoApprove: false,
145
+ sensitiveTools: SENSITIVE_TOOLS,
146
+ defaultTimeout: 6e4,
147
+ longRunningTimeout: 6e5,
148
+ stuckThreshold: 5,
149
+ stuckTimeThreshold: 3e5,
150
+ maxPhaseAttempts: 20
151
+ };
152
+ var PENTEST_PHASES = [
153
+ { id: PHASE_ID.RECON, name: "Reconnaissance", description: "Information gathering" },
154
+ { id: PHASE_ID.SCAN, name: "Scanning", description: "Port and service scanning" },
155
+ { id: PHASE_ID.ENUM, name: "Enumeration", description: "Deep service enumeration" },
156
+ { id: PHASE_ID.VULN, name: "Vulnerability Analysis", description: "Vulnerability identification" },
157
+ { id: PHASE_ID.EXPLOIT, name: "Exploitation", description: "Gaining access" },
158
+ { id: PHASE_ID.PRIVESC, name: "Privilege Escalation", description: "Elevating privileges" },
159
+ { id: PHASE_ID.PIVOT, name: "Pivoting", description: "Lateral movement" },
160
+ { id: PHASE_ID.PERSIST, name: "Persistence", description: "Maintaining access" },
161
+ { id: PHASE_ID.EXFIL, name: "Data Exfiltration", description: "Data extraction" },
162
+ { id: PHASE_ID.REPORT, name: "Reporting", description: "Documentation" }
163
+ ];
164
+
165
+ export {
166
+ AGENT_STATUS,
167
+ PHASE_ID,
168
+ PHASE_STATUS,
169
+ THOUGHT_TYPE,
170
+ AGENT_EVENT,
171
+ CLI_COMMAND,
172
+ MESSAGE_TYPE,
173
+ TOOL_NAME,
174
+ APP_NAME,
175
+ APP_VERSION,
176
+ APP_DESCRIPTION,
177
+ LLM_API_KEY,
178
+ LLM_BASE_URL,
179
+ LLM_MODEL,
180
+ LLM_MAX_TOKENS,
181
+ AGENT_CONFIG
182
+ };
@@ -0,0 +1,134 @@
1
+ import {
2
+ APP_NAME,
3
+ APP_VERSION
4
+ } from "./chunk-IU6YJKJT.js";
5
+
6
+ // src/core/update/auto-update.ts
7
+ import { execSync } from "child_process";
8
+ import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
9
+ import { join } from "path";
10
+ import { homedir } from "os";
11
+ var UPDATE_CHECK_INTERVAL = 24 * 60 * 60 * 1e3;
12
+ var VERSION_CACHE_FILE = join(homedir(), ".pentest", "latest_version.json");
13
+ function semverTuple(version) {
14
+ const match = version.match(/^(\d+)\.(\d+)\.(\d+)/);
15
+ if (!match) return [0, 0, 0];
16
+ return [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])];
17
+ }
18
+ function compareSemver(a, b) {
19
+ const [a1, a2, a3] = semverTuple(a);
20
+ const [b1, b2, b3] = semverTuple(b);
21
+ if (a1 !== b1) return a1 < b1 ? -1 : 1;
22
+ if (a2 !== b2) return a2 < b2 ? -1 : 1;
23
+ if (a3 !== b3) return a3 < b3 ? -1 : 1;
24
+ return 0;
25
+ }
26
+ function readVersionCache() {
27
+ try {
28
+ if (!existsSync(VERSION_CACHE_FILE)) return null;
29
+ const data = JSON.parse(readFileSync(VERSION_CACHE_FILE, "utf-8"));
30
+ return data;
31
+ } catch {
32
+ return null;
33
+ }
34
+ }
35
+ function writeVersionCache(info) {
36
+ try {
37
+ const dir = join(homedir(), ".pentest");
38
+ if (!existsSync(dir)) {
39
+ mkdirSync(dir, { recursive: true });
40
+ }
41
+ writeFileSync(VERSION_CACHE_FILE, JSON.stringify(info, null, 2));
42
+ } catch {
43
+ }
44
+ }
45
+ function fetchLatestVersion(packageName = APP_NAME) {
46
+ try {
47
+ const output = execSync(`npm view ${packageName} version`, {
48
+ encoding: "utf-8",
49
+ timeout: 1e4,
50
+ stdio: ["pipe", "pipe", "pipe"]
51
+ });
52
+ return output.trim();
53
+ } catch {
54
+ return null;
55
+ }
56
+ }
57
+ function checkForUpdate(forceCheck = false) {
58
+ const currentVersion = APP_VERSION;
59
+ const cached = readVersionCache();
60
+ const now = Date.now();
61
+ if (!forceCheck && cached && now - cached.checkedAt < UPDATE_CHECK_INTERVAL) {
62
+ const hasUpdate2 = compareSemver(cached.version, currentVersion) > 0;
63
+ return {
64
+ hasUpdate: hasUpdate2,
65
+ currentVersion,
66
+ latestVersion: cached.version
67
+ };
68
+ }
69
+ const latestVersion = fetchLatestVersion();
70
+ if (!latestVersion) {
71
+ return {
72
+ hasUpdate: false,
73
+ currentVersion,
74
+ latestVersion: null,
75
+ error: "Failed to fetch latest version"
76
+ };
77
+ }
78
+ writeVersionCache({
79
+ version: latestVersion,
80
+ checkedAt: now
81
+ });
82
+ const hasUpdate = compareSemver(latestVersion, currentVersion) > 0;
83
+ return {
84
+ hasUpdate,
85
+ currentVersion,
86
+ latestVersion
87
+ };
88
+ }
89
+ async function checkForUpdateAsync() {
90
+ return new Promise((resolve) => {
91
+ setImmediate(() => {
92
+ resolve(checkForUpdate());
93
+ });
94
+ });
95
+ }
96
+ function formatUpdateNotification(result) {
97
+ if (!result.hasUpdate || !result.latestVersion) return null;
98
+ return `
99
+ \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510
100
+ \u2502 \u{1F195} A new version of ${APP_NAME} is available! \u2502
101
+ \u2502 \u2502
102
+ \u2502 Current: ${result.currentVersion.padEnd(10)} Latest: ${result.latestVersion.padEnd(10)} \u2502
103
+ \u2502 \u2502
104
+ \u2502 Run: npm update -g ${APP_NAME} \u2502
105
+ \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518
106
+ `.trim();
107
+ }
108
+ function doUpdate() {
109
+ try {
110
+ execSync(`npm update -g ${APP_NAME}`, {
111
+ encoding: "utf-8",
112
+ timeout: 12e4,
113
+ stdio: "inherit"
114
+ });
115
+ return { success: true, message: `Updated ${APP_NAME} successfully!` };
116
+ } catch (e) {
117
+ return {
118
+ success: false,
119
+ message: `Failed to update: ${e instanceof Error ? e.message : String(e)}`
120
+ };
121
+ }
122
+ }
123
+
124
+ export {
125
+ semverTuple,
126
+ compareSemver,
127
+ readVersionCache,
128
+ writeVersionCache,
129
+ fetchLatestVersion,
130
+ checkForUpdate,
131
+ checkForUpdateAsync,
132
+ formatUpdateNotification,
133
+ doUpdate
134
+ };