pentesting 0.73.13 → 0.90.1

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 (70) hide show
  1. package/README.md +120 -44
  2. package/bin/pentesting.mjs +32 -0
  3. package/lib/runtime.mjs +419 -0
  4. package/package.json +17 -46
  5. package/scripts/postinstall.mjs +30 -0
  6. package/scripts/preflight-local.sh +24 -0
  7. package/dist/ad/prompt.md +0 -60
  8. package/dist/agent-tool-KHXXTHGS.js +0 -989
  9. package/dist/api/prompt.md +0 -63
  10. package/dist/chunk-4UNNRHYY.js +0 -5797
  11. package/dist/chunk-GILD75OT.js +0 -11407
  12. package/dist/chunk-S5ZMXFHR.js +0 -1162
  13. package/dist/cloud/prompt.md +0 -49
  14. package/dist/container/prompt.md +0 -58
  15. package/dist/database/prompt.md +0 -58
  16. package/dist/email/prompt.md +0 -44
  17. package/dist/file-sharing/prompt.md +0 -56
  18. package/dist/ics/prompt.md +0 -76
  19. package/dist/main.d.ts +0 -1
  20. package/dist/main.js +0 -9777
  21. package/dist/network/prompt.md +0 -49
  22. package/dist/persistence-U2N3KWFH.js +0 -13
  23. package/dist/process-registry-4Y3HB4YQ.js +0 -30
  24. package/dist/prompts/base.md +0 -436
  25. package/dist/prompts/ctf-crypto.md +0 -168
  26. package/dist/prompts/ctf-forensics.md +0 -182
  27. package/dist/prompts/ctf-pwn.md +0 -137
  28. package/dist/prompts/evasion.md +0 -215
  29. package/dist/prompts/exploit.md +0 -416
  30. package/dist/prompts/infra.md +0 -114
  31. package/dist/prompts/llm/analyst-system.md +0 -76
  32. package/dist/prompts/llm/context-extractor-system.md +0 -19
  33. package/dist/prompts/llm/input-processor-system.md +0 -64
  34. package/dist/prompts/llm/memory-synth-system.md +0 -14
  35. package/dist/prompts/llm/playbook-synthesizer-system.md +0 -10
  36. package/dist/prompts/llm/reflector-system.md +0 -16
  37. package/dist/prompts/llm/report-generator-system.md +0 -21
  38. package/dist/prompts/llm/strategist-fallback.md +0 -9
  39. package/dist/prompts/llm/triage-system.md +0 -47
  40. package/dist/prompts/main-agent.md +0 -193
  41. package/dist/prompts/offensive-playbook.md +0 -250
  42. package/dist/prompts/payload-craft.md +0 -181
  43. package/dist/prompts/post.md +0 -185
  44. package/dist/prompts/recon.md +0 -296
  45. package/dist/prompts/report.md +0 -98
  46. package/dist/prompts/strategist-system.md +0 -472
  47. package/dist/prompts/strategy.md +0 -163
  48. package/dist/prompts/techniques/README.md +0 -40
  49. package/dist/prompts/techniques/ad-attack.md +0 -261
  50. package/dist/prompts/techniques/auth-access.md +0 -256
  51. package/dist/prompts/techniques/container-escape.md +0 -103
  52. package/dist/prompts/techniques/crypto.md +0 -296
  53. package/dist/prompts/techniques/enterprise-pentest.md +0 -175
  54. package/dist/prompts/techniques/file-attacks.md +0 -144
  55. package/dist/prompts/techniques/forensics.md +0 -313
  56. package/dist/prompts/techniques/injection.md +0 -217
  57. package/dist/prompts/techniques/lateral.md +0 -128
  58. package/dist/prompts/techniques/network-svc.md +0 -229
  59. package/dist/prompts/techniques/pivoting.md +0 -205
  60. package/dist/prompts/techniques/privesc.md +0 -190
  61. package/dist/prompts/techniques/pwn.md +0 -595
  62. package/dist/prompts/techniques/reversing.md +0 -183
  63. package/dist/prompts/techniques/sandbox-escape.md +0 -73
  64. package/dist/prompts/techniques/shells.md +0 -194
  65. package/dist/prompts/vuln.md +0 -190
  66. package/dist/prompts/web.md +0 -318
  67. package/dist/prompts/zero-day.md +0 -298
  68. package/dist/remote-access/prompt.md +0 -52
  69. package/dist/web/prompt.md +0 -59
  70. package/dist/wireless/prompt.md +0 -62
@@ -1,1162 +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
- SHELL_STABILITY_CHECKED: "shell_stability_checked",
69
- SHELL_STABILITY_INCOMPLETE: "shell_stability_incomplete",
70
- SHELL_UPGRADE_ATTEMPTED: "shell_upgrade_attempted",
71
- SHELL_STABILIZED: "shell_stabilized",
72
- POST_EXPLOITATION_ACTIVITY: "post_exploitation_activity",
73
- STOPPED: "stopped",
74
- DIED: "died",
75
- ZOMBIE_CLEANED: "zombie_cleaned"
76
- };
77
- var PROCESS_LIMITS = {
78
- GRACEFUL_SHUTDOWN_WAIT_MS: 200,
79
- OUTPUT_TRUNCATION_LIMIT: 1e4
80
- // characters
81
- };
82
-
83
- // src/agents/runtime-config/llm-runtime.ts
84
- function defineRuntimeNode(node) {
85
- return node;
86
- }
87
- var RUNTIME_CONFIG_LLM_NODES = {
88
- input_processor: {
89
- role: "\uC785\uB825 \uC804\uCC98\uB9AC \u2014 direct response / main forward / policy merge",
90
- system_prompt_file: "src/agents/prompts/llm/input-processor-system.md",
91
- reads: [
92
- "user_input.raw",
93
- ".pentesting/memory/policy.md"
94
- ],
95
- writes: [
96
- "memory.input_processing"
97
- ]
98
- },
99
- strategist: {
100
- role: "\uC804\uC220 \uC9C0\uC2DC \uC0DD\uC131 \u2014 \uB9E4 pre-step, \uCFE8\uB2E4\uC6B4 \uC815\uCC45\uC73C\uB85C \uCE90\uC2DC",
101
- system_prompt_file: "src/agents/prompts/strategist-system.md",
102
- fallback_system_prompt_file: "src/agents/prompts/llm/strategist-fallback.md",
103
- reads: [
104
- "state.phase",
105
- "state.targets",
106
- "state.findings",
107
- "state.workingMemory",
108
- "state.attackGraph"
109
- ],
110
- writes: [
111
- "prompt_fragment.strategist_directive"
112
- ],
113
- cooldown_policy: {
114
- cache_ttl_ms: 18e4,
115
- stall_turns_threshold: 2,
116
- triggers: [
117
- "no_cached_directive",
118
- "phase_changed",
119
- "stall_detected",
120
- "cache_ttl_expired"
121
- ],
122
- on_cache_hit: "reuse_previous"
123
- }
124
- },
125
- main_llm: {
126
- role: "\uCD94\uB860 + \uB3C4\uAD6C \uC0AC\uC6A9 \u2014 CoreAgent.step \uB9E4 iteration",
127
- system_prompt: "prompt_builder",
128
- model_role: "orchestrator",
129
- reads: [
130
- "messages[]",
131
- "system_prompt"
132
- ],
133
- writes: [
134
- "messages[] (append)",
135
- "tool_calls",
136
- ".pentesting/workspace/tools/"
137
- ],
138
- limits: {
139
- max_tokens: 128e3,
140
- max_prompt_chars: 4e5
141
- }
142
- },
143
- analyst: {
144
- role: "\uB3C4\uAD6C \uCD9C\uB825 \uC18C\uD654 \u2014 \uB3C4\uAD6C \uC2E4\uD589 \uC9C1\uD6C4 \uC778\uB77C\uC778 \uD638\uCD9C",
145
- trigger: "per_tool_call",
146
- system_prompt_file: "src/agents/prompts/llm/analyst-system.md",
147
- reads: [
148
- "tool.raw_output",
149
- "tool.name",
150
- "state.phase"
151
- ],
152
- writes: [
153
- "tool_journal[].analystSummary (in-memory, append)"
154
- ],
155
- on_failure: "empty_summary"
156
- },
157
- context_extractor: {
158
- role: "\uB300\uD654 \uC555\uCD95 \u2014 \uB9E4 post-step, messages[] \uAD50\uCCB4",
159
- trigger: "post_step",
160
- input_formatter: "format_for_extraction",
161
- system_prompt_file: "src/agents/prompts/llm/context-extractor-system.md",
162
- reads: [
163
- "messages"
164
- ],
165
- writes: {
166
- memory: "extracted_context"
167
- },
168
- output_handling: {
169
- wrap: "<session-context>\n{value}\n</session-context>",
170
- write_target: "messages[]",
171
- write_mode: "replace_all",
172
- on_failure: "keep_existing"
173
- }
174
- },
175
- reflector: {
176
- role: "\uD134 \uC790\uAE30\uD3C9\uAC00 \u2014 \uB9E4 post-step, state.lastReflection\uC5D0 \uC800\uC7A5",
177
- trigger: "post_step",
178
- input_formatter: "format_reflection_input",
179
- system_prompt_file: "src/agents/prompts/llm/reflector-system.md",
180
- reads: [
181
- "tools",
182
- "memo",
183
- "phase"
184
- ],
185
- writes: {
186
- memory: "reflection"
187
- },
188
- output_handling: {
189
- extract_field: "reflection",
190
- write_target: "state.lastReflection",
191
- write_mode: "overwrite",
192
- inject_as: "<last-turn-review>\n{value}\n</last-turn-review>",
193
- on_failure: "empty_string"
194
- }
195
- },
196
- memory_synth: {
197
- role: "\uD134 \uBA54\uBAA8\uB9AC \uC791\uC131 \u2014 \uB9E4 \uD134 turn-recorder\uC5D0\uC11C \uD638\uCD9C",
198
- trigger: "after_turn_recorded",
199
- input_format: 'Previous insight:\\n{existing_summary}\\n\\nCurrent turn:\\n{turn_data}\n# \uCCAB \uD134: "First turn data:\\n{turn_data}"\n',
200
- system_prompt_file: "src/agents/prompts/llm/memory-synth-system.md",
201
- reads: [
202
- "previous_insight",
203
- "current_turn_data"
204
- ],
205
- writes: {
206
- disk: {
207
- path: ".pentesting/turns/{N}-memory.md",
208
- write_mode: "overwrite"
209
- }
210
- },
211
- on_failure: "fallback_concat"
212
- },
213
- playbook_synthesizer: {
214
- role: "\uACF5\uACA9 \uD328\uD134 \uCD94\uCD9C \u2014 SUCCEEDED \uB178\uB4DC >= N \uC2DC \uC870\uAC74\uBD80 \uC2E4\uD589",
215
- trigger: "conditional",
216
- condition: "has_exploit_chain",
217
- min_succeeded_nodes: 2,
218
- system_prompt_file: "src/agents/prompts/llm/playbook-synthesizer-system.md",
219
- input_format: "SERVICE PROFILE: {service_profile}\n\nSUCCEEDED ATTACK NODES:\n{node_lines}\n\nATTACK ACTIONS (edges):\n{edge_actions} (max 8 items)\n\nEXISTING SUMMARY (regex-based, for reference): {existing_chain_summary}\n",
220
- reads: [
221
- "attack_graph.succeeded_nodes",
222
- "attack_graph.succeeded_edges",
223
- "attack_graph.service_profile",
224
- "attack_graph.existing_chain_summary"
225
- ],
226
- output_parsing: {
227
- skip_if: "SKIP",
228
- max_chars: 120
229
- },
230
- writes: {
231
- disk: {
232
- path: ".pentesting/memory/persistent-knowledge.json",
233
- write_mode: "merge"
234
- }
235
- },
236
- on_failure: "skip"
237
- },
238
- report_generator: {
239
- role: "\uBCF4\uACE0\uC11C \uC0DD\uC131 \u2014 \uC0AC\uC6A9\uC790 \uC694\uCCAD \uC2DC on-demand",
240
- trigger: "on_demand",
241
- system_prompt_file: "src/agents/prompts/llm/report-generator-system.md",
242
- input_format: "Mission Summary:\\n{mission_summary}\\n\\nFindings (Sorted by Severity):\\n{json_findings}\n",
243
- input_sorting: "severity_descending",
244
- reads: [
245
- "state.findings",
246
- "state.currentObjective"
247
- ],
248
- writes: {
249
- disk: {
250
- path: ".pentesting/reports/{timestamp}-report.md",
251
- write_mode: "overwrite"
252
- }
253
- },
254
- on_failure: {
255
- fallback_content: "# Fallback Report\nFailed to generate full report. Review raw findings in the workspace.\n"
256
- }
257
- },
258
- triager: {
259
- role: "\uD134 \uACB0\uACFC \uC6B0\uC120\uC21C\uC704 \uBD84\uB958 \u2014 \uB3C4\uAD6C \uC2E4\uD589 \uC9C1\uD6C4, Reflector \uC804 \uD638\uCD9C",
260
- trigger: "post_tool_execution",
261
- system_prompt_file: "src/agents/prompts/llm/triage-system.md",
262
- reads: [
263
- "tools",
264
- "phase",
265
- "state.lastTriageMemo"
266
- ],
267
- writes: {
268
- memory: "triage_result"
269
- },
270
- output_handling: {
271
- extract_field: "triage",
272
- write_target: "state.lastTriageMemo",
273
- write_mode: "overwrite",
274
- inject_as: "<triage-memo>\n{value}\n</triage-memo>",
275
- on_failure: "empty_string"
276
- }
277
- }
278
- };
279
- var RUNTIME_CONFIG_TURN_CYCLE = {
280
- serial: [
281
- "process_user_input",
282
- {
283
- when: {
284
- condition: "should_forward_to_main"
285
- },
286
- then: {
287
- serial: [
288
- "strategist",
289
- "build_system_prompt",
290
- "core_inference",
291
- {
292
- when: {
293
- condition: "has_tool_calls"
294
- },
295
- then: "core_tool_execution"
296
- }
297
- ]
298
- }
299
- },
300
- {
301
- when: {
302
- condition: "has_tool_calls"
303
- },
304
- then: "triager"
305
- },
306
- {
307
- when: {
308
- condition: "has_tool_calls"
309
- },
310
- then: "save_triage"
311
- },
312
- "verify_turn",
313
- "reflector",
314
- "context_extractor",
315
- {
316
- parallel: [
317
- "save_reflection",
318
- "finalize_context"
319
- ]
320
- },
321
- {
322
- when: {
323
- condition: "has_exploit_chain",
324
- min_succeeded: 2
325
- },
326
- then: "playbook_synthesizer"
327
- },
328
- "write_insight",
329
- "rotate_turns",
330
- "save_session"
331
- ]
332
- };
333
- var RUNTIME_CONFIG_NODES = {
334
- process_user_input: defineRuntimeNode({
335
- type: "action",
336
- handler: "process_user_input",
337
- log_as: "\u24EAInputProcessor \u2192 forward/policy/direct-response"
338
- }),
339
- build_system_prompt: defineRuntimeNode({
340
- type: "action",
341
- handler: "build_system_prompt",
342
- log_as: "\u2460PromptBuilder \u2192 messages"
343
- }),
344
- core_inference: defineRuntimeNode({
345
- type: "action",
346
- handler: "core_inference",
347
- log_as: "\u2461MainLLM \u2192 tool_calls"
348
- }),
349
- core_tool_execution: defineRuntimeNode({
350
- type: "action",
351
- handler: "core_tool_execution",
352
- log_as: "\u2462ToolExecutor \u2192 output"
353
- }),
354
- context_extractor: defineRuntimeNode({
355
- type: "llm",
356
- class: "context_extractor",
357
- input_formatter: "format_for_extraction",
358
- reads: [
359
- "messages"
360
- ],
361
- writes: {
362
- memory: "extracted_context"
363
- }
364
- }),
365
- reflector: defineRuntimeNode({
366
- type: "llm",
367
- class: "reflector",
368
- input_formatter: "format_reflection_input",
369
- reads: [
370
- "tools",
371
- "memo",
372
- "phase",
373
- "triageMemo"
374
- ],
375
- writes: {
376
- memory: "reflection"
377
- }
378
- }),
379
- strategist: defineRuntimeNode({
380
- type: "llm",
381
- class: "strategist",
382
- reads: [
383
- "state"
384
- ],
385
- writes: {
386
- memory: "strategist_directive"
387
- },
388
- log_as: "\u2460Strategist \u2192 ctx.memory.strategist_directive"
389
- }),
390
- triager: defineRuntimeNode({
391
- type: "llm",
392
- class: "triager",
393
- input_formatter: "format_triage_input",
394
- reads: [
395
- "tools",
396
- "phase",
397
- "previousTriage"
398
- ],
399
- writes: {
400
- memory: "triage_result"
401
- },
402
- log_as: "\u2467Triager \u2192 ctx.memory.triage_result"
403
- }),
404
- save_triage: defineRuntimeNode({
405
- type: "action",
406
- handler: "write_field_to_state",
407
- config: {
408
- from: "memory.triage_result",
409
- field: "triage",
410
- target: "state.lastTriageMemo",
411
- write_mode: "overwrite"
412
- },
413
- log_as: "\u2467Triager \u2192 state.lastTriageMemo"
414
- }),
415
- verify_turn: defineRuntimeNode({
416
- type: "action",
417
- handler: "verify_turn",
418
- log_as: "Verifier \u2192 ctx.memory.turn_verifier_report"
419
- }),
420
- save_reflection: defineRuntimeNode({
421
- type: "action",
422
- handler: "write_field_to_state",
423
- config: {
424
- from: "memory.reflection",
425
- field: "reflection",
426
- target: "state.lastReflection",
427
- write_mode: "overwrite"
428
- },
429
- log_as: "\u2464Reflector \u2192 state.lastReflection"
430
- }),
431
- finalize_context: defineRuntimeNode({
432
- type: "action",
433
- handler: "replace_messages_from_memory",
434
- config: {
435
- from: "memory.extracted_context",
436
- field: "extractedContext",
437
- wrap: "<session-context>\n{value}\n</session-context>",
438
- write_mode: "replace_all"
439
- },
440
- log_as: "\u2463ContextExtractor \u2192 messages REPLACED"
441
- }),
442
- playbook_synthesizer: defineRuntimeNode({
443
- type: "action",
444
- handler: "synthesize_playbook",
445
- config: {
446
- min_succeeded_nodes: 2
447
- },
448
- reads: [
449
- "attack_graph.succeeded"
450
- ],
451
- writes: {
452
- disk: {
453
- path: ".pentesting/memory/persistent-knowledge.json",
454
- write_mode: "merge"
455
- }
456
- },
457
- log_as: "\u2466PlaybookSynth \u2192 .pentesting/memory/persistent-knowledge.json"
458
- }),
459
- write_insight: defineRuntimeNode({
460
- type: "action",
461
- handler: "write_insight"
462
- }),
463
- rotate_turns: defineRuntimeNode({
464
- type: "action",
465
- handler: "rotate_turns"
466
- }),
467
- save_session: defineRuntimeNode({
468
- type: "action",
469
- handler: "save_session"
470
- })
471
- };
472
- var RUNTIME_CONFIG_USER_INPUT_QUEUE = {
473
- format: "tagged",
474
- tag: "user-input",
475
- inject_position: "messages_end"
476
- };
477
-
478
- // src/agents/runtime-config/prompt-runtime.ts
479
- function definePromptLayer(layer) {
480
- return layer;
481
- }
482
- var RUNTIME_CONFIG_PROMPT_BUILDER = {
483
- max_chars: 4e5,
484
- truncation: "back",
485
- preserved_last: "user_context",
486
- layers: [
487
- definePromptLayer({
488
- id: 1,
489
- type: "file",
490
- source: "src/agents/prompts/base.md",
491
- label: "core_identity"
492
- }),
493
- definePromptLayer({
494
- id: 1.5,
495
- type: "file",
496
- source: "src/agents/prompts/main-agent.md",
497
- label: "delegation_and_tactics"
498
- }),
499
- definePromptLayer({
500
- id: 2,
501
- type: "file",
502
- source: "src/agents/prompts/offensive-playbook.md",
503
- label: "offensive_playbook"
504
- }),
505
- definePromptLayer({
506
- id: 3,
507
- type: "file_phase_mapped",
508
- mapping: "prompt_sources.phase_prompts",
509
- label: "phase_specialist"
510
- }),
511
- definePromptLayer({
512
- id: 4,
513
- type: "state",
514
- source: "state.scope",
515
- label: "scope_constraints",
516
- format: "<scope>\n allowed-cidrs: {cidrs}\n allowed-domains: {domains}\n exclusions: {exclusions}\n flags: DOS={is_dos_allowed} | Social={is_social_allowed}\n</scope>\n",
517
- on_empty: "No scope defined \u2014 treat all discovered hosts as in-scope."
518
- }),
519
- definePromptLayer({
520
- id: 5,
521
- type: "state",
522
- source: "state.todo",
523
- label: "todo_list",
524
- filter: "status != DONE",
525
- format_item: "[{status_symbol}] {content} ({priority})"
526
- }),
527
- definePromptLayer({
528
- id: 6,
529
- type: "state",
530
- source: "state.time",
531
- label: "time_status",
532
- format: '<time-status>{time_status}</time-status>\n<time-strategy phase="{phase}" urgency="{urgency}">{directive}</time-strategy>\n'
533
- }),
534
- definePromptLayer({
535
- id: 7,
536
- type: "memory",
537
- source: "memory.strategist_directive",
538
- label: "strategist_directive",
539
- on_empty: "skip"
540
- }),
541
- definePromptLayer({
542
- id: 7.5,
543
- type: "file_read",
544
- source: ".pentesting/memory/policy.md",
545
- label: "policy_memory",
546
- wrap: "<policy-memory>\n{content}\n</policy-memory>",
547
- on_missing: "skip"
548
- }),
549
- definePromptLayer({
550
- id: 8,
551
- type: "file_read",
552
- source: ".pentesting/turns/{N-1}-memory.md",
553
- label: "session_journal",
554
- format: "<session-journal>\n{content}\n</session-journal>",
555
- on_missing: "skip"
556
- }),
557
- definePromptLayer({
558
- id: 9,
559
- type: "state",
560
- source: "state.serialized",
561
- label: "current_state",
562
- format: "<current-state>\n{content}\n</current-state>"
563
- }),
564
- definePromptLayer({
565
- id: 10,
566
- type: "state",
567
- source: "state.workingMemory",
568
- label: "working_memory"
569
- }),
570
- definePromptLayer({
571
- id: 11,
572
- type: "state",
573
- source: "state.challengeAnalysis",
574
- label: "challenge_analysis",
575
- on_empty: "skip"
576
- }),
577
- definePromptLayer({
578
- id: 12,
579
- type: "state",
580
- source: "state.attackGraph",
581
- label: "attack_graph"
582
- }),
583
- definePromptLayer({
584
- id: 12.5,
585
- type: "state",
586
- source: "state.branchMemory",
587
- label: "branch_memory",
588
- on_empty: "skip"
589
- }),
590
- definePromptLayer({
591
- id: 13,
592
- type: "static",
593
- label: "blind_spots_guidelines",
594
- content: "<blind-spots-guidelines>\nWhen writing your mandatory <critical-reflection> before acting, ensure you evaluate:\n\na) Are there services/ports discovered but NOT yet tested?\nb) Have credentials/tokens been found but NOT sprayed on other services?\nc) Is there a SIMPLER explanation? (misconfiguration vs complex vuln)\nd) Are you drilling too deep while ignoring other viable attack surfaces?\ne) Could a custom script (Python/bash) accomplish what tool attempts have failed to do?\nf) Are there findings from PREVIOUS turns noted but not followed up on?\ng) What would an experienced human tester try RIGHT now?\n\nCRITICAL: You MUST explicitly acknowledge and accept any warnings or Pivot directions.\n</blind-spots-guidelines>\n"
595
- }),
596
- definePromptLayer({
597
- id: 14,
598
- type: "state",
599
- source: "state.lastReflection",
600
- label: "last_turn_review",
601
- format: "<last-turn-review>\n{value}\n</last-turn-review>",
602
- written_by: "reflector",
603
- on_empty: "skip"
604
- }),
605
- definePromptLayer({
606
- id: "14_triage",
607
- type: "state",
608
- source: "state.lastTriageMemo",
609
- label: "triage_memo",
610
- format: "<triage-memo>\n{value}\n</triage-memo>",
611
- written_by: "triager",
612
- on_empty: "skip"
613
- }),
614
- definePromptLayer({
615
- id: 15,
616
- type: "state",
617
- source: "state.episodicMemory",
618
- label: "episodic_memory"
619
- }),
620
- definePromptLayer({
621
- id: 16,
622
- type: "state",
623
- source: "state.dynamicTechniques",
624
- label: "dynamic_techniques",
625
- pruning: "confidence < 10"
626
- }),
627
- definePromptLayer({
628
- id: 16.5,
629
- type: "state",
630
- source: "state.persistentMemory",
631
- label: "persistent_memory",
632
- on_empty: "skip"
633
- }),
634
- definePromptLayer({
635
- id: 17,
636
- type: "files",
637
- sources: "prompt_sources.core_knowledge",
638
- label: "core_knowledge",
639
- exclude_current_phase_file: true,
640
- wrap: '<reference-knowledge area="{label}">\n{content}\n</reference-knowledge>'
641
- }),
642
- definePromptLayer({
643
- id: 18,
644
- type: "files_phase_mapped",
645
- mapping: "prompt_sources.phase_techniques",
646
- label: "phase_techniques",
647
- base_dir: "src/agents/prompts/techniques/",
648
- wrap: '<technique-reference category="{name}">\n{content}\n</technique-reference>'
649
- }),
650
- definePromptLayer({
651
- id: 19,
652
- type: "state",
653
- source: "state.targets_ports",
654
- label: "attack_intelligence",
655
- format: "<service-inventory>\nDiscovered services \u2014 use get_owasp_knowledge, web_search, or get_web_attack_surface for attack ideas:\n{lines}\n</service-inventory>\n"
656
- }),
657
- definePromptLayer({
658
- id: 20,
659
- type: "user_input",
660
- label: "user_context",
661
- always_included: true
662
- })
663
- ]
664
- };
665
- var RUNTIME_CONFIG_PROMPT_SOURCES = {
666
- base_dir: "src/agents/prompts/",
667
- always: [
668
- "base.md",
669
- "offensive-playbook.md"
670
- ],
671
- phase_prompts: {
672
- recon: "recon.md",
673
- vulnerability_analysis: "vuln.md",
674
- exploit: "exploit.md",
675
- web: "web.md",
676
- post_exploitation: "post.md",
677
- privilege_escalation: "post.md",
678
- lateral_movement: "post.md",
679
- persistence: "post.md",
680
- exfiltration: "post.md",
681
- report: "report.md",
682
- pwn: "ctf-pwn.md",
683
- crypto: "ctf-crypto.md",
684
- forensics: "ctf-forensics.md"
685
- },
686
- core_knowledge: [
687
- "strategy.md",
688
- "evasion.md",
689
- "zero-day.md",
690
- "payload-craft.md",
691
- "infra.md"
692
- ],
693
- techniques_dir: "src/agents/prompts/techniques/",
694
- phase_techniques: {
695
- recon: [
696
- "network-svc.md",
697
- "shells.md",
698
- "crypto.md",
699
- "auth-access.md"
700
- ],
701
- vulnerability_analysis: [
702
- "injection.md",
703
- "network-svc.md",
704
- "auth-access.md",
705
- "file-attacks.md",
706
- "crypto.md",
707
- "reversing.md"
708
- ],
709
- exploit: [
710
- "injection.md",
711
- "auth-access.md",
712
- "shells.md",
713
- "file-attacks.md",
714
- "network-svc.md",
715
- "pwn.md",
716
- "container-escape.md",
717
- "sandbox-escape.md",
718
- "reversing.md"
719
- ],
720
- post_exploitation: [
721
- "privesc.md",
722
- "lateral.md",
723
- "auth-access.md",
724
- "shells.md",
725
- "container-escape.md",
726
- "sandbox-escape.md",
727
- "forensics.md",
728
- "pivoting.md",
729
- "enterprise-pentest.md"
730
- ],
731
- privilege_escalation: [
732
- "privesc.md",
733
- "auth-access.md",
734
- "shells.md",
735
- "pwn.md",
736
- "container-escape.md",
737
- "sandbox-escape.md"
738
- ],
739
- lateral_movement: [
740
- "lateral.md",
741
- "ad-attack.md",
742
- "auth-access.md",
743
- "container-escape.md",
744
- "network-svc.md",
745
- "pivoting.md",
746
- "enterprise-pentest.md"
747
- ],
748
- persistence: [
749
- "shells.md",
750
- "privesc.md",
751
- "lateral.md",
752
- "enterprise-pentest.md"
753
- ],
754
- exfiltration: [
755
- "lateral.md",
756
- "network-svc.md",
757
- "forensics.md"
758
- ],
759
- web: [
760
- "injection.md",
761
- "file-attacks.md",
762
- "auth-access.md",
763
- "crypto.md",
764
- "shells.md",
765
- "network-svc.md"
766
- ],
767
- report: [],
768
- pwn: [
769
- "pwn.md",
770
- "reversing.md",
771
- "shells.md"
772
- ],
773
- crypto: [
774
- "crypto.md",
775
- "reversing.md"
776
- ],
777
- forensics: [
778
- "forensics.md",
779
- "reversing.md",
780
- "network-svc.md"
781
- ]
782
- },
783
- strategist_system: "src/agents/prompts/strategist-system.md"
784
- };
785
-
786
- // src/agents/runtime-config/ops-runtime.ts
787
- var RUNTIME_CONFIG_LIMITS = {
788
- archive: {
789
- max_turn_entries: 50,
790
- eviction: "delete_oldest_first"
791
- },
792
- messages: {
793
- context_extractor_per_msg_limit: 3e4,
794
- truncation_direction: "back"
795
- },
796
- prompt: {
797
- max_chars: 4e5,
798
- truncation_direction: "back",
799
- preserved_last: "user_context"
800
- },
801
- tool_output: {
802
- max_chars: 2e5
803
- },
804
- agent_loop: {
805
- max_iterations: 500,
806
- max_consecutive_idle: 3,
807
- max_consecutive_llm_errors: "infinity",
808
- max_retries: 3,
809
- periodic_report_every_n_turns: 10,
810
- max_session_files: 10
811
- },
812
- state: {
813
- max_findings: 500,
814
- max_loot: 200,
815
- max_action_log: 200,
816
- max_attack_nodes: 300,
817
- max_attack_edges: 1e3,
818
- max_failed_paths: 100,
819
- working_memory_max: 20,
820
- episodic_memory_max: 100,
821
- dynamic_techniques_max: 50,
822
- technique_failure_decay: 30,
823
- technique_prune_threshold: 10,
824
- consecutive_fail_threshold: 3
825
- }
826
- };
827
- var RUNTIME_CONFIG_COMPRESSION = {
828
- messages: {
829
- strategy: "llm_compress",
830
- trigger: "every_turn",
831
- agent: "context_extractor",
832
- per_msg_max_chars: 3e4,
833
- output_format: "<session-context>\n{value}\n</session-context>",
834
- write_mode: "replace_all",
835
- on_failure: "keep_existing"
836
- },
837
- session_summary: {
838
- strategy: "llm_progressive",
839
- trigger: "every_turn",
840
- agent: "memory_synth",
841
- input: [
842
- "previous_insight",
843
- "current_turn_data"
844
- ],
845
- output_path: ".pentesting/turns/{N}-memory.md",
846
- write_mode: "overwrite",
847
- on_failure: "fallback_concat"
848
- },
849
- deterministic_summary_buckets: [
850
- "techniques_tried",
851
- "suspicious_signals",
852
- "key_findings",
853
- "credentials",
854
- "successful_vectors",
855
- "failure_causes",
856
- "next_recommendations"
857
- ],
858
- archive: {
859
- strategy: "count_based_rotation",
860
- max_turns: 50,
861
- eviction: "delete_oldest_first",
862
- trigger: "after_each_turn"
863
- },
864
- debug_log: {
865
- strategy: "size_based_rotation",
866
- rotate_at_mb: 5,
867
- rotate_mode: "keep_latest_half",
868
- wipe_at_mb: 20,
869
- wipe_mode: "truncate_all"
870
- },
871
- dynamic_techniques: {
872
- strategy: "confidence_based_pruning",
873
- max_entries: 50,
874
- prune_threshold: 10,
875
- failure_decay: 30
876
- }
877
- };
878
- var RUNTIME_CONFIG_WORKSPACE = {
879
- root: ".pentesting/",
880
- directories: {
881
- turns: ".pentesting/turns/",
882
- workspace: ".pentesting/workspace/",
883
- sessions: ".pentesting/sessions/",
884
- memory: ".pentesting/memory/",
885
- reports: ".pentesting/reports/",
886
- loot: ".pentesting/loot/",
887
- debug: ".pentesting/debug/"
888
- },
889
- turn_structure: {
890
- insight: {
891
- file: "{N}-memory.md",
892
- write_mode: "overwrite",
893
- written_by: "memory_synth",
894
- content: "core_insights_only",
895
- metadata: {
896
- file_kind: "turn_memory",
897
- includes: [
898
- "written_by",
899
- "input_sources",
900
- "notes_included",
901
- "generated_at"
902
- ]
903
- }
904
- }
905
- },
906
- persistent_files: {
907
- session: {
908
- path: ".pentesting/sessions/latest.json",
909
- write_mode: "overwrite",
910
- rotation: {
911
- strategy: "keep_latest_N",
912
- max_files: 10
913
- }
914
- },
915
- knowledge: {
916
- path: ".pentesting/memory/persistent-knowledge.json",
917
- write_mode: "merge",
918
- written_by: "playbook_synthesizer"
919
- },
920
- debug_log: {
921
- path: ".pentesting/debug/debug.log",
922
- write_mode: "append",
923
- rotation: {
924
- strategy: "size_based",
925
- rotate_at_mb: 5,
926
- wipe_at_mb: 20
927
- }
928
- }
929
- }
930
- };
931
- var RUNTIME_CONFIG_TUI = {
932
- transcript: {
933
- max_visible_turns: 6
934
- }
935
- };
936
-
937
- // src/agents/runtime-config/memory-runtime.ts
938
- var RUNTIME_CONFIG_MEMORY_ROLLOUT = {
939
- branch_memory: {
940
- main_prompt: true,
941
- strategist: true,
942
- delegated_prompt: true,
943
- resume_hints: true
944
- }
945
- };
946
-
947
- // src/agents/runtime-config.ts
948
- var RUNTIME_CONFIG = {
949
- version: "3.2",
950
- llm_nodes: RUNTIME_CONFIG_LLM_NODES,
951
- turn_cycle: RUNTIME_CONFIG_TURN_CYCLE,
952
- prompt_builder: RUNTIME_CONFIG_PROMPT_BUILDER,
953
- prompt_sources: RUNTIME_CONFIG_PROMPT_SOURCES,
954
- limits: RUNTIME_CONFIG_LIMITS,
955
- compression: RUNTIME_CONFIG_COMPRESSION,
956
- workspace: RUNTIME_CONFIG_WORKSPACE,
957
- tui: RUNTIME_CONFIG_TUI,
958
- memory_rollout: RUNTIME_CONFIG_MEMORY_ROLLOUT,
959
- nodes: RUNTIME_CONFIG_NODES,
960
- user_input_queue: RUNTIME_CONFIG_USER_INPUT_QUEUE
961
- };
962
-
963
- // src/agents/pipeline-config.ts
964
- var _config = null;
965
- function getPipelineConfig() {
966
- if (_config) return _config;
967
- _config = RUNTIME_CONFIG;
968
- return _config;
969
- }
970
-
971
- // src/agents/runtime-config-sections.ts
972
- var RUNTIME_CONFIG_SOURCE_PATH = "src/agents/runtime-config.ts";
973
- function buildMissingSectionError(sectionName) {
974
- return new Error(
975
- `[runtime-config] ${String(sectionName)} section is required but not found. Add it to ${RUNTIME_CONFIG_SOURCE_PATH}.`
976
- );
977
- }
978
- function getOptionalRuntimeSection(sectionName) {
979
- return getPipelineConfig()[sectionName];
980
- }
981
- function getRequiredRuntimeSection(sectionName) {
982
- const section = getOptionalRuntimeSection(sectionName);
983
- if (section === void 0 || section === null) {
984
- throw buildMissingSectionError(sectionName);
985
- }
986
- return section;
987
- }
988
- function getRuntimeSectionOr(sectionName, fallback) {
989
- return getOptionalRuntimeSection(sectionName) ?? fallback;
990
- }
991
-
992
- // src/agents/limits-config.ts
993
- function getLimits() {
994
- return getRequiredRuntimeSection("limits");
995
- }
996
-
997
- // src/shared/constants/system/limits.ts
998
- var _msgLimits = getLimits().messages ?? {};
999
- var SYSTEM_LIMITS = {
1000
- /** Maximum wait time for interactive shell responses (10 seconds) */
1001
- MAX_WAIT_MS_INTERACT: 1e4,
1002
- /** Default wait time for interactive shell responses (2 seconds) */
1003
- DEFAULT_WAIT_MS_INTERACT: 2e3,
1004
- /** Maximum characters for process description */
1005
- MAX_DESCRIPTION_LENGTH: 80,
1006
- /** Maximum characters for stored command string */
1007
- MAX_COMMAND_LENGTH: 200,
1008
- /** Maximum characters to show from stdout
1009
- * WHY 50K: background processes (linpeas, scans, shells) produce large
1010
- * output with findings scattered throughout. Let the LLM see it all. */
1011
- MAX_STDOUT_SLICE: 5e4,
1012
- /** Maximum characters to show from stderr */
1013
- MAX_STDERR_SLICE: 5e3,
1014
- /** Maximum characters for error detail messages */
1015
- MAX_ERROR_DETAIL_SLICE: 2e3,
1016
- /** Maximum characters for input prompt previews */
1017
- MAX_PROMPT_PREVIEW: 50,
1018
- /** Maximum characters for input snippets in logs */
1019
- MAX_INPUT_SLICE: 100,
1020
- /** Maximum events to keep in process event log */
1021
- MAX_EVENT_LOG: 30,
1022
- /** Wait time for child PID discovery via pgrep */
1023
- CHILD_PID_DISCOVERY_MS: 500,
1024
- /** Wait time between SIGTERM and SIGKILL during graceful shutdown */
1025
- SHUTDOWN_WAIT_MS: 500,
1026
- /** Wait time between process cleanup batches */
1027
- CLEANUP_BATCH_WAIT_MS: 300,
1028
- /** Timeout for pgrep and pkill operations */
1029
- PROCESS_OP_TIMEOUT_MS: 2e3,
1030
- /** Port range for web services (development servers) */
1031
- WEB_PORT_RANGE: { MIN: 8e3, MAX: 9e3 },
1032
- /** Port range for API services */
1033
- API_PORT_RANGE: { MIN: 3e3, MAX: 3500 },
1034
- /** Number of recent events to fetch for resource summary */
1035
- RECENT_EVENTS_IN_SUMMARY: 10,
1036
- /** Number of events to display in resource summary */
1037
- RECENT_EVENTS_DISPLAY: 5,
1038
- /** Number of recent output lines to show per process */
1039
- RECENT_OUTPUT_LINES: 3,
1040
- /** Maximum characters per message for context extraction.
1041
- * runtime config: limits.messages.context_extractor_per_msg_limit */
1042
- CONTEXT_EXTRACTOR_LIMIT: _msgLimits.context_extractor_per_msg_limit
1043
- };
1044
-
1045
- // src/shared/constants/system/detection.ts
1046
- var DETECTION_PATTERNS = {
1047
- LISTENER: /-(?:lvnp|nlvp|lp|p)\s+(\d+)/,
1048
- HTTP_SERVER: /(?:http\.server|SimpleHTTPServer)\s+(\d+)/,
1049
- GENERIC_PORT: /-(?:p|port|S)\s+(?:\S+:)?(\d+)/,
1050
- CONNECTION: [
1051
- /connection\s+from/i,
1052
- /connect\s+to/i,
1053
- /\$\s*$/m,
1054
- /#\s*$/m,
1055
- /bash-\d/i,
1056
- /sh-\d/i,
1057
- /www-data/i
1058
- ]
1059
- };
1060
- var ORPHAN_PROCESS_NAMES = [
1061
- "arpspoof",
1062
- "ettercap",
1063
- "mitmdump",
1064
- "mitmproxy",
1065
- "dnsspoof",
1066
- "tcpdump",
1067
- "tshark",
1068
- "socat"
1069
- ];
1070
-
1071
- // src/shared/constants/system/health.ts
1072
- var HEALTH_CONFIG = {
1073
- LONG_RUNNING_THRESHOLD_MS: 3e5,
1074
- // 5 minutes
1075
- VERY_LONG_RUNNING_THRESHOLD_MS: 9e5,
1076
- // 15 minutes
1077
- MAX_RECOMMENDATIONS_FOR_HEALTHY: 2
1078
- };
1079
-
1080
- // src/engine/process/process-registry.ts
1081
- var backgroundProcesses = /* @__PURE__ */ new Map();
1082
- var processEventLog = [];
1083
- function logEvent(processId, event, detail) {
1084
- processEventLog.push({ timestamp: Date.now(), processId, event, detail });
1085
- if (processEventLog.length > SYSTEM_LIMITS.MAX_EVENT_LOG) {
1086
- processEventLog.splice(0, processEventLog.length - SYSTEM_LIMITS.MAX_EVENT_LOG);
1087
- }
1088
- }
1089
- function getProcess(processId) {
1090
- return backgroundProcesses.get(processId);
1091
- }
1092
- function setProcess(processId, process) {
1093
- backgroundProcesses.set(processId, process);
1094
- }
1095
- function deleteProcess(processId) {
1096
- return backgroundProcesses.delete(processId);
1097
- }
1098
- function hasProcess(processId) {
1099
- return backgroundProcesses.has(processId);
1100
- }
1101
- function getAllProcessIds() {
1102
- return Array.from(backgroundProcesses.keys());
1103
- }
1104
- function getAllProcesses() {
1105
- return backgroundProcesses.values();
1106
- }
1107
- function getProcessEntries() {
1108
- return backgroundProcesses.entries();
1109
- }
1110
- function getProcessCount() {
1111
- return backgroundProcesses.size;
1112
- }
1113
- function clearAllProcesses() {
1114
- backgroundProcesses.clear();
1115
- }
1116
- function getProcessEventLog() {
1117
- return [...processEventLog];
1118
- }
1119
- function getBackgroundProcessesMap() {
1120
- return backgroundProcesses;
1121
- }
1122
- function getActiveProcessSummary() {
1123
- const processes = Array.from(getAllProcesses());
1124
- if (!processes.length) return "";
1125
- return processes.filter((p) => !p.hasExited).map((p) => {
1126
- const port = p.listeningPort ? ` port=${p.listeningPort}` : "";
1127
- const interactive = p.isInteractive ? " interactive=true" : "";
1128
- return `${p.id}: ${p.command} | role=${p.role}${port}${interactive}`;
1129
- }).join("\n");
1130
- }
1131
-
1132
- export {
1133
- __require,
1134
- EXIT_CODES,
1135
- PROCESS_ACTIONS,
1136
- PROCESS_ROLES,
1137
- PROCESS_ICONS,
1138
- STATUS_MARKERS,
1139
- PROCESS_EVENTS,
1140
- PROCESS_LIMITS,
1141
- getOptionalRuntimeSection,
1142
- getRequiredRuntimeSection,
1143
- getRuntimeSectionOr,
1144
- getLimits,
1145
- SYSTEM_LIMITS,
1146
- DETECTION_PATTERNS,
1147
- ORPHAN_PROCESS_NAMES,
1148
- HEALTH_CONFIG,
1149
- logEvent,
1150
- getProcess,
1151
- setProcess,
1152
- deleteProcess,
1153
- hasProcess,
1154
- getAllProcessIds,
1155
- getAllProcesses,
1156
- getProcessEntries,
1157
- getProcessCount,
1158
- clearAllProcesses,
1159
- getProcessEventLog,
1160
- getBackgroundProcessesMap,
1161
- getActiveProcessSummary
1162
- };