Repository navigation
Add optional Cleanuper interface for post-exploit artifact undo - #596
vlobstein-vc wants to merge 3 commits into
Conversation
Signed-off-by: Valentin Lobstein <281638514+vlobstein-vc@users.noreply.github.com>
| flag.BoolVar(&conf.NoCleanup, "no-cleanup", false, | ||
| "Skip the optional Cleanup method after RunExploit (any artifact created on the target will remain)") |
There was a problem hiding this comment.
If the programmer implements a cleanup function, don't you think it should always just be called after -e usage?
There was a problem hiding this comment.
Default is cleanup-on; the flag is the operator-side escape hatch for inspecting a dropper, leaving the artifact for blue-team analysis, or diffing a clean run vs a failed one. Happy to drop it if you still think it's not worth the surface.
| return true | ||
| } | ||
|
|
||
| func (s *MyExploit) Cleanup(conf *config.Config) bool { |
There was a problem hiding this comment.
I think very often people will want to use the shell the acquired to do cleanup. Can this support that in some way?
There was a problem hiding this comment.
Yeah I see what you mean, shell-driven cleanup is genuinely useful but it's a different surface (channel-side state + post-session dispatch hook) so I'd rather open it as a follow-up PR than balloon this one.
Signed-off-by: Valentin Lobstein <281638514+vlobstein-vc@users.noreply.github.com>
Signed-off-by: Valentin Lobstein <281638514+vlobstein-vc@users.noreply.github.com>
Summary
Adds an optional
Cleanuperinterface. Modules opt in by implementingCleanup(conf *config.Config) boolalongsideValidateTarget,CheckVersion, andRunExploit. The framework callsCleanupafterRunExploitreturns, regardless of success or failure. A panic inRunExploitis recovered, surfaced at framework error level, andCleanupstill fires before the scan moves on, so a single misbehaving target does not take down the whole run. Operators can pass-no-cleanupto skip the call.Usage
Notes
Cleanupare unchanged; the framework's deferred type assertion is hoisted out of the defer so the no-op path costs nothing.RunExploit. Documented on the interface and indocs/getting-started.md.RunExploitis recovered inside the cleanup defer: the value is logged viaoutput.PrintfFrameworkError("RunExploit panicked: %v", r),Cleanupstill runs, the scan continues onto the next target.-no-cleanupwired incli.exploitFunctionality; the framework prints a warning when the call is skipped.