-
Notifications
You must be signed in to change notification settings - Fork 14k
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
Add MySQL Arch & Platform detection by query #19022
Add MySQL Arch & Platform detection by query #19022
Conversation
57ffda4
to
1991a4c
Compare
1991a4c
to
d76d12d
Compare
turning this into draft until I fix the MySQL acceptance tests & convert the mysql_enum module to use the server variables if present. |
d76d12d
to
df2f866
Compare
3c4e39e
to
8aa2eb6
Compare
lib/rex/proto/mysql/client.rb
Outdated
# @return [Hash] Server version variables: | ||
# * :arch [String] The server architecture. | ||
# * :platform [String] The server platform. | ||
def query_server_vars |
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.
What are your thoughts on naming this something more granular, since this is a very specific implementation that handles trying to detect the target's platform+arch, and in the future it might not even query the remote server - it might use the original server version connection string that it was greeted with
Maybe one of:
def platform_and_arch
def detect_platform_and_arch
- similar to the jboss mixin, and a bunch of other modules that use thedef detect_*
conventiondef get_platform_and_arch
- similar to the mssql_clr_payload module
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.
Or I guess an explicit def query_platform_and_arch
style method works too, as in the future we could provide a different implementation that does it based the connection details - your call 👍
lib/msf/core/module/platform.rb
Outdated
@@ -383,7 +383,7 @@ class Ruby < Msf::Module::Platform | |||
# | |||
class Linux < Msf::Module::Platform | |||
Rank = 100 | |||
Alias = "linux" | |||
Aliases = [ 'linux', 'debian-linux-gnu', 'linux2.6' ] |
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.
Is there any extra details here? Is this for this part:
Verify that targeting a MariaDB server results in an x86_64 debian-linux-gnu platform, but you can call Msf::Module::Platform.find_platform(framework.sessions[session_id_here].platform) and that it returns Linux.
If so, I'm guessing we'd need a lot of new aliases for all of the possibilities that mysql will return? Or do the docs say the server will only return these values? Or does the mysql client need to normalize the platform value a bit more for the different possibilities that could be returned - presumably windows would need to be handled differently too?
8aa2eb6
to
733f42b
Compare
733f42b
to
d318b9f
Compare
d318b9f
to
a757831
Compare
edd63ca
to
d428737
Compare
@@ -5,7 +5,7 @@ | |||
|
|||
RSpec.describe Msf::Sessions::MySQL do | |||
let(:client) { instance_double(::Rex::Proto::MySQL::Client) } | |||
let(:opts) { { client: client } } | |||
let(:opts) { { client: client, platform: 'Linux', arch: 'x86_64' } } |
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 to confirm; should this be Msf::Platform::Linux
or Linux
? 👀
d428737
to
a862b16
Compare
Release NotesThis PR adds support to detect the MySQL server's host's platform and arch by running a query. |
This PR adds in the ability to detect the MySQL server's host's platform and arch by running a query.
In the future, this should instead be gathered from the initial server connection info similar to MSSQL's ENVCHANGE and
initial_connection_info
. However I wasn't able to verify this information in WireShark as the data is encrypted, even if theSSL
option is set to false:In the above image, the initial MySQL connection receives an error 1158,
Got an error reading communication packets
. The second connection request is successful, but encrypted using TLS.Before
After
Confirming we get the correct platform from the string:
Verification
Get yourself a MySQL Docker container:
and MariaDB:
msfconsole
use mysql_login
run rhost={...} etc.
sessions
returns you a MySQL Linux x86_64 session.Msf::Module::Platform.find_platform(framework.sessions[session_id_here].platform)
and that it returns Linux.