Skip to content

Commit d41f05e

Browse files
committed
Land rapid7#2776 - Avoid having the same port twice
2 parents 198667b + 80eea97 commit d41f05e

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

modules/auxiliary/scanner/sap/sap_service_discovery.rb

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,20 @@ def run_host(ip)
4747
def_ports = [
4848
'32NN', '33NN', '48NN', '80NN', '36NN', '81NN', '5NN00', '5NN01', '5NN02',
4949
'5NN03', '5NN04', '5NN05', '5NN06', '5NN07', '5NN08', '5NN10', '5NN16',
50-
'5NN13', '5NN14', '5NN17', '5NN18', '5NN19', '21212', '21213', '59975',
51-
'59976', '4238', '4239','4240', '4241', '3299', '3298', '515', '7200',
52-
'7210', '7269', '7270', '7575', '5NN15', '39NN', '3909', '4NN00', '8200',
53-
'8210', '8220', '8230', '4363', '4444', '4445', '9999', '3NN01', '3NN02',
54-
'3NN03', '3NN04', '3NN05', '3NN06', '3NN07', '3NN08', '3NN11', '3NN17',
55-
'20003', '20004', '20005', '20006', '20007', '31596', '31597', '31602',
56-
'31601', '31604', '2000', '2001', '2002', '8355', '8357', '8351' ,'8352',
57-
'8353', '8366', '1090', '1095', '20201', '1099', '1089'
50+
'5NN13', '5NN14', '5NN17', '5NN18', '5NN19', '5NN15', '39NN', '4NN00',
51+
'3NN01', '3NN02', '3NN03', '3NN04', '3NN05', '3NN06', '3NN07', '3NN08',
52+
'3NN11', '3NN17'
5853
]
54+
55+
static_ports = [
56+
'21212', '21213', '59975', '59976', '4238', '4239','4240', '4241', '3299',
57+
'3298', '515', '7200', '7210', '7269', '7270', '7575', '3909', '8200',
58+
'8210', '8220', '8230', '4363', '4444', '4445', '9999', '20003', '20004',
59+
'20005', '20006', '20007', '31596', '31597', '31602', '31601', '31604',
60+
'2000', '2001', '2002', '8355', '8357', '8351' ,'8352', '8353', '8366',
61+
'1090', '1095', '20201', '1099', '1089'
62+
]
63+
5964
ports = []
6065

6166
# Build ports array from valid instance numbers
@@ -94,7 +99,7 @@ def run_host(ip)
9499
final_ports << dport.gsub("NN", inst)
95100
end
96101
end
97-
102+
final_ports.push(*static_ports)
98103
ports = final_ports
99104

100105
if ports.empty?
@@ -222,14 +227,15 @@ def run_host(ip)
222227
end
223228
print_good("#{ip}:#{port}\t - #{service} OPEN")
224229

225-
=begin
226-
report_note(:host => "#{ip}",
227-
:proto => 'TCP',
228-
:port => "#{port}",
229-
:type => 'SAP',
230-
:data => "#{service}")
231-
=end
232-
230+
begin
231+
report_note(
232+
:host => "#{ip}",
233+
:proto => 'TCP',
234+
:port => "#{port}",
235+
:type => 'SAP',
236+
:data => "#{service}"
237+
)
238+
end
233239
r << [ip,port,"open", service]
234240
rescue ::Rex::ConnectionRefused
235241
vprint_status("#{ip}:#{port}\t - TCP closed")

0 commit comments

Comments
 (0)