A fake captcha keyboard shortcut malware page shows a normal-looking "verify you are human" box, then tells the visitor to press Win+R, press Ctrl+V and press Enter. The site has already copied a PowerShell command to the clipboard, so the visitor runs the malware on their own machine. If you see that box on your site, the site is compromised. The short answer: find the injected JavaScript or the PHP that writes it, remove it, reinstall or rebuild the affected code, close the way in, and rotate every credential. The cleanup differs between WordPress and Laravel, so the steps below cover both.
What the attack does
When the visitor clicks the fake box, the injected script writes a command into the clipboard, which browsers allow after a user click. The panel then makes the visitor finish the job. Owners often miss it because the script may fire only for some visitors, and it can be a few lines tucked into a file that looks ordinary.
Common causes, most likely first
- A vulnerable plugin, theme or package. Outdated WordPress plugins and themes are a frequent way in. On Laravel projects, outdated Composer or npm dependencies do the same job.
- Weak or leaked credentials. A guessed WordPress admin password, or a stolen FTP, SSH, Git or hosting login, lets someone edit files directly.
- Injected code in a shared file. A script added to WordPress footer.php or functions.php, or to a Laravel layout such as resources/views/layouts/app.blade.php, loads on every page.
- A poisoned build file. Code added to public/build or public/js in Laravel survives until the next rebuild.
- A backdoor. A stray PHP file in wp-content/uploads, wp-content/mu-plugins, public/ or storage/ that outputs the script. This is the one that reinfects a site after a half-done cleanup.
Step 1: Confirm the injection without triggering it
Do not click the fake box or run anything it asks for, even on a test machine. Work from the page source: open the page in a private window, press Ctrl+U, and look for unfamiliar script tags. Then search the project from its root directory:
grep -rIl -E 'clipboard|powershell|mshta|eval[(]base64_decode|gzinflate' app bootstrap config public resources routes wp-content wp-config.php .htaccess 2>/dev/nullExpect false positives. Copy buttons in themes and plugins also use the clipboard API, and many WordPress plugins legitimately use base64 or gzinflate. Check every hit by hand. Anything that mentions PowerShell or mshta, or an encoded eval that runs on page load, is a serious finding. Next, look for PHP files where none belong:
find public storage wp-content/uploads wp-content/mu-plugins -type f -name '*.php' 2>/dev/nullLaravel's public folder should hold only index.php and static assets. WordPress uploads should hold media only, so any PHP file in wp-content/uploads is a backdoor until proven otherwise.
Step 2: Find what changed recently
If the project is in Git, git status and git diff show the injected lines most clearly. Without Git, list files changed in the last 30 days:
find . -type f -mtime -30 -not -path './vendor/*' -not -path './node_modules/*' -not -path './wp-content/cache/*' -not -path './storage/logs/*'If the attacker may have been inside longer, widen the window. Anything you did not put there yourself needs a close look.
Step 3: Clean up by platform
Laravel
Clear compiled views and caches first. Blade stores compiled templates in storage/framework/views, so a cleaned template can keep serving the old script until those files are gone:
php artisan optimize:clearDo not hand-edit minified bundles. Rebuild them from clean source, after confirming your build tool writes to public/build:
rm -rf public/build
npm ci
npm run buildAlso check for a PHP settings file that loads code before every request. An auto_prepend_file line in .user.ini runs an attacker's file on every page:
find . -name '.user.ini' -not -path './vendor/*'
grep -rIn 'auto_prepend_file' . --exclude-dir=vendor --exclude-dir=node_modulesWordPress
Start by verifying WordPress core and plugins against the official checksums. WP-CLI reports any modified file:
wp core verify-checksums
wp plugin verify-checksums --allTo replace core files without touching your content, run a forced core download with skip-content. It overwrites wp-admin and wp-includes only, and leaves wp-content and wp-config.php alone:
wp core download --skip-content --forceThen check wp-config.php by hand for injected lines, and remove any plugin or theme you do not recognise. Also inspect functions.php and footer.php in your active theme, since those are common injection points. Next, check the database for injected script in options, and confirm the site URLs:
wp db query "SELECT option_name FROM wp_options WHERE option_value LIKE '%clipboard%' OR option_value LIKE '%powershell%'"
wp option get siteurl
wp option get homeReplace wp_ if your table prefix differs. Then review the admin accounts and scheduled events. Remove any administrator you did not create, and look for cron events with names you do not recognise, since malware often schedules itself to return:
wp user list --role=administrator --fields=ID,user_login,user_email,user_registered
wp cron event listStep 4: Update and audit
Check your PHP, framework, and package versions first, and make sure each is on a release that still gets security fixes. Then run the audit and update tools for your stack:
php -v
php artisan --version
composer audit
npm audit
wp core version
wp plugin list --update=available
wp theme list --update=availableUpdate plugins and themes that have pending updates, and delete any you no longer use rather than leaving them disabled. Patch-level updates are usually safe during an incident. A major Laravel or WordPress upgrade needs its own testing, so schedule it separately.
Step 5: Rotate every credential
Assume anything the attacker could read is compromised. Change the database password, mail and API keys, your hosting panel login, FTP, SSH and Git keys, and every admin password. Remove any user or key you do not recognise.
On WordPress, replace the authentication salts in wp-config.php with a fresh set from the official generator at https://api.wordpress.org/secret-key/1.1/salt/. This logs out every user, which is what you want after an incident.
On Laravel, if APP_KEY may have leaked, generate a new one. The --show flag prints the key without writing it, so paste it into .env yourself:
php artisan key:generate --showBe careful with this one. Changing APP_KEY logs out every user and makes existing encrypted values unreadable, so plan to re-save those values. Also set APP_DEBUG=false in production, because debug pages leak paths and config.
Step 6: Lock down file permissions
Use 755 for directories and 644 for files, and never use 777. Check your host's user and group setup first, since some shared hosts need different settings. On Laravel:
find . -type d -exec chmod 755 {} +
find . -type f -exec chmod 644 {} +
chmod -R 775 storage bootstrap/cacheOn WordPress, keep wp-config.php readable only by its owner and the web server, usually with 640 or 600 depending on your host. Uploads need to stay writable for media, so keep wp-content/uploads at 775 if your host requires it.
chmod 640 wp-config.phpStep 7: Verify and ask search engines to re-check
Check the page source again from a clean browser, then load a few affected pages from a phone on mobile data to confirm the fake box is gone. On WordPress, the Site Health screen in wp-admin flags common problems. If Google flagged the site, Google Search Console has a Security Issues report where you can request a review once the site is clean. Keep an eye on access logs for a few days, since reinfection usually comes from a backdoor that was missed the first time.
If visitors already ran the command
If you know specific visitors were affected, tell them. Suggest they run a full scan with an up-to-date antivirus and check for unfamiliar scheduled tasks or startup entries. The malware lives on their computer, so only that machine can be cleaned. If they are not comfortable doing that, they should ask someone who can.
For a full walkthrough covering backups, database checks and hosting logs, read the Malware Removal Guide. If you are not sure the site is clean after these steps, do not guess. Put up a maintenance page until it is verified.
Comments
No comments yet. Did this work for you, or did you hit something different? Ask below.
Leave a comment
Comments are reviewed before they appear. Your email is never shown.