-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathfilter_http_https.py
More file actions
41 lines (33 loc) · 1.13 KB
/
Copy pathfilter_http_https.py
File metadata and controls
41 lines (33 loc) · 1.13 KB
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
41
import utils
import trafficgen.PyTgen.config as cf
import socket
def save_dataframe_h5(df, dir, filename):
key = filename.split('-')[0]
df.to_hdf(dir + filename + '.h5', key=key)
Conf = cf.Conf
all_ips = []
for http in Conf.http_urls:
url = http.split('/')[2]
ip_list = []
ais = socket.getaddrinfo(url, 0, 0, 0, 0)
for result in ais:
ip_list.append(result[-1][0])
ip_list = list(set(ip_list))
all_ips.append(ip_list)
http_list = [ip for ips in all_ips for ip in ips]
all_ips = []
for http in Conf.https_urls:
url = http.split('/')[2]
ip_list = []
ais = socket.getaddrinfo(url, 0, 0, 0, 0)
for result in ais:
ip_list.append(result[-1][0])
ip_list = list(set(ip_list))
all_ips.append(ip_list)
https_list = [ip for ips in all_ips for ip in ips]
dir = 'E:/Data/'
filename = 'http_https-browse'
http_dataframe = utils.filter_pcap_by_ip(dir, filename, http_list, 'http')
save_dataframe_h5(http_dataframe, dir, 'http-browse-1104_2010')
https_dataframe = utils.filter_pcap_by_ip(dir, filename, https_list, 'https')
save_dataframe_h5(https_dataframe, dir, 'https-browse-1104_2020')