2009-08-31 21:15:13 -06:00
|
|
|
#! /usr/bin/env python3
|
|
|
|
|
|
|
|
import asyncore
|
2009-10-01 18:33:21 -06:00
|
|
|
import os
|
|
|
|
import sys
|
2009-10-07 08:19:06 -06:00
|
|
|
import optparse
|
2009-10-07 13:29:00 -06:00
|
|
|
import signal
|
2009-10-07 08:19:06 -06:00
|
|
|
from ctf import pointsd
|
|
|
|
from ctf import flagd
|
|
|
|
from ctf import histogram
|
|
|
|
from ctf import config
|
2009-10-01 18:33:21 -06:00
|
|
|
|
|
|
|
do_reap = False
|
|
|
|
|
|
|
|
def chart(s):
|
|
|
|
if not os.fork():
|
|
|
|
histogram.main(s)
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
def reap():
|
|
|
|
try:
|
|
|
|
while True:
|
|
|
|
os.waitpid(0, os.WNOHANG)
|
|
|
|
except OSError:
|
|
|
|
pass
|
|
|
|
|
2009-08-31 21:15:13 -06:00
|
|
|
def main():
|
2009-10-07 08:19:06 -06:00
|
|
|
p = optparse.OptionParser()
|
|
|
|
p.add_option('-p', '--genpass', dest='cat', default=None,
|
|
|
|
help='Generate a flagger password for the given category')
|
|
|
|
opts, args = p.parse_args()
|
|
|
|
if opts.cat:
|
|
|
|
print('%s:::%s' % (opts.cat, flagd.hexdigest(opts.cat.encode('utf-8'))))
|
|
|
|
return
|
|
|
|
|
2009-09-01 09:34:15 -06:00
|
|
|
pointsrv = pointsd.start()
|
|
|
|
flagsrv = flagd.start()
|
2009-09-29 15:36:25 -06:00
|
|
|
|
2009-09-01 09:34:15 -06:00
|
|
|
s = pointsrv.store
|
|
|
|
slen = 0
|
|
|
|
while True:
|
|
|
|
asyncore.loop(timeout=30, use_poll=True, count=1)
|
2009-10-08 16:42:26 -06:00
|
|
|
reap()
|
2009-09-01 09:34:15 -06:00
|
|
|
if len(s) > slen:
|
|
|
|
slen = len(s)
|
2009-10-01 18:33:21 -06:00
|
|
|
chart(s)
|
2009-08-31 21:15:13 -06:00
|
|
|
|
|
|
|
main()
|