forked from averagesecurityguy/scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bad_service.sh
executable file
·40 lines (34 loc) · 1012 Bytes
/
bad_service.sh
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
#!/usr/bin/env sh
# Copyright 2017 AverageSecurityGuy
#
# Simple script to find world writeable directories that are also present
# in bootup scripts. Executables in these directories may provide a way to
# escalate privileges.
#
search ()
{
ires=$(grep $1 /etc/init.d/*)
rres=$(grep -R $1 /etc/rc*)
cres=$(grep -R $1 /etc/cron*)
sres=$(grep -R $1 /etc/systemd/*)
if [ -n "$ires" ] || [ -n "$rres" ] || [ -n "$cres" ] || [ -n "$sres" ]
then
echo "\n$1"
echo "----"
if [ -n "$ires" ]; then echo $ires | tr ' ' "\n"; fi
if [ -n "$rres" ]; then echo $rres | tr ' ' "\n"; fi
if [ -n "$cres" ]; then echo $cres | tr ' ' "\n"; fi
if [ -n "$sres" ]; then echo $sres | tr ' ' "\n"; fi
echo
fi
}
files=$(find / -perm -0002 -type d -print)
for d in $files; do
case "$d" in
*/tmp*) continue ;;
*/run*) continue ;;
*/dev*) continue ;;
*/proc*) continue ;;
*) search "$d" ;;
esac
done;