Skip to content

Commit

Permalink
Add MySQL Arch & Platform detection by query
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanusz-r7 committed Apr 2, 2024
1 parent 6a32f81 commit 8aa2eb6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/msf/core/module/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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' ]
end

#
Expand Down
23 changes: 23 additions & 0 deletions lib/rex/proto/mysql/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,29 @@ def current_database
# Current database is stored as an array under the type 1 key.
session_track.fetch(1, ['']).first
end

# @return [Hash] Server version variables:
# * :arch [String] The server architecture.
# * :platform [String] The server platform.
def query_server_vars
result = {}

server_vars = query("show variables where variable_name in ('version_compile_machine', 'version_compile_os')").entries
server_vars.each do |server_var|
name, value = server_var

case name
when 'version_compile_machine'
result[:arch] = value
when 'version_compile_os'
result[:platform] = value
else
next
end
end

result
end
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions modules/auxiliary/scanner/mysql/mysql_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ def session_setup(result, client)
'PASSWORD' => result.credential.private
}

server_vars = my_session.client.query_server_vars
my_session.arch = server_vars[:arch]
my_session.platform = server_vars[:platform]

start_session(self, nil, merging, false, my_session.rstream, my_session)
end
end

0 comments on commit 8aa2eb6

Please sign in to comment.