Log in via ssh and run these two commands. For the purpose of this example, I'm assuming you want directories to be 755 and files 644.
cd <directory you want to change files in>
find . -type d | xargs chmod 755
find . -type f | xargs chmod 644
If you want to make .cgi files executable, do:
find . -type f *.cgi | xargs chmod 755
Adjust file extension as needed.
If you want useful replies, ask smart questions.