Skip to content

Commit b05198c

Browse files
committed
Clean up failure messaging when bad CHOST
1 parent 6b4eb9a commit b05198c

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

lib/msf/core/auxiliary/scanner.rb

Lines changed: 16 additions & 10 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,8 +264,12 @@ 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
@@ -275,7 +279,7 @@ def scanner_report_fatal_errors
275279
@scan_errors.uniq.each do |emsg|
276280
print_error("Fatal: #{emsg}")
277281
end
278-
print_status("Scan terminated due to one or more fatal errors")
282+
print_error("Scan terminated due to one or more fatal errors")
279283
end
280284

281285
def scanner_progress
@@ -284,6 +288,8 @@ def scanner_progress
284288
end
285289

286290
def scanner_show_progress
291+
# it should already be in the process of shutting down if there are fatal errors
292+
return if has_fatal_errors?
287293
pct = scanner_progress
288294
if pct >= (@range_percent + @show_percent)
289295
@range_percent = @range_percent + @show_percent

0 commit comments

Comments
 (0)