{"id":807,"date":"2017-02-27T18:57:00","date_gmt":"2017-02-27T18:57:00","guid":{"rendered":""},"modified":"2018-06-20T00:38:39","modified_gmt":"2018-06-19T22:38:39","slug":"training-teaser-windows-applocker-bypass","status":"publish","type":"post","link":"https:\/\/archive.brucon.org\/2018\/2017\/02\/27\/training-teaser-windows-applocker-bypass\/","title":{"rendered":"Training Teaser &#8211; Windows AppLocker bypass"},"content":{"rendered":"<p>In this short teaser, we want to demonstate a simple AppLocker bypass. AppLocker, which will be the main focus of the \u2018<i>Windows Breakout<\/i>\u2019 (Day 1) section of the BruCON\u00a0<a href=\"http:\/\/2017.brucon.org\/index.php\/Spring_Training_2017_-_Windows_Breakout_and_Privilege_Escalation\" target=\"_blank\" rel=\"noopener\" class=\"broken_link\">spring training<\/a>, is the <i>de-facto <\/i>standard for locking down Windows machines in an enterprise environment.<\/p>\n<p>It is the successor to SRP (Software Restriction Policies) and allows definition of fine-grained rules to allow or deny execution based on the path, file hash or publisher of the executable or script.<br \/>\nFor this post, let us consider a scenario where the system administrator of a company has deployed the following AppLocker rules on all company machines through Group Policy:<\/p>\n<div style=\"clear: both;text-align: center\"><a style=\"margin-left: 1em;margin-right: 1em\" href=\"https:\/\/www-new.brucon.org\/2018\/wp-content\/uploads\/sites\/16\/2017\/02\/1.jpg\" class=\"broken_link\"><img src=\"https:\/\/www-new.brucon.org\/2018\/wp-content\/uploads\/sites\/16\/2017\/02\/1.jpg\" border=\"0\" \/><\/a><\/div>\n<p>&nbsp;<\/p>\n<div style=\"clear: both;text-align: center\"><\/div>\n<p>The executable rules permit Administrators to run anything, while users which are part of the &#8216;<i>Employees<\/i>&#8216; group are only allowed to run Microsoft signed binaries, with a few exceptions.<\/p>\n<p>The explicitly-blocked binaries are the usual suspects; each of them would allow users to run arbitrary commands on their corporate machine if not blocked by AppLocker. The training course will go into detail on how to attaining code execution through <i>regsvr32, rundll32 <\/i>and <i>InstallUtil.<\/i><br \/>\nThe aim of this exercise is to run <i>PowerShell <\/i>and subsequently launch any binary on this box, such as a Meterpreter reverse shell.<\/p>\n<p>Trying to run PowerShell directly is a no go:<\/p>\n<div style=\"clear: both;text-align: center\"><a style=\"margin-left: 1em;margin-right: 1em\" href=\"https:\/\/www-new.brucon.org\/2018\/wp-content\/uploads\/sites\/16\/2017\/02\/2.jpg\" class=\"broken_link\"><img src=\"https:\/\/www-new.brucon.org\/2018\/wp-content\/uploads\/sites\/16\/2017\/02\/2.jpg\" border=\"0\" \/><\/a><\/div>\n<div style=\"clear: both;text-align: center\"><\/div>\n<div style=\"clear: both;text-align: left\">Even though the publisher information matches an &#8216;<i>Allow<\/i>&#8216; rule in AppLocker, it is explicitly denied by path. &#8216;<i>Explicit Deny<\/i>&#8216; takes precedence over &#8216;<i>Explicitly Allow<\/i>&#8216; in AppLocker.<\/div>\n<div style=\"clear: both;text-align: left\"><\/div>\n<div style=\"clear: both;text-align: left\">If we look closer at the rules, we can see that the offending rule is applied on the path of the binary and hence moving it to another location, such as the Desktop, would invalidate the rule and allow execution:<\/div>\n<div style=\"clear: both;text-align: center\"><a style=\"margin-left: 1em;margin-right: 1em\" href=\"https:\/\/www-new.brucon.org\/2018\/wp-content\/uploads\/sites\/16\/2017\/02\/3.jpg\" class=\"broken_link\"><img src=\"https:\/\/www-new.brucon.org\/2018\/wp-content\/uploads\/sites\/16\/2017\/02\/3.jpg\" border=\"0\" \/><\/a><\/div>\n<div style=\"clear: both;text-align: center\"><\/div>\n<div style=\"clear: both;text-align: left\">Easy right? The next step is to run any executable with the help of Powershell. At this point we could either beg Microsoft to sign our Meterpreter reverse shell or use the<i> Invoke-ReflectivePEInjection<\/i> PowerShell script, which is part of PowerSploit, to reflectively load our executable in memory and execute it that way.<\/div>\n<div style=\"clear: both;text-align: left\"><\/div>\n<div style=\"clear: both;text-align: left\">This time we&#8217;ll go for the latter. Transfer the Meterpreter reverse shell to the box and run the following commands:<\/div>\n<div style=\"clear: both;text-align: left\"><\/div>\n<div style=\"clear: both;text-align: center\"><a style=\"margin-left: 1em;margin-right: 1em\" href=\"https:\/\/www-new.brucon.org\/2018\/wp-content\/uploads\/sites\/16\/2017\/02\/4.jpg\" class=\"broken_link\"><img src=\"https:\/\/www-new.brucon.org\/2018\/wp-content\/uploads\/sites\/16\/2017\/02\/4.jpg\" border=\"0\" \/><\/a><\/div>\n<div style=\"clear: both;text-align: center\"><\/div>\n<div style=\"clear: both;text-align: left\">The result is a complete bypass of this AppLocker policy:<\/div>\n<div style=\"clear: both;text-align: left\"><\/div>\n<div style=\"clear: both;text-align: center\"><a style=\"margin-left: 1em;margin-right: 1em\" href=\"https:\/\/www-new.brucon.org\/2018\/wp-content\/uploads\/sites\/16\/2017\/02\/5.jpg\" class=\"broken_link\"><img src=\"https:\/\/www-new.brucon.org\/2018\/wp-content\/uploads\/sites\/16\/2017\/02\/5.jpg\" border=\"0\" \/><\/a><\/div>\n<div style=\"clear: both;text-align: center\"><\/div>\n<div style=\"clear: both;text-align: center\"><\/div>\n<div style=\"clear: both;text-align: left\">This is just a taste of what we&#8217;ll be covering during the &#8216;<i>Windows Breakout<\/i>&#8216; section of this 3-day training course.<\/div>\n<div style=\"clear: both;text-align: left\"><\/div>\n<div style=\"clear: both;text-align: left\">In addition to this we&#8217;ll be going through <i>Windows Privilege Escalation and UAC Bypasses<\/i>. For a more complete overview as well as registration information, please visit this <a href=\"http:\/\/2017.brucon.org\/index.php\/Spring_Training_2017_-_Windows_Breakout_and_Privilege_Escalation.\" target=\"_blank\" rel=\"noopener\" class=\"broken_link\">page<\/a><\/div>\n<div style=\"clear: both;text-align: left\"><\/div>\n<div style=\"clear: both;text-align: left\">BruCON Spring Training is hosted on 19,20 and 21 April 2017 at the Novotel Ghent Centrum in Belgium. \u00a0<a href=\"http:\/\/2017.brucon.org\/\" target=\"_blank\" rel=\"noopener\" class=\"broken_link\">http:\/\/2017.brucon.org<\/a><\/div>\n<div style=\"clear: both;text-align: left\"><\/div>\n<div style=\"clear: both;text-align: left\">See you there!!<\/div>\n<div style=\"text-align: center\"><\/div>\n<div style=\"clear: both;text-align: left\"><\/div>\n<div style=\"clear: both;text-align: left\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this short teaser, we want to demonstate a simple AppLocker bypass. AppLocker, which will be the main focus of the \u2018Windows Breakout\u2019 (Day 1) section of the BruCON\u00a0spring training, is the de-facto standard for locking down Windows machines in an enterprise environment. It is the successor to SRP (Software Restriction Policies) and allows definition of fine-grained rules to allow or deny execution based on the path, file hash or publisher of the executable or&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1008,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":{"0":"post-807","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-uncategorized"},"menu_order":0,"_links":{"self":[{"href":"https:\/\/archive.brucon.org\/2018\/wp-json\/wp\/v2\/posts\/807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archive.brucon.org\/2018\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archive.brucon.org\/2018\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archive.brucon.org\/2018\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/archive.brucon.org\/2018\/wp-json\/wp\/v2\/comments?post=807"}],"version-history":[{"count":2,"href":"https:\/\/archive.brucon.org\/2018\/wp-json\/wp\/v2\/posts\/807\/revisions"}],"predecessor-version":[{"id":1458,"href":"https:\/\/archive.brucon.org\/2018\/wp-json\/wp\/v2\/posts\/807\/revisions\/1458"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/archive.brucon.org\/2018\/wp-json\/wp\/v2\/media\/1008"}],"wp:attachment":[{"href":"https:\/\/archive.brucon.org\/2018\/wp-json\/wp\/v2\/media?parent=807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archive.brucon.org\/2018\/wp-json\/wp\/v2\/categories?post=807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archive.brucon.org\/2018\/wp-json\/wp\/v2\/tags?post=807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}