Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
goelp14
GitHub Repository: goelp14/easyctf-iv-problems
Path: blob/master/intro.web/grader.py
650 views
1
from io import StringIO
2
3
template = """
4
<!doctype html>
5
<html>
6
<head>
7
<style>
8
body {{ font-family: sans-serif; padding-left: 30px; padding-top: 15px; }}
9
</style>
10
</head>
11
<body>
12
<h1>Welcome to EasyCTF!</h1>
13
14
<p>The flag is just below:</p>
15
<!-- {flag} -->
16
</body>
17
</html>
18
"""
19
20
flag = "hidden_from_the_masses"
21
alphabet = "abcdefghijklmnopqrstuvwxyz"
22
23
24
def get_problem(random):
25
salt = "".join([random.choice("0123456789abcdef") for i in range(6)])
26
return salt
27
28
29
def generate(random):
30
salt = get_problem(random)
31
contents = template.format(flag=("easyctf{%s}" % "{}_{}".format(flag, salt)))
32
return dict(files={
33
"index.html": StringIO(contents)
34
})
35
36
37
def grade(random, key):
38
salt = get_problem(random)
39
if(key.find("{}_{}".format(flag, salt)) != -1):
40
return True, "Good job!"
41
return False, "Try again."
42
43