forked from M507/RamiGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroot_detection.py
More file actions
30 lines (24 loc) · 750 Bytes
/
Copy pathroot_detection.py
File metadata and controls
30 lines (24 loc) · 750 Bytes
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
import re
def get_GOT_ROOT_REGEXPs(hostname):
GOT_ROOT_REGEXPs = [
re.compile("^# $"),
re.compile("^bash-[0-9]+.[0-9]# $"),
re.compile(f"root@{hostname}:.*#\s")
]
return GOT_ROOT_REGEXPs
def got_root(hostname: str, output: str) -> bool:
GOT_ROOT_REGEXPs = get_GOT_ROOT_REGEXPs(hostname)
for i in GOT_ROOT_REGEXPs:
if i.fullmatch(output):
return True
if output.startswith(f'root@{hostname}:'):
return True
if f"root@{hostname}:" in output:
return True
if "uid=0(root)" in output:
return True
if "root" == output:
return True
return False
if __name__ == "__main__":
print(got_root("pehost", "root@pehost:/home/lowpriv# "))