generators/flag/flag_concat: joins strings and wraps in flag{}

This commit is contained in:
thomashaw
2017-06-22 09:06:57 +01:00
parent 58c53269ad
commit 2e35c1e915
4 changed files with 60 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
#!/usr/bin/ruby
require_relative '../../../../../lib/objects/local_string_encoder.rb'
class ConcatFlagGenerator < StringEncoder
attr_accessor :strings_to_join
def initialize
super
self.module_name = 'Concat Flag Generator'
self.strings_to_join = []
end
def encode_all
contents = self.strings_to_join.join(' ')
self.outputs << "flag{#{contents}}"
end
def get_options_array
super + [['--strings_to_join', GetoptLong::REQUIRED_ARGUMENT]]
end
def process_options(opt, arg)
super
case opt
when '--strings_to_join'
self.strings_to_join << arg;
end
end
def encoding_print_string
'strings_to_join: ' + self.strings_to_join.to_s
end
end
ConcatFlagGenerator.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>Concatenated Flag Generator</name>
<author>Thomas Shaw</author>
<module_license>MIT</module_license>
<description>Concatenates the contents of strings_to_join, separated with a space, outputs flag{result}.</description>
<type>flag_generator</type>
<type>concat_flag_generator</type>
<type>local_calculation</type>
<platform>linux</platform>
<platform>windows</platform>
<read_fact>strings_to_join</read_fact>
<default_input into="strings_to_join">
<generator type="random_word_generator"/>
<generator type="random_word_generator"/>
</default_input>
<output_type>generated_strings</output_type>
</generator>