Skip to content

Commit 67246ec

Browse files
authored
include attackInfo and exploit method (#13)
1 parent 8437935 commit 67246ec

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

enochecker_cli/base.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import hashlib
23
import sys
34

45
import jsons
@@ -28,7 +29,7 @@ def _add_arguments(parser: argparse.ArgumentParser, hide_checker_address=False)
2829
default=1,
2930
help="The round in which the flag or noise was stored when method is getflag/getnoise. Equal to current_round_id otherwise.",
3031
)
31-
parser.add_argument("-f", "--flag", type=str, default="ENOFLAGENOFLAG=", help="The Flag, a Fake flag or a Unique ID, depending on the mode")
32+
parser.add_argument("-f", "--flag", type=str, default="ENOFLAGENOFLAG=", help="The flag for putflag/getflag or the flag to find in exploit mode")
3233
parser.add_argument("-v", "--variant_id", type=int, default=0, help="The variantId for the method being called")
3334
parser.add_argument(
3435
"-x", "--timeout", type=int, default=30000, help="The maximum amount of time the script has to execute in milliseconds (default 30 000)"
@@ -41,23 +42,33 @@ def _add_arguments(parser: argparse.ArgumentParser, hide_checker_address=False)
4142
default=None,
4243
help="A unique Id which must be identical for all related putflag/getflag calls and putnoise/getnoise calls",
4344
)
45+
parser.add_argument("--flag_regex", type=str, default=None, help="A regular expression matched by the flag, used only when running the exploit method")
46+
parser.add_argument(
47+
"--attack_info", type=str, default=None, help="The attack info returned by the corresponding putflag, used only when running the exploit method"
48+
)
4449

4550

4651
def task_message_from_namespace(ns: argparse.Namespace) -> CheckerTaskMessage:
4752
task_chain_id = ns.task_chain_id
4853
method = CheckerMethod(ns.method)
4954
if not task_chain_id:
5055
option = None
51-
if method in (CheckerMethod.CHECKER_METHOD_PUTFLAG, CheckerMethod.CHECKER_METHOD_GETFLAG):
56+
if method in (CheckerMethod.PUTFLAG, CheckerMethod.GETFLAG):
5257
option = "flag"
53-
elif method in (CheckerMethod.CHECKER_METHOD_PUTNOISE, CheckerMethod.CHECKER_METHOD_GETNOISE):
58+
elif method in (CheckerMethod.PUTNOISE, CheckerMethod.GETNOISE):
5459
option = "noise"
55-
elif method == CheckerMethod.CHECKER_METHOD_HAVOC:
60+
elif method == CheckerMethod.HAVOC:
5661
option = "havoc"
62+
elif method == CheckerMethod.EXPLOIT:
63+
option = "exploit"
5764
else:
5865
raise ValueError(f"Unexpected CheckerMethod: {method}")
5966
task_chain_id = f"{option}_s0_r{ns.related_round_id}_t{ns.team_id}_i{ns.variant_id}"
6067

68+
flag_hash = None
69+
if method == CheckerMethod.EXPLOIT:
70+
flag_hash = hashlib.sha256(ns.flag.encode()).hexdigest()
71+
6172
msg = CheckerTaskMessage(
6273
task_id=ns.task_id,
6374
method=method,
@@ -66,11 +77,14 @@ def task_message_from_namespace(ns: argparse.Namespace) -> CheckerTaskMessage:
6677
team_name=ns.team_name,
6778
current_round_id=ns.current_round_id,
6879
related_round_id=ns.related_round_id,
69-
flag=ns.flag,
80+
flag=ns.flag if method != CheckerMethod.EXPLOIT else None,
7081
variant_id=ns.variant_id,
7182
timeout=ns.timeout,
7283
round_length=ns.round_length,
7384
task_chain_id=task_chain_id,
85+
flag_regex=ns.flag_regex,
86+
flag_hash=flag_hash,
87+
attack_info=ns.attack_info,
7488
)
7589

7690
return msg

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
argparse>=1.4
22
requests>=2.20
3-
enochecker_core==0.8.1
3+
enochecker_core==0.10.0
44
jsons>=1.0.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name='enochecker_cli',
11-
version='0.6.0',
11+
version='0.7.0',
1212
entry_points = {
1313
"console_scripts": ['enochecker_cli = enochecker_cli.base:main']
1414
},

0 commit comments

Comments
 (0)