-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.py
More file actions
24 lines (17 loc) · 795 Bytes
/
shell.py
File metadata and controls
24 lines (17 loc) · 795 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
import subprocess
def shell(string):
return subprocess.run(string, capture_output=True, shell=True)
def shell_extract(string, _return=True):
ret = shell(string)
if _return:
return ret.stdout.decode().strip()
if __name__ == "__main__":
base_command = 'ls -l /etc/shadow | cut -d " " -f'
command = f'{base_command} 1 | cut -c5-6'
group_name_command = f'{base_command} 4'
result, group = shell_extract(command), shell_extract(group_name_command)
if 'r' in result:
print(f'The {group} group has readable access to the shadow file!')
if 'w' in result:
print(f'The {group} group has writable access to the shadow file!')
print(f'All others has the following access: {shell_extract(command[:-3] + "8-9")}')