Skip to content

Commit 2e75481

Browse files
committed
Changed simulation-type to include 'intensive-stress-test'.
1 parent e1a1ec4 commit 2e75481

File tree

10 files changed

+59
-33
lines changed

10 files changed

+59
-33
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ There are two configuration files that need to be supplied before launching the
155155
"teams": "<int> <required> <the number of teams that should participate in the simulation>",
156156
"services": "<List(string)> <required> <the repository names of the services that should be used for the simulation>",
157157
"checker-ports": "<List(int)> <required> <the port numbers of the service checkers. the order should be the same as in services>",
158-
"simulation-type": "<string> <required> <the type of simulation to run. choose between 'realistic' and 'stress-test'>",
158+
"simulation-type": "<string> <required> <the type of simulation to run. choose between 'realistic', 'basic-stress-test', 'stress-test' and 'intesive-stress-test'>",
159159
"scoreboard-file": "<string> <optional> <the path to a scoreboard file in json format from a past competition that will be used to derive a team experience distribution for the simulation>"
160160
},
161161
"ctf-json": {

config/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"teams": "<int> <required> <the number of teams that should participate in the simulation>",
1919
"services": "<List(string)> <required> <the repository names of the services that should be used for the simulation>",
2020
"checker-ports": "<List(int)> <required> <the port numbers of the service checkers. the order should be the same as in services>",
21-
"simulation-type": "<string> <required> <the type of simulation to run. choose between 'realistic', 'basic-stress-test' and 'stress-test'>",
21+
"simulation-type": "<string> <required> <the type of simulation to run. choose between 'realistic', 'basic-stress-test', 'stress-test' and 'intesive-stress-test'>",
2222
"scoreboard-file": "<string> <optional> <the path to a scoreboard file in json format from a past competition that will be used to derive a team experience distribution for the simulation>"
2323
},
2424
"ctf-json": {

enosimulator/setup/setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,13 @@ def _generate_service(
282282
"name": service,
283283
"flagsPerRoundMultiplier": 30
284284
if simulation_type == "basic-stress-test"
285+
else 10
286+
if simulation_type == "intensive-stress-test"
285287
else 1,
286288
"noisesPerRoundMultiplier": 30
287289
if simulation_type == "basic-stress-test"
290+
else 10
291+
if simulation_type == "intensive-stress-test"
288292
else 1,
289293
"havocsPerRoundMultiplier": 1,
290294
"weightFactor": 1,

enosimulator/setup/setup_helper/team_generator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ def __init__(self, config: Config):
125125
if self.config.settings.simulation_type == "basic-stress-test":
126126
self.team_distribution = {Experience.HAXXOR: 1}
127127

128-
elif self.config.settings.simulation_type == "stress-test":
128+
elif self.config.settings.simulation_type in (
129+
"stress-test",
130+
"intensive-stress-test",
131+
):
129132
self.team_distribution = {Experience.HAXXOR: self.config.settings.teams}
130133

131134
else:

enosimulator/simulation/orchestrator.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -203,32 +203,34 @@ def _create_exploit_requests(
203203
or other_team.address == team.address
204204
):
205205
continue
206+
206207
try:
207-
attack_info = ",".join(
208-
self.attack_info["services"][
209-
self.service_info[service][1]
210-
][other_team.address][str(round_id)][str(flagstore_id)]
211-
)
208+
service_name = self.service_info[service][1]
209+
attack_info = self.attack_info["services"][service_name][
210+
other_team.address
211+
][str(round_id)][str(flagstore_id)]
212212
except:
213213
attack_info = None
214214

215-
exploit_request = checker_request(
216-
method="exploit",
217-
round_id=round_id,
218-
team_id=other_team.id,
219-
team_name=other_team.name,
220-
variant_id=flagstore_id,
221-
service_address=other_team.address,
222-
flag_regex=FLAG_REGEX_ASCII,
223-
flag=None,
224-
flag_hash=FLAG_HASH,
225-
unique_variant_index=None,
226-
attack_info=attack_info,
227-
)
228-
229-
exploit_requests[
230-
other_team.name, service, flagstore
231-
] = exploit_request
215+
if attack_info:
216+
for info in attack_info:
217+
exploit_request = checker_request(
218+
method="exploit",
219+
round_id=round_id,
220+
team_id=other_team.id,
221+
team_name=other_team.name,
222+
variant_id=flagstore_id,
223+
service_address=other_team.address,
224+
flag_regex=FLAG_REGEX_ASCII,
225+
flag=None,
226+
flag_hash=FLAG_HASH,
227+
unique_variant_index=None,
228+
attack_info=info,
229+
)
230+
231+
exploit_requests[
232+
other_team.name, service, flagstore, info
233+
] = exploit_request
232234

233235
return exploit_requests
234236

@@ -237,7 +239,7 @@ async def _send_exploit_requests(
237239
) -> List[str]:
238240
flags = []
239241
for (
240-
(team_name, service, flagstore),
242+
(team_name, service, flagstore, _info),
241243
exploit_request,
242244
) in exploit_requests.items():
243245
exploit_checker_ip = self.private_to_public_ip[team.address]

enosimulator/types_.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def from_(settings):
183183
if settings["simulation-type"] not in [
184184
"stress-test",
185185
"basic-stress-test",
186+
"intensive-stress-test",
186187
"realistic",
187188
]:
188189
raise ValueError("Invalid simulation type in config file.")

infra/azure/templates/data/engine.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if [ -f "./docker-compose.yml" ]; then
6969
fi
7070

7171
# Start the engine
72-
echo -e "\033[32m[+] Starting EnoEngine...\033[0m"
72+
echo -e "\033[32m[+] Starting EnoEngine ...\033[0m"
7373
cd EnoEngine
7474
retry sudo dotnet build
7575
retry sudo docker compose up -d

infra/hetzner/templates/data/engine.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if [ -f "./docker-compose.yml" ]; then
6969
fi
7070

7171
# Start the engine
72-
echo -e "\033[32m[+] Starting EnoEngine...\033[0m"
72+
echo -e "\033[32m[+] Starting EnoEngine ...\033[0m"
7373
cd EnoEngine
7474
retry sudo dotnet build
7575
retry sudo docker compose up -d

tests/test_setup.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,20 @@ def test_team_generator_stress_test(setup_container):
3636
assert len(ctf_json_teams) == 3
3737
assert len(ctf_json_teams) == len(setup_teams)
3838

39+
def test_team_generator_intensive_stress_test(setup_container):
40+
setup_container.reset_singletons()
41+
setup_container.configuration.config.from_dict(
42+
{"settings": {"teams": 3, "simulation-type": "intensive-stress-test"}}
43+
)
44+
team_generator = setup_container.team_generator()
45+
assert all([exp.name == "HAXXOR" for exp in team_generator.team_distribution])
46+
47+
ctf_json_teams, setup_teams = team_generator.generate()
48+
assert len(ctf_json_teams) == 3
49+
assert len(ctf_json_teams) == len(setup_teams)
50+
3951

40-
def test_team_generator_realistic(setup_container, test_setup_dir):
52+
def test_team_generator_realistic(setup_container):
4153
setup_container.reset_singletons()
4254
setup_container.configuration.config.from_dict(
4355
{"settings": {"teams": 15, "simulation-type": "realistic"}}

tests/test_simulation.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ async def test_orchestrator_send_exploit_requests(simulation_container):
374374
orchestrator.service_info = service_info
375375

376376
exploit_requests = {
377-
("TestTeam2", "CVExchange", "Flagstore0"): CheckerTaskMessage(
377+
("TestTeam2", "CVExchange", "Flagstore0", "12"): CheckerTaskMessage(
378378
task_id=10,
379379
method=CheckerMethod.EXPLOIT,
380380
address="10.1.2.1",
@@ -391,7 +391,7 @@ async def test_orchestrator_send_exploit_requests(simulation_container):
391391
flag_hash="ignore_flag_hash",
392392
attack_info="12",
393393
),
394-
("TestTeam2", "CVExchange", "Flagstore1"): CheckerTaskMessage(
394+
("TestTeam2", "CVExchange", "Flagstore1", "13"): CheckerTaskMessage(
395395
task_id=10,
396396
method=CheckerMethod.EXPLOIT,
397397
address="10.1.2.1",
@@ -419,13 +419,17 @@ async def test_orchestrator_send_exploit_requests(simulation_container):
419419
assert mock_client.post.call_count == 2
420420
mock_client.post.assert_any_call(
421421
"http://234.123.12.32:7331",
422-
data=req_to_json(exploit_requests[("TestTeam2", "CVExchange", "Flagstore0")]),
422+
data=req_to_json(
423+
exploit_requests[("TestTeam2", "CVExchange", "Flagstore0", "12")]
424+
),
423425
headers={"Content-Type": "application/json"},
424426
timeout=10,
425427
)
426428
mock_client.post.assert_any_call(
427429
"http://234.123.12.32:7331",
428-
data=req_to_json(exploit_requests[("TestTeam2", "CVExchange", "Flagstore1")]),
430+
data=req_to_json(
431+
exploit_requests[("TestTeam2", "CVExchange", "Flagstore1", "13")]
432+
),
429433
headers={"Content-Type": "application/json"},
430434
timeout=10,
431435
)

0 commit comments

Comments
 (0)