This article is originally stored as a github gist.
See here how to disable dontkinhooot.tw malware from a WordPress site manually. Use the instructions below to fix your site temporarily. Then proceed to rebuild your site in an updated WordPress instance. This guide won’t guarantee there won’t be reinfection.
This malware didn’t damage the site or stole data. It redirects the visitor to another site, probably to make money from affiliation programs.
I did not identify any injection in database entries, just js
files and a
malicious plugin (php
files).
Observed symptoms
- The site takes a long time to load.
- Few seconds after loading, the site automatically redirects to another site, completely unrelated.
- In the network tab of the browser, there are lots of calls to wp-admin/new-user.php.
- A call is made to the domain dontkinhooot.tw, which does a 302 redirect to another site.
Backup your files first
First of all, make a backup of the WordPress files folder (usually www
or
public_html
in most hosting services), just in case things go wrong:
|
|
Cleaning Javascript files
The malware injects the code below at the begin of all Javascript files (2256 characters). This is what causes the site to get insanely slow.
|
|
Option 1: clean JS using a script
You need to find all infected files and remove the injected stuff. You may use
the script antivi.sh
in this gist for this task (find below). You have to
run it inside the WordPress folder (in most cases www
or public_html
).
antivi.sh
: check how many files are infectedantivi.sh list
: list infected files namesantivi.sh clean
: clean up javascript files - backup your stuff before using it!!!!
Use this script at your own risk.
Option 2: clean JS files yourself
You need to chose a piece of the malware as footprint (
String.fromCharCode(115,99,114,105,112,116)
in this case) and find all files
that have it.
|
|
Once you know the infected files, you can loop through them and remove the first bytes (up to the malware lenght). For some reason, eventhough this malware lenght is 2256, I had to cut 2257 bytes, not sure why.
|
|
The malware seta a 777
access mode to all files. As a temporary solution,
make all js files read-only (to keep the malware from re-injecting into them)
and remove “write” and “execute” permission to “others”:
|
|
Deactivating the malicious plugin
After removing the piece injected in JS files, the redirection continued to happen.
The malware was also installed as a malicious plugin. There is no script to fix this, you just need to disable the plugin execution. Removing the plugin folder completely may break WordPress execution.
One obfuscation technique used by this malware was concatenating characters using their ASCII code.
A search for ).chr(
, revealed the file
wp-content/plugins/wp-strongs/wp-strongs.php
(you can find it below).
Comment out the call to the start()
function to disable it:
|
|
Clean your visitor’s cache
If you use any caching mechanism in WordPress, disable it, since the cached content may be infected.
Those who saw the infected version of the site will have the infected version of
JS files cached locally. To force visitors to clean their caches, add the
following line to the file index.php
of WordPress' root folder
(the site entry point), right after the <?php
tag.
|
|
Some reference links of extended analysis for this malware
- https://www.joesandbox.com/analysis/356196/0/html
- https://guides.magefix.com/2021/02/clean-chr-malware-dontkinhooot-tw/
Attachments
antivi.sh
|
|
malware-01 injectedjs_unminified.js
|
|
malware-02 injectedjs_unminified_deobfuscated.js
|
|
malware-03 remotefile_stat.js
|
|
malware-04 wp-strongs_original.php
|
|
malware-05 wp-strongs_deobfuscated_strings.php
|
|