Lucene search
K

MySQL SQL Generic Query

🗓️ 26 Dec 2009 05:22:34Reported by Bernardo Damele A. G. <[email protected]>Type 
metasploit
 metasploit
🔗 www.rapid7.com👁 16 Views

This module allows for execution of simple SQL statements against a MySQL instance with appropriate credentials

Code
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Auxiliary
  include Msf::Exploit::Remote::MYSQL
  include Msf::OptionalSession::MySQL

  def initialize(info = {})
    super(update_info(info,
      'Name'			=> 'MySQL SQL Generic Query',
      'Description'	=> %q{
          This module allows for simple SQL statements to be executed
          against a MySQL instance given the appropriate credentials.
      },
      'Author'		=> [ 'Bernardo Damele A. G. <bernardo.damele[at]gmail.com>' ],
      'License'		=> MSF_LICENSE,
    ))

    register_options(
      [
        OptString.new('SQL', [ true, 'The SQL to execute.',  'select version()'])
      ])
  end

  def auxiliary_commands
    { "select" => "Run a select query (a LIMIT clause is probably a really good idea)" }
  end

  def cmd_select(*args)
    datastore["SQL"] = "select #{args.join(" ")}"
    run
  end

  def run
    # If we have a session make use of it
    if session
      print_status("Using existing session #{session.sid}")
      self.mysql_conn = session.client
    else
      # otherwise fallback to attempting to login
      return unless mysql_login_datastore
    end

    print_status("Sending statement: '#{datastore['SQL']}'...")
    res = mysql_query(datastore['SQL']) || []
    res.each do |row|
      print_status(" | #{row.join(" | ")} |")
    end
  end
end

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

14 Feb 2024 15:45Current
7.8High risk
Vulners AI Score7.8
16