Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
goelp14
GitHub Repository: goelp14/easyctf-iv-problems
Path: blob/master/intro.caesar/grader.py
650 views
1
flag = "w3lc0m3_70_345yc7f"
2
alphabet = "abcdefghijklmnopqrstuvwxyz"
3
4
def get_problem(random):
5
n = random.randint(1, 25)
6
salt = "".join([random.choice("0123456789abcdef") for i in range(6)])
7
return (n, salt)
8
9
def generate(random):
10
n, salt = get_problem(random)
11
trans = str.maketrans(alphabet, alphabet[n:] + alphabet[:n])
12
ciphertext = ("easyctf{%s}" % "{}_{}".format(flag, salt)).translate(trans)
13
return dict(variables=dict(
14
ciphertext=ciphertext
15
))
16
17
def grade(random, key):
18
_, salt = get_problem(random)
19
if(key.find("{}_{}".format(flag, salt)) != -1):
20
return True, "Great! We hope you enjoy the competition."
21
return False, "Try again."
22
23