-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreverse_ruleset.py
40 lines (37 loc) · 1.24 KB
/
reverse_ruleset.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 sys
import time
def main():
file = open('./setting.txt', 'r')
lines = file.readlines()
try:
if sys.platform[:5] == 'linux':
from landlock import Ruleset
rs = Ruleset()
count = 0
for line in lines:
try:
count = count + 1
line = str(line)
j = line.replace('__init__.py', '').replace(' ', '').replace("\n", "").replace("'", "")
print(count)
print(j)
if j.endswith("/") and j.startswith("/")
rs.allow(j)
except Exception as error:
print(error)
rs.apply()
print('..reverse..on..setup.py..set..linux-landlock')
elif sys.platform[:7] == 'openbsd':
import openbsd
openbsd.unveil('/*', 'r')
openbsd.unveil('.', 'rwx')
for i in list:
openbsd.unveil(os.path.abspath(i))
print('..reverse..on..setup.py..set..openbsd..unveil')
except:
print('no suitable OS, try linux or openbsd')
sys.exit()
#use the absolute path for access control
if __name__=='__main__':
main()