easyctf-2017/qrt/grader.py

22 lines
519 B
Python
Raw Normal View History

2017-03-06 07:58:08 +00:00
from cStringIO import StringIO
from qrt import generate
FLAG = "are_triangles_more_secure_than_squares?_%s}"
def get_salt(random):
return "".join([random.choice("0123456789abcdef") for i in range(8)])
def generate(random):
salt = get_salt(random)
im = generate("easyctf{%s}" % (FLAG % salt))
flag = StringIO()
im.save(buf, format="PNG")
return dict(files={
"flag.png": flag
})
def grade(random, key):
salt = get_salt(random)
if key.find(FLAG % salt) >= 0:
return True, "Correct!"
return False, "Nope."