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/mysql/mysql_sql.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::MYSQL7include Msf::OptionalSession::MySQL89def initialize(info = {})10super(update_info(info,11'Name' => 'MySQL SQL Generic Query',12'Description' => %q{13This module allows for simple SQL statements to be executed14against a MySQL instance given the appropriate credentials.15},16'Author' => [ 'Bernardo Damele A. G. <bernardo.damele[at]gmail.com>' ],17'License' => MSF_LICENSE,18))1920register_options(21[22OptString.new('SQL', [ true, 'The SQL to execute.', 'select version()'])23])24end2526def auxiliary_commands27{ "select" => "Run a select query (a LIMIT clause is probably a really good idea)" }28end2930def cmd_select(*args)31datastore["SQL"] = "select #{args.join(" ")}"32run33end3435def run36# If we have a session make use of it37if session38print_status("Using existing session #{session.sid}")39self.mysql_conn = session.client40else41# otherwise fallback to attempting to login42return unless mysql_login_datastore43end4445print_status("Sending statement: '#{datastore['SQL']}'...")46res = mysql_query(datastore['SQL']) || []47res.each do |row|48print_status(" | #{row.join(" | ")} |")49end50end51end525354