Skip to content

Commit 48765fb

Browse files
committed
allow setting the RPORT option for pipe_auditor
1 parent b172ef8 commit 48765fb

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

modules/auxiliary/scanner/smb/pipe_auditor.rb

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ def initialize
2323
'Author' => 'hdm',
2424
'License' => MSF_LICENSE,
2525
)
26+
end
27+
28+
def connect(*args, **kwargs)
29+
super(*args, **kwargs, direct: @smb_direct)
30+
end
2631

27-
deregister_options('RPORT', 'SMBDirect')
32+
def rport
33+
@rport
2834
end
2935

3036
# Fingerprint a single host
@@ -40,10 +46,20 @@ def run_host(ip)
4046
self.simple.connect("\\\\#{session.address}\\IPC$")
4147
pipes += check_pipes
4248
else
43-
[[139, false], [445, true]].each do |info|
49+
if datastore['RPORT'].blank? || datastore['RPORT'] == 0
50+
smb_services = [
51+
{ port: 445, direct: true },
52+
{ port: 139, direct: false }
53+
]
54+
else
55+
smb_services = [
56+
{ port: datastore['RPORT'], direct: datastore['SMBDirect'] }
57+
]
58+
end
4459

45-
datastore['RPORT'] = info[0]
46-
datastore['SMBDirect'] = info[1]
60+
smb_services.each do |smb_service|
61+
@rport = smb_service[:port]
62+
@smb_direct = smb_service[:direct]
4763

4864
begin
4965
connect
@@ -52,12 +68,12 @@ def run_host(ip)
5268
disconnect
5369
break
5470
rescue Rex::Proto::SMB::Exceptions::SimpleClientError, Rex::ConnectionError => e
55-
vprint_error("SMB client Error with RPORT=#{info[0]} SMBDirect=#{info[1]}: #{e.to_s}")
71+
vprint_error("SMB client Error with RPORT=#{@rport} SMBDirect=#{@smb_direct}: #{e.to_s}")
5672
end
73+
5774
end
5875
end
5976

60-
6177
if(pipes.length > 0)
6278
print_good("Pipes: #{pipes.join(", ")}")
6379
# Add Report

0 commit comments

Comments
 (0)