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
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
3 changes: 3 additions & 0 deletions gem/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ data/*
# never include private bins!
# If you're interested in these, consider http://metasploit.pro
data/meterpreter/ext_server_pivot.*

manifest
manifest.uuid
15 changes: 13 additions & 2 deletions gem/Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
require "bundler/gem_tasks"
require 'openssl'

c_source = "../c/meterpreter/"
java_source = "../java"
php_source = "../php/meterpreter/"
python_source = "../python/meterpreter/"
dest = "./data"
meterpreter_dest = "./data/meterpreter"
manifest_file = './manifest'
manifest_uuid_file = './manifest.uuid'
manifest_hash_type = 'SHA3-256'

platform_config = {
:windows => {
Expand Down Expand Up @@ -90,7 +94,14 @@ task :python_copy do
copy_files(platform_config[:python], meterpreter_dest)
end

task :win_prep => [:create_dir, :win_compile, :win_copy] do
task :create_manifest do
all_data_files = ::Dir.glob(dest + '/**/*').select { |f| ::File.file?(f) }.sort
manifest = all_data_files.map { |f| [f, manifest_hash_type, ::OpenSSL::Digest.new(manifest_hash_type, ::File.binread(f))].join(':') }
::File.binwrite(manifest_file, manifest.join("\n"))
::File.binwrite(manifest_uuid_file, ::OpenSSL::Digest.new(manifest_hash_type, ::File.binread(manifest_file)))
end

task :win_prep => [:create_dir, :win_compile, :win_copy, :create_manifest] do
end

task :java_prep => [:create_dir, :java_compile, :java_copy] do
Expand All @@ -102,7 +113,7 @@ end
task :python_prep => [:create_dir, :python_copy] do
end

task :default => [:python_prep, :php_prep, :java_prep] do
task :default => [:python_prep, :php_prep, :java_prep, :create_manifest] do
end

# Override tag_version in bundler-#.#.#/lib/bundler/gem_helper.rb to force signed tags
Expand Down