pentesting 0.2.6 → 0.2.7
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 +73 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1376,7 +1376,7 @@ const { chromium } = require('playwright');
|
|
|
1376
1376
|
}
|
|
1377
1377
|
|
|
1378
1378
|
// src/config/constants.ts
|
|
1379
|
-
var APP_VERSION = "0.2.
|
|
1379
|
+
var APP_VERSION = "0.2.7";
|
|
1380
1380
|
var APP_DESCRIPTION = "Autonomous Penetration Testing AI Agent";
|
|
1381
1381
|
var LLM_API_KEY = process.env.PENTEST_API_KEY || process.env.ANTHROPIC_API_KEY || "";
|
|
1382
1382
|
var LLM_BASE_URL = process.env.PENTEST_BASE_URL || void 0;
|
|
@@ -4326,8 +4326,10 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
4326
4326
|
const [currentStatus, setCurrentStatus] = useState("");
|
|
4327
4327
|
const [elapsedTime, setElapsedTime] = useState(0);
|
|
4328
4328
|
const [pendingApproval, setPendingApproval] = useState(null);
|
|
4329
|
+
const [approvalSelectedIndex, setApprovalSelectedIndex] = useState(0);
|
|
4329
4330
|
const [tokenUsage, setTokenUsage] = useState({ input: 0, output: 0, total: 0 });
|
|
4330
4331
|
const [showCommandHints, setShowCommandHints] = useState(false);
|
|
4332
|
+
const [mode, setMode] = useState("agent");
|
|
4331
4333
|
const [agent] = useState(() => new AutonomousHackingAgent(void 0, { autoApprove }));
|
|
4332
4334
|
const sessionManager2 = getSessionManager();
|
|
4333
4335
|
const approvalManager2 = getApprovalManager({ yoloMode: autoApprove });
|
|
@@ -4604,6 +4606,27 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
4604
4606
|
return;
|
|
4605
4607
|
}
|
|
4606
4608
|
}
|
|
4609
|
+
if (mode === "shell") {
|
|
4610
|
+
setIsProcessing(true);
|
|
4611
|
+
startTimer();
|
|
4612
|
+
setCurrentStatus(`Running: ${trimmed}`);
|
|
4613
|
+
try {
|
|
4614
|
+
const { execSync } = await import("child_process");
|
|
4615
|
+
const output = execSync(trimmed, {
|
|
4616
|
+
encoding: "utf-8",
|
|
4617
|
+
timeout: 3e4,
|
|
4618
|
+
maxBuffer: 1024 * 1024
|
|
4619
|
+
}).trim();
|
|
4620
|
+
addMessage(MESSAGE_TYPE.RESULT, output || "(no output)");
|
|
4621
|
+
} catch (e) {
|
|
4622
|
+
const error = e;
|
|
4623
|
+
addMessage(MESSAGE_TYPE.ERROR, error.stderr?.toString() || error.message || "Command failed");
|
|
4624
|
+
}
|
|
4625
|
+
stopTimer();
|
|
4626
|
+
setIsProcessing(false);
|
|
4627
|
+
setCurrentStatus("");
|
|
4628
|
+
return;
|
|
4629
|
+
}
|
|
4607
4630
|
setIsProcessing(true);
|
|
4608
4631
|
startTimer();
|
|
4609
4632
|
setCurrentStatus("Thinking...");
|
|
@@ -4618,8 +4641,31 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
4618
4641
|
stopTimer();
|
|
4619
4642
|
setIsProcessing(false);
|
|
4620
4643
|
setCurrentStatus("");
|
|
4621
|
-
}, [agent, isProcessing, pendingApproval, addMessage, exit, startTimer, stopTimer, sessionManager2, approvalManager2]);
|
|
4644
|
+
}, [agent, isProcessing, pendingApproval, addMessage, exit, startTimer, stopTimer, sessionManager2, approvalManager2, mode]);
|
|
4645
|
+
const approvalOptions = [
|
|
4646
|
+
{ label: "\u2713 Approve once", decision: "approve" },
|
|
4647
|
+
{ label: "\u2713 Approve always (this session)", decision: "approve_always" },
|
|
4648
|
+
{ label: "\u2717 Deny", decision: "deny" }
|
|
4649
|
+
];
|
|
4622
4650
|
useInput((input2, key) => {
|
|
4651
|
+
if (pendingApproval) {
|
|
4652
|
+
if (key.upArrow) {
|
|
4653
|
+
setApprovalSelectedIndex((i) => (i - 1 + approvalOptions.length) % approvalOptions.length);
|
|
4654
|
+
return;
|
|
4655
|
+
}
|
|
4656
|
+
if (key.downArrow) {
|
|
4657
|
+
setApprovalSelectedIndex((i) => (i + 1) % approvalOptions.length);
|
|
4658
|
+
return;
|
|
4659
|
+
}
|
|
4660
|
+
if (key.return) {
|
|
4661
|
+
const selected = approvalOptions[approvalSelectedIndex];
|
|
4662
|
+
approvalManager2.respond(pendingApproval.id, selected.decision);
|
|
4663
|
+
addMessage(MESSAGE_TYPE.SYSTEM, selected.decision === "deny" ? "\u2717 Denied" : `\u2713 Approved${selected.decision === "approve_always" ? " (always)" : ""}`);
|
|
4664
|
+
setPendingApproval(null);
|
|
4665
|
+
setApprovalSelectedIndex(0);
|
|
4666
|
+
return;
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4623
4669
|
if (key.ctrl && input2 === "c") {
|
|
4624
4670
|
if (isProcessing) {
|
|
4625
4671
|
agent.pause();
|
|
@@ -4631,6 +4677,11 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
4631
4677
|
exit();
|
|
4632
4678
|
}
|
|
4633
4679
|
}
|
|
4680
|
+
if (key.ctrl && input2 === "x") {
|
|
4681
|
+
const newMode = mode === "agent" ? "shell" : "agent";
|
|
4682
|
+
setMode(newMode);
|
|
4683
|
+
addMessage(MESSAGE_TYPE.SYSTEM, `Mode: ${newMode === "agent" ? "\u{1F916} Agent" : "$ Shell"}`);
|
|
4684
|
+
}
|
|
4634
4685
|
});
|
|
4635
4686
|
const getStyle = (type) => {
|
|
4636
4687
|
const styles = {
|
|
@@ -4659,13 +4710,21 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
4659
4710
|
] })
|
|
4660
4711
|
] }) }, msg.id);
|
|
4661
4712
|
} }) }),
|
|
4662
|
-
pendingApproval && /* @__PURE__ */
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4713
|
+
pendingApproval && /* @__PURE__ */ jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 1, marginBottom: 1, children: [
|
|
4714
|
+
/* @__PURE__ */ jsxs(Text, { color: "yellow", bold: true, children: [
|
|
4715
|
+
"\u26A0\uFE0F APPROVAL NEEDED: ",
|
|
4716
|
+
pendingApproval.toolName,
|
|
4717
|
+
" (",
|
|
4718
|
+
pendingApproval.riskLevel,
|
|
4719
|
+
" risk)"
|
|
4720
|
+
] }),
|
|
4721
|
+
/* @__PURE__ */ jsx(Text, { dimColor: true, children: Object.entries(pendingApproval.toolInput).slice(0, 2).map(([k, v]) => `${k}=${typeof v === "string" ? v.slice(0, 50) : JSON.stringify(v).slice(0, 50)}`).join(", ") }),
|
|
4722
|
+
/* @__PURE__ */ jsx(Box, { flexDirection: "column", marginTop: 1, children: approvalOptions.map((opt, idx) => /* @__PURE__ */ jsxs(Text, { color: idx === approvalSelectedIndex ? "cyan" : "gray", children: [
|
|
4723
|
+
idx === approvalSelectedIndex ? "\u2192 " : " ",
|
|
4724
|
+
opt.label
|
|
4725
|
+
] }, opt.decision)) }),
|
|
4726
|
+
/* @__PURE__ */ jsx(Box, { marginTop: 1, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2191\u2193 to select, Enter to confirm, or type /y /n /ya" }) })
|
|
4727
|
+
] }),
|
|
4669
4728
|
isProcessing ? /* @__PURE__ */ jsxs(Box, { children: [
|
|
4670
4729
|
/* @__PURE__ */ jsx(Text, { color: THEME.status.running, children: /* @__PURE__ */ jsx(Spinner, { type: "dots" }) }),
|
|
4671
4730
|
/* @__PURE__ */ jsxs(Text, { color: THEME.text.muted, children: [
|
|
@@ -4690,7 +4749,7 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
4690
4749
|
pendingApproval ? "/y /n /ya" : ""
|
|
4691
4750
|
].filter((cmd) => cmd && cmd.toLowerCase().includes(input.toLowerCase().slice(1))).slice(0, 5).join(" \u2502 ") }) }),
|
|
4692
4751
|
/* @__PURE__ */ jsxs(Box, { children: [
|
|
4693
|
-
/* @__PURE__ */ jsx(Text, { color: THEME.status.success, children: "\
|
|
4752
|
+
/* @__PURE__ */ jsx(Text, { color: mode === "agent" ? THEME.status.success : "yellow", children: mode === "agent" ? "\u2728 " : "$ " }),
|
|
4694
4753
|
/* @__PURE__ */ jsx(
|
|
4695
4754
|
TextInput,
|
|
4696
4755
|
{
|
|
@@ -4700,13 +4759,15 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
4700
4759
|
setShowCommandHints(val.startsWith("/") && val.length > 0);
|
|
4701
4760
|
},
|
|
4702
4761
|
onSubmit: handleSubmit,
|
|
4703
|
-
placeholder: "Message or /help..."
|
|
4762
|
+
placeholder: mode === "agent" ? "Message or /help..." : "Shell command..."
|
|
4704
4763
|
}
|
|
4705
4764
|
)
|
|
4706
4765
|
] })
|
|
4707
4766
|
] }),
|
|
4708
4767
|
/* @__PURE__ */ jsxs(Box, { marginTop: 1, justifyContent: "space-between", children: [
|
|
4709
4768
|
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
4769
|
+
mode === "agent" ? "\u{1F916}" : "$",
|
|
4770
|
+
" ",
|
|
4710
4771
|
state.target.primary || "No target",
|
|
4711
4772
|
" \u2502",
|
|
4712
4773
|
state.findings.length,
|
|
@@ -4717,7 +4778,7 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
4717
4778
|
state.currentPhase !== AGENT_STATUS.IDLE && ` ${state.currentPhase} \u2502`
|
|
4718
4779
|
] }),
|
|
4719
4780
|
/* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
|
|
4720
|
-
"/help \u2502 Ctrl+C ",
|
|
4781
|
+
"Ctrl+X mode \u2502 /help \u2502 Ctrl+C ",
|
|
4721
4782
|
isProcessing ? "stop" : "exit"
|
|
4722
4783
|
] })
|
|
4723
4784
|
] })
|