1838612 Members
2840 Online
110128 Solutions
New Discussion

SUIDed scripts

 
Mike_21
Frequent Advisor

SUIDed scripts

Is there any way to search for all scripts on a machine that are SUIDed scripts?

Thanks
5 REPLIES 5
Sridhar Bhaskarla
Honored Contributor

Re: SUIDed scripts

You can use -perm switch with find command.

find / -perm -4000

will printout all the executables (irrespective of regular permissions) with suid on.

If you want to find out the files with exact permissions, you need to skip -.

For ex., if you want to find files that have 4550 permissions, you would be executing

find / -perm 4550

- is significant.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
harry d brown jr
Honored Contributor

Re: SUIDed scripts

Along with Sridhar's examples, you might also want to take a look at this document:

http://people.hp.se/stevesk/bastion.html

live free or die
harry
Live Free or Die
Anthony deRito
Respected Contributor

Re: SUIDed scripts

# cd [dir_to_search]
# find . -user root -perm -4000 -print
James R. Ferguson
Acclaimed Contributor

Re: SUIDed scripts

Hi Mike:

# find / -type f -perm -4000

Regards!

...JRF...
G. Vrijhoeven
Honored Contributor

Re: SUIDed scripts

Hi,

for i in `ls -Rl`
do
TEST=`echo $i | awk '{ print $1}'`
grep [sS] $TEST
if [ "$?" -eq 0 ]
then
echo $i >sbit.out
fi
done

Hope this wil help,

Gideon