Class: Nessus::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/gemcache/ruby-nessus/ruby-nessus/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCLI

Returns a new instance of CLI.



12
13
14
15
16
# File 'lib/gemcache/ruby-nessus/ruby-nessus/cli.rb', line 12

def initialize
  @file = nil
  @nessus_version = nil
  @args = []
end

Class Method Details

.runObject



18
19
20
# File 'lib/gemcache/ruby-nessus/ruby-nessus/cli.rb', line 18

def CLI.run
  self.new.run(*ARGV)
end

Instance Method Details

#run(*args) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/gemcache/ruby-nessus/ruby-nessus/cli.rb', line 22

def run(*args)
  optparse(*args)

  Log.it "Recess - Ruby-Nessus CLI"
  Log.it "Version: #{Nessus::VERSION}"
  Log.it

  Nessus::Parse.new("#{@file}") do |scan|

    Log.h1 "SCAN Metadata"
    Log.it
    Log.h2 "Scan Title", scan.title
    Log.h2 "Policy Title", scan.policy_title
    Log.it
    Log.h1 "SCAN Statistics"
    Log.it
    Log.h2 "Host Count", scan.host_count
    Log.h2 "Open Port Count", scan.open_ports_count

    unless scan.version == 1
      Log.h2 "TCP Count", scan.tcp_count
      Log.h2 "UDP Count", scan.udp_count
      Log.h2 "ICMP Count", scan.icmp_count
    end

    Log.it
    Log.h1 "EVENT Statistics"
    Log.it

    unless scan.version == 1
      Log.informational "Informational Severity Count", scan.informational_severity_count
    end

    Log.low "Low Severity Count", scan.low_severity_count
    Log.medium "Medium Severity Count", scan.medium_severity_count
    Log.high "High Severity Count", scan.high_severity_count
    Log.h3 "Total Event Count", scan.total_event_count
    Log.break
    Log.it! "Low Event Percentage: #{scan.event_percentage_for('low', true)}"
    Log.it! "Medium Event Percentage: #{scan.event_percentage_for('medium', true)}"
    Log.it! "High Event Percentage: #{scan.event_percentage_for('high', true)}"
    Log.it

    Log.h1 "HOSTS"
    Log.it

    scan.each_host do |host|
      Log.h2 "Hostname", host.hostname
      Log.h5 "IP Address:", host.ip
      
      unless scan.version == 1
        Log.h5 "Informational Count", host.informational_severity_count
        Log.h5 "Low Count", host.low_severity_count
        Log.h5 "Medium Count", host.medium_severity_count
        Log.h5 "High Count", host.high_severity_count
      end
      Log.it
    end

    Log.end

  end

end