mirror of
https://github.com/cliffe/SecGen.git
synced 2026-02-21 11:18:06 +00:00
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:
1
Gemfile
1
Gemfile
@@ -7,6 +7,7 @@ gem 'wordlist'
|
||||
gem 'faker'
|
||||
gem 'forgery'
|
||||
gem 'redcarpet'
|
||||
gem 'rqrcode'
|
||||
|
||||
#development only gems go here
|
||||
group :test, :development do
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
0
modules/generators/image/qr_code/qr_code.pp
Normal file
0
modules/generators/image/qr_code/qr_code.pp
Normal file
37
modules/generators/image/qr_code/secgen_local/local.rb
Normal file
37
modules/generators/image/qr_code/secgen_local/local.rb
Normal 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
|
||||
26
modules/generators/image/qr_code/secgen_metadata.xml
Normal file
26
modules/generators/image/qr_code/secgen_metadata.xml
Normal 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>
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user