Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zerfiXOR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ruben Anthony Gonzalez
zerfiXOR
Commits
66abfa1f
Commit
66abfa1f
authored
5 years ago
by
Ruben Anthony Gonzalez
Browse files
Options
Downloads
Patches
Plain Diff
minor refactoring
parent
e424f575
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changeme.py
+7
-23
7 additions, 23 deletions
changeme.py
main.py
+2
-2
2 additions, 2 deletions
main.py
submitter.py
+22
-1
22 additions, 1 deletion
submitter.py
with
31 additions
and
26 deletions
changeme.py
+
7
−
23
View file @
66abfa1f
...
...
@@ -2,6 +2,7 @@
These are ctf dependent functions.
They have to be aligned.
"""
from
random
import
randint
MESSAGES
=
[
...
...
@@ -11,9 +12,6 @@ MESSAGES = [
"
ERROR
"
]
RES_FILE_PATH
=
"
results.txt
"
RES_FILE
=
None
# TODO: Change these values
# list of team ids
...
...
@@ -22,10 +20,15 @@ all_teams = [i for i in range(16)]
flag_regex
=
b
"
flag{[A-Za-z0-9_.]+}
"
exploit_dir
=
"
exploits
"
wait_between_runs
=
3
0
wait_between_runs
=
1
0
# Number of exploit workers
proc_num
=
4
res_file_path
=
"
results.txt
"
def
submission_logic
(
flag
):
# TODO: Add actual submission logic
return
randint
(
0
,
len
(
MESSAGES
)
-
1
)
def
team_id_to_ip
(
team_id
):
"""
...
...
@@ -34,22 +37,3 @@ def team_id_to_ip(team_id):
return
"
10.13.37.{}
"
.
format
(
team_id
)
def
submit_flag
(
team_id
,
flag
):
"""
Submit individual flag.
"""
global
RES_FILE
if
RES_FILE
is
None
:
RES_FILE
=
open
(
RES_FILE_PATH
,
"
a
"
)
# TODO: submission logic
# e.g. requests.put(...)
# set return val to index of appropriate message code
return_val
=
0
RES_FILE
.
write
(
"
{} {} {}
\n
"
.
format
(
return_val
,
team_id
,
flag
))
RES_FILE
.
flush
()
# dirty but works for now
return
MESSAGES
[
return_val
]
This diff is collapsed.
Click to expand it.
main.py
+
2
−
2
View file @
66abfa1f
...
...
@@ -5,8 +5,8 @@ import changeme
import
time
from
runner
import
runner
from
submitter
import
do_submissions
from
changeme
import
submit_flag
,
all_teams
from
submitter
import
do_submissions
,
submit_flag
from
changeme
import
all_teams
REMAINING_FILE
=
"
remaining_flags.json
"
EXPLOIT_DIR
=
changeme
.
exploit_dir
...
...
This diff is collapsed.
Click to expand it.
submitter.py
+
22
−
1
View file @
66abfa1f
import
changeme
import
logging
as
log
RES_FILE_PATH
=
changeme
.
res_file_path
RES_FILE
=
None
def
submit_flag
(
team_id
,
flag
):
"""
Submit individual flag.
"""
global
RES_FILE
if
RES_FILE
is
None
:
RES_FILE
=
open
(
RES_FILE_PATH
,
"
a
"
)
return_val
=
changeme
.
submission_logic
(
flag
)
RES_FILE
.
write
(
"
{} {} {}
\n
"
.
format
(
return_val
,
team_id
,
flag
))
RES_FILE
.
flush
()
# dirty but works for now
return
changeme
.
MESSAGES
[
return_val
]
def
do_submissions
(
flag_queue
):
while
True
:
answer
=
flag_queue
.
get
()
flag
=
answer
[
'
flag
'
]
team_id
=
answer
[
'
team_id
'
]
result
=
changeme
.
submit_flag
(
team_id
,
flag
)
result
=
submit_flag
(
team_id
,
flag
)
log
.
info
(
"
[SUBMITTER] Flag submission %s [team %d] returned %s
"
,
flag
,
team_id
,
result
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment