Land #8412, fix for smb_login errors
Merge branch 'land-8412' into upstream-masterbug/bundler_fix 4.14.19
commit
02211db664
|
@ -343,7 +343,7 @@ GEM
|
|||
rspec-mocks (~> 3.6.0)
|
||||
rspec-support (~> 3.6.0)
|
||||
rspec-support (3.6.0)
|
||||
ruby_smb (0.0.12)
|
||||
ruby_smb (0.0.14)
|
||||
bindata
|
||||
rubyntlm
|
||||
windows_error
|
||||
|
|
|
@ -100,19 +100,21 @@ module Metasploit
|
|||
client = RubySMB::Client.new(self.dispatcher, username: username, password: password, domain: realm)
|
||||
status_code = client.login
|
||||
|
||||
# Windows SMB will return an error code during Session
|
||||
# Setup, but nix Samba requires a Tree Connect. Try admin$
|
||||
# first, since that will tell us if this user has local
|
||||
# admin access. Fall back to IPC$ which should be accessible
|
||||
# to any user with valid creds.
|
||||
begin
|
||||
tree = client.tree_connect("\\\\#{host}\\admin$")
|
||||
# Check to make sure we can write a file to this dir
|
||||
if tree.permissions.add_file == 1
|
||||
access_level = AccessLevels::ADMINISTRATOR
|
||||
if status_code == WindowsError::NTStatus::STATUS_SUCCESS
|
||||
# Windows SMB will return an error code during Session
|
||||
# Setup, but nix Samba requires a Tree Connect. Try admin$
|
||||
# first, since that will tell us if this user has local
|
||||
# admin access. Fall back to IPC$ which should be accessible
|
||||
# to any user with valid creds.
|
||||
begin
|
||||
tree = client.tree_connect("\\\\#{host}\\admin$")
|
||||
# Check to make sure we can write a file to this dir
|
||||
if tree.permissions.add_file == 1
|
||||
access_level = AccessLevels::ADMINISTRATOR
|
||||
end
|
||||
rescue Exception => e
|
||||
client.tree_connect("\\\\#{host}\\IPC$")
|
||||
end
|
||||
rescue Exception => e
|
||||
client.tree_connect("\\\\#{host}\\IPC$")
|
||||
end
|
||||
|
||||
case status_code.name
|
||||
|
|
Loading…
Reference in New Issue