pentesting 0.73.2 → 0.73.4

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.
@@ -1,331 +0,0 @@
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
- // src/shared/constants/system/process.ts
9
- var EXIT_CODES = {
10
- /** Successful execution */
11
- SUCCESS: 0,
12
- /** General error */
13
- GENERAL_ERROR: 1,
14
- /** Command not found */
15
- COMMAND_NOT_FOUND: 127,
16
- /** Process killed by SIGALRM (timeout) */
17
- TIMEOUT: 124,
18
- /** Process killed by SIGINT (Ctrl+C) */
19
- SIGINT: 130,
20
- /** Process killed by SIGTERM */
21
- SIGTERM: 143,
22
- /** Process killed by SIGKILL */
23
- SIGKILL: 137,
24
- /** Invalid or missing configuration (Unix EX_CONFIG convention = 78) */
25
- CONFIG_ERROR: 78
26
- };
27
- var PROCESS_ACTIONS = {
28
- LIST: "list",
29
- STATUS: "status",
30
- INTERACT: "interact",
31
- PROMOTE: "promote",
32
- STOP: "stop",
33
- STOP_ALL: "stop_all"
34
- };
35
- var PROCESS_ROLES = {
36
- LISTENER: "listener",
37
- ACTIVE_SHELL: "active_shell",
38
- SERVER: "server",
39
- SNIFFER: "sniffer",
40
- SPOOFER: "spoofer",
41
- CALLBACK: "callback",
42
- PROXY: "proxy",
43
- BACKGROUND: "background"
44
- };
45
- var PROCESS_ICONS = {
46
- [PROCESS_ROLES.LISTENER]: "[LISTENER]",
47
- [PROCESS_ROLES.ACTIVE_SHELL]: "[SHELL]",
48
- [PROCESS_ROLES.SERVER]: "[SERVER]",
49
- [PROCESS_ROLES.SNIFFER]: "[SNIFFER]",
50
- [PROCESS_ROLES.SPOOFER]: "[SPOOFER]",
51
- [PROCESS_ROLES.CALLBACK]: "[CALLBACK]",
52
- [PROCESS_ROLES.PROXY]: "[PROXY]",
53
- [PROCESS_ROLES.BACKGROUND]: "[BG]"
54
- };
55
- var STATUS_MARKERS = {
56
- RUNNING: "[RUNNING]",
57
- STOPPED: "[STOPPED]",
58
- WARNING: "[WARNING]",
59
- INFO: "[INFO]",
60
- INTERACTIVE: "[INTERACTIVE]",
61
- EXITED: "[EXITED]"
62
- };
63
- var PROCESS_EVENTS = {
64
- STARTED: "started",
65
- CONNECTION_DETECTED: "connection_detected",
66
- ROLE_CHANGED: "role_changed",
67
- COMMAND_SENT: "command_sent",
68
- STOPPED: "stopped",
69
- DIED: "died",
70
- ZOMBIE_CLEANED: "zombie_cleaned"
71
- };
72
- var PROCESS_LIMITS = {
73
- GRACEFUL_SHUTDOWN_WAIT_MS: 200,
74
- OUTPUT_TRUNCATION_LIMIT: 1e4
75
- // characters
76
- };
77
-
78
- // src/agents/pipeline-config.ts
79
- import { readFileSync, existsSync } from "fs";
80
- import { join } from "path";
81
- import { parse as yamlParse } from "yaml";
82
- var PROJECT_ROOT = process.cwd();
83
- var _config = null;
84
- function getPipelineConfig() {
85
- if (_config) return _config;
86
- const yamlPath = join(PROJECT_ROOT, "pipeline.yaml");
87
- const content = readFileSync(yamlPath, "utf-8");
88
- _config = yamlParse(content);
89
- return _config;
90
- }
91
- function resolvePromptFile(declaredPath, context) {
92
- const filePath = join(PROJECT_ROOT, declaredPath);
93
- if (!existsSync(filePath)) {
94
- throw new Error(
95
- `[pipeline.yaml] ${context} points to "${declaredPath}" which does not exist at ${filePath}.`
96
- );
97
- }
98
- return readFileSync(filePath, "utf-8").trim();
99
- }
100
- function llmNodeSystemPrompt(nodeName) {
101
- const nodeConfig = getPipelineConfig().llm_nodes?.[nodeName];
102
- if (!nodeConfig) {
103
- throw new Error(
104
- `[pipeline.yaml] llm_nodes.${nodeName} is not declared. Add it to pipeline.yaml.`
105
- );
106
- }
107
- if (nodeConfig.system_prompt_file) {
108
- return resolvePromptFile(
109
- nodeConfig.system_prompt_file,
110
- `llm_nodes.${nodeName}.system_prompt_file`
111
- );
112
- }
113
- if (nodeConfig.fallback_system_prompt_file) {
114
- return resolvePromptFile(
115
- nodeConfig.fallback_system_prompt_file,
116
- `llm_nodes.${nodeName}.fallback_system_prompt_file`
117
- );
118
- }
119
- if (nodeConfig.system_prompt) {
120
- return nodeConfig.system_prompt.trim();
121
- }
122
- if (nodeConfig.fallback_system_prompt) {
123
- return nodeConfig.fallback_system_prompt.trim();
124
- }
125
- throw new Error(
126
- `[pipeline.yaml] llm_nodes.${nodeName} must declare system_prompt_file, fallback_system_prompt_file, or system_prompt. Add one to pipeline.yaml.`
127
- );
128
- }
129
- function llmNodeOutputParsing(nodeName) {
130
- return getPipelineConfig().llm_nodes?.[nodeName]?.output_parsing;
131
- }
132
- function llmNodeCooldownPolicy(nodeName) {
133
- const policy = getPipelineConfig().llm_nodes?.[nodeName]?.cooldown_policy;
134
- if (!policy) {
135
- throw new Error(
136
- `[pipeline.yaml] llm_nodes.${nodeName}.cooldown_policy is required but not set. Add it to pipeline.yaml.`
137
- );
138
- }
139
- return policy;
140
- }
141
- function getPromptSources() {
142
- const sources = getPipelineConfig().prompt_sources;
143
- if (!sources) {
144
- throw new Error(
145
- `[pipeline.yaml] prompt_sources section is required but not found. Add it to pipeline.yaml.`
146
- );
147
- }
148
- return sources;
149
- }
150
- function getLimits() {
151
- const limits = getPipelineConfig().limits;
152
- if (!limits) {
153
- throw new Error(
154
- `[pipeline.yaml] limits section is required but not found. Add it to pipeline.yaml.`
155
- );
156
- }
157
- return limits;
158
- }
159
- function getPromptBuilderConfig() {
160
- return getPipelineConfig().prompt_builder ?? {};
161
- }
162
-
163
- // src/shared/constants/system/limits.ts
164
- var _msgLimits = getLimits().messages ?? {};
165
- var SYSTEM_LIMITS = {
166
- /** Maximum wait time for interactive shell responses (10 seconds) */
167
- MAX_WAIT_MS_INTERACT: 1e4,
168
- /** Default wait time for interactive shell responses (2 seconds) */
169
- DEFAULT_WAIT_MS_INTERACT: 2e3,
170
- /** Maximum characters for process description */
171
- MAX_DESCRIPTION_LENGTH: 80,
172
- /** Maximum characters for stored command string */
173
- MAX_COMMAND_LENGTH: 200,
174
- /** Maximum characters to show from stdout
175
- * WHY 50K: background processes (linpeas, scans, shells) produce large
176
- * output with findings scattered throughout. Let the LLM see it all. */
177
- MAX_STDOUT_SLICE: 5e4,
178
- /** Maximum characters to show from stderr */
179
- MAX_STDERR_SLICE: 5e3,
180
- /** Maximum characters for error detail messages */
181
- MAX_ERROR_DETAIL_SLICE: 2e3,
182
- /** Maximum characters for input prompt previews */
183
- MAX_PROMPT_PREVIEW: 50,
184
- /** Maximum characters for input snippets in logs */
185
- MAX_INPUT_SLICE: 100,
186
- /** Maximum events to keep in process event log */
187
- MAX_EVENT_LOG: 30,
188
- /** Wait time for child PID discovery via pgrep */
189
- CHILD_PID_DISCOVERY_MS: 500,
190
- /** Wait time between SIGTERM and SIGKILL during graceful shutdown */
191
- SHUTDOWN_WAIT_MS: 500,
192
- /** Wait time between process cleanup batches */
193
- CLEANUP_BATCH_WAIT_MS: 300,
194
- /** Timeout for pgrep and pkill operations */
195
- PROCESS_OP_TIMEOUT_MS: 2e3,
196
- /** Port range for web services (development servers) */
197
- WEB_PORT_RANGE: { MIN: 8e3, MAX: 9e3 },
198
- /** Port range for API services */
199
- API_PORT_RANGE: { MIN: 3e3, MAX: 3500 },
200
- /** Number of recent events to fetch for resource summary */
201
- RECENT_EVENTS_IN_SUMMARY: 10,
202
- /** Number of events to display in resource summary */
203
- RECENT_EVENTS_DISPLAY: 5,
204
- /** Number of recent output lines to show per process */
205
- RECENT_OUTPUT_LINES: 3,
206
- /** Maximum characters per message for context extraction.
207
- * pipeline.yaml: limits.messages.context_extractor_per_msg_limit */
208
- CONTEXT_EXTRACTOR_LIMIT: _msgLimits.context_extractor_per_msg_limit
209
- };
210
-
211
- // src/shared/constants/system/detection.ts
212
- var DETECTION_PATTERNS = {
213
- LISTENER: /-(?:lvnp|nlvp|lp|p)\s+(\d+)/,
214
- HTTP_SERVER: /(?:http\.server|SimpleHTTPServer)\s+(\d+)/,
215
- GENERIC_PORT: /-(?:p|port|S)\s+(?:\S+:)?(\d+)/,
216
- CONNECTION: [
217
- /connection\s+from/i,
218
- /connect\s+to/i,
219
- /\$\s*$/m,
220
- /#\s*$/m,
221
- /bash-\d/i,
222
- /sh-\d/i,
223
- /www-data/i
224
- ]
225
- };
226
- var ORPHAN_PROCESS_NAMES = [
227
- "arpspoof",
228
- "ettercap",
229
- "mitmdump",
230
- "mitmproxy",
231
- "dnsspoof",
232
- "tcpdump",
233
- "tshark",
234
- "socat"
235
- ];
236
-
237
- // src/shared/constants/system/health.ts
238
- var HEALTH_CONFIG = {
239
- LONG_RUNNING_THRESHOLD_MS: 3e5,
240
- // 5 minutes
241
- VERY_LONG_RUNNING_THRESHOLD_MS: 9e5,
242
- // 15 minutes
243
- MAX_RECOMMENDATIONS_FOR_HEALTHY: 2
244
- };
245
-
246
- // src/engine/process/process-registry.ts
247
- var backgroundProcesses = /* @__PURE__ */ new Map();
248
- var processEventLog = [];
249
- function logEvent(processId, event, detail) {
250
- processEventLog.push({ timestamp: Date.now(), processId, event, detail });
251
- if (processEventLog.length > SYSTEM_LIMITS.MAX_EVENT_LOG) {
252
- processEventLog.splice(0, processEventLog.length - SYSTEM_LIMITS.MAX_EVENT_LOG);
253
- }
254
- }
255
- function getProcess(processId) {
256
- return backgroundProcesses.get(processId);
257
- }
258
- function setProcess(processId, process2) {
259
- backgroundProcesses.set(processId, process2);
260
- }
261
- function deleteProcess(processId) {
262
- return backgroundProcesses.delete(processId);
263
- }
264
- function hasProcess(processId) {
265
- return backgroundProcesses.has(processId);
266
- }
267
- function getAllProcessIds() {
268
- return Array.from(backgroundProcesses.keys());
269
- }
270
- function getAllProcesses() {
271
- return backgroundProcesses.values();
272
- }
273
- function getProcessEntries() {
274
- return backgroundProcesses.entries();
275
- }
276
- function getProcessCount() {
277
- return backgroundProcesses.size;
278
- }
279
- function clearAllProcesses() {
280
- backgroundProcesses.clear();
281
- }
282
- function getProcessEventLog() {
283
- return [...processEventLog];
284
- }
285
- function getBackgroundProcessesMap() {
286
- return backgroundProcesses;
287
- }
288
- function getActiveProcessSummary() {
289
- const processes = Array.from(getAllProcesses());
290
- if (!processes.length) return "";
291
- return processes.filter((p) => !p.hasExited).map((p) => {
292
- const port = p.listeningPort ? ` port=${p.listeningPort}` : "";
293
- const interactive = p.isInteractive ? " interactive=true" : "";
294
- return `${p.id}: ${p.command} | role=${p.role}${port}${interactive}`;
295
- }).join("\n");
296
- }
297
-
298
- export {
299
- __require,
300
- EXIT_CODES,
301
- PROCESS_ACTIONS,
302
- PROCESS_ROLES,
303
- PROCESS_ICONS,
304
- STATUS_MARKERS,
305
- PROCESS_EVENTS,
306
- PROCESS_LIMITS,
307
- getPipelineConfig,
308
- llmNodeSystemPrompt,
309
- llmNodeOutputParsing,
310
- llmNodeCooldownPolicy,
311
- getPromptSources,
312
- getLimits,
313
- getPromptBuilderConfig,
314
- SYSTEM_LIMITS,
315
- DETECTION_PATTERNS,
316
- ORPHAN_PROCESS_NAMES,
317
- HEALTH_CONFIG,
318
- logEvent,
319
- getProcess,
320
- setProcess,
321
- deleteProcess,
322
- hasProcess,
323
- getAllProcessIds,
324
- getAllProcesses,
325
- getProcessEntries,
326
- getProcessCount,
327
- clearAllProcesses,
328
- getProcessEventLog,
329
- getBackgroundProcessesMap,
330
- getActiveProcessSummary
331
- };