Skip to content
Technology for businesses since 2008

Help center · Security

How to use AI to remove viruses from a WordPress site

An AI assistant can help you remove viruses from a WordPress site in three ways: it explains the warnings you received, analyzes the code snippets and log lines you paste into the conversation, and builds a checklist for your specific case. It does not access the server, delete anything, or confirm that the site is clean. You, or a professional, carry out each step and check the result.

This article shows what to paste, what to ask, and what never to send, with requests you can copy and use right away. The examples work with any chat assistant, such as ChatGPT, Claude, Gemini, or Copilot. We don’t recommend any one in particular.

What AI does and doesn’t do

Task Does AI help? Limit
Explain a warning from Google or your hosting provider Yes It only knows what is in the text you pasted
Explain what a code snippet does Yes It can get heavily obfuscated or incomplete code wrong
Build a verification checklist Yes The checklist stays generic until you give context about the site
Read log lines and point out strange access Yes It only sees the lines you send, not the full log
Write the review request to Google Yes You check that what it says is true
Find all infected files No It cannot see the server
Delete the virus, change passwords, update plugins No You do it
Guarantee that the site is clean No No one can confirm that from snippets alone

Some AI tools run commands directly on a server. Giving that access to a hacked site, where passwords may be compromised, is a decision for someone who can review every command before it runs. This article covers the simplest and safest use: a conversation, where you copy and paste.

What never to paste into an AI assistant

Before your first request, separate out what must not leave your computer:

  • Passwords and keys. Control panel, hosting, FTP, and database passwords, API keys, and payment gateway keys.
  • The entire wp-config.php file. It contains the database username and password and the WordPress security keys. If you need to show part of it, replace those values with XXXX first.
  • Customer data. Names, emails, taxpayer IDs, orders, database exports, and user lists with email addresses.
  • Unreviewed logs. Log lines contain IP addresses and sometimes emails and parameters with personal data. Remove anything that identifies people.

Also check the settings of the assistant you use to see how conversations are stored and whether they can be used to train the model. If your company has an AI use policy, it applies here too.

Step 1: preserve the site before investigating

AI comes in after containment. Before any conversation:

  1. Don’t delete any files.
  2. Download a copy of the files and export the database, even if they are infected.
  3. Change the passwords for WordPress, the hosting account, FTP or SSH, and the database.
  4. If the site is redirecting visitors, put it in maintenance mode.

The full order is on the page Virus and malware removal from a hacked site, in the section “Hacked site: what to do now”.

Step 2: give context and ask for a checklist

A vague request gets a vague answer. Tell the assistant the platform, the hosting, the symptom, what you have already done, and what you can access. And ask it not to tell you to delete anything.

My WordPress site was hacked. Context:
- Shared hosting with cPanel. I have access to the control panel
  and the File Manager, but I don't have SSH.
- Symptom: people who arrive from Google get redirected to a
  gambling site. When I open the site directly, it looks normal.
- What I've already done: copied the files and the database, changed the passwords.
- I don't have a backup from before the hack.

Build a verification checklist, from most likely to least likely,
saying at each step where to look and what would be suspicious.
Don't tell me to delete anything: I want to find and understand
first. If information is missing, ask before assuming.

The checklist usually covers the places where a WordPress infection most often shows up: the .htaccess file, the index.php and wp-config.php files, the theme’s functions.php, .php files inside wp-content/uploads, the wp-content/mu-plugins folder, the list of administrator users, and the siteurl and home options in the database. Use the checklist as a review list and come back to the conversation with what you find.

Step 3: ask for an explanation of the warning

Paste the text of the email from Google Search Console, the Security issues report, or the warning from your hosting provider. Remove your name and email address first.

I received this warning about my site. Explain in plain language:
what was detected, what it indicates about the type of intrusion,
and what I should check first. If the warning doesn't say
something, tell me it doesn't say, instead of guessing.

[paste the text of the warning here]

The Security issues report in Search Console shows the type of problem (for example, malware, code injection, content injection, or URL injection), the date it was detected, and a sample of the affected pages. Bring these three pieces of information into the conversation: they point to what to look for.

Step 4: show plugins, themes, and users

In the WordPress admin, copy the list of plugins and themes with their versions, and the list of users with the administrator role. Send only the usernames, without email addresses.

This is the list of plugins and themes on my WordPress site, with
their versions, and the names of the administrator users.

1. Which items should I check first because they are abandoned,
   deactivated and unused, or very outdated?
2. Does any plugin or user name look illegitimate?
3. What should I confirm on each plugin's official page?

Don't claim that a plugin has a known vulnerability unless you are sure. If you don't know,
tell me I need to check the official source.

[paste the lists here]

The last instruction matters. The assistant may “remember” a vulnerability that does not exist, or be unaware of a recent one, because what it knows has a cutoff date. Confirm versions and fixes on the plugin’s page in the official WordPress plugin directory or on the developer’s website.

Step 5: analyze a suspicious code snippet

This is where AI helps the most. Malicious code is often obfuscated, and explaining what obfuscated code does is slow work for a person.

These are usually worth showing:

  • the contents of the .htaccess file in the main folder of the site;
  • the first and last lines of index.php and of the theme’s functions.php, where injected code often hides;
  • .php files inside wp-content/uploads, a folder that should only hold images and documents;
  • files with a recent modification date that nobody on the team changed;
  • files with strange names, or names almost identical to a WordPress file.
I found this snippet in the file [file name and folder] of my
WordPress site. The modification date is [date], and no one on
the team changed this file.

1. Explain, step by step, what this code does.
2. Is it part of WordPress, a known plugin, or does it look
   injected? Tell me how certain you are and what I can do to
   confirm it.
3. If it is malicious, what other files or database records
   usually accompany this kind of code?

Don't run or complete the code. Only analyze it.

[paste the snippet here, without passwords or keys]

To confirm the answer, compare the file with the original. The WordPress core files and the plugin files from the official directory can be downloaded again, at the same version, and compared with the ones on your site. If you have SSH access and the WP-CLI tool, you can use the commands wp core verify-checksums and wp plugin verify-checksums --all, which point out files that differ from the originals. Custom-made themes and paid plugins don’t have this public reference.

Step 6: share the log lines

The server’s access logs show how the attacker got in. In cPanel, they are under “Raw Access” or “Access Logs”; on other hosting providers, ask support. The full file is too large and contains visitor data. Pick out the lines close to the date the suspicious file was created, or the lines that mention its name.

These are lines from my site's access log, close to the time the
file [name] was created. I replaced the IP addresses with letters
(IP-A, IP-B).

1. Is there any pattern that shows how the attacker got in?
2. Which requests are normal for WordPress and which
   are not?
3. What should I look for in the rest of the log to confirm?

[paste the lines here]

What the assistant says based on twenty lines is a hypothesis. Confirmation is in the complete log, which only you or the professional have.

Step 7: write the review request to Google

Once the site is clean and the vulnerability is closed, the request to lift the warning is made in the Security issues report in Search Console, using the Request Review button. The Search Console help asks for three things in the text: explain the problem, describe what was done to fix it, and document the result.

I'm going to ask Google to review my site's security.
Write the text of the request based on these facts, without
adding anything I haven't said:

- Problem flagged in the report: [type and date]
- What we found: [files, users, cause]
- What was fixed: [cleanup, updates, passwords]
- How we checked: [what was verified afterward]

Objective text, in English, with no promises.

Read the result before you send it. According to the same help article, requesting a review before the problem is fixed can delay the response to your next request, and most reviews take from several days to a few weeks.

Where AI gets it wrong

  • It invents with confidence. It may cite a file, a function, a command, or a plugin vulnerability that doesn’t exist, in the same tone it uses for correct statements.
  • It flags legitimate code. Cache, security, and license plugins use compressed code that looks malicious. Deleting a file only because the AI was suspicious of it can break the site.
  • It clears malicious code. A cut-off snippet, or one that loads the rest of its code from another file, may look harmless on its own.
  • It can’t see what you didn’t show it. “This snippet is clean” does not mean “the site is clean.” The rest of the files and the database were left out.
  • It is out of date. The model’s knowledge has a cutoff date. Vulnerabilities disclosed later are not in it, unless the assistant searches the internet and cites its sources.
  • It agrees too readily. If you write “I think it’s plugin X,” the answer tends to confirm it. Ask “what else could it be?” and “what would prove me wrong?”

One simple rule reduces the risk: AI explains and suggests where to look; no change is made to the site just because it said so. Before deleting or changing anything, confirm it another way and keep a copy of the site.

When to stop and call a professional

The conversation with AI answers questions. These signs indicate that the case has gone beyond what you can solve on your own:

  • the virus came back after a cleanup;
  • Google or browsers show a dangerous site warning;
  • the site is a store or holds customers’ personal data;
  • there is no backup from before the hack;
  • there is more than one site on the same hosting account;
  • you don’t have access to the files, the database, or the logs;
  • the checklist calls for commands or database changes you don’t feel safe making;
  • the site is down and every hour offline costs sales.

In these cases, bring the professional everything you have gathered with AI’s help: the warning, the suspicious files, and the dates. That shortens the diagnosis. MigraCloud does this work: see the page Virus and malware removal from a hacked site or contact us.

Frequently asked questions

Can AI remove the virus from my WordPress site on its own?

No. A chat assistant does not access the server: it explains warnings, analyzes what you paste, and suggests where to look. Finding all the infected files, deleting the code, closing the vulnerability, and checking the result are still work for whoever has access to the site.

Is it safe to paste code from my site into an AI assistant?

Code snippets, yes, as long as you first remove passwords, API keys, and customer data. Never paste the entire wp-config.php file, because it contains the database password. Also check how the assistant stores conversations.

What should I paste into AI when my site has been hacked?

The text of the Search Console or hosting warning, the list of plugins and themes with their versions, the names of the administrator users, the suspicious code snippets, and the log lines close to the date of the intrusion. Always without passwords and without personal data.

Can AI tell me whether my site is clean?

No. It can only evaluate what was shown in the conversation. A harmless snippet says nothing about the other files or the database. What indicates a clean site is comparing the files with the originals, reviewing the database and the users, and going a period of time without reinfection.

Can AI make mistakes when analyzing suspicious code?

Yes, in both directions: it can flag legitimate code as malicious and let disguised malicious code slip through. That’s why no file should be deleted just because AI suggested it. Compare it with the original WordPress or plugin file first.

Which AI assistant is best for analyzing WordPress malware?

There is no single recommendation. The requests in this article work with any current chat assistant. What matters more than the tool is the context you provide, the care you take with what you paste, and the checking of every answer.

Does AI help remove the dangerous site warning from Google?

It helps in two steps: understanding what the Security issues report flagged, and drafting the review request. Cleaning the site and submitting the request in Search Console are done by you, and the review timeline is set by Google.

When should I stop trying on my own and hire a cleanup service?

When the virus comes back after a cleanup, when there is a Google warning, when the site holds customer data, or when there is no clean backup. In those cases, professional virus removal is usually the shortest path.

More on Security

See all →

Help center

Looking for something else?

See all tutorials, organized by topic.