Skip to content

Commit

Permalink
Update ssh login pubkey module to correctly identify windows ssh plat…
Browse files Browse the repository at this point in the history
…form
  • Loading branch information
adfoster-r7 committed Nov 17, 2023
1 parent 04361e1 commit 1b12dc3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/metasploit/framework/ssh/platform.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def self.get_platform_from_info(info)
'hpux'
when /AIX/i
'aix'
when /cygwin|Win32|Windows|Microsoft/i
when /MSYS_NT|cygwin|Win32|Windows|Microsoft/i
'windows'
when /Unknown command or computer name|Line has invalid autocommand/i
'cisco-ios'
Expand Down
17 changes: 17 additions & 0 deletions spec/lib/metasploit/framework/ssh/platform_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'
require 'metasploit/framework/ssh/platform'

RSpec.describe Metasploit::Framework::Ssh::Platform do
describe '.get_platform_from_info' do
[
{
info: 'uid=197616(vagrant) gid=197121(None) groups=197121(None),11(Authenticated Users),66048(LOCAL),66049(CONSOLE LOGON),4(INTERACTIVE),15(This Organization),545(Users),4095(CurrentSession),544(Administrators),559(Performance Log Users),405504(High Mandatory Level) MSYS_NT-10.0-17763 EC2AMAZ-PDSMQ8L 3.4.9.x86_64 2023-09-15 12:15 UTC x86_64 Msys ',
expected: 'windows'
}
].each do |test|
it "correctly identifies #{test[:info]} as #{test[:expected]}" do
expect(described_class.get_platform_from_info(test[:info])).to eq(test[:expected])
end
end
end
end
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
# https://github.com/rapid7/rex-text/blob/11e59416f7d8cce18b8b8b9893b3277e6ad0bea1/lib/rex/text/wrapped_table.rb#L74
# This can cause some integration tests to fail if the tests are run from smaller consoles
# This mock will ensure that the tests run without word-wrapping.
require 'bigdecimal'
config.before(:each) do
mock_io_console = double(:console, winsize: { rows: 30, columns: ::BigDecimal::INFINITY }.values)
allow(::IO).to receive(:console).and_return(mock_io_console)
Expand Down

0 comments on commit 1b12dc3

Please sign in to comment.