Home > Blogs, Tech, Wordpress > WordPress Hacked – eval base64_decode _SERVER[HTTP_REFERER]

WordPress Hacked – eval base64_decode _SERVER[HTTP_REFERER]

September 4th, 2009 Leave a comment Go to comments

if your wordpress links not working, is redirected or url have this text:

eval(base64_decode($_SERVER[HTTP_REFERER]))

your WordPress Has Been Hacked! Malicious codes, especially those that interpreted with eval() or base64_decode() command been inserted into WordPress PHP files or in database.

Solution for nasty url (MySQL Injection) in Wp 2.8.*:

Use phpMyAdmin to browse WordPress MySQL database tables. Go to wp_options table,

  • empty the row named _transient_rewrite_rules
  • edit the row named permalink_structure –>

remove this text: &({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&

example content before

/%year%/%monthnum%/%day%/%postname%/%&({${eval(base64_decode($_SERVER[HTTP_REFERER]))}}|.+)&%/

example content after

/%year%/%monthnum%/%day%/%postname%/

… must replace with real permailk for your site.

Note: Wordpress Permalink Structure can be modified from options permalink config page: http://your-site/wp-admin/options-permalink.php (must replace with real permailk for your site)

from ssh , use grep and search for particular strings in all database from server :

grep -H -r “eval(base64_decode” /var/lib/mysql
grep -H -r “var setUserName = function” /var/lib/mysql

-> result:

[root@ip-server1 mysql]# grep -H -r “var setUserName = function” /var/lib/mysql
grep: /var/lib/mysql/mysql.sock: No such device or address
Binary file /var/lib/mysql/database1/wp_usermeta.MYD matches
Binary file /var/lib/mysql/database2/wp_usermeta.MYD matches
Binary file /var/lib/mysql/databae3/wp_usermeta.MYD matches

where infected database is:  database1, database2, database3

from phpMyAdmin, search string “var setUserName = function” in all infected database and

  1. remember all “user_id” value from wp_usermeta table where meta_key = “first_name”
  2. from wp_users table remove all user with ID = user_id
  3. remove row from wp_usermeta table where meta_key = “first_name”.
  1. October 18th, 2009 at 23:26 | #1

    Once they have your username and password, they can log on any time they wish and upload and download files. Url Cloaking

  2. September 12th, 2009 at 01:30 | #2

    so I went on phpmyadmin and went to wp_option.. but there is absolutely NO table called _transient_rewrite_rules

    there are other transient rss and stuff like that..

  3. September 6th, 2009 at 18:41 | #3

    @samelody
    I think instead of 3. remove all meta with user_id found at point 1. is the right thing

  4. September 5th, 2009 at 14:06 | #4

    remove all users with administration rights except your user ;)

  5. September 5th, 2009 at 08:47 | #5

    Thanks. but I think it need not to delete all user with ID=userid, only remove the ID that meta_key include “var setUserName = function” in wp_usermeta table.

  6. September 5th, 2009 at 02:50 | #6

    i d’nt know … is “secure” until the next infection :D !

  7. ann
    September 5th, 2009 at 02:45 | #7

    10x … save my life

  8. September 5th, 2009 at 00:44 | #8

    HUGE THANKS!!! I used this to fix my site and am now going to fix all of my other client sites. After upgrading to 2.8.4 the vulnerability that allowed this hack has been fixed, correct?

  1. September 5th, 2009 at 04:52 | #1
  2. September 5th, 2009 at 14:08 | #2
  3. September 6th, 2009 at 16:58 | #3
  4. September 7th, 2009 at 03:10 | #4
GoCache - ByREV-Cache v1.0 - live served in : 0.183702 sec (gzip)