-
Notifications
You must be signed in to change notification settings - Fork 0
/
pacextractor.py
40 lines (30 loc) · 1015 Bytes
/
pacextractor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
import json
import time
from concurrent.futures import ProcessPoolExecutor
cmd_list = []
def cmd_generator():
dir = '/home/ljk/data/dataset/'
with open('data_filtered.txt') as f:
data = json.load(f)
for domain in data:
for ip in data[domain]:
ip_src, ip_dst = ip.split()
# no -2
cmd = 'tshark -r /home/ljk/data/5mindata/5min_00000_20130523142355 -n -R "ip.addr == ' + ip_src + \
' and ip.addr == ' + ip_dst + ' and dns.qry.name contains "' + domain + '""' \
+ ' -w ' + dir + domain + '_' + ip_src + '_' + ip_dst +'.pcap'
cmd_list.append(cmd)
def system_exec(cmd_str):
os.system(cmd_str)
if __name__ == '__main__':
cmd_generator()
tmp = []
with ProcessPoolExecutor() as pool:
for cmd in cmd_list:
tmp.append(pool.submit(system_exec, cmd))
for a in tmp:
a.result()
# print cmd_list
# cmd_generator()
# print(cmd_list)