-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
Extract SMB, PostgreSQL, MySQL and MSSQL optional sessions into their own mixins #18770
Extract SMB, PostgreSQL, MySQL and MSSQL optional sessions into their own mixins #18770
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all works for and looks good to me and - seems to be an issue in #18763 as well, I'll add a commit to that following this pattern
995322f
to
60291ec
Compare
60291ec
to
448313e
Compare
@dwelch-r7 I think this needs a rebase 👀 |
4addfab
to
5b10b92
Compare
5b10b92
to
1e76bbc
Compare
Tested the steps outlined in the verification steps above and repeated those for the MySQL scenarios as well and everything appears to be working as expected 👍 Assuming we wont want to land this until we have the MSSQL modules in and tested against this as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything worked when tested but noticed a few things that may need updated due to lots of overlapping PRs and things needing updated since this was opened.
[ | ||
Msf::OptInt.new('SESSION', [ false, 'The session to run this module on' ]), | ||
Msf::Opt::RHOST(nil, false), | ||
Msf::Opt::RPORT(nil, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context: I think some final changes were made after this PR was put up.
Msf::Opt::RPORT(nil, false) | |
Msf::Opt::RPORT(3306, false) |
super( | ||
update_info( | ||
info, | ||
'SessionTypes' => %w[MySQL] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this added to address this comment?
Also, I have a PR that updates these session types to be aligned with the rest of framework to use lowercase. Makes sense to align it here as well to avoid a race condition on which PR lands first:
'SessionTypes' => %w[MySQL] | |
'SessionTypes' => %w[mysql] |
super( | ||
update_info( | ||
info, | ||
'SessionTypes' => %w[PostgreSQL] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
'SessionTypes' => %w[PostgreSQL] | |
'SessionTypes' => %w[postgresql] |
Msf::OptString.new('DATABASE', [ false, 'The database to authenticate against', 'postgres']), | ||
Msf::OptString.new('USERNAME', [ false, 'The username to authenticate as', 'postgres']), | ||
Msf::Opt::RHOST(nil, false), | ||
Msf::Opt::RPORT(nil, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as MySQL port
Msf::Opt::RPORT(nil, false) | |
Msf::Opt::RPORT(5432, false) |
lib/msf/core/optional_session/smb.rb
Outdated
super( | ||
update_info( | ||
info, | ||
'SessionTypes' => %w[SMB] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'SessionTypes' => %w[SMB] | |
'SessionTypes' => %w[smb] |
lib/msf/core/optional_session/smb.rb
Outdated
[ | ||
Msf::OptInt.new('SESSION', [ false, 'The session to run this module on' ]), | ||
Msf::Opt::RHOST(nil, false), | ||
Msf::Opt::RPORT(nil, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, the other session types needed the RPORT
value defaulted, is there a reason as to why the SMB session type doesn't require a default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea not sure what happened, I added it elsewhere in the default options values part of the info hash but it's not there now and I'm not sure what happened but makes sense to add it in here
@@ -18,7 +18,6 @@ def initialize | |||
), | |||
'Author' => ['theLightCosine'], | |||
'License' => MSF_LICENSE, | |||
'SessionTypes' => %w[PostgreSQL] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this was done here, but lots of other modules didn't have this removed. If we're going ahead with initialising the session type within the mixin, I'm assuming we want all of these removed?
Looks like it's mostly the MySQL and PostgreSQL modules were this was the case, so I assume you just forgot to remove them after updating the mxin 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking more about this, do we really want the session type not being on the module? As a user I'd expect to be able to view that kinda of module info within the module.
Just thinking removing the existing module information could cause confusion, whereas the call in the module is just more information for the user to work with. Not super strongly opinionated on this just thought I'd call it out 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it still appears when you do info -d
though right? I think that's how a majority of users would see it rather than looking at the module code itself
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that's true. Maybe I'm looking at it too much from a developer perspective were I'd be working with the module and just get my information there. Whereas you say, users would probably get it from console.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dean's current pattern looks good to me 👍
Needs a rebase, and probably some changes back-ported to the recently changed mssql modules 👍 |
1e76bbc
to
d258c52
Compare
9b9a175
to
d73293d
Compare
d73293d
to
fa5c4c0
Compare
Release NotesFixes a bug when multiple new session types (SMB, PostgreSQL, MSSQL, MySQL) were enabled with the |
Spotted an issue where having any of the new SMB/MySQL/PostgreSQL/MSSQL session type features enabled would end up enabling the new feature for each which was unintended, also fixes an issue where if the postgres session feature is enabled it starts registering postgres specific datastore options in the included other session type modules, this PR resolves both of these issues by splitting the
Msf::OptionalSession
out into individual mixins for each session type.The
Msf::OptionalSession
mixin is left quite bare at the minute, but it will fill up in the near future with stuff common to all sessions (like theSESSION
datastore option as an example) once the sessions are no longer behind individual feature flagsVerification steps
features set smb_session_type false
andfeatures set postgresql_session_type false
SESSION
datastore option is not available in the smb/postgres modulesDATABASE
datastore option registeredfeatures set smb_session_type true
andfeatures set postgresql_session_type false
SESSION
datastore option is not available in the postgres modulesSESSION
datastore option is available in the SMB modulesDATABASE
datastore option registeredfeatures set smb_session_type false
andfeatures set postgresql_session_type true
SESSION
datastore option is not available in the SMB modulesSESSION
datastore option is available in the postgres modulesDATABASE
datastore option registeredfeatures set smb_session_type true
andfeatures set postgresql_session_type true
SESSION
datastore option is available in the postgres/SMB modulesDATABASE
datastore option registeredContinue the above steps for each new session type