Skip to content

Commit aaab834

Browse files
committed
Added excel report to icmp_recon and improved error handling on ssl analyzer
1 parent 6a0108e commit aaab834

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

icmp_recon.rb

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def initialize(arguments)
8181
@options.csv_report = false
8282
@options.html_report = false
8383
@options.rtf_report = false
84+
@options.excel_report = false
8485
@options.bypass_root_check = false
8586

8687
opts = OptionParser.new do |opts|
@@ -111,8 +112,12 @@ def initialize(arguments)
111112
@options.rtf_report = true
112113
end
113114

115+
opts.on("--excelReport", "Create an Excel Report") do |excelrep|
116+
@options.excel_report = true
117+
end
118+
114119
opts.on("--reportPrefix [REPREF]", "Prefix for report files") do |reppref|
115-
@options.report_file_base = reppref
120+
@options.report_file_base = reppref + "_icmp"
116121
end
117122

118123
opts.on("-b", "Bypass root check") do |bypass|
@@ -150,10 +155,10 @@ def initialize(arguments)
150155
exit
151156
end
152157

153-
unless @options.rtf_report || @options.csv_report || @options.html_report
158+
unless @options.rtf_report || @options.csv_report || @options.html_report || @options.excel_report
154159
@log.debug('errored on reporting check')
155160
puts "No reporting specified"
156-
puts " you need to use one or more of --csvReport, --rtfReport or --htmlReport"
161+
puts " you need to use one or more of --csvReport, --rtfReport, --htmlReport or --excelReport"
157162
exit
158163
end
159164

@@ -193,6 +198,7 @@ def run
193198
csv_report if @options.csv_report
194199
html_report if @options.html_report
195200
rtf_report if @options.rtf_report
201+
excel_report if @options.excel_report
196202
end
197203

198204
def icmp_scan
@@ -235,6 +241,55 @@ def csv_report
235241
end
236242
end
237243

244+
def excel_report
245+
begin
246+
require 'rubyXL'
247+
rescue LoadError
248+
puts "You need the rubyXL gem to run the excel report"
249+
puts "try gem install rubyXL"
250+
exit
251+
end
252+
253+
workbook = RubyXL::Workbook.new
254+
icmp_sheet = workbook.worksheets[0]
255+
icmp_sheet.sheet_name = "ICMP Recon Results"
256+
icmp_sheet.add_cell(0,0,"Address")
257+
icmp_sheet.add_cell(0,1,"Echo Response")
258+
icmp_sheet.add_cell(0,2,"Timestamp Response")
259+
icmp_sheet.add_cell(0,3,"Netmask Response")
260+
261+
row_count = 1
262+
@all_hosts.each do |address|
263+
icmp_sheet.add_cell(row_count,0,address)
264+
if @echo_hosts.include?(address)
265+
icmp_sheet.add_cell(row_count,1,"Y")
266+
icmp_sheet.sheet_data[row_count][1].change_fill('d4004b')
267+
else
268+
icmp_sheet.add_cell(row_count,1,"N")
269+
icmp_sheet.sheet_data[row_count][1].change_fill('27ae60')
270+
end
271+
272+
if @timestamp_hosts.include?(address)
273+
icmp_sheet.add_cell(row_count,2,"Y")
274+
icmp_sheet.sheet_data[row_count][2].change_fill('d4004b')
275+
else
276+
icmp_sheet.add_cell(row_count,2,"N")
277+
icmp_sheet.sheet_data[row_count][2].change_fill('27ae60')
278+
end
279+
280+
if @address_mask_hosts.include?(address)
281+
icmp_sheet.add_cell(row_count,3,"Y")
282+
icmp_sheet.sheet_data[row_count][3].change_fill('d4004b')
283+
else
284+
icmp_sheet.add_cell(row_count,3,"N")
285+
icmp_sheet.sheet_data[row_count][3].change_fill('27ae60')
286+
end
287+
row_count = row_count + 1
288+
end
289+
290+
workbook.write(@options.report_file_base + '.xlsx')
291+
end
292+
238293
def html_report
239294
@builder = Nokogiri::HTML::Builder.new do |doc|
240295
doc.html {

sslyzeautoanalyzer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ def excel_report
282282
require 'rubyXL'
283283
rescue LoadError
284284
puts "Excel report needs the rubyXL gem"
285+
exit
285286
end
286287

287288
workbook = RubyXL::Workbook.new

0 commit comments

Comments
 (0)