From 2d52e01f55fb8ef01856e822cc12315bde8c8b7f Mon Sep 17 00:00:00 2001 From: Andrea Dalla Costa Date: Mon, 6 May 2019 21:16:19 +0200 Subject: [PATCH] create a new submitter that uses a post request --- submitter.py | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/submitter.py b/submitter.py index 564a90f..9b14b97 100644 --- a/submitter.py +++ b/submitter.py @@ -4,7 +4,7 @@ from logger import log from config import STATUS from time import sleep - +import requests class SubmitterBase(object): @@ -116,5 +116,44 @@ def submit(self, flags): return status +class CYGAMESubmitter(SubmitterBase): + + def __init__(self): + super(Submitter, self).__init__() + + def submit(self, flags): + """ this function will submit the flags to the scoreboard""" + status = [] + + try: + for flag in flags: + params = { + 'csrfmiddlewaretoken': '', + 'flag_input': flag + } + cookies = { + 'sessionid': '', + 'csrftoken': '' + } + r = requests.post("http://10.100.50.10/competition/submit/", + data=params, cookies=cookies) + + output = r.content.decode('utf-8') + + if "Thank you" in output: + s = STATUS["accepted"] + elif "once" in output: + s = STATUS["old"] + else: + s = STATUS["rejected"] + + status.append(s) + + except Exception as e: + log.exception(e) + + return status + + # choose the submit function here :) -Submitter = ruCTFeSubmitter +Submitter = CYGAMESubmitter