I have a site that allows a system administrator to upload files via a password protected web interface. The directory where the files are being upload has permissions of 777 - recently, somebody has uploaded a php mail script into this directory in an attempt to use the server to send out spam (it doesn't look like they got into the administration panel to upload these files, that seems secure).
What permissions should I be using on this directory to ensure that this doesn't happen in the future - These user uploaded files still need to be accessible via the web site.
Also, is there an easy way to find all the directories on the server that have permissions set as 777 and change them without doing it all manually?
Thanks!