Skip to content

Instantly share code, notes, and snippets.

@captainGeech42
Created November 9, 2021 01:31
Show Gist options
  • Save captainGeech42/c68ed2afcc6818c82d394487a33f5eef to your computer and use it in GitHub Desktop.
Save captainGeech42/c68ed2afcc6818c82d394487a33f5eef to your computer and use it in GitHub Desktop.
Export ctftime compatible scoreboard from rCTF
#!/usr/bin/env python3
import requests
import sys
# use an account with bit 1<<2 set (put 7 for ultimate laziness)
BASE_URL = "https://damctf.xyz"
TEAM_TOKEN = "redacted" # the thing from the url on the team profile page
r = requests.post(BASE_URL + "/api/v1/auth/login", json={"teamToken": TEAM_TOKEN})
if r.status_code != 200 or r.json()["kind"] != "goodLogin":
print("Failed to authenticate to rCTF, bad team token?")
sys.exit(1)
auth_token = r.json()["data"]["authToken"]
print("authed")
r = requests.get(BASE_URL + "/api/v1/integrations/ctftime/leaderboard", headers={"Authorization": f"Bearer {auth_token}"})
if r.status_code != 200:
print("couldn't get scoreboard")
print(r.content.decode())
with open("ctftime.json", "w") as f:
f.write(r.content.decode())
print("exported scoreboard to ctftime.json")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment