3 from dateutil.parser import parse
4 from datetime import datetime
5 from subprocess import call
10 START_DATE = 'Thu Nov 10 01:45:06 CET 2016'
14 EXPLOITABLEVM = '192.168.1.20'
18 exit("Need to run as root.")
20 time_diff = datetime.now() - parse(START_DATE).replace(tzinfo=None)
21 time_diff = time_diff.total_seconds()
23 begin = int(round(START_TS + (time_diff - EPSILON) * FREQUENCY))
24 end = int(round(START_TS + (time_diff + EPSILON) * FREQUENCY))
26 retcode = call("iptables -t nat -I GAMEBOT 1 -m bpf --bytecode '15,48 0 0 0,84 0 0 240,21 0 11 64,48 0 0 9,21 0 9 6,40 0 0 6,69 7 0 8191,177 0 0 0,64 0 0 20,21 0 3 16844810,64 0 0 24,53 0 1 %d,37 0 1 %d,6 0 0 65535,6 0 0 0' -j DNAT --to-destination %s" % (begin, end, EXPLOITABLEVM), shell=True)
27 assert(retcode == 0), 'ERROR: iptables command failed.'
29 retcode = call("iptables -t nat -D GAMEBOT 2", shell=True)
30 assert(retcode == 0), 'ERROR: iptables command failed.'