My site was hacked, how can I use chmod permissions to avoid this?
See: Securing file permissions and ownership

You also might want to try adding the Security Review module to help make sure your site is following the correct file permission settings.