Adds support for unicode keys
This commit is contained in:
Kevin Chung
2016-11-29 01:02:24 -05:00
parent 24845336dc
commit 9fc83b636c

View File

@@ -181,7 +181,7 @@ def chal(chalid):
# Challange not solved yet # Challange not solved yet
if not solves: if not solves:
chal = Challenges.query.filter_by(id=chalid).first() chal = Challenges.query.filter_by(id=chalid).first()
key = str(request.form['key'].strip().lower()) key = unicode(request.form['key'].strip().lower())
keys = json.loads(chal.flags) keys = json.loads(chal.flags)
# Hit max attempts # Hit max attempts
@@ -205,7 +205,7 @@ def chal(chalid):
# return "1" # key was correct # return "1" # key was correct
return jsonify({'status':'1', 'message':'Correct'}) return jsonify({'status':'1', 'message':'Correct'})
elif x['type'] == 1: #regex elif x['type'] == 1: #regex
res = re.match(str(x['flag']), key, re.IGNORECASE) res = re.match(x['flag'], key, re.IGNORECASE)
if res and res.group() == key: if res and res.group() == key:
if ctftime(): if ctftime():
solve = Solves(chalid=chalid, teamid=session['id'], ip=get_ip(), flag=key) solve = Solves(chalid=chalid, teamid=session['id'], ip=get_ip(), flag=key)