forked from rapid7/metasploit-framework
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unify http and retry options between payloads #21
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This adds named parameters for all of the current array-index based options. It also allows specifying the description as the 2nd parameter, allowing the 'required' parameter to be implicitly false (the most common value). A simple parameter like: OptAddress.new('ReverseListenerBindAddress', [false, 'The specific IP address to bind to on the local system']), Can now be rewritten as: OptAddress.new('ReverseListenerBindAddress', 'The specific IP address to bind to on the local system'), More complex options are also now easier to read: OptString.new( 'HttpUserAgent', 'The user-agent that the payload should use', default: Rex::UserAgent.shortest, aliases: ['MeterpreterUserAgent'] ), This also makes dealing with enums easier because default is implicit unless specified. This: OptEnum.new('PayloadProxyType', [true, 'The proxy type, HTTP or SOCKS', 'HTTP', ['HTTP', 'SOCKS']]), Becomes: OptEnum.new('HttpProxyType', 'The proxy type, HTTP or SOCKS', required: true, enums: ['HTTP', 'SOCKS']) This maintains full backward compatibility with existing code as well.
this also adds aliases where needed
This was referenced Sep 24, 2017
I moved the generic stuff to rapid7#9000 |
Thanks @busterb, landed! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is one of those 'fix broken windows when you find them' commits, sorry for the extra length.
The first thing I did here was get annoyed by the module option declaration API, so I extended that along the way to not require as much boilerplate, while staying backward compatible. You'll notice that the newly DRY'd options use the newer more explicit syntax for specifying default values, enums, etc.
This also renames a number of parameters, the Proxy options and Http options, to all start with Http, including aliases for backward compatibility as well.
This resulted in a net addition for lines of code, mostly because I expanded a few option declarations to take multiple lines for better readability.