Created
June 5, 2024 08:27
-
-
Save DanyWallace/fb55c7d924a651de99419297660d759e to your computer and use it in GitHub Desktop.
compare all of upx's compressions levels on your binary with this script or something
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# execute as "ruby upx-outputs.rb BINARYNAME | |
# you will get BINARYNAME-.txt and BINARYNAME-full.txt (contains upx's shell output) | |
require "digest" | |
compression_levels = 1..9 | |
file_name = ARGV[0] | |
file_logs = "" | |
full_logs = "" | |
compression_levels.each do |level| | |
output_file = "#{file_name}-#{level}" | |
command = "./upx -#{level} -o #{output_file} #{file_name}" | |
puts command | |
command_exec = `#{command}` | |
file_size = File.size(output_file) / 1024 # filesize as kb | |
file_hash = Digest::MD5.file(output_file).hexdigest | |
file_logs += "#{output_file}: #{file_size}kb - #{file_hash}\n" | |
full_logs += "#{output_file}: #{file_size}kb - #{file_hash}\n#{command_exec}\n++++++++\n" | |
command_exec = `rm -rf #{output_file}` | |
end | |
File.write("#{file_name}.txt", file_logs) | |
File.write("#{file_name}-full.txt", full_logs) | |
puts "finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment