Skip to content

Commit

Permalink
Land #14050, fixes db_import bug with zip files
Browse files Browse the repository at this point in the history
  • Loading branch information
agalway-r7 committed Sep 1, 2020
2 parents b135367 + 97eb04a commit 3690baf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/msf/core/db_manager/import/metasploit_framework/zip.rb
Expand Up @@ -3,9 +3,9 @@ module Msf::DBManager::Import::MetasploitFramework::Zip
# XXX: This function is stupidly long. It needs to be refactored.
def import_msf_collateral(args={}, &block)
data = ::File.open(args[:filename], "rb") {|f| f.read(f.stat.size)}
wspace = Msf::Util::DBManager.process_opts_workspace(args, framework).name
wspace = Msf::Util::DBManager.process_opts_workspace(args, framework)
args = args.clone()
args.detele(:workspace)
args.delete(:workspace)
bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : []
basedir = args[:basedir] || args['basedir'] || ::File.join(Msf::Config.data_directory, "msf")

Expand Down Expand Up @@ -59,7 +59,7 @@ def parse_zip_loot(loot, wspace, bl, allow_yaml, btag, args, basedir, host_info,
return 0 if bl.include? host_info[loot.at("host-id").text.to_s.strip]
loot_info = {}
loot_info[:host] = host_info[loot.at("host-id").text.to_s.strip]
loot_info[:workspace] = args[:workspace]
loot_info[:workspace] = wspace
loot_info[:ctype] = nils_for_nulls(loot.at("content-type").text.to_s.strip)
loot_info[:info] = nils_for_nulls(unserialize_object(loot.at("info"), allow_yaml))
loot_info[:ltype] = nils_for_nulls(loot.at("ltype").text.to_s.strip)
Expand Down Expand Up @@ -104,7 +104,7 @@ def parse_zip_loot(loot, wspace, bl, allow_yaml, btag, args, basedir, host_info,
# Parses task Nokogiri::XML::Element
def parse_zip_task(task, wspace, bl, allow_yaml, btag, args, basedir, host_info, &block)
task_info = {}
task_info[:workspace] = args[:workspace]
task_info[:workspace] = wspace
# Should user be imported (original) or declared (the importing user)?
task_info[:user] = nils_for_nulls(task.at("created-by").text.to_s.strip)
task_info[:desc] = nils_for_nulls(task.at("description").text.to_s.strip)
Expand Down Expand Up @@ -165,7 +165,7 @@ def parse_zip_report(report, wspace, bl, allow_yaml, btag, args, basedir, host_i
# XXX: Refactor so it's not quite as sanity-blasting.
def import_msf_zip(args={}, &block)
data = args[:data]
wspace = Msf::Util::DBManager.process_opts_workspace(args, framework).name
wspace = Msf::Util::DBManager.process_opts_workspace(args, framework)
bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : []

new_tmp = ::File.join(Dir::tmpdir,"msf","imp_#{Rex::Text::rand_text_alphanumeric(4)}",@import_filedata[:zip_basename])
Expand Down

0 comments on commit 3690baf

Please sign in to comment.