{"id":4118,"date":"2017-01-27T00:13:40","date_gmt":"2017-01-27T00:13:40","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=4118"},"modified":"2017-01-27T00:24:28","modified_gmt":"2017-01-27T00:24:28","slug":"beyond-good-ol-run-key-part-57","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2017\/01\/27\/beyond-good-ol-run-key-part-57\/","title":{"rendered":"Beyond good ol\u2019 Run key, Part 57"},"content":{"rendered":"<p>The best persistence mechanisms are these that are well documented. They work perfectly and are often compatible with many versions of Windows. Here&#8217;s a story of one.<\/p>\n<p>According to Microsoft&#8217;s page, the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/aa387021(v=vs.85).aspx\">OffloadModExpo<\/a> function offloads modular exponentiation from a CSP to a hardware accelerator.<\/p>\n<p>We don&#8217;t really care too much what it means other than it has something to do with the crypto**, and that the function is exported by a plug-in-like DLL that is loaded from the path specified in the following location:<\/p>\n<pre>HKLM\\Software\\Microsoft\\Cryptography\\\r\nOffload\\ExpoOffload = DLL Path<\/pre>\n<p>Yup. It&#8217;s that simple.<\/p>\n<p>Add the key, add the DLL. It doesn&#8217;t even need to export the OffloadModExpo function.<\/p>\n<p>The only question remaining is when.<\/p>\n<p>The answer is &#8211; pretty much all the time.<\/p>\n<p>The library is loaded by either dssenh.dll, or rsaenh.dll and these libraries provide crypto services to pretty much any possible software running on Windows. At some stage it&#8217;s loaded by svchost.exe, iexplore.exe (f.ex. when you visit https:\/\/ page), mscorsvw.exe, taskhostw.exe, sdiagnhost.exe and other processes.<\/p>\n<p>Here&#8217;s an example log from promcon immediately after I added the .reg file that installs a rogue DLL (soon after more processes pick it up):<\/p>\n<p><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/offload1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-4119\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/offload1-300x223.png\" width=\"500\" height=\"372\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/offload1-300x223.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/offload1.png 535w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a>and the debug view log confirming the loading:<\/p>\n<p><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/offload2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-4120\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/offload2-300x181.png\" alt=\"\" width=\"300\" height=\"181\" srcset=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/offload2-300x181.png 300w, https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2017\/01\/offload2.png 486w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>**Bonus:<\/p>\n<p>Last, but not least &#8211; the very same thing was described in <a href=\"http:\/\/www.securiteam.com\/windowsntfocus\/5WQ0E000EY.html\">2000<\/a> as a vulnerability; apparently the DLL will receive all the private keys used by the Crypto API \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The best persistence mechanisms are these that are well documented. They work perfectly and are often compatible with many versions of Windows. Here&#8217;s a story of one. According to Microsoft&#8217;s page, the OffloadModExpo function offloads modular exponentiation from a CSP &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2017\/01\/27\/beyond-good-ol-run-key-part-57\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,35,15,19,46,9],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/4118"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=4118"}],"version-history":[{"count":4,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/4118\/revisions"}],"predecessor-version":[{"id":4124,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/4118\/revisions\/4124"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=4118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=4118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=4118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}