Sorry to hear about the hack — I tested the code you linked to, and Wordfence should find it if a scan was able to complete, but since the scan had stopped, that was probably the reason the notices did not come out.
If you still have it, can you send me a copy of the file mentioned in the error: /wp-content/plugins/wordfence/lib/wfDict.php ? In the current version of Wordfence, there is not a preg_replace, so that file may have been affected as well. My email is mattr (at) wordfence.com
I will take a look at the “empty data response” warning, as well.
To help clean up the hack, I would suggest removing and reinstalling Wordfence to make sure you have a clean copy, and then following the guide here:
How do I clean my hacked site using Wordfence
I’m not sure what the source of the hack might be if all plugins and WordPress itself are up to date. It could be that one of the plugins has a newly discovered security problem that has not been fixed, or some of the site’s passwords (FTP, hosting account, etc.)
If you have trouble getting Wordfence running again or other questions on the cleanup, let us know here.
-Matt R
Hi Matt,
thanks for your quick reply!
Yes, I’m sure /wp-content/plugins/wordfence/lib/wfDict.php was affected as well, since in our debug.log there’s huge amount of error messages like that, each referring to different php files. So it’s the hacker code which is causing the error message in the first place. I’m sorry I don’t have the affected file anymore, since I cleaned the whole site.
I forgot to mention one plugin which was also installed: WP Retina 2x. That was not activated though.
Here’s more detailed timeline if it helps:
– Sat 10.10. at 12:11: I receive an email from WordFence that someone signed in with the username “backup”. Before that there was no such username. (I didn’t check my email on saturday which I regret…)
– Sat 10.10. at 15:48: Wordfence reports that the username “backup” signs in for the second time.
– Sat 10.10. at 16:00: Wordfence completes the scan. Everything’s ok.
– Sat 10.10. at 17:32: First error in our debug.log (debug happens to be on, accidentally). This is caused by the code which the hacker has added in almost every wordpress php file. It looks like this “Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in …/wp-content/…*filename*.php on line 1”
– Sun 11.10. at 01:06: Wordfence starts to scan, but stops with the error message “Scan terminated with error: We received an empty data response from the Wordfence scanning servers when calling the ‘is_safe_file’ function”.
– Sun 11.10. I realize that the site has been hacked and find the code in almost every php file. In addition to this, I find a new folder in wp-content/upgrade/, named “small.jpg”. It’s empty.
Thanks for the additional details. Since the first thing you noticed was the new “backup” user logging in, that might mean that someone was able to get into the database directly to add the user without going through WordPress — if you haven’t changed the database password already, that is definitely recommended.
-Matt R
Hey Matt, about 20 of my sites got hit with this a couple days ago, along with the ‘backup’ user being installed in all our WP sites across all the mysql db’s.
Could this have been the culprit?
https://blog.sucuri.net/2015/10/security-advisory-stored-xss-in-akismet-wordpress-plugin.html
I haven’t seen that method used to create a user, but it could be possible if you use Akismet and haven’t updated it yet. I would start by making sure all plugins, themes, and WordPress are up to date on all of the sites — if any of the sites are using the same hosting account or database user, it could be any one of them that had been hacked, which could cross-infect the others.
We have a guide to cleaning hacked sites, here, with a lot of good recommendations:
How do I clean my hacked site using Wordfence?
-Matt R
Hi,
I can confirm that on our site commenting and “Convert emoticons like 🙂 and 😛 to graphics on display” was enabled. So theoretically Akismet could have been the culprit.
EDIT: Sorry, Akismet was disabled. So Akismet WAS NOT the culprit. 🙂
Ok, thanks for the follow-up. Were you able to get the site cleaned up from the initial problem above?
-Matt R
Yes, it looks like it’s clean. I made a “high sensitivity” scanning with Wordfence and the report says everything’s fine. I’m also looking for other ways to make wp more secure. Apparently 2-step verifications (like https://wordpress.org/plugins/miniorange-2-factor-authentication/) are not very widely used, but maybe that could add one more security layer?
Yes, two-factor authentication can help in many cases, but not all.
Wordfence’s premium version does have two-factor authentication options, and other features that may help. More details are at wordfence.com — if you have questions on the premium version, you can email presales (at) wordfence.com since the forum rules don’t allow us to support premium features here.
-Matt R