Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rake task to generate manifest #675

Merged
merged 1 commit into from
Sep 22, 2023

Conversation

sjanusz-r7
Copy link
Contributor

@sjanusz-r7 sjanusz-r7 commented Sep 22, 2023

This PR is a pre-requisite for #673
This PR adds a Rake task to generate a manifest allowing us to keep track of all the necessary Meterpreter files in this gem.

Example:

manifest

./data/meterpreter/dump_sam.x64.debug.dll:SHA3-256:6326bcf12074a1b3c987d4ef8a590f746879a07c4485e34bd2bd7d0e1aa2f08b
./data/meterpreter/dump_sam.x64.dll:SHA3-256:fe8a1a4bf17988e9b9457b8058c500dda9fb7cf8d2baff900d297a34711534d8
./data/meterpreter/dump_sam.x86.debug.dll:SHA3-256:ef28b3971032a0a532ad67971b86247aa4572ef5c320e013833ababc4761dac7
./data/meterpreter/dump_sam.x86.dll:SHA3-256:58f2e89466287199affbfc07dd05acba94fbd9cc172826cc8543571b11d2f717
./data/meterpreter/elevator.x64.debug.dll:SHA3-256:6c8e412d550f343453b8f327af3e7bcc4d81c4d952fc414dff766095134eb5ab
./data/meterpreter/elevator.x64.dll:SHA3-256:f1dce39c09da8ecb361d401ace57c76c30bbacb2943b4f49256c6f80aa4ed65f
./data/meterpreter/elevator.x86.debug.dll:SHA3-256:03bb05b0d58289e2a8ee00402f45ef355ef9078228bdbd16f391c858a07475fc
./data/meterpreter/elevator.x86.dll:SHA3-256:b0173d8a5e433b621294e8e235c4d6f1587dfab34e19f862d111a6814d272e2e

manifest.uuid

25b9ff7f3931007a47e3c21e975244404cf159b3237e8d54ac37934fc1a77cae

Testing

  • bundle install
  • bundle exec 'rake create_manifest'
  • Confirm that the manifest file is created and contains a list of all Meterpreter files
  • Confirm that the manifest.uuid file contains the SHA3-256 hash for the manifest file

gem/Rakefile Outdated Show resolved Hide resolved
gem/Rakefile Outdated Show resolved Hide resolved
@sjanusz-r7 sjanusz-r7 force-pushed the add-files-rake-task branch 2 times, most recently from 17a33e9 to 3e3a6dd Compare September 22, 2023 15:47
@sjanusz-r7 sjanusz-r7 changed the title Add Rake task to generate bill of materials Add Rake task to generate manifest Sep 22, 2023
gem/Rakefile Outdated Show resolved Hide resolved
gem/Rakefile Outdated Show resolved Hide resolved
gem/Rakefile Outdated Show resolved Hide resolved
gem/Rakefile Outdated Show resolved Hide resolved
gem/Rakefile Outdated
task :win_prep => [:create_dir, :win_compile, :win_copy] do
task :create_manifest do
all_meterpreter_data = ::Dir.glob(dest + '/**/*').select { |f| ::File.file?(f) }.sort
manifest = all_meterpreter_data.map { |f| "#{f}:#{hash_type}:#{::OpenSSL::Digest.new(hash_type, ::File.read(f))}" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
manifest = all_meterpreter_data.map { |f| "#{f}:#{hash_type}:#{::OpenSSL::Digest.new(hash_type, ::File.read(f))}" }
manifest = all_meterpreter_data.map { |f| [f, hash_type, ::OpenSSL::Digest.new(hash_type, ::File.binread(f))].join(':') }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want the hashes to be different on windows/linux - so prefer binread and binwrite

rapid7/metasploit-framework#16325

@adfoster-r7 adfoster-r7 merged commit 5e1acb2 into rapid7:master Sep 22, 2023
2 checks passed
@adfoster-r7
Copy link
Contributor

Looks good to me; We'll need to wire this up as part of the release process

@adfoster-r7
Copy link
Contributor

@sjanusz-r7 I don't think this is working on CI just yet, the manifest file didn't seem to generate when downloading the created gem

I think this needs to be updated:

spec.files = `git ls-files`.split("\n")
spec.files += Dir['data/**/*']

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants