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/admin/mssql/mssql_sql.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::OptionalSession::MSSQL89def initialize(info = {})10super(update_info(info,11'Name' => 'Microsoft SQL Server Generic Query',12'Description' => %q{13This module will allow for simple SQL statements to be executed against a14MSSQL/MSDE instance given the appropriate credentials.15},16'Author' => [ 'tebo <tebo[at]attackresearch.com>' ],17'License' => MSF_LICENSE,18'References' =>19[20[ 'URL', 'http://www.attackresearch.com' ],21[ 'URL', 'http://msdn.microsoft.com/en-us/library/cc448435(PROT.10).aspx'],22]23))2425register_options(26[27OptString.new('SQL', [ false, 'The SQL query to execute', 'select @@version']),28])29end3031def auxiliary_commands32{ "select" => "Run a select query (a LIMIT clause is probably a really good idea)" }33end3435def cmd_select(*args)36datastore["SQL"] = "select #{args.join(" ")}"37run38end3940def run41if session42set_mssql_session(session.client)43else44unless mssql_login_datastore45print_error("Error with mssql_login call")46info = self.mssql_client.initial_connection_info47if info[:errors] && !info[:errors].empty?48info[:errors].each do |err|49print_error(err)50end51end52return53end54end5556mssql_query(datastore['SQL'], true)57end58end596061