Module: Msf::DBManager::Import::IPList

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

Instance Method Summary collapse

Instance Method Details

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



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/msf/core/db_manager/import/ip_list.rb', line 2

def import_ip_list(args={}, &block)
  data = args[:data]
  wspace = Msf::Util::DBManager.process_opts_workspace(args, framework).name
  bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : []

  data.each_line do |ip|
    ip.strip!
    if bl.include? ip
      next
    else
      yield(:address,ip) if block
    end
    host = find_or_create_host(:workspace => wspace, :host=> ip, :state => Msf::HostState::Alive, :task => args[:task])
  end
end

#import_ip_list_file(args = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/msf/core/db_manager/import/ip_list.rb', line 18

def import_ip_list_file(args={})
  filename = args[:filename]

  data = ""
  ::File.open(filename, 'rb') do |f|
    data = f.read(f.stat.size)
  end
  import_ip_list(args.merge(:data => data))
end