How to Monitor WordPress File Changes and Detect Suspicious Website Activity

How to Monitor WordPress File Changes and Detect Suspicious Website Activity

Cyber attackers could use your WordPress site without any visible changes on your site to know that something wrong is going on. Attackers could make changes to your existing PHP files, could add their own script or could create an unauthorized admin account.

This is one of the many reasons why security on websites entails more than just installing a security plugin and upgrading your WordPress system. This is because you need to know what happens to your important files, who is who is accessing your site, and what goes on in the background.

WordPress file change monitoring can enable you to detect any unexpected changes before they become a real threat to your security. Also, monitoring site activity will make it easier for you to look into any suspicious activities that might be going on.

Reasons Why You Should Track File Changes in WordPress

WordPress uses certain files and directories for proper functioning. These include core files, plugins, themes, configuration files, and uploaded content. While some of these files tend to change while updating websites, others can change unexpectedly and point to a security risk.

For instance, after hacking into your website, a hacker can introduce malicious PHP code within the theme file you use. The malicious code can be used to gather sensitive information, take users to new websites, or give a different way of accessing your website in future.

Moreover, attackers can inject new files to the directories that are supposed to contain only images and uploads. They might change the configuration files and settings to reroute visitors and execute malicious code.

Otherwise, these issues will go undetected for quite some time. Thus, monitoring the WordPress files will help you:

  • Detect any unauthorized alterations: Look for any unexpected alterations of the files or directories.
  • Detect any malicious scripts: Detect any malicious code which attackers may plant into your legitimate website files.
  • Ensure your website’s operations: Look for any changes which may impact your website’s operations.
  • Be aware of security risks: Look into any unusual creation, removal, or modification of files.
  • Respond to threats earlier: Investigate suspicious activities before they cause further damage.

Though, keep in mind that just because a file has been changed does not mean that there has been any kind of cyber attack performed on your system. The key is to know what changes to expect, and detect those that you can’t figure out.

How to Monitor WordPress File Changes

There are several ways to monitor changes to your WordPress files. You can use security plugins, compare files with official versions or examine your website directories through your hosting control panel.

1. Install a WordPress Security Plugin with File Integrity Monitoring

The easiest way to check for changes to WordPress files is by using a security plugin that includes file integrity monitoring.

Plugins such as Wordfence and Sucuri Security can assist in detecting any suspicious file alterations and other security issues related to your website.

For example, Wordfence includes file integrity checks that compare WordPress core, plugin and theme files with their expected versions. Whenever there are inconsistencies, it is able to provide information about the affected files.

After installing a suitable security plugin, configure its scanning options to check important website files regularly. It is important to activate security alerts, so that in case there are any changes made on your site, you will be informed through such alerts.

However, you should note that not all notifications signify a malware. There could be a legitimate update to the plugin or a modification of your theme that triggers the notification. Analyze the concerned file to know whether this change was expected before doing anything about it.

2. Compare WordPress Core Files with Official Checksums

A similar approach includes comparing your WordPress core files with the officially released versions of WordPress.

Attackers often alter legitimate core files to embed some malicious codes in them.

Comparing your installation with official checksums can help identify unexpected changes.

In case you have access to WP-CLI, go to your WordPress installation folder and enter the following command:

  wp core verify-checksums

WP-CLI will compare your core WordPress installation files with the official checksums for the particular release. It can show files that are not matched by the expected version and files that are not available.

In case this command picks up an unanticipated difference, look into the file in question before restoring it. Keep in mind that this command checks WordPress core files, not every plugin, theme or custom file on your website. Thus, further measures will be required in order to check those elements.

3. Monitoring of Plugin and Theme Files Modifying

Plugins and themes are vital elements of your WordPress web site, but at the same time, these elements might serve as attack vectors if they have any security flaws.

If your web site gets compromised, an attacker can modify an already existing plugin or theme file rather than creating a new one. Such a method may make detection of anomalies rather difficult.

Therefore, pay attention to changes in important plugin and theme directories. You can always compare your current files to clean files from the developers themselves or from some other repository. Also, investigate unexpected changes to files such as functions.php, plugin entry files and other PHP scripts.

If you discover an unfamiliar modification, check whether it resulted from a recent update or a change made by someone authorised to manage the website.

When you establish that there is a plugin or theme that has been compromised, it is best to reinstall the unaltered version of that software. Do not just delete any line of code if you do not know how the component functions.

4. Track Changes in Important WordPress Directories

Monitoring important WordPress directories can help you identify where suspicious files appear. Be sure to look into the following directories:

  1. wp-admin: Includes files used for administration of WordPress. Any suspicious PHP files or modification to existing files should be investigated.
  2. wp-includes: Folder where critical WordPress core files and features are stored. Any unauthorized modifications in this folder can impact your site’s performance.
  3. wp-content: Contains your plugins, themes and uploaded media files. Attackers may target this directory because it holds several website components.
  4. wp-content/uploads: Normally stores uploaded images, documents and other media. Unexpected executable PHP files in this location should be investigated.
  5. wp-content/mu-plugins: Contains must-use plugins that load automatically. Strange files in this directory can bypass normal scans done via the standard plugins dashboard.

One can check out these folders either by using cPanel File Manager or any FTP or SFTP application. Check the names of files, last modified date and unexpected additions.

However, do not delete files simply because you do not recognise them. Some plugins and hosting services create files that may not be familiar to ordinary website owners. Ensure that you know what the function is before making any

5. Important Configuration Files in WordPress to Monitor

A special note should be made about configuration files, since these files could have been changed by the attacker in order to maintain their access or change the behavior of your website. For instance, wp-config.php contains important database connection details and other WordPress settings.

A hacker who modifies this file may inject some malicious code or even alter the behavior of the website.

Additional files you need to watch out for are:

  • .htaccess: This file may be altered by hackers to cause unauthorized redirections or strange rewrite rules.
  • .user.ini: Any modifications to this file might add PHP configurations and/or automatic inclusion of files.
  • functions.php: The file may have been injected with code and would be executed upon loading of the theme in WordPress.

Where possible, keep an up-to-date copy of your configuration file(s). It will help you find any anomalies when performing security audits on these files.

Also, lock down your configuration files by using proper permissions. Nevertheless, do not forget about compatibility with your hosting environment.

6. Use File Monitoring Tools Through Your Hosting Control Panel

Your hosting control panel can provide another way to monitor WordPress file activity.

For example, cPanel File Manager allows you to examine file modification dates, review directory contents and identify unfamiliar files. If your hosting company gives you an option to monitor changes to files or security alerts, you can take advantage of it.

You might also make use of SSH commands in order to check on the files and directories provided that your hosting package offers support for SSH. For example, the below command will list all the files which were updated in the past seven days:

     find . -type f -mtime -7

Execute it from the directory of your WordPress installation. This might help you find out the recently modified files, which need to be investigated.

However, it does not mean that any recent changes would suggest malicious behavior. There are various legitimate reasons for the modification of files such as updates of WordPress or installation of plugins. Check your maintenance logs and determine whether a file should be considered suspect.

How to Detect Suspicious WordPress Website Activity

File monitoring is only one part of website security. You should also examine activities involving user accounts, server requests and scheduled tasks.

1. Review WordPress Login Activity and Administrator Accounts

Unauthorised access is one of the ways attackers gain control of WordPress websites.

Begin by checking your administrator accounts from the Dashboard -> Users -> All Users section in WordPress. Search for any unknown usernames, accounts created recently and unusual changes in user role.

In addition, it is important to track the login activity using a security plug-in which logs successful and unsuccessful login attempts. Pay attention to repeated failed logins, unexpected administrator sessions and login activity that you cannot associate with authorised users.

In case you find out that there is some unauthorised account, try to find out how it was created, secure the website from any potential threat and delete it.

2. Website Access and Error Logs

Access and error logs in your hosting account could be useful in finding out more about interactions of your visitors with your website. Incoming requests are tracked by the access logs whereas the error logs give information about issues faced during the process of dealing with such requests.

These logs can be viewed through the hosting control panel or help from the hosting service provider can be sought for this purpose. Search for any odd requests made for PHP files that are unknown and access made for suspicious URLs.

Moreover, look into any errors caused by unknown scripts and files as they can show that some attacker is trying to run malicious code or enter restricted regions. Nevertheless, having an unknown IP address or a request failure doesn’t mean that somebody has hacked your website.

Before making any decisions, take note of the activities happening around you.

3. WordPress Cron Jobs for Suspicious Scheduled Activity

The WP-Cron of WordPress manages the scheduled activities including publishing of scheduled posts and update check.

Though the feature can support the functioning of websites, malicious hackers can misuse it to run their malicious scripts at set intervals.

You can inspect scheduled WordPress events using a plugin such as WP Crontrol. Go through any unusual occurrences, callbacks and activities that you cannot relate to any plugins installed or regular functionalities of the website.

Also look for server-side cron jobs using cPanel or SSH, if your web host gives you such options.

Look into any scheduled commands for running strange PHP scripts and files. In case you discover anything suspicious, locate the root of the problem and delete the scheduled job.

4. Monitor for Unusual Website Behavior

Often, unusual behavior of your website is a sign of suspicious activity.

For instance, visitors can be redirected to a different page, see strange ads, or pages that do not even belong on your website. In addition, the website may run unusually slowly as some scripts are using up server resources.

Keep an eye on your website for:

  • Redirects to unknown sites.
  • Spam pages or suspicious links.
  • Changes to website content without reason.
  • Frequent security warning alerts from monitoring software.

These do not necessarily mean that there is a security breach. However, they provide reasons to investigate your website and check for unauthorised changes.

What to Do When You Detect Suspicious WordPress File Changes

Finding an unfamiliar file or unexpected modification does not mean you should immediately delete it. Rather than that, look into the changes and see if it is a real security issue.

  1. Determine if the Changes are Valid or Malicious: Start by comparing the changed files against any recent site maintenance that you have done. This is because updates to the plugins can change multiple files, while theme modifications can change functions.php. Check your update history and ask other website administrators whether they made the changes. In case you do not know about an update, check the modified file against the clean version provided by the original developer of the software.
  2. Preservation of Information and Finding the Original Source: Prior to making modifications, preserve information which can help you understand what happened. Keep copies of suspicious files, along with their location and modification date. Also, keep logs of any security scans and accesses to them. This will enable you to determine how the attacker breached security and whether the vulnerability is present elsewhere within your hosting account.
  3. Eliminate the Malicious File and Reupload the Clean Version: Once you verify that there is some malicious code in a particular file, get rid of it. Replace compromised WordPress core files with clean versions from the official WordPress release. Likewise, reinstall any compromised plugins or themes that you use. In case of unauthorised user accounts, malicious database entries, and other suspicious scheduled tasks, take care of such problems. In case of severe infection, it is advisable to consult a WordPress security expert instead of taking steps that you do not understand.
  4. Secure Your Website Against Further Unauthorised Changes: Cleaning infected files is not enough if the original security weakness remains. Upgrade all your WordPress plugins and themes to the secure ones. Reset passwords for all admin accounts, including the hosting control panel account. Furthermore, enable two-factor authentication, remove unused plugins and themes, and review file and directory permissions. Make sure that you perform regular backups as this will give you a backup solution when another security breach happens.

Good Practices for Continuous Monitoring of Files and Activities on WordPress

Monitoring should be a continuous process in your website management strategy. The following actions will assist you in finding suspicious alterations more consistently.

  • Set Up File Change Notifications Automatically: Install a security plugin that will send notifications about any unexpected changes to your critical files. Configure alerts for WordPress core files, plugins, themes and sensitive configuration files.
  • Perform Frequent Security Checks: Keep records of plugin installations, theme updates, website customisations and other maintenance activities. Instead of overlooking repeated alerts and changes in files, investigate them.
  • Maintain a Record of Legitimate File Changes: Keep records of plugin installations, theme updates, website customisations and other maintenance activities. This will help you to differentiate between good changes and bad changes.
  • Restrict File Access and Assign Proper Permissions: Ensure that users and the website have only the access required by them. Assign proper file and directory permissions and do not use unnecessarily broad permissions like 777.
  • Maintain Backup for the Website: Take regular backups for your WordPress files and the database. Keep the copies safe and perform a restoration test to make sure that you can restore your website when needed.

Conclusion

By keeping track of WordPress file changes, logging in and server logs, you will be able to notice unauthorized changes before they evolve into any major security issues. Regular scanning, integrity checking and backup will help you to analyze any suspicious behavior on your website.

However, the detection of threats is just one aspect of site security. You should take care of the flaws that make it possible for an attacker to hack into your system. HarmonWeb provides reliable web hosting solutions designed to support website performance, stability and security. Explore our hosting plans for a dependable hosting environment.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply