diff --git a/Gemfile b/Gemfile index 17ccccfdd..077ce9abf 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,7 @@ gem 'rqrcode' gem 'mini_exiftool_vendored' gem 'rmagick' gem 'sshkey' +gem 'zipruby' #development only gems go here group :test, :development do diff --git a/Gemfile.lock b/Gemfile.lock index d28ee61da..6f26fc5f3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -60,6 +60,7 @@ GEM wordlist (0.1.1) spidr (~> 0.2) yard (0.8.7.6) + zipruby (0.3.6) PLATFORMS ruby @@ -80,6 +81,7 @@ DEPENDENCIES sshkey wordlist yard + zipruby BUNDLED WITH 1.14.3 diff --git a/modules/generators/challenges/hidden_data_in_image_file/hidden_data_in_image_file.pp b/modules/generators/challenges/hidden_strings_in_image_file/hidden_strings_in_image_file.pp similarity index 100% rename from modules/generators/challenges/hidden_data_in_image_file/hidden_data_in_image_file.pp rename to modules/generators/challenges/hidden_strings_in_image_file/hidden_strings_in_image_file.pp diff --git a/modules/generators/challenges/hidden_data_in_image_file/manifests/.no_puppet b/modules/generators/challenges/hidden_strings_in_image_file/manifests/.no_puppet similarity index 100% rename from modules/generators/challenges/hidden_data_in_image_file/manifests/.no_puppet rename to modules/generators/challenges/hidden_strings_in_image_file/manifests/.no_puppet diff --git a/modules/generators/challenges/hidden_data_in_image_file/secgen_local/local.rb b/modules/generators/challenges/hidden_strings_in_image_file/secgen_local/local.rb similarity index 87% rename from modules/generators/challenges/hidden_data_in_image_file/secgen_local/local.rb rename to modules/generators/challenges/hidden_strings_in_image_file/secgen_local/local.rb index 9ad51ecf5..2b1914ab3 100644 --- a/modules/generators/challenges/hidden_data_in_image_file/secgen_local/local.rb +++ b/modules/generators/challenges/hidden_strings_in_image_file/secgen_local/local.rb @@ -1,13 +1,13 @@ #!/usr/bin/ruby require_relative '../../../../../lib/objects/local_string_encoder.rb' -class HideDataInImgChallenge < StringEncoder +class HideStringsInImgChallenge < StringEncoder attr_accessor :base64_image attr_accessor :strings_to_leak def initialize super - self.module_name = 'Hidden Data in Image File Challenge Generator' + self.module_name = 'Hidden Strings in Image File Challenge Generator' self.base64_image = '' self.strings_to_leak = [] end @@ -44,4 +44,4 @@ class HideDataInImgChallenge < StringEncoder end end -HideDataInImgChallenge.new.run \ No newline at end of file +HideStringsInImgChallenge.new.run \ No newline at end of file diff --git a/modules/generators/challenges/hidden_data_in_image_file/secgen_metadata.xml b/modules/generators/challenges/hidden_strings_in_image_file/secgen_metadata.xml similarity index 96% rename from modules/generators/challenges/hidden_data_in_image_file/secgen_metadata.xml rename to modules/generators/challenges/hidden_strings_in_image_file/secgen_metadata.xml index 3c6064f43..07025ad78 100644 --- a/modules/generators/challenges/hidden_data_in_image_file/secgen_metadata.xml +++ b/modules/generators/challenges/hidden_strings_in_image_file/secgen_metadata.xml @@ -3,7 +3,7 @@ - Hidden Data in Image File + Hidden Strings in Image File Thomas Shaw MIT Makes use of a random image, encodes a string_to_leak (flag) then inserts the data to decode into the end diff --git a/modules/generators/challenges/hidden_zip_in_image_file/hidden_zip_in_image_file.pp b/modules/generators/challenges/hidden_zip_in_image_file/hidden_zip_in_image_file.pp new file mode 100644 index 000000000..e69de29bb diff --git a/modules/generators/challenges/hidden_zip_in_image_file/manifests/.no_puppet b/modules/generators/challenges/hidden_zip_in_image_file/manifests/.no_puppet new file mode 100644 index 000000000..e69de29bb diff --git a/modules/generators/challenges/hidden_zip_in_image_file/secgen_local/local.rb b/modules/generators/challenges/hidden_zip_in_image_file/secgen_local/local.rb new file mode 100644 index 000000000..7e3aaadd7 --- /dev/null +++ b/modules/generators/challenges/hidden_zip_in_image_file/secgen_local/local.rb @@ -0,0 +1,48 @@ +#!/usr/bin/ruby +require_relative '../../../../../lib/objects/local_string_encoder.rb' + +class HideZipInImgChallenge < StringEncoder + attr_accessor :base64_image + attr_accessor :zip_file + + def initialize + super + self.module_name = 'Hidden Zip in Image File Challenge Generator' + self.base64_image = '' + self.zip_file = '' + end + + def encode_all + # Decode the base64 image data into raw contents + raw_image_contents = Base64.strict_decode64(self.base64_image) + raw_zip_contents = Base64.strict_decode64(self.zip_file) + + # Append data to the end of the file + contents_with_data = raw_image_contents + raw_zip_contents + + # Re-encode in base64 and return + self.outputs << Base64.strict_encode64(contents_with_data) + end + + def get_options_array + super + [['--base64_image', GetoptLong::REQUIRED_ARGUMENT], + ['--zip_file', GetoptLong::REQUIRED_ARGUMENT]] + end + + def process_options(opt, arg) + super + case opt + when '--base64_image' + self.base64_image << arg; + when '--zip_file' + self.zip_file << arg; + end + end + + def encoding_print_string + 'base64_image: + zip_file: ' + self.zip_file.to_s + end +end + +HideZipInImgChallenge.new.run \ No newline at end of file diff --git a/modules/generators/challenges/hidden_zip_in_image_file/secgen_metadata.xml b/modules/generators/challenges/hidden_zip_in_image_file/secgen_metadata.xml new file mode 100644 index 000000000..8a1bba474 --- /dev/null +++ b/modules/generators/challenges/hidden_zip_in_image_file/secgen_metadata.xml @@ -0,0 +1,34 @@ + + + + Hidden Zip in Image File + Thomas Shaw + MIT + Makes use of a random image, encodes a string_to_leak (flag) then inserts the data to decode into the end + of the image file in ascii. + + + hidden_zip_in_image_file + image_generator + image_challenge_generator + local_calculation + linux + windows + + Inspect the file's raw hex. Look at end for something to decode. Example tools: hexedit/hexeditor + + base64_image + zip_file + + + + + + + + + + generated_image + \ No newline at end of file diff --git a/modules/generators/compression/zip/manifests/.no_puppet b/modules/generators/compression/zip/manifests/.no_puppet new file mode 100644 index 000000000..e69de29bb diff --git a/modules/generators/compression/zip/secgen_local/local.rb b/modules/generators/compression/zip/secgen_local/local.rb new file mode 100644 index 000000000..60cd0a9bd --- /dev/null +++ b/modules/generators/compression/zip/secgen_local/local.rb @@ -0,0 +1,51 @@ +#!/usr/bin/ruby +require_relative '../../../../../lib/objects/local_string_encoder.rb' +require 'rubygems' +require 'zip' + +class ZipFileGenerator < StringEncoder + attr_accessor :file_name + attr_accessor :strings_to_leak + + def initialize + super + self.module_name = 'Zip File Generator' + self.file_name = '' + self.strings_to_leak = [] + end + + def encode_all + zip_file_path = GENERATORS_DIR + 'compression/zip/secgen_local/archive.zip' + + Zip::File.open(zip_file_path, Zip::File::CREATE) do |zip_file| + zip_file.get_output_stream(self.file_name) { |os| + os.write self.strings_to_leak.join("\n") + } + end + + file_contents = File.binread(zip_file_path) + self.outputs << Base64.strict_encode64(file_contents) + end + + def get_options_array + super + [['--file_name', GetoptLong::REQUIRED_ARGUMENT], + ['--strings_to_leak', GetoptLong::REQUIRED_ARGUMENT]] + end + + def process_options(opt, arg) + super + case opt + when '--file_name' + self.file_name << arg; + when '--strings_to_leak' + self.strings_to_leak << arg; + end + end + + def encoding_print_string + 'file_name: ' + self.file_name.to_s + + 'file_contents: ' + self.strings_to_leak.to_s + end +end + +ZipFileGenerator.new.run \ No newline at end of file diff --git a/modules/generators/compression/zip/secgen_metadata.xml b/modules/generators/compression/zip/secgen_metadata.xml new file mode 100644 index 000000000..3950a53da --- /dev/null +++ b/modules/generators/compression/zip/secgen_metadata.xml @@ -0,0 +1,28 @@ + + + + Zip File Generator + Thomas Shaw + MIT + TODO + + zip_file + zip_file_generator + linux + windows + + file_name + strings_to_leak + + + flag.txt + + + + + + + zip_file + \ No newline at end of file diff --git a/modules/generators/compression/zip/zip.pp b/modules/generators/compression/zip/zip.pp new file mode 100644 index 000000000..e69de29bb