Merge pull request #117 from rapid7/feature/MSP-9943/db-import-creds
Deprecation warning exorcised, specs passing, export/import accuracy confirmed. MSP-9943 #landbug/bundler_fix
commit
ed1ed5d5a4
|
@ -47,3 +47,6 @@ module Metasploit
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Silence warnings about this defaulting to true
|
||||
I18n.enforce_available_locales = true
|
||||
|
|
|
@ -2938,7 +2938,6 @@ class DBManager
|
|||
# is unknown.
|
||||
def import(args={}, &block)
|
||||
data = args[:data] || args['data']
|
||||
wspace = args[:wspace] || args['wspace'] || workspace
|
||||
ftype = import_filetype_detect(data)
|
||||
yield(:filetype, @import_filedata[:type]) if block
|
||||
self.send "import_#{ftype}".to_sym, args, &block
|
||||
|
@ -2959,6 +2958,7 @@ class DBManager
|
|||
# :ip_list
|
||||
# :libpcap
|
||||
# :mbsa_xml
|
||||
# :msf_cred_dump_zip
|
||||
# :msf_pwdump
|
||||
# :msf_xml
|
||||
# :msf_zip
|
||||
|
@ -2980,6 +2980,8 @@ class DBManager
|
|||
# :wapiti_xml
|
||||
#
|
||||
# If there is no match, an error is raised instead.
|
||||
#
|
||||
# @raise DBImportError if the type can't be detected
|
||||
def import_filetype_detect(data)
|
||||
|
||||
if data and data.kind_of? Zip::File
|
||||
|
@ -2992,6 +2994,11 @@ class DBManager
|
|||
@import_filedata[:zip_basename] = @import_filedata[:zip_filename].gsub(/\.zip$/,"")
|
||||
@import_filedata[:zip_entry_names] = data.entries.map {|x| x.name}
|
||||
|
||||
if @import_filedata[:zip_entry_names].include?(Metasploit::Credential::Importer::Zip::MANIFEST_FILE_NAME)
|
||||
@import_filedata[:type] = "Metasploit Credential Dump"
|
||||
return :msf_cred_dump_zip
|
||||
end
|
||||
|
||||
xml_files = @import_filedata[:zip_entry_names].grep(/^(.*)\.xml$/)
|
||||
|
||||
# TODO This check for our zip export should be more extensive
|
||||
|
@ -3613,10 +3620,10 @@ class DBManager
|
|||
}
|
||||
|
||||
data.entries.each do |e|
|
||||
target = ::File.join(@import_filedata[:zip_tmp],e.name)
|
||||
target = ::File.join(@import_filedata[:zip_tmp], e.name)
|
||||
data.extract(e,target)
|
||||
|
||||
if target =~ /^.*.xml$/
|
||||
if target =~ /\.xml\z/
|
||||
target_data = ::File.open(target, "rb") {|f| f.read 1024}
|
||||
if import_filetype_detect(target_data) == :msf_xml
|
||||
@import_filedata[:zip_extracted_xml] = target
|
||||
|
@ -3801,7 +3808,9 @@ class DBManager
|
|||
end
|
||||
|
||||
# Import credentials given a path to a valid manifest file
|
||||
#
|
||||
# @param creds_dump_manifest_path [String]
|
||||
# @param workspace [Mdm::Workspace] Default: {#workspace}
|
||||
# @return [void]
|
||||
def import_msf_cred_dump(creds_dump_manifest_path, workspace)
|
||||
manifest_file = File.open(creds_dump_manifest_path)
|
||||
|
@ -3810,6 +3819,18 @@ class DBManager
|
|||
importer.import!
|
||||
end
|
||||
|
||||
# Import credentials given a path to a valid manifest file
|
||||
#
|
||||
# @option args [String] :filename
|
||||
# @option args [Mdm::Workspace] :wspace Default: {#workspace}
|
||||
# @return [void]
|
||||
def import_msf_cred_dump_zip(args = {})
|
||||
wspace = args[:wspace] || workspace
|
||||
origin = Metasploit::Credential::Origin::Import.create!(filename: File.basename(args[:filename]))
|
||||
importer = Metasploit::Credential::Importer::Zip.new(workspace: wspace, input: File.open(args[:filename]), origin: origin)
|
||||
importer.import!
|
||||
nil
|
||||
end
|
||||
|
||||
# @param report [REXML::Element] to be imported
|
||||
# @param args [Hash]
|
||||
|
|
Loading…
Reference in New Issue