Module: Msf::DBManager::Import::MetasploitFramework

Includes:
Credential, XML, Zip
Included in:
Msf::DBManager::Import
Defined in:
lib/msf/core/db_manager/import/metasploit_framework.rb

Defined Under Namespace

Modules: Credential, XML, Zip

Constant Summary

Constants included from XML

XML::MSF_WEB_PAGE_TEXT_ELEMENT_NAMES, XML::MSF_WEB_TEXT_ELEMENT_NAMES, XML::MSF_WEB_VULN_TEXT_ELEMENT_NAMES

Instance Method Summary collapse

Methods included from Zip

#import_msf_collateral, #import_msf_zip, #is_child_of?, #parse_zip_host, #parse_zip_loot, #parse_zip_report, #parse_zip_task

Methods included from XML

#import_msf_file, #import_msf_note_element, #import_msf_web_form_element, #import_msf_web_page_element, #import_msf_web_vuln_element, #import_msf_xml

Methods included from Credential

#import_msf_cred_dump, #import_msf_cred_dump_zip, #import_msf_pwdump

Instance Method Details

#nils_for_nulls(str) ⇒ Object

Convert the string “NULL” to actual nil



11
12
13
# File 'lib/msf/core/db_manager/import/metasploit_framework.rb', line 11

def nils_for_nulls(str)
  str == "NULL" ? nil : str
end

#unserialize_object(xml_elem, allow_yaml = false) ⇒ Object



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
# File 'lib/msf/core/db_manager/import/metasploit_framework.rb', line 15

def unserialize_object(xml_elem, allow_yaml = false)
  return nil unless xml_elem
  string = xml_elem.text.to_s.strip
  return string unless string.is_a?(String)
  return nil if (string.empty? || string.nil?)

  begin
    # Validate that it is properly formed base64 first
    if string.gsub(/\s+/, '') =~ /^([a-z0-9A-Z\+\/=]+)$/
      Marshal.load($1.unpack("m")[0])
    else
      if allow_yaml
        begin
          YAML.load(string)
        rescue
          dlog("Badly formatted YAML: '#{string}'")
          string
        end
      else
        string
      end
    end
  rescue ::Exception => e
    if allow_yaml
      YAML.load(string) rescue string
    else
      string
    end
  end
end