Hacking - I think I have been hacked

I Think I Have Been Hacked. How Do I Check?
If any of your php files start with anything other than <?php all by itself on the line, or if an expert advises that any of your executable files have been infected with malicious code, you should be very suspicious. If your site is unexpectedly sending users to another website or causing unexpected pop ups, if users report that your site causes malware warning or if any of your files has a more recent modified date than you expect it to have, consult an expert quickly.

I Am Sure I Have Been Hacked, What Do I Do Now?
First of all, keep calm. When the forum has been hacked, there are a few simple steps for the administrator to do. Most infections can be eliminated in just a few minutes.


 * If you can do it quickly and easily, Shut down your website temporarily to stop any bad things happening while you are fixing the problem. See  instructions below for tips on how to do this.  If you cannot shut down your site, skip this step and move on to getting rid of the problem.

A virus on your PC might have given the hacker your password, or uploaded a file to your website.
 * Check your desktop computer for malware

You do not know yet if any of them have been stolen. That includes all SMF admins, ftp accounts, telnet/ssh users, hosting control panel, database, and even email. If you cannot log into your SMF admin account, see below for how to fix the problem. If you do not know how to change your database password or any other passwords associated with your hosting account, get help from your host.
 * Change all your passwords

This is important. You need to have a copy of your database in case something goes wrong. You need a backup of your attachment directory, since you cannot get those files back if you accidentally delete them. If you have any other custom file directoris, such as gallery or document storage, you must protect them too. You need to have copies of all the SMF files, so that you or someone else can figure out how you were hacked in the first place. Copy the backup files to a safe place. If you are using FTP to copy the backup files, make sure that you use binary mode.
 * Backup your database and your files (even the infected ones) and store it in a safe place.

Let them know about the problem. Ask them to check log files to find out where the attack may have come from. Find out what they recommend to eliminate the infection. Ask them if the malware has left any shell processes running.
 * Tell your host that you have been hacked.

If you think the hacker got in by exploiting SMF, please report it right away at security reports. Please be prepared to share information about your files and your account logs, so that the developers can determine whether a vulnerability in SMF was the cause, and how to fix SMF if it needs it.
 * File a security report with SMF.


 * Delete all files except for your attachments and custom avatars directories (be very cautious because infected files might be in there).  Make sure your backup files are stored somewhere safe and that they do not get deleted. Ask for help if you are unsure.  In addition to your SMF files, you should delete any "extra" php files, and you may need to delete .htaccess files, php.ini files, or other configuration files.  Talk to your host about this. If you cannot delete a file, talk to your host about how to fix the problem.


 * Replace all your SMF files with uninfected files.
 * It is safest to use a fresh set of SMF files rather than a recent file backup. Only use your file backup if you are 100% certain that it was not infected.
 * To get a fresh set of files for the same version of SMF you are already using, follow these instructions.
 * If you have any custom directories (like a gallery mod directory), double check them now.
 * Get a copy of Settings.php from your recent file backup, edit it to correct the password you just changed, and place a copy in your SMF directory.
 * Check your SMF file permissions. Make sure that they are secure.  Ask your host if you are not sure.
 * Patch or upgrade SMF to the most recent and most secure version.
 * Re-install your mods. Use repair_settings if you run into any trouble.
 * Back up your files again.


 * Change all your passwords again. Now that the infection has been removed, changing all of your passwords again is recommended in case they were stolen again before you finished eliminating the infection.


 * Get your website running again.

I Have Cleaned My Hacked SMF Installation. How Can I Prevent This from Happening Again?
Keep your SMF software up-to-date by downloading new versions whenever security fixes are available. Apply some of the security tips, which can help you to protect your forum from any further attacks.

If Your Admin Password No Longer Works
See Resetting an admin user's password to find out how to set your password back to something you can use. Login, change the password again, and double-check the email address. Make sure that you had already changed your database password and the email password. If the admin account no longer has administrator powers, or if the account has been deleted, read through I accidentally lost my admin account! What can I do for more helpful tips.

Shutting Down Your Linux/Apache Site
If you can alter your .htaccess file and if your site uses the Apache web server with mod_rewrite installed, you can shut down your site using these two files. First, make a copy of your .htaccess file and save it in a safe place. Then replace it with the one below and create a file called maintenance.html in the same directory. If your site does not use the Apache web server, then this method will not work. If you cannot find your .htaccess file, or if this change to your .htaccess file does not shut your site down, get support from your host.

.htaccess RewriteEngine on
 * 1) Enables runtime rewriting engine

RewriteCond %{REQUEST_URI} !/maintenance.html$ RewriteRule $ /maintenance.html [R=503,L] maintenance.html This site is undergoing maintenance This site is undergoing maintenance
 * 1) Show maintenance page to visitors
 * 2) RewriteCond %{REMOTE_ADDR} !^111\.111\.111\.111 # except if they come from this IP (commented out)

Shutting Down Your Windows Site
If you are using the IIS webserver and have the ipsecurity restriction for IP Address and Domain Names installed and enabled, save a copy of web.config, replace it with the one below and restart your IIS web server.        