Skip to content

Commit d1a836e

Browse files
author
HD Moore
committed
Fix logins where SYSTEM doesnt have SYSDBA privileges
1 parent 4ffffa5 commit d1a836e

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

lib/msf/core/exploit/oracle.rb

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,37 @@ 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+
handle = OCI8.new(
73+
datastore['DBUSER'],
74+
datastore['DBPASS'],
75+
"//#{datastore['RHOST']}:#{datastore['RPORT']}/#{datastore['SID']}"
76+
)
77+
end
6778
else
6879
handle = OCI8.new(
6980
datastore['DBUSER'],
7081
datastore['DBPASS'],
7182
"//#{datastore['RHOST']}:#{datastore['RPORT']}/#{datastore['SID']}"
7283
)
7384
end
74-
85+
handle
7586
end
7687

7788
def disconnect

0 commit comments

Comments
 (0)