ruby-nessus 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -10
- data/VERSION +1 -1
- data/examples/example.nessus +1 -1
- data/examples/example.rb +25 -10
- data/examples/pdf_example.rb +54 -69
- data/examples/ruby-nessus-example.pdf +44 -19
- data/lib/ruby-nessus/core_ext/helpers.rb +8 -0
- data/lib/ruby-nessus/host.rb +11 -11
- data/lib/ruby-nessus/xml.rb +35 -28
- metadata +2 -3
- data/lib/ruby-nessus/scan.rb +0 -13
data/lib/ruby-nessus/xml.rb
CHANGED
@@ -25,25 +25,38 @@ module Nessus
|
|
25
25
|
|
26
26
|
block.call(self) if block
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
# Return the nessus report title.
|
30
30
|
# @return [String]
|
31
31
|
# The Nessus Report Title
|
32
32
|
# @example
|
33
33
|
# scan.report_name #=> "My Super Cool Nessus Report"
|
34
34
|
def report_name
|
35
|
-
@report_name ||= @xml.xpath("//NessusClientData//Report//ReportName").inner_text
|
35
|
+
@report_name ||= @xml.xpath("//NessusClientData//Report//ReportName").inner_text.split(' - ').last
|
36
36
|
end
|
37
37
|
alias name report_name
|
38
38
|
alias title report_name
|
39
|
-
|
39
|
+
|
40
|
+
# Return the nessus report time.
|
41
|
+
# @return [String]
|
42
|
+
# The Nessus Report Time
|
43
|
+
# @example
|
44
|
+
# scan.report_time #=> "09/11/08 02:21:22 AM"
|
45
|
+
def report_time
|
46
|
+
#09/11/08 02:21:22 AM
|
47
|
+
datetime = @xml.xpath("//NessusClientData//Report//ReportName").inner_text.split(' - ').first
|
48
|
+
@report_time ||= DateTime.strptime(datetime, fmt='%y/%m/%d %I:%M:%S %p')
|
49
|
+
end
|
50
|
+
alias time report_time
|
51
|
+
alias date report_time
|
52
|
+
|
40
53
|
# Return the scan start time.
|
41
54
|
# @return [DateTime]
|
42
55
|
# The Nessus Scan Start Time
|
43
56
|
# @example
|
44
57
|
# scan.start_time #=> 'Fri Nov 11 23:36:54 1985'
|
45
58
|
def start_time
|
46
|
-
@start_time = @xml.xpath("//NessusClientData//Report//StartTime").inner_text
|
59
|
+
@start_time = DateTime.strptime(@xml.xpath("//NessusClientData//Report//StartTime").inner_text, fmt='%a %b %d %H:%M:%S %Y')
|
47
60
|
end
|
48
61
|
|
49
62
|
# Return the scan stop time.
|
@@ -52,7 +65,7 @@ module Nessus
|
|
52
65
|
# @example
|
53
66
|
# scan.stop_time #=> 'Mon Nov 11 23:36:54 1985'
|
54
67
|
def stop_time
|
55
|
-
@stop_time = @xml.xpath("//NessusClientData//Report//StopTime").inner_text
|
68
|
+
@stop_time = DateTime.strptime(@xml.xpath("//NessusClientData//Report//StopTime").inner_text, fmt='%a %b %d %H:%M:%S %Y')
|
56
69
|
end
|
57
70
|
|
58
71
|
# Return the scan run time.
|
@@ -61,9 +74,9 @@ module Nessus
|
|
61
74
|
# @example
|
62
75
|
# scan.runtime #=> '2 hours 5 minutes and 16 seconds'
|
63
76
|
def runtime
|
64
|
-
h = ("#{Time.parse(stop_time).strftime('%H').to_i - Time.parse(start_time).strftime('%H').to_i}").gsub('-', '')
|
65
|
-
m = ("#{Time.parse(stop_time).strftime('%M').to_i - Time.parse(start_time).strftime('%M').to_i}").gsub('-', '')
|
66
|
-
s = ("#{Time.parse(stop_time).strftime('%S').to_i - Time.parse(start_time).strftime('%S').to_i}").gsub('-', '')
|
77
|
+
h = ("#{Time.parse(stop_time.to_s).strftime('%H').to_i - Time.parse(start_time.to_s).strftime('%H').to_i}").gsub('-', '')
|
78
|
+
m = ("#{Time.parse(stop_time.to_s).strftime('%M').to_i - Time.parse(start_time.to_s).strftime('%M').to_i}").gsub('-', '')
|
79
|
+
s = ("#{Time.parse(stop_time.to_s).strftime('%S').to_i - Time.parse(start_time.to_s).strftime('%S').to_i}").gsub('-', '')
|
67
80
|
return "#{h} hours #{m} minutes and #{s} seconds"
|
68
81
|
end
|
69
82
|
|
@@ -97,7 +110,7 @@ module Nessus
|
|
97
110
|
|
98
111
|
@plugin_ids
|
99
112
|
end
|
100
|
-
|
113
|
+
|
101
114
|
# Returns and array of the plugin names userd for the passed .nessus scan.
|
102
115
|
# @return [Array]
|
103
116
|
# The Nessus Scan Plugin Names
|
@@ -145,7 +158,7 @@ module Nessus
|
|
145
158
|
hosts.size
|
146
159
|
end
|
147
160
|
|
148
|
-
# Retunrs an array of all unique ports.
|
161
|
+
# Retunrs an array of all unique ports.
|
149
162
|
# @return [Array]
|
150
163
|
# @example
|
151
164
|
# scan.unique_ports #=> 234
|
@@ -226,7 +239,7 @@ module Nessus
|
|
226
239
|
raise "Error: #{type} is not an acceptable severity. Possible options include: all, high, medium, low and informational."
|
227
240
|
end
|
228
241
|
end
|
229
|
-
|
242
|
+
|
230
243
|
# Creates a new Host object to be parser from a passed search param.
|
231
244
|
# @param [String] hostname the hostname to build a Host object for.
|
232
245
|
# @yield [prog] If a block is given, it will be passed the newly
|
@@ -257,24 +270,18 @@ module Nessus
|
|
257
270
|
@medium = 0
|
258
271
|
@high = 0
|
259
272
|
|
260
|
-
@xml.xpath("//
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
@low += 1
|
266
|
-
when 2
|
267
|
-
@medium += 1
|
268
|
-
when 3
|
269
|
-
@high += 1
|
270
|
-
end
|
273
|
+
@xml.xpath("//ReportHost").each do |s|
|
274
|
+
@open_ports += s.at('num_ports').inner_text.to_i
|
275
|
+
@low += s.at('num_lo').inner_text.to_i
|
276
|
+
@medium += s.at('num_med').inner_text.to_i
|
277
|
+
@high += s.at('num_hi').inner_text.to_i
|
271
278
|
end
|
272
|
-
|
273
|
-
@count = { :open_ports => @open_ports,
|
274
|
-
:low => @low,
|
275
|
-
:medium => @medium,
|
276
|
-
:high => @high,
|
277
|
-
|
279
|
+
|
280
|
+
@count = { :open_ports => @open_ports,
|
281
|
+
:low => @low,
|
282
|
+
:medium => @medium,
|
283
|
+
:high => @high,
|
284
|
+
:all => (@low + @medium + @high) }
|
278
285
|
end
|
279
286
|
|
280
287
|
return @count
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-nessus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Willis Webber
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-10 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -67,7 +67,6 @@ files:
|
|
67
67
|
- lib/ruby-nessus/host.rb
|
68
68
|
- lib/ruby-nessus/nessus.rb
|
69
69
|
- lib/ruby-nessus/port.rb
|
70
|
-
- lib/ruby-nessus/scan.rb
|
71
70
|
- lib/ruby-nessus/xml.rb
|
72
71
|
- spec/ruby-nessus_spec.rb
|
73
72
|
- spec/spec.opts
|