Module: Msf::DBManager::Import::Spiceworks

Included in:
Msf::DBManager::Import
Defined in:
lib/msf/core/db_manager/import/spiceworks.rb

Instance Method Summary collapse

Instance Method Details

#import_spiceworks_csv(args = {}, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
# File 'lib/msf/core/db_manager/import/spiceworks.rb', line 4

def import_spiceworks_csv(args={}, &block)
  data = args[:data]
  wspace = Msf::Util::DBManager.process_opts_workspace(args, framework).name
  bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : []
  CSV.parse(data) do |row|
    next unless (["Name", "Manufacturer", "Device Type"] & row).empty? #header
    name = row[0]
    manufacturer = row[1]
    device = row[2]
    model = row[3]
    ip = row[4]
    serialno = row[5]
    location = row[6]
    os = row[7]

    next unless ip
    next if bl.include? ip

    conf = {
    :workspace => wspace,
    :host      => ip,
    :name      => name,
    :task      => args[:task]
    }


    if os
      report_note(
        :workspace => wspace,
        :task => args[:task],
        :host => ip,
        :type => 'host.os.spiceworks_fingerprint',
        :data => {
          :os => os.to_s.strip
        }
      )
    end

    info = []
    info << "Serial Number: #{serialno}" unless (serialno.blank? or serialno == name)
    info << "Location: #{location}" unless location.blank?
    conf[:info] = info.join(", ") unless info.empty?

    host = report_host(conf)
    report_import_note(wspace, host)
  end
end