Skip to content

Commit

Permalink
cache prelogin packet
Browse files Browse the repository at this point in the history
  • Loading branch information
zgoldman-r7 committed Apr 24, 2024
1 parent 04c5d8b commit c990542
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions lib/rex/proto/mssql/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ def detect_platform_and_arch
#

def mssql_login(user='sa', pass='', db='', domain_name='')
mssql_prelogin

prelogin_data = mssql_prelogin
if auth == Msf::Exploit::Remote::AuthOption::KERBEROS
idx = 0
pkt = ''
Expand Down Expand Up @@ -234,6 +233,7 @@ def mssql_login(user='sa', pass='', db='', domain_name='')
info = {:errors => []}
info = mssql_parse_reply(resp, info)
self.initial_connection_info = info
self.initial_connection_info[:prelogin_data] = prelogin_data

return false if not info
return info[:login_ack] ? true : false
Expand Down Expand Up @@ -466,6 +466,7 @@ def mssql_login(user='sa', pass='', db='', domain_name='')
info = {:errors => []}
info = mssql_parse_reply(resp, info)
self.initial_connection_info = info
self.initial_connection_info[:prelogin_data] = prelogin_data

return false if not info
info[:login_ack] ? true : false
Expand Down
12 changes: 6 additions & 6 deletions modules/auxiliary/scanner/mssql/mssql_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ def initialize
def run
if session
set_mssql_session(session.client)
data = mssql_client.initial_connection_info[:prelogin_data]
else
create_mssql_client
data = mssql_prelogin
end

data = mssql_prelogin

if data.blank?
print_error("Unable to retrieve version information for #{mssql_client.address}")
print_error("Unable to retrieve version information for #{mssql_client.peerhost}")
return
end

data[:status] = 'open' if data[:version] || data[:encryption]

print_status("SQL Server for #{mssql_client.address}:")
print_status("SQL Server for #{mssql_client.peerhost}:")
if data[:version]
print_good("Version: #{data[:version]}")
else
Expand All @@ -61,7 +61,7 @@ def run
print_error('Unknown encryption status')
end

report_mssql_service(mssql_client.address, data)
report_mssql_service(mssql_client.peerhost, data)
mssql_client.disconnect
end

Expand All @@ -72,7 +72,7 @@ def report_mssql_service(ip, data)
]
report_service(
host: ip,
port: mssql_client.port,
port: mssql_client.peerport,
name: 'mssql',
info: mssql_info,
state: (data['Status'].nil? ? 'closed' : data['Status'])
Expand Down

0 comments on commit c990542

Please sign in to comment.