Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/scanner/mssql/mssql_version.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::MSSQL7include Msf::Auxiliary::Scanner8include Msf::OptionalSession::MSSQL910def initialize11super(12'Name' => 'MSSQL Version Utility',13'Description' => 'Executes a TDS7 pre-login request against the MSSQL instance to query for version information.',14'Author' => 'Zach Goldman',15'License' => MSF_LICENSE16)1718register_options([19Opt::RPORT(1433)20])21end2223def run24if session25set_mssql_session(session.client)26data = mssql_client.initial_connection_info[:prelogin_data]27else28create_mssql_client29data = mssql_prelogin30end3132if data.blank?33print_error("Unable to retrieve version information for #{mssql_client.peerhost}")34return35end3637data[:status] = 'open' if data[:version] || data[:encryption]3839print_status("SQL Server for #{mssql_client.peerhost}:")40if data[:version]41print_good("Version: #{data[:version]}")42else43print_error('Unknown Version')44end45if data[:encryption]46case data[:encryption]47when ENCRYPT_OFF48data[:encryption] = 'off'49when ENCRYPT_ON50data[:encryption] = 'on'51when ENCRYPT_NOT_SUP52data[:encryption] = 'unsupported'53when ENCRYPT_REQ54data[:encryption] = 'required'55else56data[:encryption] = 'unknown'57end58print_good("Encryption: #{data[:encryption]}")59else60print_error('Unknown encryption status')61end6263report_mssql_service(mssql_client.peerhost, data)64end6566def report_mssql_service(ip, data)67mssql_info = 'Version: %<version>s, Encryption: %<encryption>s' % [68version: data[:version] || 'unknown',69encryption: data[:encryption] || 'unknown'70]71report_service(72host: ip,73port: mssql_client.peerport,74name: 'mssql',75info: mssql_info,76state: (data['Status'].nil? ? 'closed' : data['Status'])77)78end79end808182