{"id":20353,"date":"2026-11-22T08:46:56","date_gmt":"2026-11-22T05:46:56","guid":{"rendered":"https:\/\/www.hyyat.com\/knowledgebase\/clean-hacked-wordpress-site-remove-malware\/"},"modified":"2026-11-22T08:47:13","modified_gmt":"2026-11-22T05:47:13","password":"","slug":"clean-hacked-wordpress-site-remove-malware","status":"publish","type":"docs","link":"https:\/\/www.hyyat.com\/en\/knowledgebase\/clean-hacked-wordpress-site-remove-malware\/","title":{"rendered":"How to Clean a Hacked WordPress Site: Removing Malware Step by Step"},"content":{"rendered":"<div class=\"hkb\" dir=\"ltr\">\n<div class=\"hkb-tldr\"><b>In short<\/b>If your WordPress site has been hacked: take a <b>backup<\/b>, lock the site temporarily, and find <b>how they got in<\/b>. Then replace WordPress core, plugins and themes with <b>clean original copies<\/b>, check <code>uploads<\/code>, <code>wp-config.php<\/code> and <code>.htaccess<\/code>, delete unknown users, and change every password and secret key. Finally update everything and ask Google for a review.<\/div>\n<figure class=\"hkb-fig\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.hyyat.com\/zasogooh\/2026\/11\/hkb-tr-13411-en.webp\" alt=\"How to Clean a Hacked WordPress Site: Removing Malware Step by Step\" width=\"1200\" height=\"630\" loading=\"lazy\" \/><\/figure>\n<p>A hacked WordPress site is stressful, but it can be cleaned if you follow an organised plan. The cleanup must be thorough: one missed infected file is enough for the attacker to come back. This guide is the full plan; you will need access to cPanel or FTP, and phpMyAdmin.<\/p>\n<h2>Why do WordPress sites get hacked?<\/h2>\n<p>The main motive is money: placing links to gambling, pharmacy or shady sites to boost their Google ranking, sending spam from your site, or redirecting your visitors to scams. The most common ways in:<\/p>\n<ul class=\"hkb-list\">\n<li><b>Weak passwords<\/b> for admin or FTP accounts.<\/li>\n<li><b>Outdated WordPress, plugins or themes<\/b> with known vulnerabilities.<\/li>\n<li><b>Nulled plugins and themes<\/b> from unofficial sources, which come with malware.<\/li>\n<\/ul>\n<h2>Signs of a hack<\/h2>\n<ul class=\"hkb-list\">\n<li>Unfamiliar links on your pages, sometimes hidden in the background colour.<\/li>\n<li>Visitors redirected to other sites, sometimes only on mobile or only when arriving from Google.<\/li>\n<li>Strange results when searching for your site, or a &#8220;This site may be hacked&#8221; warning.<\/li>\n<li>A notice from your host about unusual amounts of email sent from your site.<\/li>\n<li>Admin users in WordPress you do not recognise.<\/li>\n<\/ul>\n<h2>1) Prepare<\/h2>\n<ol class=\"hkb-steps\">\n<li><b>Take a full backup<\/b> of files and database, even if infected. You may need it for comparison or to roll back.<\/li>\n<li><b>Lock the site temporarily<\/b> so it does not infect visitors and the attacker cannot interfere during cleanup. You can allow only your own IP address by adding this to <code>.htaccess<\/code>, replacing the number with your address:<\/li>\n<\/ol>\n<pre class=\"hkb-code\">Require all denied\nRequire ip 203.0.113.10<\/pre>\n<h2>2) Find how they got in<\/h2>\n<ul class=\"hkb-list\">\n<li>Check your WordPress, plugin and theme versions against the <a href=\"https:\/\/wpscan.com\/\" rel=\"nofollow noopener\" target=\"_blank\">WPScan<\/a> vulnerability database.<\/li>\n<li>Open <a href=\"https:\/\/search.google.com\/search-console\/about\" rel=\"nofollow noopener\" target=\"_blank\">Google Search Console<\/a> and look at Security issues.<\/li>\n<li>Check your site in <a href=\"https:\/\/transparencyreport.google.com\/safe-browsing\/search\" rel=\"nofollow noopener\" target=\"_blank\">Google&#8217;s Safe Browsing report<\/a>.<\/li>\n<li>Search your access logs for <code>POST<\/code> requests to unfamiliar php files. Not every POST is malicious; contact forms and the login page use it too.<\/li>\n<\/ul>\n<figure class=\"hkb-fig hkb-shot\"><img decoding=\"async\" src=\"https:\/\/www.hyyat.com\/zasogooh\/2019\/03\/google-security.png\" alt=\"Checking the site&#x27;s security status in Google tools\" loading=\"lazy\" \/><\/figure>\n<h2>3) Replace WordPress core files<\/h2>\n<ol class=\"hkb-steps\">\n<li><b>Find your WordPress version<\/b> in <code>wp-includes\/version.php<\/code>.<\/li>\n<li><b>Download the same version<\/b> from the official WordPress archive and unzip it on your computer.<\/li>\n<li><b>Delete wp-admin and wp-includes<\/b> from your site and upload the clean copies.<\/li>\n<li><b>Replace the root files<\/b> in public_html with the originals, <b>except wp-config.php<\/b>.<\/li>\n<li><b>Check any other files or folders<\/b> in the root you do not recognise. If unsure, ask support before deleting.<\/li>\n<\/ol>\n<h2>4) Plugins and themes<\/h2>\n<ul class=\"hkb-list\">\n<li>Delete every plugin or theme you do not use.<\/li>\n<li>Delete each plugin folder, then upload a clean copy from the WordPress repository or your developer account.<\/li>\n<li>Do the same with your theme. If it was customised, keep your changes in a child theme after checking them line by line.<\/li>\n<li>Delete any nulled plugin or theme.<\/li>\n<\/ul>\n<p>If you see pop-ups or unwanted redirects, also read <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/wordpress-popup-ads-wp-vcd-malware\/\">removing wp-vcd malware<\/a>.<\/p>\n<h2>5) Check the remaining files<\/h2>\n<ul class=\"hkb-list\">\n<li><b>The uploads folder<\/b> should not contain <code>.php<\/code>, <code>.sh<\/code> or <code>.exe<\/code> files. Any you find most likely came from the attacker.<\/li>\n<li><b>Files with no original copy:<\/b> search them for words like <code>eval<\/code>, <code>base64_decode<\/code>, <code>gzinflate<\/code> and <code>exec<\/code>, and for very long unreadable lines.<\/li>\n<li><b>wp-config.php:<\/b> compare it with the original, remove any unfamiliar code, and change the secret keys (salts) to end all open sessions. Details in <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/protect-wp-config\/\">protecting wp-config.php<\/a>.<\/li>\n<li><b>.htaccess:<\/b> the standard WordPress file contains only these lines; anything else you do not recognise is worth checking:<\/li>\n<\/ul>\n<pre class=\"hkb-code\"># BEGIN WordPress\nRewriteEngine On\nRewriteBase \/\nRewriteRule ^index\\.php$ - [L]\nRewriteCond %{REQUEST_FILENAME} !-f\nRewriteCond %{REQUEST_FILENAME} !-d\nRewriteRule . \/index.php [L]\n# END WordPress<\/pre>\n<p>An <code>.htaccess<\/code> in uploads containing only <code>Options -Indexes<\/code> is normal.<\/p>\n<h2>6) Users, database and passwords<\/h2>\n<ul class=\"hkb-list\">\n<li>Delete any user you do not recognise, especially administrators. Read <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/wordpress-user-roles\/\">WordPress user roles<\/a>.<\/li>\n<li>Search the database posts and options tables for <code>&lt;script<\/code> and links to strange sites.<\/li>\n<li>Change passwords for WordPress admins, cPanel, FTP, the database and email. You can reset a WordPress password from <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/reset-wordpress-password-phpmyadmin\/\">phpMyAdmin<\/a> if you cannot log in.<\/li>\n<\/ul>\n<figure class=\"hkb-fig hkb-shot\"><img decoding=\"async\" src=\"https:\/\/www.hyyat.com\/zasogooh\/2019\/03\/wordpress-users-safety-450x300.jpg\" alt=\"Reviewing WordPress users and passwords\" loading=\"lazy\" \/><\/figure>\n<h2>7) After the cleanup<\/h2>\n<ol class=\"hkb-steps\">\n<li><b>Update WordPress, plugins and theme<\/b> to the latest versions. See <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/update-wordpress-safely\/\">updating safely<\/a>.<\/li>\n<li><b>Reopen the site<\/b> by removing the lock lines from .htaccess, and browse your key pages.<\/li>\n<li><b>Ask Google for a review<\/b> in Search Console if it showed a warning.<\/li>\n<li><b>Protect the login page<\/b> as in <a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/protect-wordpress-login-wp-admin\/\">protecting wp-admin<\/a>, and turn on two-factor authentication for admins.<\/li>\n<\/ol>\n<div class=\"hkb-note\"><b>On Hyyat Host hosting:<\/b> files are scanned with ImunifyAV and each account is isolated with CloudLinux, so a hacked site cannot spread to other sites on the server.<\/div>\n<div class=\"hkb-hh\">\n<h2>Summary<\/h2>\n<ul>\n<li>Take a backup and lock the site before cleaning.<\/li>\n<li>Replace files with original copies instead of fixing them one by one.<\/li>\n<li>Change every password and key, then update everything.<\/li>\n<\/ul>\n<p style=\"margin:10px 0 0\">Rather not clean it yourself? Our <a href=\"https:\/\/www.hyyat.com\/en\/technical-support\/\">technical support and maintenance<\/a> team can clean and secure your site.<\/p>\n<\/div>\n<h2>Frequently asked questions<\/h2>\n<div class=\"hkb-faq\">\n<details>\n<summary>How do I know my WordPress site has been hacked?<\/summary>\n<p>Signs include strange links, visitors redirected elsewhere, a Google warning, unknown admin users, or a notice about lots of email sent from your site.<\/p>\n<\/details>\n<details>\n<summary>Is deleting the infected file enough?<\/summary>\n<p>Usually not. Attackers leave several files and backdoors. The safe cleanup is replacing all files with originals and changing passwords.<\/p>\n<\/details>\n<details>\n<summary>Can I restore an old backup instead?<\/summary>\n<p>Yes, if you are sure it predates the hack. Then update everything and change passwords, or the same hole will be used again.<\/p>\n<\/details>\n<details>\n<summary>Why does Google still show a warning after cleaning?<\/summary>\n<p>Google needs to re-check. Request a review in Search Console once you are sure the site is clean.<\/p>\n<\/details>\n<\/div>\n<div class=\"hkb-rel\"><b>Related guides<\/b><\/p>\n<ul>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/wordpress-popup-ads-wp-vcd-malware\/\">Pop-up Ads and Redirects on Your WordPress Site? How to Remove wp-vcd Malware<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/protect-wp-config\/\">How to Protect wp-config.php in WordPress: 7 Steps to Secure Your Most Important File<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/protect-wordpress-login-wp-admin\/\">How to Protect the WordPress Login Page (wp-admin): 7 Practical Steps<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/update-wordpress-safely\/\">How to Update WordPress and Plugins Safely Without Breaking Your Site<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/wordpress-user-roles\/\">WordPress User Roles and Permissions: Who Needs Administrator Access and Who Does Not<\/a><\/li>\n<li><a href=\"https:\/\/www.hyyat.com\/en\/knowledgebase\/recover-hacked-email-account\/\">Email Hacked or Sending Spam? Steps to Recover and Secure Your Mailbox<\/a><\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.hyyat.com\/en\/kb\/wordpress-explanations\/\">All guides in this section \u2192<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In shortIf your WordPress site has been hacked: take a backup, lock the site temporarily, and find how they got in. Then replace WordPress core, plugins and themes with clean original copies, check uploads, wp-config.php and .htaccess, delete unknown users, and change every password and secret key. Finally update everything and ask Google for a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":20321,"comment_status":"open","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"_templately_pack_id":"","_templately_imported_at":"","_templately_source":"","_templately_import_session_id":"","footnotes":""},"doc_category":[2747],"doc_tag":[],"class_list":["post-20353","docs","type-docs","status-publish","has-post-thumbnail","hentry","doc_category-wordpress-explanations"],"year_month":"2026-11","word_count":999,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"admin","author_nicename":"admin","author_url":"https:\/\/www.hyyat.com\/en\/author\/admin\/"},"doc_category_info":[{"term_name":"WordPress Guides","term_url":"https:\/\/www.hyyat.com\/en\/kb\/wordpress-explanations\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs\/20353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/comments?post=20353"}],"version-history":[{"count":0,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/docs\/20353\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/media\/20321"}],"wp:attachment":[{"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/media?parent=20353"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/doc_category?post=20353"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.hyyat.com\/en\/wp-json\/wp\/v2\/doc_tag?post=20353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}