{"id":1025,"date":"2018-09-13T11:17:25","date_gmt":"2018-09-13T10:17:25","guid":{"rendered":"http:\/\/www.greyhathacker.net\/?p=1025"},"modified":"2018-09-13T19:38:54","modified_gmt":"2018-09-13T18:38:54","slug":"exploiting-stopzilla-antimalware-arbitrary-write-vulnerability-using-secreatetokenprivilege","status":"publish","type":"post","link":"https:\/\/www.greyhathacker.net\/?p=1025","title":{"rendered":"Exploiting STOPzilla AntiMalware Arbitrary Write Vulnerability using SeCreateTokenPrivilege"},"content":{"rendered":"<p>A couple of months ago I discovered 9 kernel vulnerabilities a security product called STOPzilla AntiMalware. It\u2019s been over a month with no response from the vendor so I\u2019m going public with this one. All of the vulnerabilities stem from output buffer address not being validated apart from ioctl 80002028 where the size of the output buffer is not validated. The table below lists the ioctls, related CVE and type of vulnerability<\/p>\n<table style=\"height: 301px;\" width=\"586\">\n<tbody>\n<tr>\n<td width=\"185\"><strong>IOCTL<\/strong><\/td>\n<td width=\"163\"><strong>CVE ID<\/strong><\/td>\n<td width=\"189\"><strong>Vulnerability Type<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"185\">0x8000204B<\/td>\n<td width=\"163\">CVE-2018-15729<\/td>\n<td width=\"189\">Denial of Service<\/td>\n<\/tr>\n<tr>\n<td width=\"185\">0x80002067<\/td>\n<td width=\"163\">CVE-2018-15730<\/td>\n<td width=\"189\">Denial of Service<\/td>\n<\/tr>\n<tr>\n<td width=\"185\">0x8000205B<\/td>\n<td width=\"163\">CVE-2018-15731<\/td>\n<td width=\"189\">Denial of Service<\/td>\n<\/tr>\n<tr>\n<td width=\"185\">0x80002063 0x8000206F<\/td>\n<td width=\"163\">CVE-2018-15732<\/td>\n<td width=\"189\">Arbitrary Write<\/td>\n<\/tr>\n<tr>\n<td width=\"185\">0x80002028<\/td>\n<td width=\"163\">CVE-2018-15733<\/td>\n<td width=\"189\">Null pointer dereference<\/td>\n<\/tr>\n<tr>\n<td width=\"185\">0x8000206B<\/td>\n<td width=\"163\">CVE-2018-15734<\/td>\n<td width=\"189\">Arbitrary Write<\/td>\n<\/tr>\n<tr>\n<td width=\"185\">0x8000205F<\/td>\n<td width=\"163\">CVE-2018-15735<\/td>\n<td width=\"189\">Arbitrary Write<\/td>\n<\/tr>\n<tr>\n<td width=\"185\">0x8000204F<\/td>\n<td width=\"163\">CVE-2018-15736<\/td>\n<td width=\"189\">Denial of Service<\/td>\n<\/tr>\n<tr>\n<td width=\"185\">0x80002043<\/td>\n<td width=\"163\">CVE-2018-15737<\/td>\n<td width=\"189\">Denial of Service<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Here I&#8217;m exploiting the arbitrary write vulnerability (CVE-2018-15732) by overwriting the _SEP_TOKEN_PRIVILEGES structure to obtain the SeCreateTokenPrivilege privilege. Then it\u2019s just a matter of calling the ZwCreateToken API to create a new privileged token. The excellent paper &#8220;<a href=\"https:\/\/github.com\/hatRiot\/token-priv\/blob\/master\/abusing_token_eop_1.0.txt\" target=\"_blank\" rel=\"noopener\">Abusing Token Privileges For LPE<\/a>&#8221; and source code provided needed assistance in exploiting using this privilege.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"\/images\/80002063.png\" width=\"678\" height=\"409\" \/><\/p>\n<p>The &#8220;what&#8221; dword value starts with 1 and increments each time our ioctl is called so a number of writes needed to be done in order to obtain a useful privilege.\u00a0Normal privileges would look like this<\/p>\n<pre>kd&gt; dt nt!_SEP_TOKEN_PRIVILEGES fffff8a002f11060+40\r\n+0x000 Present          : 0x6`02880000\r\n+0x008 Enabled          : 0x800000\r\n+0x010 EnabledByDefault : 0x800000\r\n\r\nkd&gt; !token fffff8a002f11060\r\n.\r\n.\r\n19 0x000000013 SeShutdownPrivilege              Attributes - \r\n23 0x000000017 SeChangeNotifyPrivilege          Attributes - Enabled Default \r\n25 0x000000019 SeUndockPrivilege                Attributes - \r\n33 0x000000021 SeIncreaseWorkingSetPrivilege    Attributes - \r\n34 0x000000022 SeTimeZonePrivilege              Attributes - \r\n.\r\n.<\/pre>\n<p>After a few writes the SeCreateTokenPrivilege privilege has been obtained. This is one of the privileges received most of the time.<\/p>\n<pre>kd&gt; dt nt!_SEP_TOKEN_PRIVILEGES fffff8a002e61a90+40\r\n+0x000 Present          : 0x6`00000015\r\n+0x008 Enabled          : 0x16\r\n+0x010 EnabledByDefault : 0x800000\r\n\r\nkd&gt; !token fffff8a002e61a90\r\n.\r\n.\r\n00 0x000000000 Unknown Privilege                Attributes - \r\n02 0x000000002 SeCreateTokenPrivilege           Attributes - Enabled \r\n04 0x000000004 SeLockMemoryPrivilege            Attributes - Enabled \r\n33 0x000000021 SeIncreaseWorkingSetPrivilege    Attributes - \r\n34 0x000000022 SeTimeZonePrivilege              Attributes - \r\n.\r\n.<\/pre>\n<p>For Windows 7 I&#8217;ve spawned a shell by switching to session 0 by calling WinStationSwitchToServicesSession(). The Windows Service &#8220;Interactive Services Detection&#8221; (UI0Detect) is set to manual and not started to begin with but starts when WinStationSwitchToServicesSession() is called. The first instance a prompt will be given to switch sessions, thereafter will switch automatically as the service is already started.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium aligncenter\" src=\"\/images\/cve-2018-15732_shell-w7.png\" width=\"641\" height=\"363\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"\/images\/cve-2018-15732_inter-w7.png\" width=\"663\" height=\"603\" \/><\/p>\n<p>In Windows 10 (1803) the &#8220;Interactive Services Detection&#8221; service has been removed and doing a quick test on 1703 I realized the service can&#8217;t be started anyway so on Windows 10 I&#8217;m just adding the current user to the local administrators group.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-medium aligncenter\" src=\"\/images\/cve-2018-15732-w10.png\" width=\"657\" height=\"826\" \/><\/p>\n<p>The CreateProcessAsUser API doesn\u2019t always behave as expected as occasionally returns 1314 error which means &#8220;A required privilege is not held by the client&#8221;. Running the exploit a few times and it ends up working so not sure exactly what is really happening here. Trying to run the exploit in another user accounts shell i.e. not logging in with the account doesn\u2019t seem to work at all and always returns 1314 error so bear that in mind.<\/p>\n<p>UPDATE: I just figured out the reason behind the 1314 error, since the CreateProcessAsUser API is still being called by our current process token so after the arbitrary writes sometimes the &#8220;SeAssignPrimaryTokenPrivilege&#8221; privilege is also obtained along with the &#8220;SeCreateTokenPrivilege&#8221; allowing the exploit to work. So even when our elevated token is successfully created we&#8217;ll need an added privilege &#8220;SeAssignPrimaryTokenPrivilege&#8221; for the CreateProcessAsUser API to succeed.<\/p>\n<p>The current vulnerable version of STOPzilla AntiMalware is 6.5.2.59 of which the driver version szkg64.sys is 3.0.23.0. The exploit can be downloaded from here [<a href=\"https:\/\/www.greyhathacker.net\/docs\/cve-2018-15732.zip\" target=\"_blank\" rel=\"noopener\">zip<\/a>] and here is the direct link to the package on the StopZilla site if you wish to play with the exploit [<a href=\"https:\/\/download.stopzilla.com\/binaries\/stopzilla\/auto_installer\/STOPzillaAntiMalware.msi\" target=\"_blank\" rel=\"noopener\">msi<\/a>]<\/p>\n<p><a href=\"https:\/\/twitter.com\/parvezghh\" target=\"_blank\" rel=\"noopener\">@ParvezGHH<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple of months ago I discovered 9 kernel vulnerabilities a security product called STOPzilla AntiMalware. It\u2019s been over a month with no response from the vendor so I\u2019m going public with this one. All of the vulnerabilities stem from output buffer address not being validated apart from ioctl 80002028 where the size of the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,8,7,6],"tags":[21,46],"class_list":["post-1025","post","type-post","status-publish","format-standard","hentry","category-all","category-bugs","category-exploits","category-vulnerabilities","tag-elevate","tag-kernel"],"_links":{"self":[{"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/posts\/1025","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1025"}],"version-history":[{"count":7,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/posts\/1025\/revisions"}],"predecessor-version":[{"id":1032,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/posts\/1025\/revisions\/1032"}],"wp:attachment":[{"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1025"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1025"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1025"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}