Skip to content

Commit

Permalink
adds pattern to catch other arch and platform values
Browse files Browse the repository at this point in the history
  • Loading branch information
zgoldman-r7 committed Apr 23, 2024
1 parent a554e52 commit 528ad85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rex/proto/mssql/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def map_compile_os_to_platform(server_info)
platform = Msf::Platform::Windows.realname
elsif os_data.match?('win')
platform = Msf::Platform::Windows.realname
elsif os_data.match?(/\bon\b\s+(\w+)/)
platform = os_data.match(/\bon\b\s+(\w+)/)[1]
else
platform = os_data
end
Expand All @@ -103,6 +105,8 @@ def map_compile_arch_to_architecture(server_info)
arch = ARCH_X86_64
elsif arch_data.match?('32-bit')
arch = ARCH_X86
elsif arch_data.match?(/\b\d+\.\d+\.\d+\.\d+\s\(([^)]*)\)/)
arch = arch_data.match(/\b\d+\.\d+\.\d+\.\d+\s\(([^)]*)\)/)[1]
else
arch = arch_data
end
Expand Down
1 change: 1 addition & 0 deletions spec/lib/rex/proto/mssql/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
[
{ version: 'Microsoft SQL Server 2022 (RTM-CU12) (KB5033663) - 16.0.4115.5 (X64) Mar 4 2024 08:56:10 Copyright (C) 2022 Microsoft Corporation Developer Edition (64-bit) on Linux (Ubuntu 22.04.4 LTS) <X64>', expected: { arch: 'x86_64', platform: 'Linux' } },
{ version: 'Microsoft SQL Server 2022 (RTM) - 16.0.1000.6 (X64) Oct 8 2022 05:58:25 Copyright (C) 2022 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2022 Standard 10.0 <X64> (Build 20348: ) (Hypervisor)', expected: { arch: 'x86_64', platform: 'Windows' } },
{ version: 'Microsoft SQL Server 2022 (RTM) - 16.0.1000.6 (32) Oct 8 2022 05:58:25 Copyright (C) 2022 Microsoft Corporation Developer Edition (2-bit) on Mac Standard 10.0 <??> (Build 20348: ) (Hypervisor)', expected: { arch: '32', platform: 'mac' } },
].each do |test|
context "when the database is version #{test[:version]}" do
it "returns #{test[:expected]}" do
Expand Down

0 comments on commit 528ad85

Please sign in to comment.