This is small script, which search upload directories and add .httaccess for disable php and cgi script execution:
#!/bin/sh
HOME=/home
NOBODY=nobody
htaccess () {
cat > "$j/.htaccess"
RemoveType php
Options -ExecCGI -Indexes
EOF
}
fixupload () {
if [ -e "$j/.htaccess" ]; then
if [ -z "`grep RemoveType "$j/.htaccess"`" ]; then
htaccess
fi
else
htaccess
chown $i:$i "$j/.htaccess"
fi
}
cd $HOME
for i in *; do
if [ -d $i/public_html ]; then
# Fix 777 upload
for j in `find $i/public_html -type d -perm 777`; do
fixupload
done
# Fix 775 nobody upload
for j in `find $i/public_html -type d -perm 775 -group $NOBODY`; do
fixupload
done
# Fix 755 nobody upload
for j in `find $i/public_html -type d -perm 775 -user $NOBODY`; do
fixupload
done
fi
done