mirror of
https://github.com/cliffe/SecGen.git
synced 2026-02-21 11:18:06 +00:00
Task 18.2 - echo string challenge selecting based on difficulty. low.rb implemented.
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
require_relative 'local_script_challenge_generator.rb'
|
||||
class RubyChallengeGenerator < ScriptChallengeGenerator
|
||||
|
||||
attr_accessor :difficulty
|
||||
|
||||
def initialize
|
||||
super
|
||||
self.module_name = 'Ruby Example Script Generator'
|
||||
|
||||
@@ -14,6 +14,7 @@ class ScriptChallengeGenerator
|
||||
attr_accessor :module_name
|
||||
attr_accessor :has_base64_inputs
|
||||
attr_accessor :outputs
|
||||
attr_accessor :difficulty
|
||||
|
||||
# override this
|
||||
def initialize
|
||||
@@ -21,6 +22,7 @@ class ScriptChallengeGenerator
|
||||
self.module_name = 'Null generator'
|
||||
self.has_base64_inputs = false
|
||||
self.outputs = []
|
||||
self.difficulty = ''
|
||||
end
|
||||
|
||||
# override this
|
||||
@@ -51,7 +53,8 @@ class ScriptChallengeGenerator
|
||||
|
||||
def get_options_array
|
||||
[['--help', '-h', GetoptLong::NO_ARGUMENT],
|
||||
['--b64', GetoptLong::OPTIONAL_ARGUMENT]]
|
||||
['--b64', GetoptLong::OPTIONAL_ARGUMENT],
|
||||
['--difficulty', GetoptLong::OPTIONAL_ARGUMENT]]
|
||||
end
|
||||
|
||||
# Override this when using read_fact's in your module. Always call super first
|
||||
@@ -67,6 +70,9 @@ class ScriptChallengeGenerator
|
||||
usage
|
||||
when '--b64'
|
||||
# do nothing
|
||||
when '--difficulty'
|
||||
self.difficulty << arg
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class EchoStringChallenge < RubyChallengeGenerator
|
||||
end
|
||||
|
||||
def challenge_content
|
||||
File.read(File.join(File.dirname(__FILE__), 'challenge.rb'))
|
||||
File.read(File.join(File.dirname(__FILE__), "#{difficulty}.rb"))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -15,6 +15,15 @@
|
||||
<platform>linux</platform>
|
||||
<platform>windows</platform>
|
||||
|
||||
<read_fact>difficulty</read_fact>
|
||||
|
||||
<default_input into="difficulty">
|
||||
<value>low</value>
|
||||
<!--TODO: implement higher difficulty options -->
|
||||
<!--<value>medium</value>-->
|
||||
<!--<value>high</value>-->
|
||||
</default_input>
|
||||
|
||||
<output_type>script</output_type>
|
||||
|
||||
</generator>
|
||||
@@ -13,6 +13,19 @@
|
||||
<platform>linux</platform>
|
||||
<platform>windows</platform>
|
||||
|
||||
|
||||
<!-- Some script challenges can take a difficulty parameter. -->
|
||||
<!-- Valid inputs are: low, medium, high -->
|
||||
|
||||
<!--<read_fact>difficulty</read_fact>-->
|
||||
|
||||
<!--<default_input into="difficulty">-->
|
||||
<!--<value>low</value>-->
|
||||
<!--<value>medium</value>-->
|
||||
<!--<value>high</value>-->
|
||||
<!--</default_input>-->
|
||||
|
||||
|
||||
<output_type>script</output_type>
|
||||
|
||||
</generator>
|
||||
Reference in New Issue
Block a user