{
    "title": "Cleaning up a hacked WordPress site: the step-by-step procedure",
    "seo_title": "Cleaning up a hacked WordPress site: the procedure",
    "h1": "Cleaning up a hacked WordPress site: the step-by-step procedure",
    "description": "Isolate, preserve evidence, regain access, clean up, find the flaw, reopen: the complete procedure after a WordPress hack.",
    "lead": "An eight-step procedure, based on WordPress.org and CERT-FR, to clean up a hacked WordPress site without reinfection: from isolation to the Google review request.",
    "language": "en",
    "locale": "en-US",
    "type": "article",
    "url": "https://www.wp-feint.com/clean-hacked-wordpress-site/",
    "canonical": "https://www.wp-feint.com/clean-hacked-wordpress-site/",
    "markdown": "https://www.wp-feint.com/clean-hacked-wordpress-site/index.md",
    "json": "https://www.wp-feint.com/clean-hacked-wordpress-site/index.json",
    "published": "2026-10-07T07:00:00+00:00",
    "modified": "2026-11-22T14:33:39+00:00",
    "site": {
        "name": "WP Feint",
        "url": "https://www.wp-feint.com/"
    },
    "translations": [
        {
            "language": "en",
            "hreflang": "en-US",
            "title": "Cleaning up a hacked WordPress site: the step-by-step procedure",
            "url": "https://www.wp-feint.com/clean-hacked-wordpress-site/",
            "markdown": "https://www.wp-feint.com/clean-hacked-wordpress-site/index.md",
            "json": "https://www.wp-feint.com/clean-hacked-wordpress-site/index.json"
        },
        {
            "language": "fr",
            "hreflang": "fr-FR",
            "title": "Nettoyer un site WordPress piraté : la procédure pas à pas",
            "url": "https://www.wp-feint.com/fr/nettoyer-site-wordpress-pirate/",
            "markdown": "https://www.wp-feint.com/fr/nettoyer-site-wordpress-pirate/index.md",
            "json": "https://www.wp-feint.com/fr/nettoyer-site-wordpress-pirate/index.json"
        },
        {
            "language": "es",
            "hreflang": "es-ES",
            "title": "Limpiar un sitio WordPress hackeado: el procedimiento paso a paso",
            "url": "https://www.wp-feint.com/es/limpiar-sitio-wordpress-hackeado/",
            "markdown": "https://www.wp-feint.com/es/limpiar-sitio-wordpress-hackeado/index.md",
            "json": "https://www.wp-feint.com/es/limpiar-sitio-wordpress-hackeado/index.json"
        },
        {
            "language": "de",
            "hreflang": "de-DE",
            "title": "Eine gehackte WordPress-Website bereinigen: das Vorgehen Schritt für Schritt",
            "url": "https://www.wp-feint.com/de/gehackte-wordpress-website-bereinigen/",
            "markdown": "https://www.wp-feint.com/de/gehackte-wordpress-website-bereinigen/index.md",
            "json": "https://www.wp-feint.com/de/gehackte-wordpress-website-bereinigen/index.json"
        },
        {
            "language": "it",
            "hreflang": "it-IT",
            "title": "Ripulire un sito WordPress violato: la procedura passo per passo",
            "url": "https://www.wp-feint.com/it/ripulire-sito-wordpress-violato/",
            "markdown": "https://www.wp-feint.com/it/ripulire-sito-wordpress-violato/index.md",
            "json": "https://www.wp-feint.com/it/ripulire-sito-wordpress-violato/index.json"
        },
        {
            "language": "pt",
            "hreflang": "pt-BR",
            "title": "Limpar um site WordPress invadido: o procedimento passo a passo",
            "url": "https://www.wp-feint.com/pt/limpar-site-wordpress-invadido/",
            "markdown": "https://www.wp-feint.com/pt/limpar-site-wordpress-invadido/index.md",
            "json": "https://www.wp-feint.com/pt/limpar-site-wordpress-invadido/index.json"
        },
        {
            "language": "nl",
            "hreflang": "nl-NL",
            "title": "Een gehackte WordPress-site opschonen: de procedure stap voor stap",
            "url": "https://www.wp-feint.com/nl/gehackte-wordpress-site-opschonen/",
            "markdown": "https://www.wp-feint.com/nl/gehackte-wordpress-site-opschonen/index.md",
            "json": "https://www.wp-feint.com/nl/gehackte-wordpress-site-opschonen/index.json"
        }
    ],
    "headings": [
        {
            "level": 1,
            "text": "Cleaning up a hacked WordPress site: the step-by-step procedure"
        },
        {
            "level": 2,
            "text": "Before touching the site: start an incident log"
        },
        {
            "level": 2,
            "text": "Step 1: isolate the site"
        },
        {
            "level": 2,
            "text": "Step 2: preserve evidence and backups"
        },
        {
            "level": 2,
            "text": "Step 3: regain control of access"
        },
        {
            "level": 2,
            "text": "Step 4: restore, clean or rebuild"
        },
        {
            "level": 2,
            "text": "Step 5: clean up, location by location"
        },
        {
            "level": 3,
            "text": "WordPress core"
        },
        {
            "level": 3,
            "text": "Plugins, themes and the rest of wp-content"
        },
        {
            "level": 2,
            "text": "Step 6: find the entry point"
        },
        {
            "level": 2,
            "text": "Steps 7 and 8: verify, then reopen"
        },
        {
            "level": 2,
            "text": "Obligations not to forget"
        },
        {
            "level": 2,
            "text": "After reopening: stop finding out about a hack by chance"
        },
        {
            "level": 3,
            "text": "Key takeaways"
        },
        {
            "level": 2,
            "text": "Sources"
        }
    ],
    "body": "A confirmed hack often triggers hasty moves: deleting the suspicious file, reinstalling a plugin, reopening the site that same evening. The site is then reinfected a few days later, because a [backdoor](https://www.wp-feint.com/glossary/backdoor/) or the original flaw was left in place. Here is an eight-step procedure, based on WordPress.org documentation and the CERT-FR incident response sheets, to regain control, clean up without destroying evidence and reopen without unpleasant surprises.\n\nIf you are not yet sure it is a hack, start with [the signs and checks for a hacked WordPress site](https://www.wp-feint.com/wordpress-site-hacked-signs/).\n\n![Eight-step diagram: isolate, preserve, regain control, choose, clean, find the entry point, verify, reopen](https://www.wp-feint.com/media/etapes-nettoyage-en.webp)\n\n## Before touching the site: start an incident log\n\nFrom the start of an incident, CERT-FR recommends keeping an incident log: one line per action or event, with the date and time (including time zone), who did it and a description. Store it off the compromised server. You will need it for your host, your insurer, a contractor, a police report or a notification to the CNIL (the French data protection authority). The WordPress.org FAQ gives the same advice: write down what you observe, when, and any recent changes (plugin installed, theme modified).\n\n## Step 1: isolate the site\n\nIn its containment sheet for website defacement, CERT-FR makes taking the site offline, regaining control of the admin area and preserving traces the top priorities. In practice:\n\n- Put the site into maintenance with a static HTML page served by the web server, not by a WordPress plugin: the compromised PHP code must no longer run for visitors.\n- Notify your host. On [shared hosting](https://www.wp-feint.com/glossary/shared-hosting/), other sites on the same account may be affected, and the host has sometimes already suspended the site.\n- Keep an administrative access path (SFTP, SSH, control panel): you will need it for what follows.\n- If the site sits behind a [CDN](https://www.wp-feint.com/glossary/cdn/) or a cache, the hacked version may still be served from that cache: purge it once the maintenance page is in place.\n\n## Step 2: preserve evidence and backups\n\nBefore deleting anything, make a full copy of the infected state: files, database and server logs. WordPress.org explicitly recommends this, even for an infected site, and CERT-FR suggests moving the affected content into a folder prefixed \"INCIDENT\" out of reach of the web server. Also put your existing backups somewhere safe (offline or exported): they may be compromised and must not be restored to production before analysis.\n\n```\n# Copy the files and the database, outside the web root\ntar czf ~/incident/infected-site-$(date +%F).tar.gz -C /path/to/site .\nwp db export ~/incident/infected-db-$(date +%F).sql --skip-plugins --skip-themes\n```\n\nThe global options `--skip-plugins` and `--skip-themes` prevent the plugins and theme from loading, and therefore prevent malicious code from running with every WP-CLI command. Keep them on throughout the cleanup. They do not neutralize plugins in the `mu-plugins` folder, which you should inspect first.\n\n## Step 3: regain control of access\n\nChange every access point, not just the WordPress password:\n\n- Hosting control panel accounts, SFTP or FTP, SSH (and authorized keys), the database user (to be updated in `wp-config.php`).\n- Every WordPress account with an administrator or editor role; delete unknown accounts after recording them in the incident log.\n- The keys and salts in `wp-config.php`, to invalidate everyone's login cookies, including the attacker's.\n- Third-party access: Search Console owners, API keys (payments, email delivery), WordPress application passwords.\n\n```\n# New keys and salts in wp-config.php\nwp config shuffle-salts\n\n# Administrators and creation dates\nwp user list --role=administrator --fields=ID,user_login,user_email,user_registered --skip-plugins --skip-themes\n\n# Close every session for every user\nwp user list --field=ID --skip-plugins --skip-themes | xargs -n 1 wp user session destroy --all --skip-plugins --skip-themes\n```\n\nDo this from a clean computer: the WordPress.org FAQ points out that some intrusions begin with a Trojan on the administrator's computer that captures FTP or admin credentials. And plan to change these passwords a second time once the site is clean.\n\n## Step 4: restore, clean or rebuild\n\n![Decision tree: with a backup from before the intrusion, restore; otherwise clean if the infection is limited and understood, or rebuild](https://www.wp-feint.com/media/choix-strategie-en.webp)\n\n| Strategy | When to choose it | Advantage | Main risk |\n| --- | --- | --- | --- |\n| Restore a backup | Intrusion date known (logs) and backup clearly older | Fast, known state | Restoring a backup that is already infected; losing recent content |\n| Clean in place | Limited infection, files identified, healthy database | Keeps all the content | Missing a backdoor |\n| Rebuild | Old intrusion, multiple backdoors, modified database | Safest in the medium term | Takes longer; content must be reimported and checked |\n\n*Comparison of the three recovery strategies*\n\nWhatever the strategy, restoring without fixing the original flaw only puts the site back in the state that allowed the intrusion.\n\n## Step 5: clean up, location by location\n\n### WordPress core\n\nWordPress.org advises against using the reinstall button in the admin area: it overwrites existing files but leaves files added by the attacker. Delete `wp-admin` and `wp-includes`, then download exactly the same version:\n\n```\nVERSION=$(wp core version --skip-plugins --skip-themes)   # installed version\nrm -rf wp-admin wp-includes\nwp core download --version=\"$VERSION\" --skip-content --force\nwp core verify-checksums --include-root\n```\n\nThe `--skip-content` option avoids reinstalling the default themes and plugins, and `--force` overwrites the files in the root. The final check flags unknown files left in the root.\n\n### Plugins, themes and the rest of wp-content\n\n| Location | Action | What to watch for |\n| --- | --- | --- |\n| `wp-content/plugins` | Delete and reinstall each plugin from wordpress.org or the vendor | Delete any unknown or unused plugin |\n| `wp-content/themes` | Reinstall the theme; carry over child theme changes after reviewing them | `functions.php` is a common hiding place |\n| `wp-content/mu-plugins` | Empty it except for known, justified files | Loaded automatically, invisible in the usual plugin list |\n| `wp-content/uploads` | Delete any `.php` file; check `.htaccess` files | Media never contains legitimate PHP |\n| `wp-config.php`, `.htaccess` | Review line by line | Includes, redirects, obfuscated code |\n| Database | Check `wp_options`, `wp_posts`, `wp_users`, cron jobs | Scripts injected into content, unknown options |\n\n*Where to clean and how*\n\nTo spot obfuscated code, Sucuri lists the functions that are commonly abused: `eval`, `base64_decode`, `gzinflate`, `str_rot13`, `assert`. Legitimate plugins use them too: a match is a lead, not proof.\n\n```\ngrep -rlE \"eval\\(|base64_decode\\(|gzinflate\\(|str_rot13\\(\" wp-content/ --include=*.php\nfind wp-content/uploads -type f -name \"*.php\" -print\nwp db search \"<script\" --skip-plugins --skip-themes\nwp cron event list --skip-plugins --skip-themes\n```\n\n## Step 6: find the entry point\n\nThis is the step most often skipped, and the reason for reinfections. Cross-reference the incident log, the access logs and the file dates to identify the most likely cause:\n\n- A vulnerable plugin or theme that was not updated: look up the installed version in vulnerability databases (WPScan, Wordfence Intelligence, Patchstack).\n- A weak or reused password: the first successful POST requests to `wp-login.php` or `xmlrpc.php` just before the intrusion.\n- An infected workstation or stolen FTP credentials: file changes with no matching web request.\n- A compromised neighboring site on the same hosting account.\n\n## Steps 7 and 8: verify, then reopen\n\n- Run `wp core verify-checksums --include-root` and `wp plugin verify-checksums --all` again, then a server-side scanner.\n- Test the site with `curl`, imitating a visitor coming from Google and a search engine crawler, to detect any remaining cloaking.\n- Update core, plugins, themes and PHP, then change the passwords again, as WordPress.org recommends.\n- Remove the maintenance page and purge every cache (plugin, server, CDN).\n- In Search Console, request a review only once every issue is fixed on every page. Google says a review can take from a few days to a few weeks, and that you should not resubmit a request in the meantime.\n\n## Obligations not to forget\n\n| Situation | Action | Deadline or benchmark |\n| --- | --- | --- |\n| Personal data exposed (customer accounts, forms) | Notify the CNIL if the incident poses a risk to individuals | Without undue delay, no later than 72 hours after discovery, otherwise justify the delay |\n| High risk to individuals | Inform the people concerned (GDPR Article 34) | Without undue delay |\n| Any breach, even if not notified | Internal documentation of the incident | Always |\n| Need help, filing a complaint | 17Cyber (Police, Gendarmerie and Cybermalveillance.gouv.fr) | Online service |\n\n*Regulatory and support steps in France*\n\n## After reopening: stop finding out about a hack by chance\n\nMost site owners learn about a hack from a customer or from Google. WP Feint Pro adds a [core integrity check](https://www.wp-feint.com/features/wordpress-integrity-check/), [email alerts](https://www.wp-feint.com/features/email-alerts/), [two-factor authentication](https://www.wp-feint.com/features/two-factor-authentication/) and [login attempt limiting](https://www.wp-feint.com/features/login-attempt-limiting/), along with an administrator activity log and vulnerable plugin alerts. The plugin does not disinfect a site and does not fix plugin flaws: it reduces the visible attack surface and warns you sooner. To scan files after the cleanup, pair it with a malware scanner: our [comparison of the best WordPress security plugins](https://www.wp-feint.com/best-wordpress-security-plugins/) shows which ones include one.\n\n*Video in French: the right reflexes when WordPress has been hacked.*\n\nBefore cleaning up, identify every infection present with [our eight-point detection guide](https://www.wp-feint.com/detect-hacked-wordpress-site/).\n\nRead also: [WordPress site hacked: how to respond and fix it](https://www.wp-feint.com/wordpress-site-hacked-what-to-do/).\n\n### Key takeaways\n\n- Isolate the site with a static page and copy the infected state, logs included, before deleting anything.\n- Change every access (host, SFTP, SSH, database, WordPress), regenerate the salts, close sessions, then change the passwords again once the site is clean.\n- Replace core, plugins and theme with official copies instead of \"repairing\" files one by one.\n- Do not reopen until you have identified and fixed the entry point.\n- Personal data affected: notify the CNIL within 72 hours if the incident poses a risk.\n\n## Sources\n\n- [WordPress.org: FAQ My site was hacked](https://wordpress.org/documentation/article/faq-my-site-was-hacked/)\n- [CERT-FR: incident response sheet, Défiguration de site web, Endiguement (CERTFR-2024-RFX-008)](https://cert.ssi.gouv.fr/uploads/CERTFR-2024-RFX-008-1.pdf)\n- [CERT-FR: incident response sheet, Défiguration de site web, Qualification (CERTFR-2024-RFX-007)](https://cert.ssi.gouv.fr/uploads/CERTFR-2024-RFX-007-1.pdf)\n- [Cybermalveillance.gouv.fr: incident response sheet, Défiguration de site Internet](https://www.cybermalveillance.gouv.fr/medias/2020/01/230417_FicheReflexe_Defiguration.pdf)\n\nOther sources consulted: official documentation and security research publications.",
    "categories": [
        "Monitoring and response"
    ],
    "format": "application/json"
}