Class: Nessus::Scan

Inherits:
Object
  • Object
show all
Defined in:
lib/nessus/scan.rb

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, targets) ⇒ Scan

Create a new scan instance

Parameters:

  • nessus (String)

    scan template name

  • target (Array<String>)

    addresses e.g localhost:3000



23
24
25
26
# File 'lib/nessus/scan.rb', line 23

def initialize(name, targets)
  set_uuid(name)
  setup_scan(targets)
end

Instance Attribute Details

#detailsObject (readonly)

Wrapper for XMLRPC client



14
15
16
# File 'lib/nessus/scan.rb', line 14

def details
  @details
end

#idObject (readonly)

Wrapper for XMLRPC client



14
15
16
# File 'lib/nessus/scan.rb', line 14

def id
  @id
end

#resultObject (readonly)

Wrapper for XMLRPC client



14
15
16
# File 'lib/nessus/scan.rb', line 14

def result
  @result
end

#uuidObject (readonly)

Wrapper for XMLRPC client



14
15
16
# File 'lib/nessus/scan.rb', line 14

def uuid
  @uuid
end

Instance Method Details

#export_csv(filepath) ⇒ Fixnum

Export scan to csv file

Parameters:

  • output (String)

    filepath

Returns:

  • (Fixnum)

    bytes written to file



62
63
64
65
66
67
# File 'lib/nessus/scan.rb', line 62

def export_csv(filepath)
  csv_id   = client.scan_export(@id, 'csv')
  csv_data = client.report_download(@id, csv_id['file'])

  File.write(filepath, csv_data)
end

#launch!Result

Launches the scan

Returns:

  • (Result)

    the result hash from the scan



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/nessus/scan.rb', line 32

def launch!
  client.scan_launch(@id)

  loop do
    raw    = client.scan_details(@id)
    status = raw['info']['status']

    if status != 'running'
      @result = Result.new(raw)
      break
    end
      
    sleep Nessus::Settings.refresh_interval
  end
end

#viewHash

View the result of a finished scan

Returns:

  • (Hash)

    the raw result hash from the scan



52
53
54
# File 'lib/nessus/scan.rb', line 52

def view
  result && result.raw
end