pentesting 0.7.5 → 0.7.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 +96 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4249,6 +4249,9 @@ var AutonomousHackingAgent = class extends EventEmitter4 {
|
|
|
4249
4249
|
output: 0,
|
|
4250
4250
|
total: 0
|
|
4251
4251
|
};
|
|
4252
|
+
// Execution control flags
|
|
4253
|
+
isPaused = false;
|
|
4254
|
+
isAborted = false;
|
|
4252
4255
|
// Rabbit hole detection settings
|
|
4253
4256
|
STUCK_THRESHOLD = 5;
|
|
4254
4257
|
// Same action repeat count
|
|
@@ -4450,6 +4453,13 @@ ${prompt}`
|
|
|
4450
4453
|
this.think(THOUGHT_TYPE.OBSERVATION, `Target Setting: ${target}`);
|
|
4451
4454
|
this.emit(AGENT_EVENT.TARGET_SET, target);
|
|
4452
4455
|
}
|
|
4456
|
+
// ===== Execution Control =====
|
|
4457
|
+
/**
|
|
4458
|
+
* Check if execution should stop (called by main loop)
|
|
4459
|
+
*/
|
|
4460
|
+
shouldStop() {
|
|
4461
|
+
return this.isPaused || this.isAborted;
|
|
4462
|
+
}
|
|
4453
4463
|
/**
|
|
4454
4464
|
* Add a target to the discovered list (multi-target support)
|
|
4455
4465
|
*/
|
|
@@ -4491,6 +4501,20 @@ ${prompt}`
|
|
|
4491
4501
|
}
|
|
4492
4502
|
return targets;
|
|
4493
4503
|
}
|
|
4504
|
+
/**
|
|
4505
|
+
* Clear all targets
|
|
4506
|
+
*/
|
|
4507
|
+
clearTargets() {
|
|
4508
|
+
this.state.target.primary = "";
|
|
4509
|
+
this.state.target.discovered = [];
|
|
4510
|
+
this.emit(AGENT_EVENT.TARGET_SET, { action: "cleared" });
|
|
4511
|
+
}
|
|
4512
|
+
/**
|
|
4513
|
+
* Get target count
|
|
4514
|
+
*/
|
|
4515
|
+
getTargetCount() {
|
|
4516
|
+
return this.getAllTargets().length;
|
|
4517
|
+
}
|
|
4494
4518
|
// ===== Phase Management =====
|
|
4495
4519
|
getCurrentPhase() {
|
|
4496
4520
|
return this.state.phases.find((p) => p.id === this.state.currentPhase);
|
|
@@ -4577,6 +4601,9 @@ ${prompt}`
|
|
|
4577
4601
|
* Uses string comparison to avoid TypeScript narrowing issues with const enums
|
|
4578
4602
|
*/
|
|
4579
4603
|
shouldStopLoop() {
|
|
4604
|
+
if (this.isPaused || this.isAborted) {
|
|
4605
|
+
return true;
|
|
4606
|
+
}
|
|
4580
4607
|
const status = this.state.status;
|
|
4581
4608
|
return status === AGENT_STATUS.PAUSED || status === AGENT_STATUS.COMPLETED || status === AGENT_STATUS.IDLE;
|
|
4582
4609
|
}
|
|
@@ -4846,6 +4873,10 @@ Use report_finding tool for important discoveries.
|
|
|
4846
4873
|
this.think(THOUGHT_TYPE.STUCK, `Tool blocked by hook: ${hookCheck.output}`);
|
|
4847
4874
|
continue;
|
|
4848
4875
|
}
|
|
4876
|
+
if (this.shouldStopLoop()) {
|
|
4877
|
+
this.think(THOUGHT_TYPE.OBSERVATION, "Execution paused before tool execution");
|
|
4878
|
+
break;
|
|
4879
|
+
}
|
|
4849
4880
|
if (this.approvalManager.requiresApproval(toolName, toolInput)) {
|
|
4850
4881
|
const risk = assessRisk(toolName, toolInput);
|
|
4851
4882
|
this.emit(AGENT_EVENT.APPROVAL_NEEDED, {
|
|
@@ -5197,19 +5228,30 @@ Available tools: ${this.tools.map((t) => t.name).join(", ")}
|
|
|
5197
5228
|
|
|
5198
5229
|
Respond helpfully to the user's message. If they ask to perform security testing actions, use the appropriate tools. Always explain what you're doing and why.`;
|
|
5199
5230
|
}
|
|
5200
|
-
// ===== Pause/Resume =====
|
|
5231
|
+
// ===== Pause/Resume/Abort =====
|
|
5201
5232
|
pause() {
|
|
5233
|
+
this.isPaused = true;
|
|
5202
5234
|
this.state.status = AGENT_STATUS.PAUSED;
|
|
5203
5235
|
this.emit(AGENT_EVENT.PAUSED);
|
|
5204
5236
|
}
|
|
5205
5237
|
resume() {
|
|
5238
|
+
this.isPaused = false;
|
|
5239
|
+
this.isAborted = false;
|
|
5206
5240
|
if (this.state.status === AGENT_STATUS.PAUSED) {
|
|
5207
5241
|
this.state.status = AGENT_STATUS.RUNNING;
|
|
5208
5242
|
this.emit(AGENT_EVENT.RESUMED);
|
|
5209
5243
|
}
|
|
5210
5244
|
}
|
|
5245
|
+
abort() {
|
|
5246
|
+
this.isPaused = true;
|
|
5247
|
+
this.isAborted = true;
|
|
5248
|
+
this.state.status = AGENT_STATUS.IDLE;
|
|
5249
|
+
this.emit(AGENT_EVENT.PAUSED);
|
|
5250
|
+
}
|
|
5211
5251
|
// ===== Reset =====
|
|
5212
5252
|
reset() {
|
|
5253
|
+
this.isPaused = false;
|
|
5254
|
+
this.isAborted = false;
|
|
5213
5255
|
this.state = this.createInitialState();
|
|
5214
5256
|
this.emit(AGENT_EVENT.RESET);
|
|
5215
5257
|
}
|
|
@@ -6637,10 +6679,15 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
6637
6679
|
agent.on(AGENT_EVENT.FINDING, (finding) => {
|
|
6638
6680
|
addMessage(MESSAGE_TYPE.SYSTEM, `\u{1F3AF} [${finding.severity.toUpperCase()}] ${finding.title}`);
|
|
6639
6681
|
wireLoggerRef.current?.statusUpdate({ event: "finding", ...finding });
|
|
6682
|
+
forceUpdate((n) => n + 1);
|
|
6640
6683
|
});
|
|
6641
6684
|
agent.on(AGENT_EVENT.PHASE_CHANGE, (data) => {
|
|
6642
6685
|
addMessage(MESSAGE_TYPE.SYSTEM, `\u{1F4CD} Phase: ${data.phaseId}`);
|
|
6643
6686
|
wireLoggerRef.current?.statusUpdate({ event: "phase_change", phase: data.phaseId });
|
|
6687
|
+
forceUpdate((n) => n + 1);
|
|
6688
|
+
});
|
|
6689
|
+
agent.on(AGENT_EVENT.CREDENTIAL, () => {
|
|
6690
|
+
forceUpdate((n) => n + 1);
|
|
6644
6691
|
});
|
|
6645
6692
|
agent.on(AGENT_EVENT.CONTEXT_COMPACTED, () => {
|
|
6646
6693
|
addMessage(MESSAGE_TYPE.SYSTEM, "\u{1F4BE} Context compacted to save tokens");
|
|
@@ -6728,9 +6775,12 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
6728
6775
|
addMessage(
|
|
6729
6776
|
MESSAGE_TYPE.SYSTEM,
|
|
6730
6777
|
`\u2500\u2500 Core \u2500\u2500
|
|
6731
|
-
/target [domain|ip] Set
|
|
6732
|
-
add <t>
|
|
6733
|
-
|
|
6778
|
+
/target [domain|ip] Set primary target
|
|
6779
|
+
add <t> Add to list rm <t> Remove
|
|
6780
|
+
list Show all set <t> Set primary
|
|
6781
|
+
clear Remove all targets
|
|
6782
|
+
/start [goal] Pentest primary target
|
|
6783
|
+
/start all Attack ALL targets
|
|
6734
6784
|
/stop Stop operation
|
|
6735
6785
|
/status Show status report
|
|
6736
6786
|
|
|
@@ -6828,10 +6878,17 @@ ${list}`);
|
|
|
6828
6878
|
if (args[1]) {
|
|
6829
6879
|
agent.setTarget(args[1]);
|
|
6830
6880
|
addMessage(MESSAGE_TYPE.SYSTEM, `\u2605 Primary target \u2192 ${args[1]}`);
|
|
6881
|
+
forceUpdate((n) => n + 1);
|
|
6831
6882
|
} else {
|
|
6832
6883
|
addMessage(MESSAGE_TYPE.ERROR, "Usage: /target set <domain|ip>");
|
|
6833
6884
|
}
|
|
6834
6885
|
break;
|
|
6886
|
+
case "clear":
|
|
6887
|
+
case "reset":
|
|
6888
|
+
agent.clearTargets();
|
|
6889
|
+
addMessage(MESSAGE_TYPE.SYSTEM, "\u2713 All targets cleared");
|
|
6890
|
+
forceUpdate((n) => n + 1);
|
|
6891
|
+
break;
|
|
6835
6892
|
default:
|
|
6836
6893
|
agent.setTarget(subCmd);
|
|
6837
6894
|
addMessage(MESSAGE_TYPE.SYSTEM, `\u{1F3AF} Target \u2192 ${subCmd}`);
|
|
@@ -6839,6 +6896,41 @@ ${list}`);
|
|
|
6839
6896
|
return;
|
|
6840
6897
|
case CLI_COMMAND.START:
|
|
6841
6898
|
case "s":
|
|
6899
|
+
if (args[0]?.toLowerCase() === "all") {
|
|
6900
|
+
const allTargets = agent.getAllTargets();
|
|
6901
|
+
if (allTargets.length === 0) {
|
|
6902
|
+
addMessage(MESSAGE_TYPE.ERROR, "No targets registered. Use /target add <domain|ip> first");
|
|
6903
|
+
return;
|
|
6904
|
+
}
|
|
6905
|
+
setIsProcessing(true);
|
|
6906
|
+
startTimer();
|
|
6907
|
+
const allObjective = args.slice(1).join(" ") || "Perform comprehensive penetration testing";
|
|
6908
|
+
addMessage(MESSAGE_TYPE.SYSTEM, `\u{1F680} Starting multi-target attack on ${allTargets.length} targets`);
|
|
6909
|
+
for (let i = 0; i < allTargets.length; i++) {
|
|
6910
|
+
const currentTarget = allTargets[i];
|
|
6911
|
+
if (agent.shouldStop()) {
|
|
6912
|
+
addMessage(MESSAGE_TYPE.SYSTEM, `\u23F8 Stopped at target ${i + 1}/${allTargets.length}`);
|
|
6913
|
+
break;
|
|
6914
|
+
}
|
|
6915
|
+
agent.setTarget(currentTarget);
|
|
6916
|
+
addMessage(MESSAGE_TYPE.SYSTEM, `
|
|
6917
|
+
\u2501\u2501\u2501 [${i + 1}/${allTargets.length}] ${currentTarget} \u2501\u2501\u2501`);
|
|
6918
|
+
forceUpdate((n) => n + 1);
|
|
6919
|
+
try {
|
|
6920
|
+
const session = await sessionManager2.createSession(allObjective, currentTarget);
|
|
6921
|
+
addMessage(MESSAGE_TYPE.SYSTEM, `\u{1F4C1} Session: ${session.id}`);
|
|
6922
|
+
agent.resume();
|
|
6923
|
+
await agent.runAutonomous(allObjective);
|
|
6924
|
+
} catch (e) {
|
|
6925
|
+
addMessage(MESSAGE_TYPE.ERROR, `${currentTarget}: ${e instanceof Error ? e.message : String(e)}`);
|
|
6926
|
+
}
|
|
6927
|
+
}
|
|
6928
|
+
stopTimer();
|
|
6929
|
+
setIsProcessing(false);
|
|
6930
|
+
setCurrentStatus("");
|
|
6931
|
+
addMessage(MESSAGE_TYPE.SYSTEM, `\u2713 Multi-target attack complete`);
|
|
6932
|
+
return;
|
|
6933
|
+
}
|
|
6842
6934
|
let startObjective = args.join(" ");
|
|
6843
6935
|
const firstArg = args[0];
|
|
6844
6936
|
if (firstArg && (firstArg.includes(".") || /^\d+\.\d+\.\d+\.\d+$/.test(firstArg))) {
|