From 1fc034e9ef69f6b92e890e8da16f8eb141cb90bc Mon Sep 17 00:00:00 2001 From: thomashaw Date: Thu, 3 Feb 2022 19:00:42 +0000 Subject: [PATCH] WebActioner generation update: updated string generation --- .../xml_alertaction_config_generator.rb | 21 +++- scenarios/tests/test_scenario.xml | 117 +++++++++++++++++- 2 files changed, 130 insertions(+), 8 deletions(-) diff --git a/lib/output/xml_alertaction_config_generator.rb b/lib/output/xml_alertaction_config_generator.rb index 37dfa0e21..de6c223f9 100644 --- a/lib/output/xml_alertaction_config_generator.rb +++ b/lib/output/xml_alertaction_config_generator.rb @@ -71,17 +71,19 @@ class XmlAlertActionConfigGenerator end def all_goal_flags_to_hacktivity(aa_conf) + auto_grader_hostname + @systems.each do |system| if system.goals != [] - @alert_actions = @alert_actions + get_web_alertactions(aa_conf, system.name, system.goals, $datastore['goal_flags'], system.hostname) + @alert_actions = @alert_actions + get_web_alertactions(aa_conf, system.name, system.goals, $datastore['goal_flags'], system.hostname, auto_grader_hostname) end system.module_selections.each do |module_selection| - @alert_actions = @alert_actions + get_web_alertactions(aa_conf, module_selection.module_path_end, module_selection.goals, module_selection.received_inputs['goal_flags'], system.hostname) + @alert_actions = @alert_actions + get_web_alertactions(aa_conf, module_selection.module_path_end, module_selection.goals, module_selection.received_inputs['goal_flags'], system.hostname, auto_grader_hostname) end end end - def get_web_alertactions(aa_conf, name, goals, goal_flags, hostname) + def get_web_alertactions(aa_conf, name, goals, goal_flags, hostname, auto_grader_hostname) alert_actions = [] # Validate whether there are an equal number of goals and goal_flags + warn / error here if not... @@ -102,7 +104,8 @@ class XmlAlertActionConfigGenerator 'action_type' => 'WebAction', 'target' => aa_conf['target'], 'request_type' => 'POST', - 'data' => goal_flags[i] + 'data' => "vm_name=" + auto_grader_hostname + "&flag=" + goal_flags[i] # TODO: test if this works + # 'data' => goal_flags[i] # TODO: Update this to the correct format } end end @@ -152,4 +155,14 @@ class XmlAlertActionConfigGenerator end builder.to_xml end + + def auto_grader_hostname + ag_hostname = '' + @systems.each do |system| + if system.hostname.include? 'grading' + ag_hostname = system.hostname + end + end + ag_hostname + end end diff --git a/scenarios/tests/test_scenario.xml b/scenarios/tests/test_scenario.xml index 7ecb78760..c496db25d 100644 --- a/scenarios/tests/test_scenario.xml +++ b/scenarios/tests/test_scenario.xml @@ -4,16 +4,81 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.github/cliffe/SecGen/scenario"> - Thomas Shaw + Experiment: Auto Grading Thomas Shaw - Test Scenario - param accs: Pass group in vs not - AGT / AAA scenario + + + + ctf easy + + + + + + + + + + hackme_desktop + + + 172.16.0.2 + + 172.16.0.3 + + 172.16.0.4 + + + + + + IP_addresses + + + IP_addresses + + + 9200 + + + 5044 + + + 5601 + + + + + + IP_addresses + + + Well done! + + + Here is some subtext from the scenario. + + + root + + + test + + + challenger + + + + + + @@ -38,7 +103,12 @@ - + + + aaa_config + + + @@ -48,5 +118,44 @@ + + + + IP_addresses + + + + + + auto_grading_server + + + + flag{static_flag_1} + flag{static_flag_2} + flag{static_flag_3} + flag{static_flag_4} + flag{static_flag_5} + + + + + + + aaa_config + + + + + + IP_addresses + + + + + + test + + \ No newline at end of file