@@ -81,6 +81,7 @@ def initialize(arguments)
81
81
@options . csv_report = false
82
82
@options . html_report = false
83
83
@options . rtf_report = false
84
+ @options . excel_report = false
84
85
@options . bypass_root_check = false
85
86
86
87
opts = OptionParser . new do |opts |
@@ -111,8 +112,12 @@ def initialize(arguments)
111
112
@options . rtf_report = true
112
113
end
113
114
115
+ opts . on ( "--excelReport" , "Create an Excel Report" ) do |excelrep |
116
+ @options . excel_report = true
117
+ end
118
+
114
119
opts . on ( "--reportPrefix [REPREF]" , "Prefix for report files" ) do |reppref |
115
- @options . report_file_base = reppref
120
+ @options . report_file_base = reppref + "_icmp"
116
121
end
117
122
118
123
opts . on ( "-b" , "Bypass root check" ) do |bypass |
@@ -150,10 +155,10 @@ def initialize(arguments)
150
155
exit
151
156
end
152
157
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
154
159
@log . debug ( 'errored on reporting check' )
155
160
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 "
157
162
exit
158
163
end
159
164
@@ -193,6 +198,7 @@ def run
193
198
csv_report if @options . csv_report
194
199
html_report if @options . html_report
195
200
rtf_report if @options . rtf_report
201
+ excel_report if @options . excel_report
196
202
end
197
203
198
204
def icmp_scan
@@ -235,6 +241,55 @@ def csv_report
235
241
end
236
242
end
237
243
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
+
238
293
def html_report
239
294
@builder = Nokogiri ::HTML ::Builder . new do |doc |
240
295
doc . html {
0 commit comments