{"id":6950,"date":"2020-02-02T01:15:50","date_gmt":"2020-02-02T01:15:50","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=6950"},"modified":"2020-02-02T01:27:55","modified_gmt":"2020-02-02T01:27:55","slug":"settingsynchost-exe-as-a-lolbin","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2020\/02\/02\/settingsynchost-exe-as-a-lolbin\/","title":{"rendered":"SettingSyncHost.exe as a LolBin"},"content":{"rendered":"\n<p>This native OS binary has two interesting options:<\/p>\n\n\n\n<ul><li>-LoadAndRunDiagScript &lt;name&gt;<\/li><li>-LoadAndRunDiagScriptNoCab &lt;name&gt;<\/li><\/ul>\n\n\n\n<p>When executed with these options, it will extract the .bat file stored inside its resources, save it as %TEMP%\\RoamDiag.cmd, and then it will execute it.<\/p>\n\n\n\n<p>There are at least two ways we can exploit it.<\/p>\n\n\n\n<p>We can create our own %TEMP%\\RoamDiag.cmd and make the SettingSyncHost.exe execute it, but there is a caveat. The .cmd file is always deleted and issues with that will stop program from working. Still, we could try a race condition approach i.e. run SettingSyncHost.exe with the parameters specified while at the same time we could run a batch file that overwrites  %TEMP%\\RoamDiag.cmd  with a content of our choice in a never ending loop. This could work, but I have not tested it.<\/p>\n\n\n\n<p>Why?<\/p>\n\n\n\n<p>Because there is an easier way. The batch file extracted from resources of  SettingSyncHost.exe and saved as %TEMP%\\RoamDiag.cmd executes a number of OS programs including:<\/p>\n\n\n\n<ul><li>wevtutil<\/li><li>makecab<\/li><li>reg<\/li><li>ipconfig<\/li><li>settingsynchost.exe<\/li><li>tracelog<\/li><\/ul>\n\n\n\n<p>These programs are executed w\/o specifying a full path, and in most of cases &#8211; not even file extensions. So&#8230; we can literally create a malicious file named like any of these 6, drop them inside the %TEMP% directory (including settingsynchost.exe !) and launch them using the following syntax:<\/p>\n\n\n\n<p>cd %TEMP% &amp; c:\\windows\\system32\\SettingSyncHost.exe -LoadAndRunDiagScript foo<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/02\/SettingSyncHost-1.gif\"><img decoding=\"async\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2020\/02\/SettingSyncHost-1.gif\" alt=\"\" class=\"wp-image-6954\" width=\"500\"\/><\/a><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>This native OS binary has two interesting options: -LoadAndRunDiagScript &lt;name&gt; -LoadAndRunDiagScriptNoCab &lt;name&gt; When executed with these options, it will extract the .bat file stored inside its resources, save it as %TEMP%\\RoamDiag.cmd, and then it will execute it. There are at &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2020\/02\/02\/settingsynchost-exe-as-a-lolbin\/\">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":[56,64,1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6950"}],"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=6950"}],"version-history":[{"count":5,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6950\/revisions"}],"predecessor-version":[{"id":6957,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6950\/revisions\/6957"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=6950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=6950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=6950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}