{"id":39987,"date":"2026-07-31T22:52:24","date_gmt":"2026-07-31T15:52:24","guid":{"rendered":"https:\/\/dps.media\/xu-ly-wordpress-bi-hack\/"},"modified":"2026-07-31T22:52:24","modified_gmt":"2026-07-31T15:52:24","slug":"handle-hacked-wordpress-2","status":"publish","type":"post","link":"https:\/\/dps.media\/en\/handle-hacked-wordpress-2\/","title":{"rendered":"Dealing with a Hacked WordPress: A 10-Step Process to Remove Malware and Secure It at the Root"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>One fine day, you visit your website and discover that the interface has been altered, or worse, customers report being redirected to strange gambling websites. When you access the admin dashboard, you notice a few unfamiliar admin accounts that you are certain you never created. Clearly, your website has been infected with malware. At this point, quickly finding a way <strong><a href=\"https:\/\/dps.media\/en\/handle-hacked-wordpress-2\/\">handle wordpress hacked<\/a><\/strong> is crucial for protecting customer data, maintaining brand reputation, and avoiding being placed on Google's dangerous site warning list.<\/p><p>In reality at DPS.MEDIA, we handle many website emergency cases in similar conditions. Most recently, it was the system of <strong>An Tam Pharmacy<\/strong>, organic traffic dropped severely by 45% within just a few days. After taking over, the technical team at DPS.MEDIA reviewed the site and discovered 2 fake plugins with the function of creating hidden admin accounts along with 1 fake Google Tag Manager mu-plugin used to inject malicious redirect code. With an optimized remediation process, we cleaned up the malware and restored the website to stable operation in exactly 2 working hours.<\/p><p>To help administrators self-troubleshoot or review technicians' work, DPS.MEDIA would like to share the standard 10-step process for handling a hacked WordPress website below.<\/p><h2>Complete 10-step process for handling a hacked WordPress site<\/h2><p>This process requires you to have basic knowledge of server administration (VPS\/Server) and using the command line (CLI). Please follow the steps in order to avoid missing any malware.<\/p><h3>Step 1: Install and configure Wordfence CLI<\/h3><p>Wordfence CLI is a professional open-source malware scanning tool that runs from the command line, helping you scan millions of files much faster than a typical plugin. First, configure its free license on the server:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wordfence configure<\/code><\/pre><h3>Step 2: Scan to detect files containing malware<\/h3><p>Run a quick scan command to compare against the database of known malware signatures. The scan results will be exported to a CSV file so you can easily monitor them:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wordfence malware-scan --output-format=csv \\\n  --output-path=\/home\/DOMAIN\/public_html\/wordfence-scan-\\\\$(date +%Y%m%d-%H%M%S).csv \\\n  \/home\/DOMAIN\/public_html\/<\/code><\/pre><p>If you suspect malware has spread to static files (such as images or the theme's custom JavaScript files), run a deep scan of the entire site:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wordfence malware-scan --include-all-files \\\n  --output-path=\/home\/DOMAIN\/public_html\/wordfence-scan-full-\\\\$(date +%Y%m%d-%H%M%S).log \\\n  \/home\/DOMAIN\/public_html\/<\/code><\/pre><h3>Step 3: Put the website into maintenance mode<\/h3><p>To prevent hackers from continuing to interfere or steal customer information during the cleanup process, you need to enable maintenance mode using WP-CLI:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wp maintenance-mode activate --allow-root --path=\/home\/DOMAIN\/public_html<\/code><\/pre><h3>Step 4: Review the list of Admin accounts<\/h3><p>List all accounts with the highest privileges on the website:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wp user list --role=administrator --allow-root --path=\/home\/DOMAIN\/public_html<\/code><\/pre><p>Pay attention to accounts with unusual emails or registration dates that coincide with the time the website began showing signs of interference. You should record the IDs of these fake accounts but <strong>do not delete them yet<\/strong>, we will remove them in the next step after cleaning the backdoor files.<\/p><h3>Step 5: Remove malicious files and fake accounts<\/h3><p>Based on the scan results from Step 2, locate and delete the malicious files. They are often disguised as:<\/p><ul>\n<li><strong>Fake plugins:<\/strong> A suspicious plugin directory containing code that calls functions to automatically create admin users. Delete the entire directory: <code data-no-translation=\"\">rm -rf \/home\/DOMAIN\/public_html\/wp-content\/plugins\/ten-plugin-gia<\/code><\/li>\n<li><strong>Must-Use Plugins (Mu-plugins):<\/strong> Located in the directory <code data-no-translation=\"\">wp-content\/mu-plugins\/<\/code>. These files run automatically without appearing in the WordPress plugin management list. Delete the suspicious file: <code data-no-translation=\"\">rm \/home\/DOMAIN\/public_html\/wp-content\/mu-plugins\/file-doc-hai.php<\/code><\/li>\n<\/ul><p>After cleaning up the backdoor files that create accounts, delete the fake admin accounts and reassign post ownership (if any) to the legitimate admin:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wp user delete ID_GIA --reassign=ID_ADMIN_THAT --allow-root --path=\/home\/DOMAIN\/public_html<\/code><\/pre><h3>Step 6: Clean up malware in the Database<\/h3><p>Many types of malware are not stored in physical files but instead save their payload directly in the database (for example, auto-loaded options in <code data-no-translation=\"\">wp_options<\/code> or by injecting advertising scripts into post content in <code data-no-translation=\"\">wp_posts<\/code>).<\/p><p>Check for options containing dangerous execution functions:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wp db query \"SELECT option_id, option_name FROM wp_options WHERE option_value LIKE '%base64_decode%' OR option_value LIKE '%eval(%';\" --allow-root --path=\/home\/DOMAIN\/public_html<\/code><\/pre><p>Check posts injected with malicious scripts:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wp db query \"SELECT ID, post_title FROM wp_posts WHERE post_content LIKE '%<script%' OR post_content LIKE '%iframe%';\" --allow-root --path=\/home\/DOMAIN\/public_html<\/code><\/pre><p>Please delete the malicious options found using the command: <code data-no-translation=\"\">wp option delete ten_option --allow-root --path=\/home\/DOMAIN\/public_html<\/code><\/p><h3>Step 7: Check the wp-config.php and .htaccess files<\/h3><p>Read the file carefully <code data-no-translation=\"\">.htaccess<\/code> v\u00e0 <code data-no-translation=\"\">wp-config.php<\/code> to ensure that no redirect snippets or unusual executable code are injected at the beginning of the file:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">cat \/home\/DOMAIN\/public_html\/.htaccess\ncat \/home\/DOMAIN\/public_html\/wp-config.php | grep -v \"^\\s*\/\/\" | grep -v \"^\\s*\\$\"<\/code><\/pre><h3>Step 8: Restore a clean WordPress Core using WP-CLI<\/h3><p>To ensure all WordPress core files have not been modified by hackers, run the command to overwrite them with clean core files from the WordPress.org server (excluding the wp-content directory):<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wp core download --version=\\$(wp core version --allow-root) --force --skip-content --allow-root --path=\/home\/DOMAIN\/public_html<\/code><\/pre><h3>Step 9: Change the password and update the Salts Key<\/h3><p>Vi\u1ec7c l\u00e0m m\u1edbi Salts Key trong file <code data-no-translation=\"\">wp-config.php<\/code> s\u1ebd l\u1eadp t\u1ee9c h\u1ee7y to\u00e0n b\u1ed9 c\u00e1c phi\u00ean \u0111\u0103ng nh\u1eadp hi\u1ec7n t\u1ea1i, bu\u1ed9c hacker ph\u1ea3i \u0111\u0103ng xu\u1ea5t kh\u1ecfi h\u1ec7 th\u1ed1ng ngay l\u1eadp t\u1ee9c:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wp config shuffle-salts --allow-root --path=\/home\/DOMAIN\/public_html<\/code><\/pre><p>Sau \u0111\u00f3, ti\u1ebfn h\u00e0nh \u0111\u1ed5i m\u1eadt kh\u1ea9u cho to\u00e0n b\u1ed9 t\u00e0i kho\u1ea3n Admin th\u1eadt c\u00f2n l\u1ea1i:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wp user update ID_ADMIN --user_pass=\"MatKhauMoiSieuBaoMat@2026\" --allow-root --path=\/home\/DOMAIN\/public_html<\/code><\/pre><p>\u0110\u1ed3ng th\u1eddi, \u0111\u1ed5i m\u1eadt kh\u1ea9u MySQL database v\u00e0 c\u1eadp nh\u1eadt l\u1ea1i th\u00f4ng tin k\u1ebft n\u1ed1i m\u1edbi trong file <code data-no-translation=\"\">wp-config.php<\/code>.<\/p><h3>Step 10: Rescan the system and disable maintenance mode<\/h3><p>Ch\u1ea1y l\u1ea1i Wordfence CLI \u0111\u1ec3 x\u00e1c nh\u1eadn h\u1ec7 th\u1ed1ng ho\u00e0n to\u00e0n s\u1ea1ch m\u00e3 \u0111\u1ed9c:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wordfence malware-scan --include-all-files --output-path=\/home\/DOMAIN\/public_html\/wordfence-scan-final.log \/home\/DOMAIN\/public_html\/<\/code><\/pre><p>Khi k\u1ebft qu\u1ea3 tr\u1ea3 v\u1ec1 ho\u00e0n to\u00e0n s\u1ea1ch s\u1ebd, t\u1eaft ch\u1ebf \u0111\u1ed9 b\u1ea3o tr\u00ec \u0111\u1ec3 \u0111\u01b0a website tr\u1edf l\u1ea1i ho\u1ea1t \u0111\u1ed9ng b\u00ecnh th\u01b0\u1eddng:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wp maintenance-mode deactivate --allow-root --path=\/home\/DOMAIN\/public_html<\/code><\/pre><p><img decoding=\"async\" src=\"https:\/\/dps.media\/wp-content\/uploads\/2026\/07\/xu_ly_wordpress_bi_hack_quy_trinh_10_buo_img3.png\" alt=\"handle wordpress hacked\" style=\"display:block;margin:20px auto;max-width:100%;height:auto\" title=\"\"><\/p><h2>Strengthen security after handling malware<\/h2><p>D\u1ecdn d\u1eb9p m\u00e3 \u0111\u1ed9c m\u1edbi ch\u1ec9 l\u00e0 ph\u1ea7n ng\u1ecdn. N\u1ebfu kh\u00f4ng b\u1ecbt c\u00e1c k\u1ebd h\u1edf b\u1ea3o m\u1eadt, website s\u1ebd nhanh ch\u00f3ng b\u1ecb hack tr\u1edf l\u1ea1i. H\u00e3y th\u1ef1c hi\u1ec7n ngay hai h\u00e0nh \u0111\u1ed9ng sau:<\/p><ul>\n<li><strong>Ph\u00e2n quy\u1ec1n file an to\u00e0n:<\/strong> Thi\u1ebft l\u1eadp quy\u1ec1n th\u01b0 m\u1ee5c l\u00e0 <code data-no-translation=\"\">755<\/code>, file l\u00e0 <code data-no-translation=\"\">644<\/code>, v\u00e0 file <code data-no-translation=\"\">wp-config.php<\/code> is <code data-no-translation=\"\">400<\/code> ho\u1eb7c <code data-no-translation=\"\">600<\/code> \u0111\u1ec3 ng\u0103n ch\u1eb7n vi\u1ec7c ghi \u0111\u00e8 tr\u00e1i ph\u00e9p.<\/li>\n<li><strong>Ch\u1eb7n ch\u1ea1y file PHP trong th\u01b0 m\u1ee5c Uploads:<\/strong> \u0110\u00e2y l\u00e0 n\u01a1i hacker hay l\u01b0u tr\u1eef webshell nh\u1ea5t. H\u00e3y t\u1ea1o file <code data-no-translation=\"\">.htaccess<\/code> b\u00ean trong th\u01b0 m\u1ee5c <code data-no-translation=\"\">wp-content\/uploads\/<\/code> v\u1edbi n\u1ed9i dung ch\u1eb7n th\u1ef1c thi PHP:\n<pre data-no-translation=\"\"><code data-no-translation=\"\"><Files *.php>\n    deny from all\n<\/Files><\/code><\/pre>\n<\/li>\n<\/ul><p>B\u00ean c\u1ea1nh \u0111\u00f3, b\u1ea1n n\u00ean tham kh\u1ea3o th\u00eam c\u00e1c khuy\u1ebfn ngh\u1ecb b\u1ea3o m\u1eadt ch\u00ednh th\u1ee9c t\u1eeb <a href=\"https:\/\/wordpress.org\/support\/article\/hardening-wordpress\/\" rel=\"nofollow noopener\" target=\"_blank\">t\u00e0i li\u1ec7u Hardening WordPress ch\u00ednh th\u1ee9c<\/a> \u0111\u1ec3 x\u00e2y d\u1ef1ng m\u1ed9t h\u00e0ng r\u00e0o b\u1ea3o v\u1ec7 v\u1eefng ch\u1eafc cho website c\u1ee7a m\u00ecnh.<\/p><p>N\u1ebfu b\u1ea1n kh\u00f4ng c\u00f3 nhi\u1ec1u th\u1eddi gian qu\u1ea3n tr\u1ecb k\u1ef9 thu\u1eadt ho\u1eb7c lo l\u1eafng v\u1ec1 vi\u1ec7c d\u1ecdn d\u1eb9p kh\u00f4ng tri\u1ec7t \u0111\u1ec3, h\u00e3y li\u00ean h\u1ec7 ngay v\u1edbi DPS.MEDIA qua Hotline\/Zalo <strong>0961545445<\/strong> ho\u1eb7c tr\u1ef1c ti\u1ebfp t\u1ea1i v\u0103n ph\u00f2ng: <strong>56 Nguyen Dinh Chieu, Tan Dinh Ward, District 1, Ho Chi Minh City<\/strong> \u0111\u1ec3 \u0111\u01b0\u1ee3c h\u1ed7 tr\u1ee3. Ch\u00fang t\u00f4i cung c\u1ea5p <a href=\"https:\/\/dps.media\/en\/\">d\u1ecbch v\u1ee5 thi\u1ebft k\u1ebf website WordPress chuy\u00ean nghi\u1ec7p<\/a> chu\u1ea9n SEO, b\u1ea3o m\u1eadt cao v\u00e0 v\u1eadn h\u00e0nh \u1ed5n \u0111\u1ecbnh, gi\u00fap doanh nghi\u1ec7p an t\u00e2m ph\u00e1t tri\u1ec3n kinh doanh m\u00e0 kh\u00f4ng lo ng\u1ea1i v\u1ec1 c\u00e1c s\u1ef1 c\u1ed1 an ninh m\u1ea1ng.<\/p>","protected":false},"excerpt":{"rendered":"<p>Detailed guide to the process of cleaning up a hacked WordPress website, removing malware, backdoors, fake admin accounts, and comprehensively strengthening website security.<\/p>","protected":false},"author":0,"featured_media":39985,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2037,2288,1204],"tags":[],"class_list":["post-39987","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bao-mat-website","category-thu-thuat-wordpress","category-wordpress-marketing"],"acf":[],"rankmath_keywords":{"primary":"x\u1eed l\u00fd wordpress b\u1ecb hack, wordpress b\u1ecb hack, c\u00e1ch x\u1eed l\u00fd wordpress b\u1ecb hack","secondary":["wordpress b\u1ecb hack","c\u00e1ch x\u1eed l\u00fd wordpress b\u1ecb hack"]},"yoast_keywords":{"primary":"","secondary":[]},"yoast_focuskw":"","rankmath_focuskw":"x\u1eed l\u00fd wordpress b\u1ecb hack, wordpress b\u1ecb hack, c\u00e1ch x\u1eed l\u00fd wordpress b\u1ecb hack","seo_keywords":{"primary":"x\u1eed l\u00fd wordpress b\u1ecb hack, wordpress b\u1ecb hack, c\u00e1ch x\u1eed l\u00fd wordpress b\u1ecb hack","secondary":["wordpress b\u1ecb hack","c\u00e1ch x\u1eed l\u00fd wordpress b\u1ecb hack"]},"_links":{"self":[{"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/posts\/39987","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/comments?post=39987"}],"version-history":[{"count":0,"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/posts\/39987\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/media\/39985"}],"wp:attachment":[{"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/media?parent=39987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/categories?post=39987"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dps.media\/en\/wp-json\/wp\/v2\/tags?post=39987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}