Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create a new submitter #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions submitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from logger import log
from config import STATUS
from time import sleep

import requests

class SubmitterBase(object):

Expand Down Expand Up @@ -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': '<csrf>',
'flag_input': flag
}
cookies = {
'sessionid': '<session_id>',
'csrftoken': '<csrf>'
}
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