Skip to content

Commit

Permalink
adjust mysql logic for unknown platform arch
Browse files Browse the repository at this point in the history
  • Loading branch information
zgoldman-r7 committed Apr 19, 2024
1 parent 5c89b6a commit 0c6af95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions lib/rex/proto/mysql/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ def current_database
# List of supported MySQL platforms & architectures:
# https://www.mysql.com/support/supportedplatforms/database.html
def map_compile_os_to_platform(compile_os)
return Msf::Platform::Unknown.realname if compile_os.blank?
return '' if compile_os.blank?

compile_os = compile_os.downcase.encode(::Encoding::BINARY)

if compile_os.match?('linux')
platform = Msf::Platform::Linux
platform = Msf::Platform::Linux.realname
elsif compile_os.match?('unix')
platform = Msf::Platform::Unix
platform = Msf::Platform::Unix.realname
elsif compile_os.match?(/(darwin|mac|osx)/)
platform = Msf::Platform::OSX
platform = Msf::Platform::OSX.realname
elsif compile_os.match?('win')
platform = Msf::Platform::Windows
platform = Msf::Platform::Windows.realname
elsif compile_os.match?('solaris')
platform = Msf::Platform::Solaris
platform = Msf::Platform::Solaris.realname
else
platform = Msf::Platform::Unknown
platform = compile_os
end

platform.realname
platform
end

def map_compile_arch_to_architecture(compile_arch)
Expand All @@ -71,7 +71,7 @@ def map_compile_arch_to_architecture(compile_arch)
elsif compile_arch.match?('86') || compile_arch.match?('i686')
arch = ARCH_X86
else
arch = ''
arch = compile_arch
end

arch
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/rex/proto/mysql/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
{ info: 'macos', expected: Msf::Platform::OSX.realname },
{ info: 'unix', expected: Msf::Platform::Unix.realname },
{ info: 'solaris', expected: Msf::Platform::Solaris.realname },
{ info: '', expected: Msf::Platform::Unknown.realname },
{ info: 'blank', expected: Msf::Platform::Unknown.realname },
{ info: nil, expected: Msf::Platform::Unknown.realname },
{ info: '', expected: '' },
{ info: 'blank', expected: 'blank' },
{ info: nil, expected: '' },
].each do |test|
it "correctly identifies '#{test[:info]}' as '#{test[:expected]}'" do
expect(subject.map_compile_os_to_platform(test[:info])).to eq(test[:expected])
Expand All @@ -69,7 +69,7 @@
{ info: 'sparc', expected: ARCH_SPARC },
{ info: 'sparc64', expected: ARCH_SPARC64 },
{ info: '', expected: '' },
{ info: 'blank', expected: '' },
{ info: 'blank', expected: 'blank' },
{ info: nil, expected: '' },
].each do |test|
it "correctly identifies '#{test[:info]}' as '#{test[:expected]}'" do
Expand Down

0 comments on commit 0c6af95

Please sign in to comment.