Module: Msf::DBManager::Import::Amap
- Included in:
- Msf::DBManager::Import
- Defined in:
- lib/msf/core/db_manager/import/amap.rb
Instance Method Summary collapse
- #import_amap_log(args = {}, &block) ⇒ Object
- #import_amap_log_file(args = {}) ⇒ Object
- #import_amap_mlog(args = {}, &block) ⇒ Object
Instance Method Details
#import_amap_log(args = {}, &block) ⇒ Object
[View source]
2 3 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 |
# File 'lib/msf/core/db_manager/import/amap.rb', line 2 def import_amap_log(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 |line| next if line =~ /^#/ next if line !~ /^Protocol on ([^:]+):([^\x5c\x2f]+)[\x5c\x2f](tcp|udp) matches (.*)$/n addr = $1 next if bl.include? addr port = $2.to_i proto = $3.downcase name = $4 host = find_or_create_host(:workspace => wspace, :host => addr, :state => Msf::HostState::Alive, :task => args[:task]) next if not host yield(:address,addr) if block info = { :workspace => wspace, :task => args[:task], :host => host, :proto => proto, :port => port } if name != "unidentified" info[:name] = name end service = find_or_create_service(info) end end |
#import_amap_log_file(args = {}) ⇒ Object
[View source]
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/msf/core/db_manager/import/amap.rb', line 32 def import_amap_log_file(args={}) filename = args[:filename] data = "" ::File.open(filename, 'rb') do |f| data = f.read(f.stat.size) end case import_filetype_detect(data) when :amap_log import_amap_log(args.merge(:data => data)) when :amap_mlog import_amap_mlog(args.merge(:data => data)) else raise Msf::DBImportError.new("Could not determine file type") end end |
#import_amap_mlog(args = {}, &block) ⇒ Object
[View source]
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 |
# File 'lib/msf/core/db_manager/import/amap.rb', line 49 def import_amap_mlog(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 |line| next if line =~ /^#/ r = line.split(':') next if r.length < 6 addr = r[0] next if bl.include? addr port = r[1].to_i proto = r[2].downcase status = r[3] name = r[5] next if status != "open" host = find_or_create_host(:workspace => wspace, :host => addr, :state => Msf::HostState::Alive, :task => args[:task]) next if not host yield(:address,addr) if block info = { :workspace => wspace, :task => args[:task], :host => host, :proto => proto, :port => port } if name != "unidentified" info[:name] = name end service = find_or_create_service(info) end end |