pentesting 0.2.5 → 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.
Files changed (2) hide show
  1. package/dist/index.js +130 -30
  2. 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.5";
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,7 +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 });
4331
+ const [showCommandHints, setShowCommandHints] = useState(false);
4332
+ const [mode, setMode] = useState("agent");
4330
4333
  const [agent] = useState(() => new AutonomousHackingAgent(void 0, { autoApprove }));
4331
4334
  const sessionManager2 = getSessionManager();
4332
4335
  const approvalManager2 = getApprovalManager({ yoloMode: autoApprove });
@@ -4397,10 +4400,15 @@ var App = ({ autoApprove = false, target }) => {
4397
4400
  setPendingApproval({
4398
4401
  id: data.id,
4399
4402
  toolName: data.toolName,
4403
+ toolInput: data.toolInput,
4400
4404
  riskLevel: data.riskLevel
4401
4405
  });
4402
4406
  addMessage(MESSAGE_TYPE.SYSTEM, `\u26A0\uFE0F APPROVAL NEEDED: ${data.toolName} (${data.riskLevel} risk)`);
4403
- addMessage(MESSAGE_TYPE.SYSTEM, " Type /approve or /deny");
4407
+ const inputPreview = Object.entries(data.toolInput).slice(0, 2).map(([k, v]) => `${k}=${typeof v === "string" ? v.slice(0, 40) : JSON.stringify(v).slice(0, 40)}`).join(", ");
4408
+ if (inputPreview) {
4409
+ addMessage(MESSAGE_TYPE.SYSTEM, ` Args: ${inputPreview}`);
4410
+ }
4411
+ addMessage(MESSAGE_TYPE.SYSTEM, " /y = approve, /n = deny, /ya = always approve");
4404
4412
  });
4405
4413
  agent.on(AGENT_EVENT.COMPLETE, () => {
4406
4414
  const duration = stopTimer();
@@ -4417,11 +4425,12 @@ var App = ({ autoApprove = false, target }) => {
4417
4425
  setPendingApproval({
4418
4426
  id: req.id,
4419
4427
  toolName: req.toolName,
4428
+ toolInput: req.toolInput,
4420
4429
  riskLevel: req.riskLevel
4421
4430
  });
4422
4431
  addMessage(MESSAGE_TYPE.SYSTEM, `\u26A0\uFE0F APPROVAL NEEDED: ${req.toolName} (${req.riskLevel} risk)`);
4423
4432
  addMessage(MESSAGE_TYPE.SYSTEM, ` ${req.reason}`);
4424
- addMessage(MESSAGE_TYPE.SYSTEM, " Type /approve or /deny");
4433
+ addMessage(MESSAGE_TYPE.SYSTEM, " /y = approve, /n = deny, /ya = always approve");
4425
4434
  });
4426
4435
  return () => {
4427
4436
  if (timerRef.current) clearInterval(timerRef.current);
@@ -4430,13 +4439,29 @@ var App = ({ autoApprove = false, target }) => {
4430
4439
  const handleSubmit = useCallback(async (value) => {
4431
4440
  const trimmed = value.trim();
4432
4441
  if (!trimmed) return;
4433
- if (pendingApproval && (trimmed === "/approve" || trimmed === "/deny" || trimmed === "/y" || trimmed === "/n")) {
4434
- const decision = trimmed === "/approve" || trimmed === "/y" ? "approve" : "deny";
4435
- approvalManager2.respond(pendingApproval.id, decision);
4436
- addMessage(MESSAGE_TYPE.SYSTEM, decision === "approve" ? "\u2713 Approved" : "\u2717 Denied");
4437
- setPendingApproval(null);
4438
- setInput("");
4439
- return;
4442
+ setShowCommandHints(false);
4443
+ if (pendingApproval) {
4444
+ if (trimmed === "/approve" || trimmed === "/y") {
4445
+ approvalManager2.respond(pendingApproval.id, "approve");
4446
+ addMessage(MESSAGE_TYPE.SYSTEM, "\u2713 Approved");
4447
+ setPendingApproval(null);
4448
+ setInput("");
4449
+ return;
4450
+ }
4451
+ if (trimmed === "/deny" || trimmed === "/n") {
4452
+ approvalManager2.respond(pendingApproval.id, "deny");
4453
+ addMessage(MESSAGE_TYPE.SYSTEM, "\u2717 Denied");
4454
+ setPendingApproval(null);
4455
+ setInput("");
4456
+ return;
4457
+ }
4458
+ if (trimmed === "/ya") {
4459
+ approvalManager2.respond(pendingApproval.id, "approve_always");
4460
+ addMessage(MESSAGE_TYPE.SYSTEM, `\u2713 Approved (always for ${pendingApproval.toolName})`);
4461
+ setPendingApproval(null);
4462
+ setInput("");
4463
+ return;
4464
+ }
4440
4465
  }
4441
4466
  if (isProcessing && !trimmed.startsWith("/")) return;
4442
4467
  setInput("");
@@ -4581,6 +4606,27 @@ var App = ({ autoApprove = false, target }) => {
4581
4606
  return;
4582
4607
  }
4583
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
+ }
4584
4630
  setIsProcessing(true);
4585
4631
  startTimer();
4586
4632
  setCurrentStatus("Thinking...");
@@ -4595,8 +4641,31 @@ var App = ({ autoApprove = false, target }) => {
4595
4641
  stopTimer();
4596
4642
  setIsProcessing(false);
4597
4643
  setCurrentStatus("");
4598
- }, [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
+ ];
4599
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
+ }
4600
4669
  if (key.ctrl && input2 === "c") {
4601
4670
  if (isProcessing) {
4602
4671
  agent.pause();
@@ -4608,6 +4677,11 @@ var App = ({ autoApprove = false, target }) => {
4608
4677
  exit();
4609
4678
  }
4610
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
+ }
4611
4685
  });
4612
4686
  const getStyle = (type) => {
4613
4687
  const styles = {
@@ -4636,13 +4710,21 @@ var App = ({ autoApprove = false, target }) => {
4636
4710
  ] })
4637
4711
  ] }) }, msg.id);
4638
4712
  } }) }),
4639
- pendingApproval && /* @__PURE__ */ jsx(Box, { marginBottom: 1, children: /* @__PURE__ */ jsxs(Text, { color: THEME.status.error, bold: true, children: [
4640
- "\u26A0\uFE0F Awaiting approval for ",
4641
- pendingApproval.toolName,
4642
- " (",
4643
- pendingApproval.riskLevel,
4644
- ")"
4645
- ] }) }),
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
+ ] }),
4646
4728
  isProcessing ? /* @__PURE__ */ jsxs(Box, { children: [
4647
4729
  /* @__PURE__ */ jsx(Text, { color: THEME.status.running, children: /* @__PURE__ */ jsx(Spinner, { type: "dots" }) }),
4648
4730
  /* @__PURE__ */ jsxs(Text, { color: THEME.text.muted, children: [
@@ -4654,20 +4736,38 @@ var App = ({ autoApprove = false, target }) => {
4654
4736
  "s)"
4655
4737
  ] })
4656
4738
  ] })
4657
- ] }) : /* @__PURE__ */ jsxs(Box, { children: [
4658
- /* @__PURE__ */ jsx(Text, { color: THEME.status.success, children: "\u276F " }),
4659
- /* @__PURE__ */ jsx(
4660
- TextInput,
4661
- {
4662
- value: input,
4663
- onChange: setInput,
4664
- onSubmit: handleSubmit,
4665
- placeholder: "Message or /help..."
4666
- }
4667
- )
4739
+ ] }) : /* @__PURE__ */ jsxs(Box, { flexDirection: "column", children: [
4740
+ showCommandHints && input.startsWith("/") && /* @__PURE__ */ jsx(Box, { flexDirection: "column", marginBottom: 1, children: /* @__PURE__ */ jsx(Text, { dimColor: true, children: [
4741
+ "/target <ip>",
4742
+ "/start",
4743
+ "/stop",
4744
+ "/findings",
4745
+ "/sessions",
4746
+ "/yolo",
4747
+ "/clear",
4748
+ "/exit",
4749
+ pendingApproval ? "/y /n /ya" : ""
4750
+ ].filter((cmd) => cmd && cmd.toLowerCase().includes(input.toLowerCase().slice(1))).slice(0, 5).join(" \u2502 ") }) }),
4751
+ /* @__PURE__ */ jsxs(Box, { children: [
4752
+ /* @__PURE__ */ jsx(Text, { color: mode === "agent" ? THEME.status.success : "yellow", children: mode === "agent" ? "\u2728 " : "$ " }),
4753
+ /* @__PURE__ */ jsx(
4754
+ TextInput,
4755
+ {
4756
+ value: input,
4757
+ onChange: (val) => {
4758
+ setInput(val);
4759
+ setShowCommandHints(val.startsWith("/") && val.length > 0);
4760
+ },
4761
+ onSubmit: handleSubmit,
4762
+ placeholder: mode === "agent" ? "Message or /help..." : "Shell command..."
4763
+ }
4764
+ )
4765
+ ] })
4668
4766
  ] }),
4669
4767
  /* @__PURE__ */ jsxs(Box, { marginTop: 1, justifyContent: "space-between", children: [
4670
4768
  /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
4769
+ mode === "agent" ? "\u{1F916}" : "$",
4770
+ " ",
4671
4771
  state.target.primary || "No target",
4672
4772
  " \u2502",
4673
4773
  state.findings.length,
@@ -4678,7 +4778,7 @@ var App = ({ autoApprove = false, target }) => {
4678
4778
  state.currentPhase !== AGENT_STATUS.IDLE && ` ${state.currentPhase} \u2502`
4679
4779
  ] }),
4680
4780
  /* @__PURE__ */ jsxs(Text, { dimColor: true, children: [
4681
- "/help \u2502 Ctrl+C ",
4781
+ "Ctrl+X mode \u2502 /help \u2502 Ctrl+C ",
4682
4782
  isProcessing ? "stop" : "exit"
4683
4783
  ] })
4684
4784
  ] })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pentesting",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Autonomous Penetration Testing AI Agent",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",