]> git.somenet.org - ctf/pub/network.git/blob - ra_fingerprinting_update_ts.py
GITOLITE.txt
[ctf/pub/network.git] / ra_fingerprinting_update_ts.py
1 #!/usr/bin/env python
2
3 from dateutil.parser import parse
4 from datetime import datetime
5 from subprocess import call
6 from os import geteuid
7 from sys import exit
8
9
10 START_DATE = 'Thu Nov 10 01:45:06 CET 2016'
11 START_TS = 175684430
12 FREQUENCY = 250
13 EPSILON = 120
14 EXPLOITABLEVM = '192.168.1.20'
15
16
17 if geteuid() != 0:
18     exit("Need to run as root.")
19
20 time_diff = datetime.now() - parse(START_DATE).replace(tzinfo=None)
21 time_diff = time_diff.total_seconds()
22
23 begin = int(round(START_TS + (time_diff - EPSILON) * FREQUENCY))
24 end = int(round(START_TS + (time_diff + EPSILON) * FREQUENCY))
25
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.'
28
29 retcode = call("iptables -t nat -D GAMEBOT 2", shell=True)
30 assert(retcode == 0), 'ERROR: iptables command failed.'