Post by halalan » Tue May 26, 2009 8:56 am

My site was recently attacked and all my files on the server with the name INDEX.PHP were altered. I have been told its safer to move any files that contain your login names and server sql information should be moved outside of the public_html folders.

I think making sure anyfiles such as the config.php but placed outside the public folder or atleast protected or have the permission changed after installation to 404.

What do others think to ensure a more hack free software setup ?!?!?

HERE ARE THE RECOMMENDATIONS FROM MY HOSTING ACCOUNT:
Solution:

Set register_globals to OFF
Turn off Display Error/Warning Messages. Set display_error to ZERO.
Never run unescaped queries
Validate all user inputs. Items on Forms, in URLs and so on
Move config.php and files containing Passwords to MySQL to a secure directory outside of the public_html folder
Change permissions on any configuration files containing private information such as database passwords or email accounts to 440 so they cannot be written to and so there is no world permissions. If you need to edit them at a later time you will need to change it back to 640.
Access Control: You don't want the user to have access to any Admin function or Clean up scripts
The .htaccess file is your friend. Use it to deny access to your site or files. (We also have an easy IP Deny Manager tool in the cpanel)
PHP can parse any valid script, whether it is called foo.php, very_long_name.php.php.php, or even deleteme.bat.
Using the default extension of ".php" means that before your hackers start you have already told them you are using PHP.
As mentioned, you can use any filename for your scripts - if you are using PHP for every script on your server, consider using the ".html" extension for your scripts and making PHP parse HTML files.
You can change your file extension by adding this line to the .htaccess or turn it on via the Apache Handlers in the cPanel (AddHandler application/x-httpd-php5 .html)
To protect against SQL injection attacks Sometimes hackers will try to screw up your database by inserting SQL code into your form input fields. They can for example, insert code that could delete all the data in your database!
To protect against this, you need to use this PHP function:
mysql_real_escape_string()
This function escapes (makes safe) any special characters in a string (programmers call text a 'string') for MySQL.
Example: $name = $_REQUEST['name']; $safe_name = mysql_real_escape_string($name); Now you know the variable $safe_name, is safe to use with your SQL code.
Keep the PHP code to yourself. If anyone can see it they can exploit vulnerabilities.
You should take care to store your PHP files and the necessary passwords to access your MySQL databases in protected files or folders.
The easy way to do this is to put the database access passwords in a file with a .inc.php extension (such as config.inc.php), and then place this file in a directory which is above the server's document root (and thus not accessible to surfers of your site).
Then, refer to the file in your PHP code with a require_once command.
By doing things this way, your PHP code can read the included file easily but hackers will find it almost impossible to hack your site.

Helping Each Other With Knowledge....
WHPOA.NET CTOA.NET CEMETERYTN.COM


User avatar
New member

Posts

Joined
Sat Mar 28, 2009 3:13 am
Location - U.S.A.

Post by removed331062 » Tue May 26, 2009 10:34 am

Do you know how your site was hacked? I also changed my admin folder to something else.

New member

Posts

Joined
Wed Feb 18, 2009 5:02 pm

Post by JNeuhoff » Tue May 26, 2009 5:02 pm

If you are using a shared web hosting, make sure that your PHP scripts don't run under the general apache account but rather under your own one.

User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by Daniel » Wed May 27, 2009 10:52 pm

why are you posting this info?

it might be that you password was not long enough.

OpenCart is already secure and does a lot fo what you have posted.

User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by halalan » Wed May 27, 2009 10:56 pm

I posted it just as a helpful FYI Maybe in the installation having some of the improtant config.php files placed outside of the public folder would be helpful...

Helping Each Other With Knowledge....
WHPOA.NET CTOA.NET CEMETERYTN.COM


User avatar
New member

Posts

Joined
Sat Mar 28, 2009 3:13 am
Location - U.S.A.

Post by Daniel » Wed May 27, 2009 11:41 pm

Placing config files out of the public_html makes no difference if a script is hackable.

config.php can not output anything. If it gets read by a hacked script that allows a hacker to browser files and directories then they will be able to access files outside public_html.

There is no useful information in the config files. Only the DB username and password. If you have a secure web site then it should be setup so nobody can access the db other than localhost or internal ip's.

User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by npn2531 » Thu May 28, 2009 11:06 pm

This list is kinda of boilerplate stuff. You can read all sorts of conflicting stuff about gloal registers, for example. Once when I asked my webhost for advice on how to make my cart secure, I was sent practically the same list. No one actually analyzed the cart I was using (oscommerce). I asked for advice because I was getting hacked, (some a#%h#$% kept changing my home page to something red, angry and gothic). Some savvy Tech at made a few changes for me, and I've had no problems since. The point is that the Tech found something amateurish I had done to a file and deleted that file ( I don't remember what and didn't really understand what he was saying at the time), but he certainly didn't run through that checklist and rewrite the oscommerce programming.

http://www.niora.com


New member

Posts

Joined
Tue May 19, 2009 11:56 am
Who is online

Users browsing this forum: Google Adsense [Bot] and 20 guests