Added Logic to Report Custom Exploit Flags #248
Merged
+240
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, one of our stated goals it to make interoperability with other software easy. One thing that breaks that is when an exploit defines command line parameters that aren't generally well known. What I don't mean is like "lhost", "rhost", "proxy", etc. Those are all well known and easily mapped out to specific exploit types.
I'm talking about this scenario. Consider our implementation for CVE-2024-45507:
Here we see the exploit define three flags. One of which is totally specific to the exploit (hostname) and two that are hooked into HTTPServeFile logic (we used httpservefile as the http server for this one... meta I actually like, but I digress).
From a "Let's use this programmatically to pwn the world" perspective, these are not great because (outside of the horrible
--help
menu) there is no way to discover them! So in this patch, I implement a way to bubble these three command line options into the--details
view.First, let me share our CVE-2024-45507 was redefined (the diff is sort of messy since I moved stuff, so this is likely easier):
Here you can see that instead of
flag
I'm usingconf.Create*Flag
. This actually eliminates the use of the globalHostname variable. Instead we usingconf.GetStringFlag("hostname")
:Additionally, --details now knows all about these three variables and their types (see CustomFlags):
The actual implementation in
config.go
is not actually all that different from howflag
works. They go the extra mile to mask types (although at the end of the day, they still have to define get/set for every type anyways and require type-oriented function anyways), but otherwise no big surprises. The parameters are stored in maps inconfig.go
for easy lookup... and that's about it.