Skip to content

Commit 13741ce

Browse files
Jrhenderson11rebootuser
authored andcommittedJan 7, 2020
Sped up interesting files check by scanning filesystem less when looking for variations on suid / sgid files (#45)
1 parent 23ac9f7 commit 13741ce

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed
 

‎LinEnum.sh

+11-9
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,8 @@ echo -e "\e[00;31m[-] Can we read/write sensitive files:\e[00m" ; ls -la /etc/pa
827827
echo -e "\n"
828828

829829
#search for suid files
830-
findsuid=`find / -perm -4000 -type f -exec ls -la {} 2>/dev/null \;`
830+
allsuid=`find / -perm -4000 -type f 2>/dev/null`
831+
findsuid=`find $allsuid -perm -4000 -type f -exec ls -la {} 2>/dev/null \;`
831832
if [ "$findsuid" ]; then
832833
echo -e "\e[00;31m[-] SUID files:\e[00m\n$findsuid"
833834
echo -e "\n"
@@ -839,28 +840,29 @@ if [ "$export" ] && [ "$findsuid" ]; then
839840
fi
840841

841842
#list of 'interesting' suid files - feel free to make additions
842-
intsuid=`find / -perm -4000 -type f -exec ls -la {} \; 2>/dev/null | grep -w $binarylist 2>/dev/null`
843+
intsuid=`find $allsuid -perm -4000 -type f -exec ls -la {} \; 2>/dev/null | grep -w $binarylist 2>/dev/null`
843844
if [ "$intsuid" ]; then
844845
echo -e "\e[00;33m[+] Possibly interesting SUID files:\e[00m\n$intsuid"
845846
echo -e "\n"
846847
fi
847848

848-
#lists word-writable suid files
849-
wwsuid=`find / -perm -4002 -type f -exec ls -la {} 2>/dev/null \;`
849+
#lists world-writable suid files
850+
wwsuid=`find $allsuid -perm -4002 -type f -exec ls -la {} 2>/dev/null \;`
850851
if [ "$wwsuid" ]; then
851852
echo -e "\e[00;33m[+] World-writable SUID files:\e[00m\n$wwsuid"
852853
echo -e "\n"
853854
fi
854855

855856
#lists world-writable suid files owned by root
856-
wwsuidrt=`find / -uid 0 -perm -4002 -type f -exec ls -la {} 2>/dev/null \;`
857+
wwsuidrt=`find $allsuid -uid 0 -perm -4002 -type f -exec ls -la {} 2>/dev/null \;`
857858
if [ "$wwsuidrt" ]; then
858859
echo -e "\e[00;33m[+] World-writable SUID files owned by root:\e[00m\n$wwsuidrt"
859860
echo -e "\n"
860861
fi
861862

862863
#search for sgid files
863-
findsgid=`find / -perm -2000 -type f -exec ls -la {} 2>/dev/null \;`
864+
allsgid=`find / -perm -2000 -type f 2>/dev/null`
865+
findsgid=`find $allsgid -perm -2000 -type f -exec ls -la {} 2>/dev/null \;`
864866
if [ "$findsgid" ]; then
865867
echo -e "\e[00;31m[-] SGID files:\e[00m\n$findsgid"
866868
echo -e "\n"
@@ -872,21 +874,21 @@ if [ "$export" ] && [ "$findsgid" ]; then
872874
fi
873875

874876
#list of 'interesting' sgid files
875-
intsgid=`find / -perm -2000 -type f -exec ls -la {} \; 2>/dev/null | grep -w $binarylist 2>/dev/null`
877+
intsgid=`find $allsgid -perm -2000 -type f -exec ls -la {} \; 2>/dev/null | grep -w $binarylist 2>/dev/null`
876878
if [ "$intsgid" ]; then
877879
echo -e "\e[00;33m[+] Possibly interesting SGID files:\e[00m\n$intsgid"
878880
echo -e "\n"
879881
fi
880882

881883
#lists world-writable sgid files
882-
wwsgid=`find / -perm -2002 -type f -exec ls -la {} 2>/dev/null \;`
884+
wwsgid=`find $allsgid -perm -2002 -type f -exec ls -la {} 2>/dev/null \;`
883885
if [ "$wwsgid" ]; then
884886
echo -e "\e[00;33m[+] World-writable SGID files:\e[00m\n$wwsgid"
885887
echo -e "\n"
886888
fi
887889

888890
#lists world-writable sgid files owned by root
889-
wwsgidrt=`find / -uid 0 -perm -2002 -type f -exec ls -la {} 2>/dev/null \;`
891+
wwsgidrt=`find $allsgid -uid 0 -perm -2002 -type f -exec ls -la {} 2>/dev/null \;`
890892
if [ "$wwsgidrt" ]; then
891893
echo -e "\e[00;33m[+] World-writable SGID files owned by root:\e[00m\n$wwsgidrt"
892894
echo -e "\n"

0 commit comments

Comments
 (0)
Please sign in to comment.