Support » Fixing WordPress » Site hacked – How do I know which files are genuine and which are not?

  • I have a hosting account, on which I have about 10 web sites, all of which are ASP.NET, except for one WP site.

    I just discovered that the file system has been compromised, and a whole pile of dubious .php files uploaded. As all other sites are ASP.NET, and so don’t have any .php files, they were easy to clean. However, as WP is built on PHP, I have no idea what files are genuine and what are not.

    I need to clean the site but don’t know where to start. If necessary, I guess I could back up my files and reinstall WP, but that means knowing which files I need to copy off the server.

    Anyone able to help? Thanks

Viewing 9 replies - 1 through 9 (of 9 total)
  • If u have a backup, take it.
    If not, i see 2 possibilities:

    1. Make a fresh install. Copy your wp-config.php and your Customized (??) Theme; after checking for malicious changes.
    2. Try a diff between a set of original files and the compromised version and figure out any differences.

    You can download appropriate version of WordPress from WP archive and compare files.
    All folders except wp_content should be identical to the original sources.

    The most customizable directories are wp_content/plugins and wp_content/themes containing third-party code for WordPress customization.

    This code is not part of WP core package so it is better to install a free security plugin providing internal scan to locate malware in these directories.

    You can use our plugin providing heuristic internal scan or any other providing internal scan capabilities.

    Please note that apart of injected files the injected infection could also infect WordPress database.

    It is better to dump WP database and scan it as well. It is very important to identify infection source and block it otherwise your sites will constantly reinfected.

    Please be sure to make website backup before you doing any changes there or remove any files.

    Any missing file can break website integrity.

    Thanks to both of you for your replies.

    I have downloaded my full web site, and will backup the database, so I should have everything backed up. I was wondering about deleting everything from the server and doing a clean install. However, I’m not sure of a couple of points…

    1) What is the best way to copy back just what I need? As far as I can see from this page, most of my files will be in wp-content, so if I check that carefully, and then upload it to the newly installed web site, would that give me back all of my content? I would still need my config files, any idea which they are? Update: Just found wp-config.php in the web site’s root folder. I guess this is the config file? If so, is this the only one I need to copy back?

    2) @quttera – Please explain how the database could be infected. I don’t really want to have to dump that, so if there is a way to check, I’d like to do that. You mention scanning it, please can you explain how.

    Thanks again

    • This reply was modified 1 year, 4 months ago by Avrohom Yisroel Silver. Reason: Added note about finding wp-config.php

    Every WordPress setup uses mysql (or mariadb) to keep all internally used data like users, plugins configuration and options, posts and the rest.

    If attackers were able to inject PHP code into your file system they freely could access and change database content using WP database related PHP functions.

    If this is well known infection I guess every antivirus should detect it, if not, it is better to review content of posts and opinions tables to be sure you are not going to migrate infection to a fresh setup.

    @quttera – thanks for the explanation. Is there an automated tool to check the database? can I do it manually? I presumably I just need to search the Wp_posts table, and check the Post_content, Post_title and Post_excerpt columns for any injected PHP. Is that good enough?

    Any comments on my first question?

    Thanks again

    [Q] – Is there an automated tool to check the database?
    [A] – Try to review functionality of free available security plugins part of them scan database as well

    [Q] – can I do it manually?
    [A] – Yes, try to search for “<script”, eval, base64, passthru strings

    You can try to keep wp-content directory and wp-config.php and replace the rest.
    It should work

    @quttera – Thanks again. I’ll check out some security plug-ins and see what looks good.

    I checked the database and couldn’t find anything suspicious, so it looks good.

    Thanks again for the help.

    I found this FAQ. Maybe it helps.

    https://codex.wordpress.org/FAQ_My_site_was_hacked

    @danthefan – Thanks, that’s very useful

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Site hacked – How do I know which files are genuine and which are not?’ is closed to new replies.