{"id":199,"date":"2018-07-02T11:11:25","date_gmt":"2018-07-02T10:11:25","guid":{"rendered":"https:\/\/cybercop-training.ch\/?p=199"},"modified":"2018-07-06T22:05:35","modified_gmt":"2018-07-06T21:05:35","slug":"auditing-permissions","status":"publish","type":"post","link":"https:\/\/cybercop-training.ch\/?p=199","title":{"rendered":"Auditing permissions"},"content":{"rendered":"<p>Inspired by the CQURE <a href=\"https:\/\/cqureacademy.com\/challenge\" target=\"_blank\" rel=\"noopener\">5 day challenge<\/a> I&#8217;ve decided to document some of the things that I&#8217;ve learned from the daily assesments. \ud83d\ude42<\/p>\n<p>Table of Content<\/p>\n<ul>\n<li><a href=\"https:\/\/cybercop-training.ch\/?p=164\" target=\"_blank\" rel=\"noopener\">Analyze a Windows Service<\/a><\/li>\n<li><strong>Auditing permissions<\/strong><\/li>\n<li><a href=\"https:\/\/cybercop-training.ch\/?p=181\" target=\"_blank\" rel=\"noopener\">About handles and the SAM file<\/a><\/li>\n<li><a href=\"https:\/\/cybercop-training.ch\/?p=213\" target=\"_blank\" rel=\"noopener\">Password Hashes<\/a><\/li>\n<li><a href=\"https:\/\/cybercop-training.ch\/?p=253\" target=\"_blank\" rel=\"noopener\">Memory Dump<\/a><\/li>\n<\/ul>\n<p>There are some command line tools in windows to check permissions. In the case above we have a file called <strong>will_Guest_read_it.txt<\/strong> with both flags &#171;Full Access&#187; and &#171;Denied&#187; set on it. That&#8217;s a strange case, but possible indeed. And that lead us to the question which permission is stronger?<\/p>\n<p>By typing the following command we get the SDDL of the File:<\/p>\n<p><code>get-acl \"Filepath\" |fl<\/code><\/p>\n<p>sddl: (<strong>A<\/strong>;ID;FA;;;LG) (<strong>D<\/strong>;ID;FA;;;LG)<\/p>\n<p><code>A= Allow<\/code><br \/>\n<code>D= Denied<\/code><br \/>\n<code>FA= Full Access<\/code><br \/>\n<code>LG= Guest Account<\/code><\/p>\n<p>Another command to read out file permissions is:<\/p>\n<p><code>icacls \"Filepath\"<\/code><\/p>\n<p><code>(I)(F) Full Access<\/code><br \/>\n<code>(I)(N) No (Denied)<\/code><\/p>\n<p>In that case <strong>Allow Full Access wins<\/strong>, because windows goes allways top down in ACL and Full Access comes first!<\/p>\n<p><a href=\"https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-200 size-large\" src=\"https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_1-1024x616.png\" alt=\"\" width=\"1024\" height=\"616\" srcset=\"https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_1-1024x616.png 1024w, https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_1-300x181.png 300w, https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_1-768x462.png 768w, https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_1.png 1444w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>Another cool thing is to get the numeric values of system rights.<\/p>\n<p><code>[system.enum]::getnames([System.Security.AccessControl.FileSystemRights])<br \/>\n[int]([System.Security.Accesscontrol.FileSystemRights]::write)<br \/>\n[int]([System.Security.Accesscontrol.FileSystemRights]::read)<\/code><\/p>\n<p>The powershell code below outputs all possible values:<\/p>\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"powershell keyword\">foreach<\/code> <code class=\"powershell plain\">(<\/code><code class=\"powershell variable\">$right<\/code> <code class=\"powershell keyword\">in<\/code> <code class=\"powershell constants\">[System.Enum]<\/code><code class=\"powershell plain\">::GetNames(<\/code><code class=\"powershell constants\">[System.Security.AccessControl.FileSystemRights]<\/code><code class=\"powershell plain\">)) {<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"powershell variable\">$intValue<\/code> <code class=\"powershell plain\">= <\/code><code class=\"powershell constants\">[int]<\/code><code class=\"powershell plain\">(<\/code><code class=\"powershell constants\">[System.Security.AccessControl.FileSystemRights]<\/code><code class=\"powershell variable\">$right<\/code><code class=\"powershell plain\">)<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"powershell functions\">Write-Host<\/code> <code class=\"powershell plain\">(<\/code><code class=\"powershell string\">\"{0,-30} : {1}\"<\/code> <code class=\"powershell operator value\">-f<\/code> <code class=\"powershell variable\">$right<\/code><code class=\"powershell plain\">, <\/code><code class=\"powershell variable\">$intValue<\/code><code class=\"powershell plain\">)<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"powershell plain\">}<\/code><\/div>\n<\/div>\n<div><\/div>\n<div><a href=\"https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-206 size-large\" src=\"https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_2-1024x365.png\" alt=\"\" width=\"1024\" height=\"365\" srcset=\"https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_2-1024x365.png 1024w, https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_2-300x107.png 300w, https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_2-768x274.png 768w, https:\/\/cybercop-training.ch\/wp-content\/uploads\/2018\/07\/2_2.png 1126w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/div>\n<div><\/div>\n<div>A good start for auditing permissions can be to work with the following command:<\/div>\n<div><\/div>\n<div><code>Get-Acl \"Folderpath\" | Select-Object -ExpandProperty Access<\/code><\/div>\n<p>Some repeating questions:<\/p>\n<p><strong>Which OS command allows you to work with file permissions in Windows10?<\/strong><br \/>\nicalcs.exe<\/p>\n<p><strong>Can one file have both deny and allow entry for the same user\/group on the Access Control list?<\/strong><br \/>\n<em>Yes with &#171;Advanced&#187; tab of &#171;File properties&#187; dialog box in graphical interface. &#8211;&gt; wrong<\/em><br \/>\nYes, however it is not easy to make this from graphical userinterface<\/p>\n<p><strong>What happens to a file when it has &#171;allow&#187; and &#171;deny&#187; for the same group of ACL?<\/strong><br \/>\nit depends for the order of ACE in ACL<\/p>\n<p><strong>How can you set file permissions from Powershell?<\/strong><br \/>\nSet-ACL<\/p>\n<p><strong>Do Registry hives have permissions (ACLs)?<\/strong><br \/>\n<em>Yes with the same rights as files and folders &#8211;&gt;wrong<\/em><br \/>\nYes, but with rights different than files and folders<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Inspired by the CQURE 5 day challenge I&#8217;ve decided to document some of the things that I&#8217;ve learned from the daily assesments. \ud83d\ude42 Table of <a class=\"mh-excerpt-more\" href=\"https:\/\/cybercop-training.ch\/?p=199\" title=\"Auditing permissions\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":2,"featured_media":208,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-199","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-windows-security"],"_links":{"self":[{"href":"https:\/\/cybercop-training.ch\/index.php?rest_route=\/wp\/v2\/posts\/199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cybercop-training.ch\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cybercop-training.ch\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cybercop-training.ch\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/cybercop-training.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=199"}],"version-history":[{"count":8,"href":"https:\/\/cybercop-training.ch\/index.php?rest_route=\/wp\/v2\/posts\/199\/revisions"}],"predecessor-version":[{"id":270,"href":"https:\/\/cybercop-training.ch\/index.php?rest_route=\/wp\/v2\/posts\/199\/revisions\/270"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cybercop-training.ch\/index.php?rest_route=\/wp\/v2\/media\/208"}],"wp:attachment":[{"href":"https:\/\/cybercop-training.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cybercop-training.ch\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cybercop-training.ch\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}