-
Notifications
You must be signed in to change notification settings - Fork 0
/
lss.py
executable file
·62 lines (45 loc) · 1.85 KB
/
lss.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
59
60
61
62
from gui.main_frame import create_main_window
from tools.json_handler import save_to_file
from tools.utils import *
import os
from policy.policy import PolicyKeys
def print_logo():
logo = '''
.-. .----. .----. .---. .----. .-. .-. .----. .----. .-. .----.
| | { {__ { {__ / ___}/ {} \\| `| |{ {__ / {} \\| | | {_
| `--..-._} }.-._} } \ }\\ /| |\\ |.-._} }\\ /| `--.| {__
`----'`----' `----' `---' `----' `-' `-'`----' `----' `----'`----'
'''
print(logo)
def check_data_folder():
data_folder = get_data_dir()
if not os.path.exists(data_folder):
os.mkdir(data_folder)
policy_folder = data_folder + "/Policies"
if not os.path.exists(policy_folder):
os.mkdir(policy_folder)
lists_folder = data_folder + "/Blocklists"
if not os.path.exists(policy_folder):
os.mkdir(policy_folder)
def create_default_policy():
check_data_folder()
policies_file = get_data_dir() + "/Policies/Accept_all.policy"
if not os.path.isfile(policies_file):
keys = [key.name for key in PolicyKeys]
values1 = ["OUTPUT", "any", "any", "any", "any", "any", "ACCEPT"]
values2 = ["INPUT", "any", "any", "any", "any", "any", "ACCEPT"]
policy = [dict(zip(keys,values1)), dict(zip(keys,values2))]
save_to_file(policies_file, policy)
def check_installed_iptables():
bin_file = "/sbin/iptables"
if not os.path.isfile(bin_file):
print("Iptables is not installed!")
exit(0)
def check_installed_syslog():
bin_file = "/sbin/syslog-ng"
if not os.path.isfile(bin_file):
print("Please install syslog-ng in order to see firewall logs.")
create_default_policy()
check_installed_iptables()
check_installed_syslog()
create_main_window()