We do not allow scripts to run under 777 for reasons of security. Executable scripts should run under 711 or 755, and PHP scripts should have permissions 644.
Using SSH you can find files of a specific permission and chmod them using one-liner such as this:
# find . -type f -perm 777 | xargs chmod 644
This finds files with the permission 777 and sets them to 644
# find . -type d -perm 777 | xargs chmod 755
This will find directories with the permission 777 and set them to 755