ruby-nessus 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/examples/example.rb CHANGED
@@ -6,35 +6,34 @@ require 'ruby-nessus'
6
6
 
7
7
  # Ruby-Nessus Example
8
8
 
9
- Nessus::XML.new("example.nessus") do |scan|
10
-
9
+ Nessus::XML.new("example.nessus") do |scan|
11
10
  puts "== SCAN ====================\n"
12
-
13
- puts "Title: #{scan.report_time.pretty}"
14
- puts "Policy: #{scan.policy_name}"
15
- puts "Policy Description: #{scan.policy_name}"
16
- puts "Start Time: #{scan.start_time.pretty}"
17
- puts "Stop Time: #{scan.stop_time.pretty}"
11
+
12
+ puts "Title: #{scan.title} #{scan.time}"
13
+ puts "Policy: #{scan.policy_title}"
14
+ puts "Policy Description: #{scan.policy_notes}"
15
+ puts "Start Time: #{scan.start_time}"
16
+ puts "Stop Time: #{scan.stop_time}"
18
17
  puts "Run Time: #{scan.runtime}"
19
18
  puts "Host Count: #{scan.host_count}"
20
19
  puts "Percentage Of Medium Events: #{scan.event_percentage_for('medium', true)}%"
21
-
20
+
22
21
  puts "Low: #{scan.low_severity_count}"
23
22
  puts "Medium: #{scan.medium_severity_count}"
24
23
  puts "High: #{scan.high_severity_count}"
25
24
  puts "Total: #{scan.total_event_count}"
26
-
25
+
27
26
  puts "\n"
28
27
  puts "== HOSTS ====================\n"
29
-
28
+
30
29
  scan.hosts do |host|
31
30
  next if host.event_count.zero?
32
31
  puts "Hostname: #{host.hostname}"
33
-
34
- puts "Start Time: #{host.scan_start_time.pretty}"
35
- puts "Stop Time: #{host.scan_stop_time.pretty}"
32
+
33
+ puts "Start Time: #{host.scan_start_time}" if host.scan_start_time
34
+ puts "Stop Time: #{host.scan_stop_time}" if host.scan_stop_time
36
35
  puts "Run Time: #{host.scan_runtime}"
37
-
36
+
38
37
  puts "Open Ports: #{host.open_ports}"
39
38
  puts "High Severity Events: #{host.high_severity_events}"
40
39
  puts "Medium Severity Events: #{host.medium_severity_events}"
@@ -19,8 +19,8 @@ Prawn::Document.generate("ruby-nessus-example.pdf") do
19
19
 
20
20
  text("#{scan.title}", :size => 20)
21
21
  move_down 2
22
- text("Policy: #{scan.policy_name}")
23
- text("Policy Description: #{scan.policy_name}")
22
+ text("Policy: #{scan.policy_title}")
23
+ text("Policy Description: #{scan.policy_notes}")
24
24
  text("Runtime: #{scan.runtime}")
25
25
  move_down 10
26
26
 
@@ -1,5 +1,5 @@
1
1
  %PDF-1.3
2
- ����
2
+ %����
3
3
  1 0 obj
4
4
  << /Creator (Prawn)
5
5
  /Producer (Prawn)
@@ -12,12 +12,12 @@ endobj
12
12
  >>
13
13
  endobj
14
14
  3 0 obj
15
- << /Pages 2 0 R
16
- /Type /Catalog
15
+ << /Type /Catalog
16
+ /Pages 2 0 R
17
17
  >>
18
18
  endobj
19
19
  4 0 obj
20
- << /Length 7303
20
+ << /Length 6771
21
21
  >>
22
22
  stream
23
23
  0.000 0.000 0.000 rg
@@ -41,7 +41,7 @@ ET
41
41
  BT
42
42
  36 714.014 Td
43
43
  /F1.0 9 Tf
44
- [<50> 50 <6f6c696379204465736372> -15 <697074696f6e3a> 50 <20527562> 20 <792d4e6573737573204578616d706c652050> 50 <6f6c696379>] TJ
44
+ [<50> 50 <6f6c696379204465736372> -15 <697074696f6e3a> 50 <20> 50 <5468697320697320616e2065> 30 <78616d706c65202e6e65737375732066696c652066> 30 <6f722074657374696e672074686520527562> 20 <792d4e65737375732067656d2e>] TJ
45
45
  ET
46
46
 
47
47
 
@@ -52,7 +52,7 @@ BT
52
52
  ET
53
53
 
54
54
  1.000 1.000 1.000 rg
55
- 36.500 659.764 55.000 19.404 re
55
+ 36.000 660.264 56.000 19.404 re
56
56
  f
57
57
  0.000 0.000 0.000 rg
58
58
  1 w
@@ -62,8 +62,8 @@ S
62
62
  92.000 680.168 m
63
63
  92.000 658.764 l
64
64
  S
65
- 36.500 679.668 m
66
- 91.500 679.668 l
65
+ 36.000 679.668 m
66
+ 92.000 679.668 l
67
67
  S
68
68
  36.000 659.264 m
69
69
  92.000 659.264 l
@@ -79,7 +79,7 @@ ET
79
79
 
80
80
  0.000 0.000 0.000 rg
81
81
  1.000 1.000 1.000 rg
82
- 92.500 659.764 91.000 19.404 re
82
+ 92.000 660.264 92.000 19.404 re
83
83
  f
84
84
  0.000 0.000 0.000 rg
85
85
  1 w
@@ -89,8 +89,8 @@ S
89
89
  184.000 680.168 m
90
90
  184.000 658.764 l
91
91
  S
92
- 92.500 679.668 m
93
- 183.500 679.668 l
92
+ 92.000 679.668 m
93
+ 184.000 679.668 l
94
94
  S
95
95
  92.000 659.264 m
96
96
  184.000 659.264 l
@@ -106,7 +106,7 @@ ET
106
106
 
107
107
  0.000 0.000 0.000 rg
108
108
  1.000 1.000 1.000 rg
109
- 184.500 659.764 107.000 19.404 re
109
+ 184.000 660.264 108.000 19.404 re
110
110
  f
111
111
  0.000 0.000 0.000 rg
112
112
  1 w
@@ -116,8 +116,8 @@ S
116
116
  292.000 680.168 m
117
117
  292.000 658.764 l
118
118
  S
119
- 184.500 679.668 m
120
- 291.500 679.668 l
119
+ 184.000 679.668 m
120
+ 292.000 679.668 l
121
121
  S
122
122
  184.000 659.264 m
123
123
  292.000 659.264 l
@@ -133,7 +133,7 @@ ET
133
133
 
134
134
  0.000 0.000 0.000 rg
135
135
  1.000 1.000 1.000 rg
136
- 292.500 659.764 93.000 19.404 re
136
+ 292.000 660.264 94.000 19.404 re
137
137
  f
138
138
  0.000 0.000 0.000 rg
139
139
  1 w
@@ -143,8 +143,8 @@ S
143
143
  386.000 680.168 m
144
144
  386.000 658.764 l
145
145
  S
146
- 292.500 679.668 m
147
- 385.500 679.668 l
146
+ 292.000 679.668 m
147
+ 386.000 679.668 l
148
148
  S
149
149
  292.000 659.264 m
150
150
  386.000 659.264 l
@@ -160,7 +160,7 @@ ET
160
160
 
161
161
  0.000 0.000 0.000 rg
162
162
  1.000 1.000 1.000 rg
163
- 386.500 659.764 55.000 19.404 re
163
+ 386.000 660.264 56.000 19.404 re
164
164
  f
165
165
  0.000 0.000 0.000 rg
166
166
  1 w
@@ -170,8 +170,8 @@ S
170
170
  442.000 680.168 m
171
171
  442.000 658.764 l
172
172
  S
173
- 386.500 679.668 m
174
- 441.500 679.668 l
173
+ 386.000 679.668 m
174
+ 442.000 679.668 l
175
175
  S
176
176
  386.000 659.264 m
177
177
  442.000 659.264 l
@@ -187,7 +187,7 @@ ET
187
187
 
188
188
  0.000 0.000 0.000 rg
189
189
  1.000 1.000 1.000 rg
190
- 442.500 659.764 82.000 19.404 re
190
+ 442.000 660.264 83.000 19.404 re
191
191
  f
192
192
  0.000 0.000 0.000 rg
193
193
  1 w
@@ -197,8 +197,8 @@ S
197
197
  525.000 680.168 m
198
198
  525.000 658.764 l
199
199
  S
200
- 442.500 679.668 m
201
- 524.500 679.668 l
200
+ 442.000 679.668 m
201
+ 525.000 679.668 l
202
202
  S
203
203
  442.000 659.264 m
204
204
  525.000 659.264 l
@@ -214,7 +214,7 @@ ET
214
214
 
215
215
  0.000 0.000 0.000 rg
216
216
  0.800 0.800 0.800 rg
217
- 36.500 639.360 55.000 19.404 re
217
+ 36.000 639.860 56.000 19.404 re
218
218
  f
219
219
  0.000 0.000 0.000 rg
220
220
  1 w
@@ -224,8 +224,8 @@ S
224
224
  92.000 659.764 m
225
225
  92.000 638.360 l
226
226
  S
227
- 36.500 659.264 m
228
- 91.500 659.264 l
227
+ 36.000 659.264 m
228
+ 92.000 659.264 l
229
229
  S
230
230
  36.000 638.860 m
231
231
  92.000 638.860 l
@@ -236,12 +236,12 @@ S
236
236
  BT
237
237
  41 645.831 Td
238
238
  /F1.0 9 Tf
239
- [<32>] TJ
239
+ [<31>] TJ
240
240
  ET
241
241
 
242
242
  0.000 0.000 0.000 rg
243
243
  0.800 0.800 0.800 rg
244
- 92.500 639.360 91.000 19.404 re
244
+ 92.000 639.860 92.000 19.404 re
245
245
  f
246
246
  0.000 0.000 0.000 rg
247
247
  1 w
@@ -251,8 +251,8 @@ S
251
251
  184.000 659.764 m
252
252
  184.000 638.360 l
253
253
  S
254
- 92.500 659.264 m
255
- 183.500 659.264 l
254
+ 92.000 659.264 m
255
+ 184.000 659.264 l
256
256
  S
257
257
  92.000 638.860 m
258
258
  184.000 638.860 l
@@ -263,12 +263,12 @@ S
263
263
  BT
264
264
  97 645.831 Td
265
265
  /F1.0 9 Tf
266
- [<323537>] TJ
266
+ [<3139>] TJ
267
267
  ET
268
268
 
269
269
  0.000 0.000 0.000 rg
270
270
  0.800 0.800 0.800 rg
271
- 184.500 639.360 107.000 19.404 re
271
+ 184.000 639.860 108.000 19.404 re
272
272
  f
273
273
  0.000 0.000 0.000 rg
274
274
  1 w
@@ -278,8 +278,8 @@ S
278
278
  292.000 659.764 m
279
279
  292.000 638.360 l
280
280
  S
281
- 184.500 659.264 m
282
- 291.500 659.264 l
281
+ 184.000 659.264 m
282
+ 292.000 659.264 l
283
283
  S
284
284
  184.000 638.860 m
285
285
  292.000 638.860 l
@@ -290,12 +290,12 @@ S
290
290
  BT
291
291
  189 645.831 Td
292
292
  /F1.0 9 Tf
293
- [<3338>] TJ
293
+ [<33>] TJ
294
294
  ET
295
295
 
296
296
  0.000 0.000 0.000 rg
297
297
  0.800 0.800 0.800 rg
298
- 292.500 639.360 93.000 19.404 re
298
+ 292.000 639.860 94.000 19.404 re
299
299
  f
300
300
  0.000 0.000 0.000 rg
301
301
  1 w
@@ -305,8 +305,8 @@ S
305
305
  386.000 659.764 m
306
306
  386.000 638.360 l
307
307
  S
308
- 292.500 659.264 m
309
- 385.500 659.264 l
308
+ 292.000 659.264 m
309
+ 386.000 659.264 l
310
310
  S
311
311
  292.000 638.860 m
312
312
  386.000 638.860 l
@@ -317,12 +317,12 @@ S
317
317
  BT
318
318
  297 645.831 Td
319
319
  /F1.0 9 Tf
320
- [<363435>] TJ
320
+ [<30>] TJ
321
321
  ET
322
322
 
323
323
  0.000 0.000 0.000 rg
324
324
  0.800 0.800 0.800 rg
325
- 386.500 639.360 55.000 19.404 re
325
+ 386.000 639.860 56.000 19.404 re
326
326
  f
327
327
  0.000 0.000 0.000 rg
328
328
  1 w
@@ -332,8 +332,8 @@ S
332
332
  442.000 659.764 m
333
333
  442.000 638.360 l
334
334
  S
335
- 386.500 659.264 m
336
- 441.500 659.264 l
335
+ 386.000 659.264 m
336
+ 442.000 659.264 l
337
337
  S
338
338
  386.000 638.860 m
339
339
  442.000 638.860 l
@@ -344,12 +344,12 @@ S
344
344
  BT
345
345
  391 645.831 Td
346
346
  /F1.0 9 Tf
347
- [<37343731>] TJ
347
+ [<36>] TJ
348
348
  ET
349
349
 
350
350
  0.000 0.000 0.000 rg
351
351
  0.800 0.800 0.800 rg
352
- 442.500 639.360 82.000 19.404 re
352
+ 442.000 639.860 83.000 19.404 re
353
353
  f
354
354
  0.000 0.000 0.000 rg
355
355
  1 w
@@ -359,8 +359,8 @@ S
359
359
  525.000 659.764 m
360
360
  525.000 638.360 l
361
361
  S
362
- 442.500 659.264 m
363
- 524.500 659.264 l
362
+ 442.000 659.264 m
363
+ 525.000 659.264 l
364
364
  S
365
365
  442.000 638.860 m
366
366
  525.000 638.860 l
@@ -371,7 +371,7 @@ S
371
371
  BT
372
372
  447 645.831 Td
373
373
  /F1.0 9 Tf
374
- [<393430>] TJ
374
+ [<3232>] TJ
375
375
  ET
376
376
 
377
377
  0.000 0.000 0.000 rg
@@ -471,34 +471,6 @@ BT
471
471
  [<0909092d2068747470202838302f74637029>] TJ
472
472
  ET
473
473
 
474
-
475
- BT
476
- 36 353.344 Td
477
- /F1.0 18 Tf
478
- [<77696e646f> 15 <7773> 15 <2e636f6d>] TJ
479
- ET
480
-
481
-
482
- BT
483
- 36 338.998 Td
484
- /F1.0 9 Tf
485
- [<5363616e20> 50 <54696d653a> 50 <203020686f757273203130206d696e> 10 <7574657320616e642034207365636f6e6473>] TJ
486
- ET
487
-
488
-
489
- BT
490
- 36 328.594 Td
491
- /F1.0 9 Tf
492
- [<4c6f> 15 <773a> 50 <20323338204d656469756d3a> 50 <20333520486967683a> 50 <2036343520> 50 <54> 120 <6f74616c3a> 50 <20393138>] TJ
493
- ET
494
-
495
-
496
- BT
497
- 36 318.19 Td
498
- /F1.0 9 Tf
499
- [<4f706572> 10 <6174696e672053797374656d3a> 50 <204c696e> 10 <7578204b> 40 <6572> -25 <6e656c20322e36206f6e205265642048617420456e746572> -30 <7072> -15 <697365204c696e> 10 <75782035>] TJ
500
- ET
501
-
502
474
  36.000 61.000 m
503
475
  576.000 61.000 l
504
476
  S
@@ -514,41 +486,37 @@ Q
514
486
  endstream
515
487
  endobj
516
488
  5 0 obj
517
- << /ProcSet 6 0 R
489
+ << /MediaBox [0 0 612.0 792.0]
518
490
  /Contents 4 0 R
519
- /Resources << /Font << /F1.0 7 0 R
491
+ /Type /Page
492
+ /Resources << /Font << /F1.0 6 0 R
520
493
  >>
494
+ /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
521
495
  >>
522
- /Type /Page
523
496
  /Parent 2 0 R
524
- /MediaBox [0 0 612.0 792.0]
525
497
  >>
526
498
  endobj
527
499
  6 0 obj
528
- [/PDF /Text]
529
- endobj
530
- 7 0 obj
531
- << /Type /Font
532
- /BaseFont /Helvetica
533
- /Encoding /WinAnsiEncoding
500
+ << /Encoding /WinAnsiEncoding
534
501
  /Subtype /Type1
502
+ /Type /Font
503
+ /BaseFont /Helvetica
535
504
  >>
536
505
  endobj
537
506
  xref
538
- 0 8
507
+ 0 7
539
508
  0000000000 65535 f
540
- 0000000014 00000 n
541
- 0000000070 00000 n
542
- 0000000127 00000 n
543
- 0000000176 00000 n
544
- 0000007531 00000 n
545
- 0000007678 00000 n
546
- 0000007706 00000 n
509
+ 0000000015 00000 n
510
+ 0000000071 00000 n
511
+ 0000000128 00000 n
512
+ 0000000177 00000 n
513
+ 0000007000 00000 n
514
+ 0000007178 00000 n
547
515
  trailer
548
- << /Size 8
549
- /Root 3 0 R
516
+ << /Root 3 0 R
550
517
  /Info 1 0 R
518
+ /Size 7
551
519
  >>
552
520
  startxref
553
- 7803
521
+ 7275
554
522
  %%EOF
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'ruby-nessus'
@@ -1,5 +1,7 @@
1
1
  module Nessus
2
2
  class Host
3
+ include Enumerable
4
+
3
5
  # Host
4
6
  attr_reader :host
5
7
 
@@ -26,7 +28,11 @@ module Nessus
26
28
  # @example
27
29
  # scan.scan_start_time #=> 'Fri Nov 11 23:36:54 1985'
28
30
  def scan_start_time
29
- @host_scan_time = DateTime.strptime(@host.at('startTime').inner_text, fmt='%a %b %d %H:%M:%S %Y')
31
+ if @host.at('startTime').inner_text.blank?
32
+ return false
33
+ else
34
+ @host_scan_time = DateTime.strptime(@host.at('startTime').inner_text, fmt='%a %b %d %H:%M:%S %Y')
35
+ end
30
36
  end
31
37
 
32
38
  # Return the host scan stop time.
@@ -35,16 +41,19 @@ module Nessus
35
41
  # @example
36
42
  # scan.scan_start_time #=> 'Fri Nov 11 23:36:54 1985'
37
43
  def scan_stop_time
38
- @host_scan_time = DateTime.strptime(@host.at('stopTime').inner_text, fmt='%a %b %d %H:%M:%S %Y')
44
+ if @host.at('stopTime').inner_text.blank?
45
+ return false
46
+ else
47
+ @host_scan_time = DateTime.strptime(@host.at('stopTime').inner_text, fmt='%a %b %d %H:%M:%S %Y')
48
+ end
39
49
  end
40
-
50
+
41
51
  # Return the host run time.
42
52
  # @return [String]
43
53
  # The Host Scan Run Time
44
54
  # @example
45
55
  # scan.scan_run_time #=> '2 hours 5 minutes and 16 seconds'
46
56
  def scan_runtime
47
- if scan_start_time.to_s.empty? | scan_stop_time.to_s.empty?; return "N/A"; end
48
57
  h = ("#{Time.parse(scan_stop_time.to_s).strftime('%H').to_i - Time.parse(scan_start_time.to_s).strftime('%H').to_i}").gsub('-', '')
49
58
  m = ("#{Time.parse(scan_stop_time.to_s).strftime('%M').to_i - Time.parse(scan_start_time.to_s).strftime('%M').to_i}").gsub('-', '')
50
59
  s = ("#{Time.parse(scan_stop_time.to_s).strftime('%S').to_i - Time.parse(scan_start_time.to_s).strftime('%S').to_i}").gsub('-', '')
@@ -97,7 +106,7 @@ module Nessus
97
106
  def open_ports
98
107
  @scanned_ports ||= @host.at('num_ports').inner_text.to_i
99
108
  end
100
-
109
+
101
110
  # Returns All Informational Event Objects For A Given Host.
102
111
  # @yield [prog] If a block is given, it will be passed the newly
103
112
  # created Event object.
@@ -119,7 +128,7 @@ module Nessus
119
128
  @informational_events << Event.new(event)
120
129
  @informational_event_count += 1
121
130
  end
122
-
131
+
123
132
  end
124
133
 
125
134
  @informational_events.each(&block)
@@ -137,9 +146,9 @@ module Nessus
137
146
  # puts low.name if low.name
138
147
  # end
139
148
  def low_severity_events(&block)
140
-
149
+
141
150
  @low_severity_count = @host.at('num_lo').inner_text.to_i
142
-
151
+
143
152
  unless @low_severity_events
144
153
  @low_severity_events = []
145
154
 
@@ -165,9 +174,9 @@ module Nessus
165
174
  # puts medium.name if medium.name
166
175
  # end
167
176
  def medium_severity_events(&block)
168
-
177
+
169
178
  @high_severity_count = @host.at('num_med').inner_text.to_i
170
-
179
+
171
180
  unless @medium_severity_events
172
181
  @medium_severity_events = []
173
182
 
@@ -193,9 +202,9 @@ module Nessus
193
202
  # puts high.name if high.name
194
203
  # end
195
204
  def high_severity_events(&block)
196
-
205
+
197
206
  @high_severity_count = @host.at('num_hi').inner_text.to_i
198
-
207
+
199
208
  unless @high_severity_events
200
209
  @high_severity_events = []
201
210
 
@@ -203,7 +212,7 @@ module Nessus
203
212
  next if event.at('severity').inner_text.to_i != 3
204
213
  @high_severity_events << Event.new(event)
205
214
  end
206
-
215
+
207
216
  end
208
217
 
209
218
  @high_severity_events.each(&block)
@@ -234,5 +243,12 @@ module Nessus
234
243
  end
235
244
  end
236
245
 
246
+ # Parses the events of the host.
247
+ # @return [Array<String>]
248
+ # The events of the host.
249
+ def all_events
250
+ Enumerator.new(self,:events).to_a
251
+ end
252
+
237
253
  end
238
254
  end
@@ -2,5 +2,13 @@ require 'ruby-nessus/xml'
2
2
  require 'ruby-nessus/core_ext/helpers'
3
3
 
4
4
  module Nessus
5
-
6
- end
5
+
6
+ class Parse
7
+
8
+ def initialize(file, options={})
9
+
10
+ end
11
+
12
+ end
13
+
14
+ end