Skip to content
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
merged 14 commits into from Sep 26, 2017

Conversation

busterb
Copy link

@busterb busterb commented Sep 21, 2017

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.

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.
@busterb
Copy link
Author

busterb commented Sep 25, 2017

I moved the generic stuff to rapid7#9000

@OJ OJ merged commit b7933e7 into OJ:add-custom-http-headers Sep 26, 2017
@OJ
Copy link
Owner

OJ commented Sep 26, 2017

Thanks @busterb, landed!

OJ pushed a commit that referenced this pull request May 7, 2018
OJ pushed a commit that referenced this pull request Nov 28, 2018
OJ pushed a commit that referenced this pull request Aug 10, 2020
fix session abort with Ctrl C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants