Module: Rhessus

Defined in:
lib/rhessus.rb,
lib/scan_runner.rb,
lib/connections/scan.rb

Defined Under Namespace

Classes: Scan, ScanRunner

Constant Summary collapse

VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.initObject

Parse the options



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
# File 'lib/rhessus.rb', line 42

def init
  @host = 'localhost'
  @username = 'admin'
  @password = 'password'
  OptionParser.new do |opts|
    opts.on('-h', '--host [HOST]', 
      "The host running the scanner (default localhost)") do |h|
        @host = h
      end
    opts.on('-u', '--username USER',
      "The username on the nessus scanner") do |u|
        @username = u
      end
    opts.on('-p', '--password PASS',
      "The password for the scanner") do |p|
        @password = p
      end
    opts.on('-o', '--port [PORT]',
      "The port of the nessus scanner (default 1241)") do |p|
        @port = p
      end
    opts.on('-s', '--site SITE', "Site to push uploads (incl. http://)") do |s|
        ::Rhessus::Scan.site = s
      end
    opts.on('-n', '--nessus NESSUS', "Nessus executable (unneeded if in path)") do |n|
      @nessus = n
    end
    opts.on('-H', '--help', "Show this message") do |h|
      puts opts
      exit
    end
  end.parse!
end

.parse_results(res) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rhessus.rb', line 19

def parse_results(res)
  puts "Attempting Parse"
  res.split("\n").collect {|x| 
    r = x.split("|")
  }.select{|x| x[0] == "results"}.
    collect do |result|
      {:ip => result[2],
        :port => result[3],
        :plugin_id => result[4],
        :severity  => (case result[5] 
        when "Security Note"
          0
        when "Security Warning"
          1
        when "Security Hole"
          2
        end),
        :details => result[6]
      }
    end
end

.scannerObject

returns the information necessary to start a scan nessus path, -T nbe -q host name password



10
11
12
13
14
15
16
17
# File 'lib/rhessus.rb', line 10

def scanner
  return @scanner if @scanner
  exe = @nessus || `which nessus`.chomp
  exe = '/opt/nessus/bin/nessus ' if exe == ""
  options = " -T nbe -q "
     = " #{@host || 'localhost'} #{@port || 1241} #{@username} #{@password} "
  @scanner = exe + options + 
end

.system_load_ok?Boolean

If can locate the average 5 minute load of the system and that load is below .6 or the user-defined threshold, returns true

Returns:

  • (Boolean)


78
79
80
# File 'lib/rhessus.rb', line 78

def system_load_ok?
  true
end