def test_getflag(getflag_fp, flag_id, token, flag):
    try:
        getflag = imp.load_source('getflag', getflag_fp)
        from getflag import GetFlag
        print 'GetFlag..'
        cf = GetFlag()
        cf.execute(HOST, PORT, flag_id, token)
        res = cf.result()
        print 'Result: %s' % str(res)
        assert res['ERROR'] == 0
        assert res['FLAG'] == flag
    except AssertionError:
        print 'AssertionError while executing Getflag'
        print traceback.format_exc()
        print '----------------------'
        print RED + 'ERROR' + ENDC
        sys.exit(2)
    except Exception:
        print 'Exception while executing Getflag'
        print traceback.format_exc()
        print '----------------------'
        print RED + 'ERROR' + ENDC
        sys.exit(2)
Example #2
0
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)
res = cf.result()
print 'Result: %s' % str(res)
assert res['FLAG'] == FLAG

print 'Benign..'
b = Benign()
b.execute(HOST, PORT)
res = b.result()
print 'Result: %s' % str(res)
assert res['ERROR'] == 0