generators/images/qr_code: creates a QR code out of a string(usually a flag) and outputs it as a .png represented as a base64 string.

This commit is contained in:
thomashaw
2017-03-16 12:32:33 +00:00
parent 638e87e571
commit 7c4d21e942
7 changed files with 89 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ gem 'wordlist'
gem 'faker'
gem 'forgery'
gem 'redcarpet'
gem 'rqrcode'
#development only gems go here
group :test, :development do

View File

@@ -2,6 +2,7 @@ GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.2.8)
chunky_png (1.3.8)
facter (2.4.6)
CFPropertyList (~> 2.2.6)
faker (1.6.6)
@@ -44,6 +45,8 @@ GEM
rdoc (4.2.2)
json (~> 1.4)
redcarpet (3.4.0)
rqrcode (0.10.1)
chunky_png (~> 1.0)
rsync (1.0.9)
semantic_puppet (0.1.3)
spidr (0.6.0)
@@ -66,6 +69,7 @@ DEPENDENCIES
rake
rdoc
redcarpet
rqrcode
wordlist
yard

View File

@@ -0,0 +1,37 @@
#!/usr/bin/ruby
require 'rqrcode'
require_relative '../../../../../lib/objects/local_string_encoder.rb'
class QRCodeGenerator < StringEncoder
attr_accessor :string_to_mask
def initialize
super
self.module_name = 'QR Code Generator'
self.string_to_mask = []
end
def encode_all
qr_code = RQRCode::QRCode.new(self.string_to_mask[0])
image = qr_code.as_png
self.outputs << Base64.strict_encode64(image.to_blob)
end
def get_options_array
super + [['--string_to_mask', GetoptLong::REQUIRED_ARGUMENT]]
end
def process_options(opt, arg)
super
case opt
when '--string_to_mask'
self.string_to_mask << arg;
end
end
def encoding_print_string
'String to mask: ' + self.string_to_mask.first
end
end
QRCodeGenerator.new.run

View File

@@ -0,0 +1,26 @@
<?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>QR Code Generator</name>
<author>Thomas Shaw</author>
<module_license>MIT</module_license>
<description>Generates a QR code image from an input string. </description>
<type>image_generator</type>
<type>qr_code_generator</type>
<type>local_calculation</type>
<platform>linux</platform>
<platform>windows</platform>
<read_fact>string_to_mask</read_fact>
<default_input into="string_to_mask">
<generator type="flag_generator"/>
</default_input>
<!--<reference>https://github.com/whomwah/rqrcode</reference>-->
<output_type>base64_encoded_image</output_type>
</generator>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<scenario xmlns="http://www.github/cliffe/SecGen/scenario"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.github/cliffe/SecGen/scenario">
<system>
<system_name>example_server</system_name>
<base platform="linux"/>
<!-- Generator which outputs an image with a QR code containing a flag. -->
<vulnerability read_fact="images_to_leak">
<input into="images_to_leak">
<generator type="qr_code_generator"/>
</input>
</vulnerability>
<network type="private_network" range="dhcp"/>
</system>
</scenario>