Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernelCTF: fix check-submission.py for v2 flags #152

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions kernelctf/check-submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
checkList(exploitFolders, lambda f: any(f.startswith(p) for p in validExploitFolderPrefixes),
f"The submission folder name (`{subDirName}`) is not consistent with the exploits in the `{EXPLOIT_DIR}` folder. " +
f"Based on the folder name (`{subDirName}`), the subfolders are expected to be prefixed with one of these: {', '.join(f'`{t}-`' for t in targets)}, " +
"but this is not true for the following entries: <LIST>. You can put the extra files into a folder prefixed with `extra-`, " +
"but this is not true for the following entries: <LIST>. You can put the extra files into a folder prefixed with `extra-`, " +
"but try to make it clear what's the difference between this exploit and the others.")

reqFilesPerExploit = ["Makefile", "exploit.c", "exploit"]
Expand Down Expand Up @@ -121,7 +121,17 @@
if cve != publicData["CVE"]:
error(f"The CVE on the public spreadsheet for submission `{submissionId}` is `{publicData['CVE']}` but the PR is for `{cve}`.")

flagTargets = set([checkRegex(flag, r"kernelCTF\{v1:([^:]+):\d+\}", f"The flag (`{flag}`) is invalid").group(1) for flag in flags])
flagRegex = r"kernelCTF\{(?:v1:([^:]+)|v2:([^:]+):([^:]*)):\d+\}"
def flagTarget(flag):
match = checkRegex(flag, flagRegex, f"The flag (`{flag}`) is invalid")
if match.group(1):
# v1 flag
return match.group(1)

# v2 flag
return match.group(2)

flagTargets = set([flagTarget(flag) for flag in flags])
if "mitigation-6.1-v2" in flagTargets:
flagTargets = flagTargets - {"mitigation-6.1-v2"} | {"mitigation-6.1"}
print(f"[-] Got flags for the following targets: {', '.join(flagTargets)}")
Expand Down Expand Up @@ -153,4 +163,3 @@ def summary(success, text):
ghSet("OUTPUT", f"artifact_backup_dir={'_'.join(submissionIds)}")

summary(True, f"✅ The file structure verification of the PR was successful!")

Loading