Skip to content

Instantly share code, notes, and snippets.

@zerowebcorp
Created October 11, 2012 08:03
Show Gist options
  • Save zerowebcorp/3870892 to your computer and use it in GitHub Desktop.
Save zerowebcorp/3870892 to your computer and use it in GitHub Desktop.
Find c99 Shell Scripts Hosted On a cPanel Server
#!/bin/sh
cd /root
echo >> c99result.txt
for j in `ls /var/cpanel/users`
do
echo "Scanning user: $j"
cd /home/$j
find /home/$j -iname '*.php' > /root/c99list
for i in `cat /root/c99list`
do
result=$( perl -e 'alarm shift @ARGV; exec @ARGV' 10 php -q $i | grep -Eie '-rw-r--r--|drwxr-xr-x|drwxrwxrwx|-rw-r-xr-x|-rwxrwxrwx|-rw-rw-rw-|-rwx------')
if [ $? -eq 0 ]; then
echo "Possible Shell Script found on $i" >> /root/c99result.txt
fi
done
echo "Completed processing $j" >> /root/c99result.txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment