mirror of
https://github.com/cliffe/SecGen.git
synced 2026-02-21 11:18:06 +00:00
exif metadata module (WIP - needs some jpg files rather than png)
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -8,6 +8,7 @@ gem 'faker'
|
||||
gem 'forgery'
|
||||
gem 'redcarpet'
|
||||
gem 'rqrcode'
|
||||
gem 'mini_exiftool_vendored'
|
||||
|
||||
#development only gems go here
|
||||
group :test, :development do
|
||||
|
||||
@@ -23,6 +23,9 @@ GEM
|
||||
rsync
|
||||
librarianp (0.6.3)
|
||||
thor (~> 0.15)
|
||||
mini_exiftool (2.8.0)
|
||||
mini_exiftool_vendored (9.2.7.v1)
|
||||
mini_exiftool (>= 1.6.0)
|
||||
mini_portile2 (2.1.0)
|
||||
minitar (0.5.4)
|
||||
minitest (5.9.0)
|
||||
@@ -63,6 +66,7 @@ DEPENDENCIES
|
||||
faker
|
||||
forgery
|
||||
librarian-puppet
|
||||
mini_exiftool_vendored
|
||||
minitest
|
||||
nokogiri
|
||||
puppet
|
||||
|
||||
0
modules/generators/challenges/exif/exif.pp
Normal file
0
modules/generators/challenges/exif/exif.pp
Normal file
76
modules/generators/challenges/exif/secgen_local/local.rb
Normal file
76
modules/generators/challenges/exif/secgen_local/local.rb
Normal file
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/ruby
|
||||
require_relative '../../../../../lib/objects/local_string_encoder.rb'
|
||||
require 'mini_exiftool_vendored'
|
||||
|
||||
class ExifModifiedGenerator < StringEncoder
|
||||
attr_accessor :base64_image
|
||||
attr_accessor :strings_to_leak
|
||||
attr_accessor :exif_field
|
||||
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'Modified Exif Image Generator'
|
||||
self.base64_image = ''
|
||||
self.strings_to_leak = []
|
||||
self.exif_field = ''
|
||||
end
|
||||
|
||||
def encode_all
|
||||
|
||||
|
||||
fields = %w(ProcessingSoftware DocumentName ImageDescription Make Model PageName Software ModifyDate Artist
|
||||
ImageHistory UserComment UniqueCameraModel LocalizedCameraModel CameraSerialNumber OriginalRawFileName
|
||||
ReelName CameraLabel OwnerName SerialNumber Lens)
|
||||
|
||||
# selected_field = fields.sample.chomp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Decode the base64 image data into raw contents
|
||||
raw_image_contents = Base64.strict_decode64(self.base64_image)
|
||||
|
||||
# Store the raw_image_contents as a temporary image file called 'tmp.png'
|
||||
tmp_file_path = GENERATORS_DIR + 'challenges/exif/secgen_local/tmp/tmp.png'
|
||||
File.open(tmp_file_path, 'wb') { |f| f.write(raw_image_contents) }
|
||||
|
||||
image = MiniExiftool.new(tmp_file_path)
|
||||
|
||||
fields.each { |field|
|
||||
image[field] = self.strings_to_leak
|
||||
}
|
||||
image.save
|
||||
|
||||
# Get a list of string-writable exif tags + create a generator
|
||||
|
||||
|
||||
# self.outputs << Base64.strict_encode64(contents_with_data)
|
||||
end
|
||||
|
||||
def get_options_array
|
||||
super + [['--base64_image', GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--strings_to_leak', GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--exif_field', GetoptLong::REQUIRED_ARGUMENT]]
|
||||
end
|
||||
|
||||
def process_options(opt, arg)
|
||||
super
|
||||
case opt
|
||||
when '--base64_image'
|
||||
self.base64_image << arg;
|
||||
when '--strings_to_leak'
|
||||
self.strings_to_leak << arg;
|
||||
when '--exif_field'
|
||||
self.exif_field << arg;
|
||||
end
|
||||
end
|
||||
|
||||
def encoding_print_string
|
||||
'base64_image: <selected_image>
|
||||
strings_to_leak: ' + self.strings_to_leak.to_s + '
|
||||
exif_field: ' + self.exif_field.to_s
|
||||
end
|
||||
end
|
||||
|
||||
ExifModifiedGenerator.new.run
|
||||
34
modules/generators/challenges/exif/secgen_metadata.xml
Normal file
34
modules/generators/challenges/exif/secgen_metadata.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<generator xmlns="http://www.github/cliffe/SecGen/generator"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.github/cliffe/SecGen/generator">
|
||||
<name>Exif</name>
|
||||
<author>Thomas Shaw</author>
|
||||
<module_license>MIT</module_license>
|
||||
<description>TODO</description>
|
||||
|
||||
<type>modified_exif</type>
|
||||
<type>string_generator</type>
|
||||
<type>local_calculation</type>
|
||||
<platform>linux</platform>
|
||||
<platform>windows</platform>
|
||||
|
||||
<read_fact>base64_image</read_fact>
|
||||
<read_fact>strings_to_leak</read_fact>
|
||||
<read_fact>exif_field</read_fact>
|
||||
|
||||
<default_input into="base64_image">
|
||||
<generator type="random_image"/>
|
||||
</default_input>
|
||||
|
||||
<default_input into="strings_to_leak">
|
||||
<generator type="flag_generator"/>
|
||||
</default_input>
|
||||
|
||||
<default_input into="exif_field">
|
||||
<generator type="exif_string_field"/>
|
||||
</default_input>
|
||||
|
||||
<output_type>generated_image</output_type>
|
||||
</generator>
|
||||
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/ruby
|
||||
require_relative '../../../../../lib/objects/local_string_generator.rb'
|
||||
|
||||
class RandomExifStringField < StringGenerator
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'Random Exif Field Generator'
|
||||
end
|
||||
|
||||
def generate
|
||||
|
||||
fields = %w(ProcessingSoftware DocumentName ImageDescription Make Model PageName Software ModifyDate Artist
|
||||
ImageHistory UserComment UniqueCameraModel LocalizedCameraModel CameraSerialNumber OriginalRawFileName
|
||||
ReelName CameraLabel OwnerName SerialNumber Lens)
|
||||
|
||||
self.outputs << fields.sample.chomp
|
||||
end
|
||||
end
|
||||
|
||||
RandomExifStringField.new.run
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<generator xmlns="http://www.github/cliffe/SecGen/generator"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.github/cliffe/SecGen/generator">
|
||||
<name>Random Exif String Field Generator</name>
|
||||
<author>Thomas Shaw</author>
|
||||
<module_license>MIT</module_license>
|
||||
<description>Selects the name of a random EXIF string type field.</description>
|
||||
|
||||
<type>exif_string_field</type>
|
||||
<type>string_generator</type>
|
||||
<type>local_calculation</type>
|
||||
<platform>linux</platform>
|
||||
<platform>windows</platform>
|
||||
|
||||
<reference>http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html</reference>
|
||||
|
||||
<output_type>generated_strings</output_type>
|
||||
</generator>
|
||||
Reference in New Issue
Block a user