@@ -2948,7 +2948,6 @@ def import_file(args={}, &block)
2948
2948
# is unknown.
2949
2949
def import ( args = { } , &block )
2950
2950
data = args [ :data ] || args [ 'data' ]
2951
- wspace = args [ :wspace ] || args [ 'wspace' ] || workspace
2952
2951
ftype = import_filetype_detect ( data )
2953
2952
yield ( :filetype , @import_filedata [ :type ] ) if block
2954
2953
self . send "import_#{ ftype } " . to_sym , args , &block
@@ -2969,6 +2968,7 @@ def import(args={}, &block)
2969
2968
# :ip_list
2970
2969
# :libpcap
2971
2970
# :mbsa_xml
2971
+ # :msf_cred_dump_zip
2972
2972
# :msf_pwdump
2973
2973
# :msf_xml
2974
2974
# :msf_zip
@@ -2990,6 +2990,8 @@ def import(args={}, &block)
2990
2990
# :wapiti_xml
2991
2991
#
2992
2992
# If there is no match, an error is raised instead.
2993
+ #
2994
+ # @raise DBImportError if the type can't be detected
2993
2995
def import_filetype_detect ( data )
2994
2996
2995
2997
if data and data . kind_of? Zip ::File
@@ -3002,6 +3004,10 @@ def import_filetype_detect(data)
3002
3004
@import_filedata [ :zip_basename ] = @import_filedata [ :zip_filename ] . gsub ( /\. zip$/ , "" )
3003
3005
@import_filedata [ :zip_entry_names ] = data . entries . map { |x | x . name }
3004
3006
3007
+ if @import_filedata [ :zip_entry_names ] . include? ( "manifest.csv" )
3008
+ return :msf_cred_dump_zip
3009
+ end
3010
+
3005
3011
xml_files = @import_filedata [ :zip_entry_names ] . grep ( /^(.*)\. xml$/ )
3006
3012
3007
3013
# TODO This check for our zip export should be more extensive
@@ -3623,10 +3629,10 @@ def import_msf_zip(args={}, &block)
3623
3629
}
3624
3630
3625
3631
data . entries . each do |e |
3626
- target = ::File . join ( @import_filedata [ :zip_tmp ] , e . name )
3632
+ target = ::File . join ( @import_filedata [ :zip_tmp ] , e . name )
3627
3633
data . extract ( e , target )
3628
3634
3629
- if target =~ /^.*. xml$ /
3635
+ if target =~ /\. xml\z /
3630
3636
target_data = ::File . open ( target , "rb" ) { |f | f . read 1024 }
3631
3637
if import_filetype_detect ( target_data ) == :msf_xml
3632
3638
@import_filedata [ :zip_extracted_xml ] = target
@@ -3811,7 +3817,9 @@ def import_msf_collateral(args={}, &block)
3811
3817
end
3812
3818
3813
3819
# Import credentials given a path to a valid manifest file
3820
+ #
3814
3821
# @param creds_dump_manifest_path [String]
3822
+ # @param workspace [Mdm::Workspace]
3815
3823
# @return [void]
3816
3824
def import_msf_cred_dump ( creds_dump_manifest_path , workspace )
3817
3825
manifest_file = File . open ( creds_dump_manifest_path )
@@ -3820,6 +3828,17 @@ def import_msf_cred_dump(creds_dump_manifest_path, workspace)
3820
3828
importer . import!
3821
3829
end
3822
3830
3831
+ # Import credentials given a path to a valid manifest file
3832
+ #
3833
+ # @opt args [String] :filename
3834
+ # @return [void]
3835
+ def import_msf_cred_dump_zip ( args = { } )
3836
+ wspace = args [ :wspace ] || workspace
3837
+ origin = Metasploit ::Credential ::Origin ::Import . create! ( filename : File . basename ( args [ :filename ] ) )
3838
+ importer = Metasploit ::Credential ::Importer ::Zip . new ( workspace : wspace , input : File . open ( args [ :filename ] ) , origin : origin )
3839
+ importer . import!
3840
+ nil
3841
+ end
3823
3842
3824
3843
# @param report [REXML::Element] to be imported
3825
3844
# @param args [Hash]
0 commit comments