prenus 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +2 -1
  2. data/bin/prenus +1 -1
  3. data/lib/input/nessusin.rb +28 -10
  4. metadata +4 -4
data/README.rdoc CHANGED
@@ -92,7 +92,7 @@ Well, getting GD and all the other Circos dependencies was a bit of a pain in th
92
92
 
93
93
  You might also need to fiddle with the circos.conf file, but eventually I had it working pretty solidly. I had circos installed in ~/circos/circos-0.62-1/ and the circos tools in ~/circos/circos-tools-0.16/
94
94
 
95
- s will only work if you're in the Circos Tools tableviewer folder (in my instance, ~/circos/circos-tools-0.16/tools/tableviewer/)
95
+ This will only work if you're in the Circos Tools tableviewer folder (in my instance, ~/circos/circos-tools-0.16/tools/tableviewer/)
96
96
 
97
97
  prenus -t circos -s 4 /folder/where/nessus/files/are/*.nessus | bin/parse-table -conf samples/parse-table-01.conf | bin/make-conf -dir data
98
98
  ../../../circos-0.62-1/bin/circos -conf etc/circos.conf -outputfile prenus.png
@@ -100,4 +100,5 @@ s will only work if you're in the Circos Tools tableviewer folder (in my instanc
100
100
  This will dump the png into the img/ folder.
101
101
 
102
102
  == Changes
103
+ * Version 0.0.2 - Updated input - handles duplicate hosts a bit nicer (but not much nicer)
103
104
  * Version 0.0.1 - initial release .. buggy to the max
data/bin/prenus CHANGED
@@ -18,7 +18,7 @@ require 'lib/output'
18
18
  require 'lib/input'
19
19
 
20
20
  #Versioning and .. those things
21
- $verstring = "Version 0.0.1 - 27th of July, 2012 - Created by Christian \"xntrik\" Frichot.\n\n"
21
+ $verstring = "Version 0.0.2 - 20th of August, 2012 - Created by Christian \"xntrik\" Frichot.\n\n"
22
22
  $verstring += "Copyright 2012 Christian Frichot\n\n"
23
23
  $verstring += "Licensed under the Apache License, Version 2.0 (the \"License\");\n"
24
24
  $verstring += "you may not use this file except in compliance with the License.\n"
@@ -67,25 +67,46 @@ class Nessusin
67
67
  high = host.high_severity_count || 0 #grab the number of high findings
68
68
  crit = host.critical_severity_count || 0 #grab the number of critical findings
69
69
 
70
- # add the host into the hosts hash
71
- # I'm not yet doing any 'unique' validation, although I probably should .. oh so slack
72
- hosts[hostid] = {:ip => ip, :hostname => hostname, :os => os, :info => info, :low => low, :med => med, :high => high, :crit => crit, :total => info+low+med+high+crit, :total_excl_info => low+med+high+crit}
70
+ targethostid = hostid #For the moment
71
+
72
+ # Check to see if we already have the host (based on IP, Hostname and OS)
73
+ if hosts.select {|key,f| f[:os].to_s == os and f[:ip].to_s == ip and f[:hostname].to_s == hostname}.count == 0
74
+ # Okay, we don't have this host yet
75
+
76
+ # add the host into the hosts hash
77
+ hosts[hostid] = {:ip => ip, :hostname => hostname, :os => os, :info => info, :low => low, :med => med, :high => high, :crit => crit, :total => info+low+med+high+crit, :total_excl_info => low+med+high+crit}
78
+ hostid += 1 # We only increase because we've added a new host
79
+ else
80
+ # We do have this host, lets grab the host id
81
+ hosts.select {|key,f| f[:os].to_s == os and f[:ip].to_s == ip and f[:hostname] == hostname}.each {|k,v| targethostid = k}
82
+
83
+ # Lets now check who has the greatest number of findings, and then we'll use that one going forward
84
+ if hosts[targethostid][:total].to_i < (info + low + med + high) #therefore the older, previously detected host had more - update the counters
85
+ hosts[targethostid][:info] = info
86
+ hosts[targethostid][:low] = low
87
+ hosts[targethostid][:med] = med
88
+ hosts[targethostid][:high] = high
89
+ hosts[targethostid][:crit] = crit
90
+ hosts[targethostid][:total] = info + low + med + high + crit
91
+ hosts[targethostid][:total_excl_info] = low + med + high + crit
92
+ end
93
+ end
73
94
 
74
95
  # Now lets iterate through each of the findings in this particular host
75
96
  host.each_event do |event|
76
97
 
77
- # If the events hash already has this event, lets just add this hostid to it's hosts array within the ports hash
98
+ # If the events hash already has this event, lets just add this targethostid to it's hosts array within the ports hash
78
99
  if events.has_key?(event.id)
79
100
 
80
101
  #Lets check the ports hash
81
102
  if events[event.id][:ports].has_key?(event.port.to_s)
82
103
 
83
104
  # We'll only add the hostid if the host's not already in the array
84
- events[event.id][:ports][event.port.to_s][:hosts][hostid] = event.output unless events[event.id][:ports][event.port.to_s][:hosts].include?(hostid)
105
+ events[event.id][:ports][event.port.to_s][:hosts][targethostid] = event.output unless events[event.id][:ports][event.port.to_s][:hosts].include?(targethostid)
85
106
 
86
107
  #Lets add this new port to this hash
87
108
  else
88
- events[event.id][:ports][event.port.to_s] = {:hosts => { hostid => event.output}}
109
+ events[event.id][:ports][event.port.to_s] = {:hosts => { targethostid => event.output}}
89
110
  end
90
111
 
91
112
  # okay, this event doesn't exist, lets add it to the events hash
@@ -105,12 +126,9 @@ class Nessusin
105
126
  #:port => event.port.to_s || "" #port
106
127
  :ports => {}
107
128
  }
108
- events[event.id][:ports][event.port.to_s] = {:hosts => {hostid => event.output}}
129
+ events[event.id][:ports][event.port.to_s] = {:hosts => {targethostid => event.output}}
109
130
  end
110
131
  end
111
-
112
- #increase the unique host id
113
- hostid += 1
114
132
  end
115
133
  end
116
134
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prenus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-31 00:00:00.000000000Z
12
+ date: 2012-08-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ruby-nessus
16
- requirement: &70165631471960 !ruby/object:Gem::Requirement
16
+ requirement: &70160182782920 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.0.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70165631471960
24
+ version_requirements: *70160182782920
25
25
  description: Pretty Nessus = Prenus
26
26
  email: xntrik@gmail.com
27
27
  executables: