Skip to content
Snippets Groups Projects
Commit e424f575 authored by Ruben Anthony Gonzalez's avatar Ruben Anthony Gonzalez
Browse files

minor refactoring

parent 88625195
No related branches found
No related tags found
No related merge requests found
......@@ -15,8 +15,16 @@ RES_FILE_PATH = "results.txt"
RES_FILE = None
# TODO: Make list of team ids
# TODO: Change these values
# list of team ids
all_teams = [i for i in range(16)]
# Has to be byte string since wre looking through byte output (STDOUT)
flag_regex = b"flag{[A-Za-z0-9_.]+}"
exploit_dir = "exploits"
wait_between_runs = 30
# Number of exploit workers
proc_num = 4
def team_id_to_ip(team_id):
......
# Has to be byte string since wre looking through byte output (STDOUT)
flag_regex = b"flag{[A-Za-z0-9_.]+}"
exploit_dir = "exploits"
wait_between_runs = 30
proc_num = 4
import multiprocessing as mp
import logging as log
import os
import config
import changeme
import time
from runner import runner
......@@ -9,7 +9,7 @@ from submitter import do_submissions
from changeme import submit_flag, all_teams
REMAINING_FILE = "remaining_flags.json"
EXPLOIT_DIR = config.exploit_dir
EXPLOIT_DIR = changeme.exploit_dir
runners = []
submitter = None
......@@ -52,12 +52,12 @@ def do_scheduling(work_queue, flag_queue):
"team_id": team_id,
"exploit": exploit
})
if config.wait_between_runs:
time.sleep(config.wait_between_runs)
if changeme.wait_between_runs:
time.sleep(changeme.wait_between_runs)
def main():
submit_remaining()
procs = config.proc_num
procs = changeme.proc_num
flag_queue = mp.Queue()
work_queue = mp.Queue()
......
......@@ -2,7 +2,7 @@ import os
import logging as log
from changeme import team_id_to_ip
import subprocess as sp
import config
import changeme
import re
import logging as log
......@@ -16,7 +16,7 @@ def flags_iter(s, flag_regex):
def runner(runner_id, work_queue, flag_queue):
log.info("[RUNNER %d] started", runner_id)
os.chdir(config.exploit_dir)
os.chdir(changeme.exploit_dir)
while True:
job = work_queue.get()
......@@ -25,7 +25,7 @@ def runner(runner_id, work_queue, flag_queue):
log.info("[RUNNER %d] launching %s against %d", runner_id, exploit, team_id)
try:
result = sp.check_output(["./" + exploit, team_id_to_ip(team_id), str(team_id)], stderr=sp.STDOUT)
for flag in flags_iter(result, config.flag_regex):
for flag in flags_iter(result, changeme.flag_regex):
log.info("[RUNNER %d] found flag %s for team %d", runner_id, flag, team_id)
flag_queue.put({
'team_id': team_id,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment