From 262dd6ed4f51d12e62f90893e22f0f4d8fafeef7 Mon Sep 17 00:00:00 2001 From: Eli McRae Date: Fri, 22 Sep 2023 19:08:39 -0500 Subject: [PATCH] fix byoc_commit cost calculation --- byoctf_discord.py | 17 ++++++++++++++++- example_challenges/xss_in_desc_test.toml | 15 +++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 example_challenges/xss_in_desc_test.toml diff --git a/byoctf_discord.py b/byoctf_discord.py index 5fa52ce..7e8e6cd 100755 --- a/byoctf_discord.py +++ b/byoctf_discord.py @@ -208,8 +208,23 @@ def renderChallenge(result: dict, preview=False): avg_flag_val = sum([f["flag_value"] for f in result["flags"]])/len(result["flags"]) - break_even_solves = result["cost"] / avg_flag_val + flag_vals = [f["flag_value"] for f in result["flags"]] + num_flags = len(flag_vals) + flag_vals.sort() + least_middle_most = flag_vals[num_flags//2 - 1] + + + # break_even_solves = result["cost"] / avg_flag_val + + # In [28]: vals = [100, 225, 250, 350, 400, 475, 600] + + # In [29]: vals.sort();vals[len(vals)//2 - 1] + # Out[29]: 250 + + # This is the minimum number of solves of a obtainable flag to recoup cost. + break_even_solves = result["cost"] / least_middle_most + # break_even_solves = result['cost'] / (avg_flag_val * byoc_rate) diff --git a/example_challenges/xss_in_desc_test.toml b/example_challenges/xss_in_desc_test.toml new file mode 100644 index 0000000..7bc139d --- /dev/null +++ b/example_challenges/xss_in_desc_test.toml @@ -0,0 +1,15 @@ +author = "shyft_xero" +challenge_title = "xss in desc test" +uuid = "b42881f8-284d-47aa-9a7e-e2fde4c25d7f" +challenge_description = "" +tags = [ "hack",] +depends_on = [] +[[flags]] +flag_title = "123" +flag_value = 123 +flag_flag = "FLAG{xss_me_daddy}" + +[[hints]] +hint_cost = 1 +hint_text = "" +