-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdangcmds.py
More file actions
73 lines (71 loc) · 2.16 KB
/
dangcmds.py
File metadata and controls
73 lines (71 loc) · 2.16 KB
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
63
64
65
66
67
68
69
70
71
72
73
dangerous_linux_commands = {
"File Deletion": [
"rm -fr",
"rm -r",
"eval $(rm -rf /)", # Executes dangerous eval
"command $(rm -rf *)", # Dangerous command substitution
"rm --no-preserve-root",
"rm -r --no-preserve-root",
"mkfs",
"mkfs.ext4",
"mkfs.xfs",
"mkfs.vfat",
"dd if=",
"dd of=/dev/",
"shred", # Securely deletes disk content
"mv /",
"find / ",
"crontab -r",
"wipefs",
],
"Fork Bombs": [
":(){:|:&};:", # Bash fork bomb
">:()",
"perl -e 'fork while 1'", # Perl fork bomb
],
"Network Manipulation": [
"ifconfig eth0 down", # Disables network interface
"ip link set eth0 down",
"iptables -F", # Flushes all firewall rules
"route del default", # Deletes default route
],
"Overwriting Or Corrupting Files": [
">:filename", # Truncates a file
"cat /dev/zero >", # Overwrites file with zeros
"cat /dev/urandom >",
"echo > file", # Clears file content
],
"System Shutdown Reboot": [
"halt", # Shuts down system
"reboot", # Reboots system
"shutdown", # Immediate shutdown
"poweroff",
"init 0",
"init 6",
"kill -9 1",
],
"User And Permission Manipulation": [
"chmod",
"chown", # Changes ownership recursively
"userdel", # Deletes root user
"passwd", # Removes root password
],
"Writing To Disk": [
"> /dev/",
">/dev/",
],
"Resource Exhaustion": [
"dd if=/dev/zero of=/dev/null &", # CPU hog
"tail -f /dev/null", # Keeps process running forever
],
"Filesystem Modification": [
"mount", # Overwrites root mount
"umount", # Unmounts root
]
}
def is_dangerous(command: str):
for category, commands in dangerous_linux_commands.items():
for dangerous in commands:
if dangerous in command.lower():
return True, category
return False, ""