Skip to content

Commit d10b20b

Browse files
committed
Land rapid7#5251, @hmoore-r7's second opportunity to Oracle connect
SYSTEM shouldn't have SYSDBA privileges by default anymore
2 parents 5bceeb4 + 41a86b2 commit d10b20b

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

lib/msf/core/exploit/oracle.rb

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,38 @@ def check_dependencies
5252
end
5353

5454
def connect
55+
handle = nil
56+
5557
if(not @oci8_loaded)
5658
raise RuntimeError, "Could not load the Oracle driver (oci8): #{@oci8_error}"
5759
end
5860

5961
# Create a Connection to the Database
6062
if datastore['DBUSER'] == 'SYS' || datastore['DBUSER'] == 'SYSTEM'
61-
handle = OCI8.new(
62-
datastore['DBUSER'],
63-
datastore['DBPASS'],
64-
"//#{datastore['RHOST']}:#{datastore['RPORT']}/#{datastore['SID']}",
65-
:SYSDBA
66-
)
63+
begin
64+
handle = OCI8.new(
65+
datastore['DBUSER'],
66+
datastore['DBPASS'],
67+
"//#{datastore['RHOST']}:#{datastore['RPORT']}/#{datastore['SID']}",
68+
:SYSDBA
69+
)
70+
rescue ::OCIError
71+
# Try again without a request for SYSDBA
72+
vprint_status('Insufficient privileges, trying without SYSDBA')
73+
handle = OCI8.new(
74+
datastore['DBUSER'],
75+
datastore['DBPASS'],
76+
"//#{datastore['RHOST']}:#{datastore['RPORT']}/#{datastore['SID']}"
77+
)
78+
end
6779
else
6880
handle = OCI8.new(
6981
datastore['DBUSER'],
7082
datastore['DBPASS'],
7183
"//#{datastore['RHOST']}:#{datastore['RPORT']}/#{datastore['SID']}"
7284
)
7385
end
74-
86+
handle
7587
end
7688

7789
def disconnect

0 commit comments

Comments
 (0)