{"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\/xu-ly-wordpress-bi-hack\/","title":{"rendered":"Dealing with a Hacked WordPress: A 10-Step Process to Remove Malware and Secure It at the Root"},"content":{"rendered":"<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 the 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 for 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>Remove any malicious options found using the following 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> and <code data-no-translation=\"\">wp-config.php<\/code> to ensure no redirect code or unknown executable code is 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 make sure all WordPress core files have not been tampered with by hackers, run the command to overwrite the core with a clean copy from the WordPress.org server (skip the wp-content folder):<\/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 Passwords and Update the Salts Key<\/h3><p>Regenerating the Salts Keys in the file <code data-no-translation=\"\">wp-config.php<\/code> will immediately terminate all current login sessions, forcing hackers to log out of the system right away:<\/p><pre data-no-translation=\"\"><code data-no-translation=\"\">wp config shuffle-salts --allow-root --path=\/home\/DOMAIN\/public_html<\/code><\/pre><p>Then, proceed to change the passwords for all remaining genuine Admin accounts:<\/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>At the same time, change the MySQL database password and update the new connection information in the file <code data-no-translation=\"\">wp-config.php<\/code>.<\/p><h3>Step 10: Rescan the system and turn off maintenance mode<\/h3><p>Run Wordfence CLI again to confirm the system is completely free of malware:<\/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>Once the results come back completely clean, turn off maintenance mode to return the website to normal operation:<\/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 Removing Malware<\/h2><p>Removing malware is only the surface-level fix. Without closing security gaps, the website will quickly be hacked again. Take the following two actions immediately:<\/p><ul>\n<li><strong>Set safe file permissions:<\/strong> Set the directory permissions to <code data-no-translation=\"\">755<\/code>, the file is <code data-no-translation=\"\">644<\/code>, and file <code data-no-translation=\"\">wp-config.php<\/code> is <code data-no-translation=\"\">400<\/code> or <code data-no-translation=\"\">600<\/code> to prevent unauthorized overwriting.<\/li>\n<li><strong>Block PHP file execution in the Uploads folder:<\/strong> This is where hackers most often store webshells. Create a file <code data-no-translation=\"\">.htaccess<\/code> inside the folder <code data-no-translation=\"\">wp-content\/uploads\/<\/code> with content that blocks PHP execution:\n<pre data-no-translation=\"\"><code data-no-translation=\"\"><Files *.php>\n    deny from all\n<\/Files><\/code><\/pre>\n<\/li>\n<\/ul><p>In addition, you should also refer to the official security recommendations from <a href=\"https:\/\/wordpress.org\/support\/article\/hardening-wordpress\/\" rel=\"nofollow noopener\" target=\"_blank\">the official WordPress Hardening documentation<\/a> to build a solid protective barrier for your website.<\/p><p>If you do not have much time for technical administration or are concerned about incomplete cleanup, contact DPS.MEDIA immediately via Hotline\/Zalo <strong>0961545445<\/strong> or directly at the office: <strong>56 Nguyen Dinh Chieu, Tan Dinh Ward, District 1, Ho Chi Minh City<\/strong> for support. We provide <a href=\"https:\/\/dps.media\/en\/\">professional WordPress website design service<\/a> SEO-optimized, highly secure and stably operated, helping businesses grow with confidence without concern over cybersecurity incidents.<\/p>","protected":false},"excerpt":{"rendered":"<p>A detailed guide to the process of handling a hacked WordPress site, helping you clean out malware, backdoors, and fake admin accounts and comprehensively harden the website's security.<\/p>","protected":false},"author":0,"featured_media":39985,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"rs_blank_template":"","rs_page_bg_color":"","slide_template_v7":"","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":"Agency collaboration cost optimization strategy","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}