def test_setflag(setflag_fp, flag):
    try:
        setflag = imp.load_source('setflag', setflag_fp)
        from setflag import SetFlag
        print 'SetFlag..'
        sf = SetFlag()
        sf.execute(HOST, PORT, flag)
        res = sf.result()
        print 'Result: %s' % str(res)
        flag_id = res['FLAG_ID']
        token = res['TOKEN']
        assert res['ERROR'] == 0
        return flag_id, token
    except AssertionError:
        print 'AssertionError while executing Setflag'
        print traceback.format_exc()
        print '----------------------'
        print RED + 'ERROR' + ENDC
        sys.exit(2)
    except Exception:
        print 'Exception while executing Setflag'
        print traceback.format_exc()
        print '----------------------'
        print RED + 'ERROR' + ENDC
        sys.exit(2)
예제 #2
0
#!/usr/bin/env python
import sys

from benign import Benign
from exploit import Exploit
from getflag import GetFlag
from setflag import SetFlag

HOST = '127.0.0.1'
PORT = int(sys.argv[1])

FLAG = 'xxxflagxxx'

print 'Setflag..'
sf = SetFlag()
sf.execute(HOST, PORT, FLAG)
res = sf.result()
print 'Result: %s' % str(res)
flag_id = res['FLAG_ID']
cookie = res['TOKEN']

print 'Exploit..'
e = Exploit()
e.execute(HOST, PORT, flag_id)
res = e.result()
print 'Result: %s' % str(res)
assert res['FLAG'] == FLAG

print 'Getflag..'
cf = GetFlag()
cf.execute(HOST, PORT, flag_id, cookie)