Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/metasploit/credential/exporter/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def render_manifest_output_and_keys
def render_zip
zip_dir_path = Pathname.new(output_final_directory_path)

Zip::File.open(output_zipfile_path, Zip::File::CREATE) do |zipfile|
Zip::File.open(output_zipfile_path, create: true) do |zipfile|
Dir[File.join(output_final_directory_path, '**', '**')].each do |file|
file_path = Pathname.new(file)
path_in_zip = file_path.relative_path_from(zip_dir_path)
Expand Down
4 changes: 2 additions & 2 deletions lib/metasploit/credential/importer/zip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class Metasploit::Credential::Importer::Zip
def import!
::Zip::File.open(input.path) do |zip_file|
zip_file.each do |entry|
entry.extract(File.join(extracted_zip_directory, entry.name))
entry.extract(destination_directory: File.join(extracted_zip_directory))
end
end

Expand All @@ -80,7 +80,7 @@ def extracted_zip_directory
# @return [void]
def input_is_well_formed
begin
Zip::File.open input.path do |archive|
::Zip::File.open(input.path) do |archive|
glob_check = archive.glob("**#{File::SEPARATOR}#{MANIFEST_FILE_NAME}")
if glob_check.present?
true
Expand Down
2 changes: 1 addition & 1 deletion metasploit-credential.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |s|
# Metasploit::Credential::NTLMHash helper methods
s.add_runtime_dependency 'rubyntlm'
# Required for supporting the en masse importation of SSH Keys
s.add_runtime_dependency 'rubyzip', '<3.0.0'
s.add_runtime_dependency 'rubyzip', '>= 3.1.1', '< 4.0'

Comment thread
adfoster-r7 marked this conversation as resolved.
s.add_runtime_dependency 'rex-socket'

Expand Down
6 changes: 3 additions & 3 deletions spec/factories/metasploit/credential/importer/zips.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

# Write out zip file
zip_location = "#{path}.zip"
::Zip::File.open(zip_location, ::Zip::File::CREATE) do |zipfile|
::Zip::File.open(zip_location, create: true) do |zipfile|
Dir[File.join(path, '**', '**')].each do |file|
zipfile.add(file.sub(path + '/', ''), file)
Comment thread
adfoster-r7 marked this conversation as resolved.
end
Expand Down Expand Up @@ -98,7 +98,7 @@

# Write out zip file
zip_location = "#{path}.zip"
::Zip::File.open(zip_location, ::Zip::File::CREATE) do |zipfile|
::Zip::File.open(zip_location, create: true) do |zipfile|
Dir[File.join(path, '**', '**')].each do |file|
zipfile.add(file.sub(path + '/', ''), file)
end
Expand Down Expand Up @@ -140,7 +140,7 @@

# Write out zip file
zip_location = "#{path}.zip"
::Zip::File.open(zip_location, ::Zip::File::CREATE) do |zipfile|
::Zip::File.open(zip_location, create: true) do |zipfile|
Dir[File.join(path, '**', '**')].each do |file|
zipfile.add(file.sub(path + '/', ''), file)
end
Expand Down
10 changes: 8 additions & 2 deletions spec/lib/metasploit/credential/migrator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@

context "when Cred#pass points to a file system path" do

let(:path_to_ssh_key) do
let(:ssh_key_tempfile) do
t = Tempfile.new('ssh')
t.write(ssh_key_content)
t.close
t.path
t
end

Comment thread
adfoster-r7 marked this conversation as resolved.
let(:path_to_ssh_key) { ssh_key_tempfile.path }

let(:cred) do
FactoryBot.create(:mdm_cred,
service: service,
Expand All @@ -114,6 +116,10 @@
)
end

after(:example) do
ssh_key_tempfile.unlink
end

before(:example) do
migrator.convert_creds_in_workspace(cred.service.host.workspace)
end
Expand Down
Loading