Quick answer: If your website is hacked, act in this order: take the site offline or restrict access, save a copy of the files, database and logs, change every password, scan and remove the malicious code, patch the weakness that let the attacker in, ask search engines to review any warnings, then monitor closely for reinfection.
A hacked site is stressful, but it is a common and fixable problem. Most compromises are automated attacks against known weaknesses, not someone targeting you personally. What matters now is working in the right order. The usual mistakes, such as deleting files in a panic or restoring a backup without closing the hole, make recovery slower.
How do you know your website has been hacked?
You know a site has been hacked when it starts doing things you did not set up. The signs below are the most common, and one of them is enough to start the plan in the next section.
- Redirects. Visitors, often only those arriving from Google or on a phone, are sent to gambling, pharmacy or fake prize sites.
- Spam pages in search results. A search for your domain shows pages you never wrote, often in another language or selling unrelated products.
- Browser warnings. Chrome, Safari or Firefox show a full-screen warning before your site loads, or Google Search Console reports a security issue.
- Unknown admin users. New administrator accounts appear in your CMS, or existing accounts have a changed email address.
- Host suspension. Your hosting company suspends the account for malware, phishing pages or outgoing spam email.
- Unexplained changes. You find modified files, new files with random names, unfamiliar scheduled tasks or a sudden jump in server load.
What should you do in the first 24 hours?
Follow these seven steps in order. Each one protects the step after it, so resist the urge to skip ahead to cleaning.
- Isolate the site. Put the site in maintenance mode or restrict access to your own IP address, so visitors and customers are not exposed. If the server is sending spam, pause outgoing mail. Tell your hosting provider, who may already have logs or a scan report.
- Preserve evidence. Before changing anything, download a full copy of the files and the database, and export the server access and error logs. Logs are often kept for a short time only, and they are the best record of how the attacker got in.
- Change credentials. Reset passwords for hosting, SFTP or SSH, the database, every CMS administrator and connected email accounts. Rotate API keys, remove users you do not recognize and turn on two-factor authentication. On WordPress, replace the security keys in wp-config.php to end every active session.
- Scan and clean. Scan the files and database with a malware scanner, then check by hand. Replace core, plugin and theme files with fresh copies from the official source. Look for backdoors in upload folders, must-use plugins, scheduled tasks and the .htaccess file.
- Patch the entry point. Use the logs and file dates to find what was exploited, then fix it. Update or remove the vulnerable plugin or theme, correct the custom code or close the exposed service. Cleaning without patching invites the same attack back.
- Request a review of warnings. Once the site is clean, open the Security Issues report in Google Search Console and request a review. Do the same with any other service that blocklisted you, and ask your host to lift the suspension.
- Monitor. Watch file changes, new user accounts, logins and outgoing traffic closely over the following weeks. Change the passwords once more after cleanup, in case any were captured while a backdoor was still active.
If the site stores customer accounts, orders or payment details, find out whether that data was accessed. Depending on where you and your customers are, you may have a legal duty to notify people or regulators, so speak to a lawyer early. Tell your payment provider too if card data could be involved.
If you do not have the time or access to do this safely, a malware removal service follows the same sequence. Codefreex handles cleanups this way: evidence first, then cleaning, then the fix that stops it from happening again.
Which symptom points to which cause?
Each symptom points to a short list of likely causes, which tells you where to look first. Use the table to choose a starting point, then confirm it in the logs.
| Symptom | Likely cause | First action |
|---|---|---|
| Redirects to unrelated sites | Injected JavaScript, or rules added to .htaccess or the database | Restrict access, then check recently modified files and the site URL settings |
| Spam pages in search results | Hidden pages or injected links, often through a vulnerable plugin | Save the logs, list the spam URLs, then find the files or database entries that generate them |
| Browser warning screen | The site has been flagged for malware or phishing | Open the Security Issues report in Google Search Console and note the sample URLs |
| Unknown admin users | A stolen or weak password, or a privilege escalation flaw | Delete the accounts, reset all passwords and end active sessions |
| Host suspension | Phishing pages, outgoing spam or heavy resource use | Ask the host for its scan report and the list of flagged files |
| Defaced or altered content | A compromised admin account or write access to files | Keep a copy, then restore the content once the entry point is closed |
| Spam email sent from your domain | An abused contact form or a malicious mail script | Pause outgoing mail and inspect the mail log for the sending script |
What should you not do after a hack?
Do not take actions that destroy evidence or leave the door open. These are the mistakes that turn a single incident into a recurring one.
- Do not delete everything before taking a copy. You lose the evidence needed to find the entry point.
- Do not restore a backup and stop there. If the backup contains the same vulnerable plugin, the site will be reinfected, and the backup may already include the backdoor.
- Do not remove only the visible symptoms. A deleted spam page comes back if the script that creates it is still present.
- Do not keep any old password. Assume every credential stored on the server has been read.
- Do not install several security plugins at once and hope. Overlapping tools conflict with each other and still do not close the original weakness.
- Do not request a search engine review before the site is clean. A failed review slows down the removal of the warning.
- Do not hide the incident from customers if their data was exposed.
How do websites usually get hacked?
Most sites are compromised through known, preventable weaknesses and not through sophisticated attacks. Automated bots scan the web for them around the clock.
- Outdated plugins and themes. A vulnerability is published, a fix is released, and sites that have not updated are found and exploited. Abandoned plugins that no longer receive fixes are a particular risk.
- Weak or reused passwords. Attackers try leaked username and password pairs against login pages, hosting panels and SFTP. One reused password can open everything.
- Vulnerable custom code. Forms, upload features and custom endpoints that do not validate input or check permissions allow SQL injection, cross-site scripting and malicious file uploads.
- Pirated themes and plugins. Unofficial copies of paid software often ship with a backdoor already inside.
- Poorly isolated hosting. On some shared setups, one infected site can reach other sites in the same account.
The technical flaws behind these attacks have standard names. The Common Weakness Enumeration (CWE) catalogs them: CWE-89 is SQL injection, CWE-79 is cross-site scripting and CWE-434 is unrestricted file upload. The Codefreex CWE directory explains the weaknesses behind most attacks in plain language, which helps when you are reading a scanner report or a plugin advisory.
How do you prevent a repeat?
You prevent a repeat by closing the specific hole, then reducing the number of ways in. No site is unhackable, but these habits remove the easy routes.
- Keep the CMS, plugins and themes updated, and delete the ones you do not use. A WordPress maintenance plan makes this routine work instead of an emergency.
- Use unique passwords stored in a password manager, and require two-factor authentication for every administrator.
- Give each user the lowest role they need, and remove accounts when people leave.
- Put a web application firewall in front of the site and limit login attempts.
- Keep automated, off-site backups and test that you can restore one.
- Monitor file changes and logins so the next problem is caught early.
- Have custom code reviewed and tested. Penetration testing finds the flaws in forms, logins and APIs before an attacker does.
Ongoing website security work combines these into one process: hardening, monitoring, patching and a tested recovery plan. The goal is fewer ways in and faster detection when something does get through.
When should you call a specialist?
Call a specialist when the site handles payments or personal data, when the infection returns after you clean it or when you cannot find how the attacker got in. Reinfection almost always means a backdoor or the original vulnerability is still there.
Codefreex cleans hacked WordPress, WooCommerce, Magento and PHP sites, and the first conversation is about containment: what to switch off, what to save and what to change today. A cleanup is finished only when the entry point has been identified and closed.
Frequently asked questions
How long does it take to recover a hacked website?
It depends on the size of the site, how deep the infection goes and how quickly the entry point is found. A small site with one infected plugin is usually a short job, while large or repeatedly infected sites take longer. Search and browser warnings are removed on the reviewer’s schedule, not yours.
Will my site lose its Google rankings after a hack?
A short incident that is cleaned quickly often has little lasting effect. Longer infections can hurt, because spam pages get indexed and warnings stop people from clicking. After cleanup, make spam URLs return a 404 or 410 status, request a review in Google Search Console and watch the indexing reports while visibility recovers.
Can I just restore a backup?
Only if you are sure the backup predates the compromise, and only if you patch the weakness immediately after restoring. Attackers often wait days or weeks before acting, so a recent backup may already contain the backdoor. Restoring also discards orders, form entries and content created since the backup was taken.
How do I remove a browser warning from my site?
Clean the site completely first. Then verify the site in Google Search Console, open the Security Issues report, check the example URLs and request a review, describing what you removed and fixed. If the review confirms the site is clean, the warning is lifted. Asking too early leads to a rejection and more delay.
Do I need to tell customers that my website was hacked?
If personal data, accounts or payment details may have been accessed, you may be legally required to notify the people affected and sometimes a regulator, depending on where you and they are located. Ask a lawyer promptly. Even where notice is not required, a clear and factual message protects trust better than silence.
Dealing with a hacked site right now? Contact Codefreex and describe what you are seeing. The team will help you contain it, clean it and close the weakness behind it.



