Skip to content

Commit 2abc636

Browse files
author
HD Moore
committed
Merge pull request #7 from jhart-r7/landing-4177-jhart
Clean up failure messaging when bad CHOST
2 parents 6b4eb9a + e658640 commit 2abc636

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

lib/msf/core/auxiliary/scanner.rb

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ def run
9696

9797
loop do
9898
# Stop scanning if we hit a fatal error
99-
break if @scan_errors.length > 0
99+
break if has_fatal_errors?
100100

101101
# Spawn threads for each host
102102
while (@tl.length < threads_max)
103103

104104
# Stop scanning if we hit a fatal error
105-
break if @scan_errors.length > 0
105+
break if has_fatal_errors?
106106

107107
ip = ar.next_ip
108108
break if not ip
@@ -131,7 +131,7 @@ def run
131131
end
132132

133133
# Stop scanning if we hit a fatal error
134-
break if @scan_errors.length > 0
134+
break if has_fatal_errors?
135135

136136
# Exit once we run out of hosts
137137
if(@tl.length == 0)
@@ -152,7 +152,7 @@ def run
152152
scanner_show_progress() if @show_progress
153153
end
154154

155-
scanner_report_fatal_errors
155+
scanner_handle_fatal_errors
156156
return
157157
end
158158

@@ -171,7 +171,7 @@ def run
171171
nohosts = false
172172

173173
# Stop scanning if we hit a fatal error
174-
break if @scan_errors.length > 0
174+
break if has_fatal_errors?
175175

176176
while (@tl.length < threads_max)
177177

@@ -218,7 +218,7 @@ def run
218218
end
219219

220220
# Stop scanning if we hit a fatal error
221-
break if @scan_errors.length > 0
221+
break if has_fatal_errors?
222222

223223
# Exit if there are no more pending threads
224224
if (@tl.length == 0)
@@ -241,7 +241,7 @@ def run
241241
scanner_show_progress() if @show_progress
242242
end
243243

244-
scanner_report_fatal_errors
244+
scanner_handle_fatal_errors
245245
return
246246
end
247247

@@ -264,18 +264,23 @@ def seppuko!
264264
end
265265
end
266266

267-
def scanner_report_fatal_errors
268-
return unless @scan_errors && @scan_errors.length > 0
267+
def has_fatal_errors?
268+
@scan_errors && !@scan_errors.empty?
269+
end
270+
271+
def scanner_handle_fatal_errors
272+
return unless has_fatal_errors?
269273
return unless @tl
270274

271275
# First kill any running threads
272276
@tl.each {|t| t.kill if t.alive? }
273277

274278
# Show the unique errors triggered by the scan
275-
@scan_errors.uniq.each do |emsg|
279+
uniq_errors = @scan_errors.uniq
280+
uniq_errors.each do |emsg|
276281
print_error("Fatal: #{emsg}")
277282
end
278-
print_status("Scan terminated due to one or more fatal errors")
283+
print_error("Scan terminated due to #{uniq_errors.size} fatal error(s)")
279284
end
280285

281286
def scanner_progress
@@ -284,6 +289,8 @@ def scanner_progress
284289
end
285290

286291
def scanner_show_progress
292+
# it should already be in the process of shutting down if there are fatal errors
293+
return if has_fatal_errors?
287294
pct = scanner_progress
288295
if pct >= (@range_percent + @show_percent)
289296
@range_percent = @range_percent + @show_percent

0 commit comments

Comments
 (0)