-
Notifications
You must be signed in to change notification settings - Fork 1
/
parser.py
58 lines (47 loc) · 1.57 KB
/
parser.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import configparser
import subprocess
import utils
def parsed_policy():
config = utils.get_config(utils.policy_file_path)
rows = ""
for section in config.sections():
if config[section]['enabled']:
row=config[section]['src_address'] + "," + \
config[section]['dst_address'] + "," + \
config[section]['src_port'] + "," + \
config[section]['dst_port'] + "," + \
config[section]['protocol'].lower()
if rows == "":
rows = row
else:
rows = rows + "\n" + row
utils.parse_file(rows, utils.parsed_policy)
def parsed_dns():
config = utils.get_config(utils.dns_policy_path)
rows = ""
for section in config.sections():
if config[section]['enabled']:
row=config[section]['domain']
if rows == "":
rows = row
else:
rows = rows + "\n" + row
utils.parse_file(rows, utils.parsed_dns)
def parsed_dpi():
config = utils.get_config(utils.dpi_policy_path)
rows = ""
for section in config.sections():
if config[section]['enabled']:
row=config[section]['string']
if rows == "":
rows = row
else:
rows = rows + "\n" + row
utils.parse_file(rows, utils.parsed_dpi)
def main():
parsed_policy()
parsed_dpi()
parsed_dns()
if __name__ == "__main__":
main()
#armadillo = subprocess.Popen(["C:\\Users\\doron\\ARMadillo\\parser\\main.exe", "a", "b"], stdout=subprocess.PIPE)