Skip to content

Commit

Permalink
Land #19163, Allow setting the RPORT option for smb_version
Browse files Browse the repository at this point in the history
  • Loading branch information
adfoster-r7 committed May 7, 2024
2 parents 8c76143 + 0863700 commit 2ea116e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
4 changes: 2 additions & 2 deletions modules/auxiliary/scanner/smb/smb_enumusers.rb
Expand Up @@ -43,8 +43,8 @@ def run_host(_ip)

if datastore['RPORT'].blank? || datastore['RPORT'] == 0
smb_services = [
{ port: 139, direct: false },
{ port: 445, direct: true }
{ port: 445, direct: true },
{ port: 139, direct: false }
]
else
smb_services = [
Expand Down
29 changes: 22 additions & 7 deletions modules/auxiliary/scanner/smb/smb_version.rb
Expand Up @@ -40,22 +40,26 @@ def initialize
'License' => MSF_LICENSE
)

register_options([
Msf::Opt::RPORT(nil, false)
])

register_advanced_options(
[
*kerberos_storage_options(protocol: 'SMB'),
*kerberos_auth_options(protocol: 'SMB', auth_methods: Msf::Exploit::Remote::AuthOption::SMB_OPTIONS),
]
)

deregister_options('RPORT', 'SMBDIRECT', 'SMB::ProtocolVersion')
deregister_options('SMB::ProtocolVersion')
end

def rport
@smb_port
@rport
end

def smb_direct
(@smb_port == 445)
def connect(*args, **kwargs)
super(*args, **kwargs, direct: @smb_direct)
end

def seconds_to_timespan(seconds)
Expand Down Expand Up @@ -189,10 +193,21 @@ def smb_os_description(res, nd_smb_fingerprint)
# Fingerprint a single host
#
def run_host(ip)
smb_ports = [445, 139]
if datastore['RPORT'].blank? || datastore['RPORT'] == 0
smb_services = [
{ port: 445, direct: true },
{ port: 139, direct: false }
]
else
smb_services = [
{ port: datastore['RPORT'], direct: datastore['SMBDirect'] }
]
end

lines = [] # defer status output to the very end to group lines together by host
smb_ports.each do |pnum|
@smb_port = pnum
smb_services.each do |smb_service|
@rport = smb_service[:port]
@smb_direct = smb_service[:direct]
self.simple = nil

begin
Expand Down

0 comments on commit 2ea116e

Please sign in to comment.