@@ -2938,7 +2938,6 @@ def import_file(args={}, &block)
2938
2938
# is unknown.
2939
2939
def import ( args = { } , &block )
2940
2940
data = args [ :data ] || args [ 'data' ]
2941
- wspace = args [ :wspace ] || args [ 'wspace' ] || workspace
2942
2941
ftype = import_filetype_detect ( data )
2943
2942
yield ( :filetype , @import_filedata [ :type ] ) if block
2944
2943
self . send "import_#{ ftype } " . to_sym , args , &block
@@ -2959,6 +2958,7 @@ def import(args={}, &block)
2959
2958
# :ip_list
2960
2959
# :libpcap
2961
2960
# :mbsa_xml
2961
+ # :msf_cred_dump_zip
2962
2962
# :msf_pwdump
2963
2963
# :msf_xml
2964
2964
# :msf_zip
@@ -2980,6 +2980,8 @@ def import(args={}, &block)
2980
2980
# :wapiti_xml
2981
2981
#
2982
2982
# If there is no match, an error is raised instead.
2983
+ #
2984
+ # @raise DBImportError if the type can't be detected
2983
2985
def import_filetype_detect ( data )
2984
2986
2985
2987
if data and data . kind_of? Zip ::File
@@ -2992,6 +2994,11 @@ def import_filetype_detect(data)
2992
2994
@import_filedata [ :zip_basename ] = @import_filedata [ :zip_filename ] . gsub ( /\. zip$/ , "" )
2993
2995
@import_filedata [ :zip_entry_names ] = data . entries . map { |x | x . name }
2994
2996
2997
+ if @import_filedata [ :zip_entry_names ] . include? ( Metasploit ::Credential ::Importer ::Zip ::MANIFEST_FILE_NAME )
2998
+ @import_filedata [ :type ] = "Metasploit Credential Dump"
2999
+ return :msf_cred_dump_zip
3000
+ end
3001
+
2995
3002
xml_files = @import_filedata [ :zip_entry_names ] . grep ( /^(.*)\. xml$/ )
2996
3003
2997
3004
# TODO This check for our zip export should be more extensive
@@ -3613,10 +3620,10 @@ def import_msf_zip(args={}, &block)
3613
3620
}
3614
3621
3615
3622
data . entries . each do |e |
3616
- target = ::File . join ( @import_filedata [ :zip_tmp ] , e . name )
3623
+ target = ::File . join ( @import_filedata [ :zip_tmp ] , e . name )
3617
3624
data . extract ( e , target )
3618
3625
3619
- if target =~ /^.*. xml$ /
3626
+ if target =~ /\. xml\z /
3620
3627
target_data = ::File . open ( target , "rb" ) { |f | f . read 1024 }
3621
3628
if import_filetype_detect ( target_data ) == :msf_xml
3622
3629
@import_filedata [ :zip_extracted_xml ] = target
@@ -3801,7 +3808,9 @@ def import_msf_collateral(args={}, &block)
3801
3808
end
3802
3809
3803
3810
# Import credentials given a path to a valid manifest file
3811
+ #
3804
3812
# @param creds_dump_manifest_path [String]
3813
+ # @param workspace [Mdm::Workspace] Default: {#workspace}
3805
3814
# @return [void]
3806
3815
def import_msf_cred_dump ( creds_dump_manifest_path , workspace )
3807
3816
manifest_file = File . open ( creds_dump_manifest_path )
@@ -3810,6 +3819,18 @@ def import_msf_cred_dump(creds_dump_manifest_path, workspace)
3810
3819
importer . import!
3811
3820
end
3812
3821
3822
+ # Import credentials given a path to a valid manifest file
3823
+ #
3824
+ # @option args [String] :filename
3825
+ # @option args [Mdm::Workspace] :wspace Default: {#workspace}
3826
+ # @return [void]
3827
+ def import_msf_cred_dump_zip ( args = { } )
3828
+ wspace = args [ :wspace ] || workspace
3829
+ origin = Metasploit ::Credential ::Origin ::Import . create! ( filename : File . basename ( args [ :filename ] ) )
3830
+ importer = Metasploit ::Credential ::Importer ::Zip . new ( workspace : wspace , input : File . open ( args [ :filename ] ) , origin : origin )
3831
+ importer . import!
3832
+ nil
3833
+ end
3813
3834
3814
3835
# @param report [REXML::Element] to be imported
3815
3836
# @param args [Hash]
0 commit comments