pentesting 0.1.8 → 0.1.9
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/dist/index.js +89 -43
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2610,6 +2610,52 @@ var ASCII_BANNER = `
|
|
|
2610
2610
|
\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
|
|
2611
2611
|
`;
|
|
2612
2612
|
|
|
2613
|
+
// src/config/agent-constants.ts
|
|
2614
|
+
var AGENT_EVENT = {
|
|
2615
|
+
// Lifecycle
|
|
2616
|
+
PLUGINS_LOADED: "plugins_loaded",
|
|
2617
|
+
HOOKS_LOADED: "hooks_loaded",
|
|
2618
|
+
COMMANDS_LOADED: "commands_loaded",
|
|
2619
|
+
MCP_SERVER_ADDED: "mcp_server_added",
|
|
2620
|
+
// Execution
|
|
2621
|
+
ITERATION: "iteration",
|
|
2622
|
+
THOUGHT: "thought",
|
|
2623
|
+
RESPONSE: "response",
|
|
2624
|
+
TOOL_CALL: "tool_call",
|
|
2625
|
+
TOOL_RESULT: "tool_result",
|
|
2626
|
+
COMMAND_EXECUTE: "command_execute",
|
|
2627
|
+
// State changes
|
|
2628
|
+
TARGET_SET: "target_set",
|
|
2629
|
+
PHASE_CHANGE: "phase_change",
|
|
2630
|
+
AGENT_SWITCH: "agent_switch",
|
|
2631
|
+
// Discoveries
|
|
2632
|
+
FINDING: "finding",
|
|
2633
|
+
CREDENTIAL: "credential",
|
|
2634
|
+
COMPROMISED: "compromised",
|
|
2635
|
+
// Completion
|
|
2636
|
+
COMPLETE: "complete",
|
|
2637
|
+
REPORT: "report",
|
|
2638
|
+
ERROR: "error"
|
|
2639
|
+
};
|
|
2640
|
+
var CLI_COMMAND = {
|
|
2641
|
+
HELP: "help",
|
|
2642
|
+
TARGET: "target",
|
|
2643
|
+
START: "start",
|
|
2644
|
+
STOP: "stop",
|
|
2645
|
+
FINDINGS: "findings",
|
|
2646
|
+
CLEAR: "clear",
|
|
2647
|
+
EXIT: "exit"
|
|
2648
|
+
};
|
|
2649
|
+
var MESSAGE_TYPE = {
|
|
2650
|
+
USER: "user",
|
|
2651
|
+
ASSISTANT: "assistant",
|
|
2652
|
+
TOOL: "tool",
|
|
2653
|
+
THINKING: "thinking",
|
|
2654
|
+
ERROR: "error",
|
|
2655
|
+
SYSTEM: "system",
|
|
2656
|
+
RESULT: "result"
|
|
2657
|
+
};
|
|
2658
|
+
|
|
2613
2659
|
// src/cli/app.tsx
|
|
2614
2660
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2615
2661
|
var App = ({ autoApprove = false, target }) => {
|
|
@@ -2647,39 +2693,39 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
2647
2693
|
return duration;
|
|
2648
2694
|
}, []);
|
|
2649
2695
|
useEffect(() => {
|
|
2650
|
-
addMessage(
|
|
2696
|
+
addMessage(MESSAGE_TYPE.SYSTEM, "Pentesting Agent initialized. Type /help for commands.");
|
|
2651
2697
|
if (target) {
|
|
2652
2698
|
agent.setTarget(target);
|
|
2653
|
-
addMessage(
|
|
2699
|
+
addMessage(MESSAGE_TYPE.SYSTEM, `Target: ${target}`);
|
|
2654
2700
|
}
|
|
2655
|
-
agent.on(
|
|
2656
|
-
setCurrentStatus(content.slice(0, 60));
|
|
2701
|
+
agent.on(AGENT_EVENT.THOUGHT, (thought) => {
|
|
2702
|
+
setCurrentStatus(thought.content.slice(0, 60));
|
|
2657
2703
|
});
|
|
2658
|
-
agent.on(
|
|
2704
|
+
agent.on(AGENT_EVENT.TOOL_CALL, (data) => {
|
|
2659
2705
|
const args = Object.entries(data.input).slice(0, 2).map(([k, v]) => `${k}=${typeof v === "string" ? v.slice(0, 30) : "..."}`).join(" ");
|
|
2660
2706
|
setCurrentStatus(`Running ${data.name}...`);
|
|
2661
|
-
addMessage(
|
|
2707
|
+
addMessage(MESSAGE_TYPE.TOOL, `\u25B6 ${data.name} ${args}`);
|
|
2662
2708
|
});
|
|
2663
|
-
agent.on(
|
|
2709
|
+
agent.on(AGENT_EVENT.TOOL_RESULT, (data) => {
|
|
2664
2710
|
const icon = data.result.success ? "\u2713" : "\u2717";
|
|
2665
2711
|
const preview = data.result.output?.slice(0, 100).replace(/\n/g, " ") || "";
|
|
2666
|
-
addMessage(
|
|
2712
|
+
addMessage(MESSAGE_TYPE.RESULT, `${icon} ${preview}`);
|
|
2667
2713
|
});
|
|
2668
|
-
agent.on(
|
|
2669
|
-
setCurrentStatus(`Phase: ${data.phase} (iteration ${data.
|
|
2714
|
+
agent.on(AGENT_EVENT.ITERATION, (data) => {
|
|
2715
|
+
setCurrentStatus(`Phase: ${data.phase} (iteration ${data.current})`);
|
|
2670
2716
|
});
|
|
2671
|
-
agent.on(
|
|
2672
|
-
addMessage(
|
|
2717
|
+
agent.on(AGENT_EVENT.FINDING, (finding) => {
|
|
2718
|
+
addMessage(MESSAGE_TYPE.SYSTEM, `\u{1F3AF} [${finding.severity.toUpperCase()}] ${finding.title}`);
|
|
2673
2719
|
});
|
|
2674
|
-
agent.on(
|
|
2720
|
+
agent.on(AGENT_EVENT.COMPLETE, () => {
|
|
2675
2721
|
const duration = stopTimer();
|
|
2676
|
-
addMessage(
|
|
2722
|
+
addMessage(MESSAGE_TYPE.SYSTEM, `\u2713 Complete (${duration}s)`);
|
|
2677
2723
|
setIsProcessing(false);
|
|
2678
2724
|
setCurrentStatus("");
|
|
2679
2725
|
});
|
|
2680
|
-
agent.on(
|
|
2726
|
+
agent.on(AGENT_EVENT.ERROR, (error) => {
|
|
2681
2727
|
stopTimer();
|
|
2682
|
-
addMessage(
|
|
2728
|
+
addMessage(MESSAGE_TYPE.ERROR, error.message);
|
|
2683
2729
|
setIsProcessing(false);
|
|
2684
2730
|
});
|
|
2685
2731
|
return () => {
|
|
@@ -2690,14 +2736,14 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
2690
2736
|
const trimmed = value.trim();
|
|
2691
2737
|
if (!trimmed || isProcessing) return;
|
|
2692
2738
|
setInput("");
|
|
2693
|
-
addMessage(
|
|
2739
|
+
addMessage(MESSAGE_TYPE.USER, trimmed);
|
|
2694
2740
|
if (trimmed.startsWith("/")) {
|
|
2695
2741
|
const [cmd, ...args] = trimmed.slice(1).split(" ");
|
|
2696
2742
|
switch (cmd) {
|
|
2697
|
-
case
|
|
2743
|
+
case CLI_COMMAND.HELP:
|
|
2698
2744
|
case "h":
|
|
2699
2745
|
addMessage(
|
|
2700
|
-
|
|
2746
|
+
MESSAGE_TYPE.SYSTEM,
|
|
2701
2747
|
`/target <ip> Set target
|
|
2702
2748
|
/start [goal] Start pentest
|
|
2703
2749
|
/stop Stop operation
|
|
@@ -2706,16 +2752,16 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
2706
2752
|
/exit Exit`
|
|
2707
2753
|
);
|
|
2708
2754
|
return;
|
|
2709
|
-
case
|
|
2755
|
+
case CLI_COMMAND.TARGET:
|
|
2710
2756
|
case "t":
|
|
2711
2757
|
if (args[0]) {
|
|
2712
2758
|
agent.setTarget(args[0]);
|
|
2713
|
-
addMessage(
|
|
2759
|
+
addMessage(MESSAGE_TYPE.SYSTEM, `Target \u2192 ${args[0]}`);
|
|
2714
2760
|
} else {
|
|
2715
|
-
addMessage(
|
|
2761
|
+
addMessage(MESSAGE_TYPE.ERROR, "Usage: /target <ip>");
|
|
2716
2762
|
}
|
|
2717
2763
|
return;
|
|
2718
|
-
case
|
|
2764
|
+
case CLI_COMMAND.START:
|
|
2719
2765
|
case "s":
|
|
2720
2766
|
setIsProcessing(true);
|
|
2721
2767
|
startTimer();
|
|
@@ -2724,39 +2770,39 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
2724
2770
|
try {
|
|
2725
2771
|
await agent.runAutonomous(objective);
|
|
2726
2772
|
} catch (e) {
|
|
2727
|
-
addMessage(
|
|
2773
|
+
addMessage(MESSAGE_TYPE.ERROR, e instanceof Error ? e.message : String(e));
|
|
2728
2774
|
}
|
|
2729
2775
|
stopTimer();
|
|
2730
2776
|
setIsProcessing(false);
|
|
2731
2777
|
setCurrentStatus("");
|
|
2732
2778
|
return;
|
|
2733
|
-
case
|
|
2779
|
+
case CLI_COMMAND.STOP:
|
|
2734
2780
|
agent.pause();
|
|
2735
2781
|
stopTimer();
|
|
2736
|
-
addMessage(
|
|
2782
|
+
addMessage(MESSAGE_TYPE.SYSTEM, "Stopped.");
|
|
2737
2783
|
setIsProcessing(false);
|
|
2738
2784
|
setCurrentStatus("");
|
|
2739
2785
|
return;
|
|
2740
|
-
case
|
|
2786
|
+
case CLI_COMMAND.FINDINGS:
|
|
2741
2787
|
case "f":
|
|
2742
2788
|
const findings = agent.getState().findings;
|
|
2743
2789
|
if (findings.length === 0) {
|
|
2744
|
-
addMessage(
|
|
2790
|
+
addMessage(MESSAGE_TYPE.SYSTEM, "No findings.");
|
|
2745
2791
|
} else {
|
|
2746
|
-
findings.forEach((f) => addMessage(
|
|
2792
|
+
findings.forEach((f) => addMessage(MESSAGE_TYPE.SYSTEM, `[${f.severity}] ${f.title}`));
|
|
2747
2793
|
}
|
|
2748
2794
|
return;
|
|
2749
|
-
case
|
|
2795
|
+
case CLI_COMMAND.CLEAR:
|
|
2750
2796
|
case "c":
|
|
2751
2797
|
setMessages([]);
|
|
2752
2798
|
return;
|
|
2753
|
-
case
|
|
2799
|
+
case CLI_COMMAND.EXIT:
|
|
2754
2800
|
case "quit":
|
|
2755
2801
|
case "q":
|
|
2756
2802
|
exit();
|
|
2757
2803
|
return;
|
|
2758
2804
|
default:
|
|
2759
|
-
addMessage(
|
|
2805
|
+
addMessage(MESSAGE_TYPE.ERROR, `Unknown: ${cmd}`);
|
|
2760
2806
|
return;
|
|
2761
2807
|
}
|
|
2762
2808
|
}
|
|
@@ -2765,9 +2811,9 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
2765
2811
|
setCurrentStatus("Thinking...");
|
|
2766
2812
|
try {
|
|
2767
2813
|
await agent.processUserHint(trimmed);
|
|
2768
|
-
addMessage(
|
|
2814
|
+
addMessage(MESSAGE_TYPE.SYSTEM, "Hint received.");
|
|
2769
2815
|
} catch (e) {
|
|
2770
|
-
addMessage(
|
|
2816
|
+
addMessage(MESSAGE_TYPE.ERROR, e instanceof Error ? e.message : String(e));
|
|
2771
2817
|
}
|
|
2772
2818
|
stopTimer();
|
|
2773
2819
|
setIsProcessing(false);
|
|
@@ -2780,7 +2826,7 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
2780
2826
|
stopTimer();
|
|
2781
2827
|
setIsProcessing(false);
|
|
2782
2828
|
setCurrentStatus("");
|
|
2783
|
-
addMessage(
|
|
2829
|
+
addMessage(MESSAGE_TYPE.SYSTEM, "Interrupted.");
|
|
2784
2830
|
} else {
|
|
2785
2831
|
exit();
|
|
2786
2832
|
}
|
|
@@ -2788,15 +2834,15 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
2788
2834
|
});
|
|
2789
2835
|
const getStyle = (type) => {
|
|
2790
2836
|
const styles = {
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2837
|
+
[MESSAGE_TYPE.USER]: { color: THEME.text.accent, prefix: "\u276F" },
|
|
2838
|
+
[MESSAGE_TYPE.ASSISTANT]: { color: THEME.text.primary, prefix: "\u25C8" },
|
|
2839
|
+
[MESSAGE_TYPE.TOOL]: { color: THEME.text.muted, prefix: " ", dim: true },
|
|
2840
|
+
[MESSAGE_TYPE.RESULT]: { color: THEME.text.muted, prefix: " ", dim: true },
|
|
2841
|
+
[MESSAGE_TYPE.THINKING]: { color: THEME.status.running, prefix: "\u25CB" },
|
|
2842
|
+
[MESSAGE_TYPE.ERROR]: { color: THEME.status.error, prefix: "\u2717" },
|
|
2843
|
+
[MESSAGE_TYPE.SYSTEM]: { color: THEME.text.muted, prefix: "\u2022" }
|
|
2798
2844
|
};
|
|
2799
|
-
return styles[type] || styles.
|
|
2845
|
+
return styles[type] || styles[MESSAGE_TYPE.SYSTEM];
|
|
2800
2846
|
};
|
|
2801
2847
|
const state = agent.getState();
|
|
2802
2848
|
return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", paddingX: 1, children: [
|