<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Compliance on Janik von Rotz</title>
    <link>https://janikvonrotz.ch/tags/compliance/</link>
    <description>Recent content in Compliance on Janik von Rotz</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Thu, 12 Oct 2017 15:54:08 +0000</lastBuildDate>
    <atom:link href="https://janikvonrotz.ch/tags/compliance/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Monitor and audit Active Directory user and group management</title>
      <link>https://janikvonrotz.ch/2017/10/12/monitor-and-audit-active-directory-user-and-group-management/</link>
      <pubDate>Thu, 12 Oct 2017 15:54:08 +0000</pubDate>
      <guid>https://janikvonrotz.ch/2017/10/12/monitor-and-audit-active-directory-user-and-group-management/</guid>
      <description>&lt;p&gt;Traceability is key when collaborating in the Active Directory (AD). Multiple admins changing and updating permissions and policies makes it difficult being compliant with the company&amp;rsquo;s policies. It is important to monitor mutations in the directory. By default audit policies are disabled for Domain Controllers (DC) and must be enabled explicitly. Enabling auditing for the DCs is quite easy, querying the logs for a specific event is a bit more difficult.&lt;/p&gt;&#xA;&lt;p&gt;In this guide you&amp;rsquo;ll learn how to enable auditing for a specific case and how to query the audit logs for a specific event.&lt;/p&gt;&#xA;&lt;p&gt;The  tutorial assumes that there is a:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Domain Controller.&lt;/li&gt;&#xA;&lt;li&gt;Group policies, security groups, users, &amp;hellip;&lt;/li&gt;&#xA;&lt;li&gt;Admins with DC access.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1 id=&#34;enable-auditing&#34;&gt;Enable Auditing&lt;/h1&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s start by have a look on the already enabled audit categories.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Log into the DC.&lt;/li&gt;&#xA;&lt;li&gt;Open PowerShell as admin.&lt;/li&gt;&#xA;&lt;li&gt;Run &lt;code&gt;auditpol /get /category:*&lt;/code&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;The command returns a list of audit categories and its status. These settings have been enabled by either the auditpol tool or via GPOs.&lt;/p&gt;&#xA;&lt;p&gt;In our scenario we would like to track management of users and groups, which is part of the &lt;strong&gt;Audit Account Management&lt;/strong&gt;. To enable this audit category create a new group policiy for the DC.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;Open the GPO management console.&lt;/li&gt;&#xA;&lt;li&gt;Right-click the &lt;em&gt;Domain Controllers&lt;/em&gt; organizational unit.&lt;/li&gt;&#xA;&lt;li&gt;Create new GPO and open it in the GPO editor.&lt;/li&gt;&#xA;&lt;li&gt;Enable logging for subcategories: &lt;code&gt;Computer Configuration &amp;gt; Policies &amp;gt; Windows Settings &amp;gt; Security Settings &amp;gt; Local Policies &amp;gt; Security Options &amp;gt; Audit: Force audit policy subcategory settings...&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Increase the security log size to 4GB: &lt;code&gt;Computer Configuration &amp;gt; Windows Settings &amp;gt; Security Settings &amp;gt; Event Log &amp;gt; Maximum security log size: 4268032&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Then navigate to &lt;code&gt;Computer Configuration &amp;gt; Windows Settings &amp;gt; Security Settings &amp;gt; Advanced Audit Policy Configuration &amp;gt; Account Management&lt;/code&gt;&lt;/li&gt;&#xA;&lt;li&gt;Enable the required audit categories.&lt;/li&gt;&#xA;&lt;li&gt;Make a &lt;code&gt;gpupdate /force&lt;/code&gt; on the DC.&lt;/li&gt;&#xA;&lt;li&gt;Run &lt;code&gt;auditpol /get /Category:*&lt;/code&gt; and double-check whether the settings are correct.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;If you open the security event log on the DC there should be events logging account management mutations.&lt;/p&gt;&#xA;&lt;p&gt;Source: &lt;a href=&#34;https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/plan/security-best-practices/monitoring-active-directory-for-signs-of-compromise&#34;&gt;Microsoft Docs - Monitoring Active Directory for Signs of Compromise&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h1 id=&#34;query-audit-logs&#34;&gt;Query Audit Logs&lt;/h1&gt;&#xA;&lt;p&gt;As mentioned querying the event log is a bit more difficult. The event log viewer offers limited features for filtering events and searching by specific keywords. In contrast with PowerShell it is possible to filter and search the event log by any property and keyword.&lt;/p&gt;&#xA;&lt;p&gt;Here is a simple example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-powershell&#34; data-lang=&#34;powershell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$LogName = &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;security&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$StartTime = Get-Date(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2017-10-12 12:50&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$EndTime = Get-Date(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;2017-10-12 13:00&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$SearchKey = &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;username&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Get-WinEvent -FilterHashtable @{LogName=$LogName; StartTime=$StartTime;EndTime=$EndTime} | Where-Object {$_.Message &lt;span style=&#34;color:#f92672&#34;&gt;-match&lt;/span&gt; $SearchKey} | select Id, TimeCreated, Message | Format-List&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Source: &lt;a href=&#34;https://blogs.technet.microsoft.com/heyscriptingguy/2015/10/20/filtering-event-log-events-with-powershell/&#34;&gt;Hey, Scripting Guy! Blog - Filtering Event Log Events with PowerShell&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Get unlinked GPOs with PowerShell</title>
      <link>https://janikvonrotz.ch/2017/10/06/get-unlinked-gpos-with-powershell/</link>
      <pubDate>Fri, 06 Oct 2017 10:06:49 +0000</pubDate>
      <guid>https://janikvonrotz.ch/2017/10/06/get-unlinked-gpos-with-powershell/</guid>
      <description>&lt;p&gt;In terms of IT compliance having valid GPOs is essential. They must be update to date and the GPO directory should be free of any unlinked GPOs. Retrieving a list of unlinked GPOs in the management console is impossible. With PowerShell it is quite easy.&lt;/p&gt;&#xA;&lt;p&gt;Take this function for example:&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Get-UnlinkedGPOs.ps1&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-powershell&#34; data-lang=&#34;powershell&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; Get-UnlinkedGPOs {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    Import-Module GroupPolicy&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    $Report = @() &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    $GPOs = Get-GPO -All&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    $GPOs | ForEach-Object { &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        $GPO = $_&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;    Write-Progress -Activity &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Get GPO settings&amp;#34;&lt;/span&gt; -status &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Analyze GPO: &lt;/span&gt;$($GPO.DisplayName)&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt; -percentComplete ([&lt;span style=&#34;color:#66d9ef&#34;&gt;int&lt;/span&gt;]([&lt;span style=&#34;color:#66d9ef&#34;&gt;array&lt;/span&gt;]::IndexOf($GPOs, $GPO)/$GPOs.Count*&lt;span style=&#34;color:#ae81ff&#34;&gt;100&lt;/span&gt;))&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        $GPOReport = ([&lt;span style=&#34;color:#66d9ef&#34;&gt;XML&lt;/span&gt;]$($GPO | Get-GPOReport -ReportType Xml)).GPO&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;If&lt;/span&gt;(($GPOReport.LinksTo &lt;span style=&#34;color:#f92672&#34;&gt;-eq&lt;/span&gt; $null) &lt;span style=&#34;color:#f92672&#34;&gt;-or&lt;/span&gt; (&lt;span style=&#34;color:#f92672&#34;&gt;-not&lt;/span&gt; ($GPOReport.LinksTo | Where-Object{$_.Enabled &lt;span style=&#34;color:#f92672&#34;&gt;-eq&lt;/span&gt; $true}))){&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;            $Report += $GPO&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;     &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;If&lt;/span&gt; ($Report.Count &lt;span style=&#34;color:#f92672&#34;&gt;-eq&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        Wirte-Warning &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;No unlinked GPOs found&amp;#34;&lt;/span&gt; &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt;{ &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; $Report&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    }&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Make sure the group policy PowerShell module is installed.&lt;/p&gt;&#xA;&lt;p&gt;Once the function is available in your shell you can things like: &lt;code&gt;Get-UnlinkedGPOs | Select DisplayName, GpoStatus | Sort-Object DisplayName | Format-Table&lt;/code&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Nginx SSL website</title>
      <link>https://janikvonrotz.ch/2014/04/03/nginx-ssl-website/</link>
      <pubDate>Thu, 03 Apr 2014 07:54:04 +0000</pubDate>
      <guid>https://janikvonrotz.ch/2014/04/03/nginx-ssl-website/</guid>
      <description>&lt;p&gt;&lt;em&gt;This post is part of my &lt;a href=&#34;https://janikvonrotz.ch/your-own-virtual-private-server-hosting-solution/&#34;&gt;Your own Virtual Private Server hosting solution&lt;/a&gt; project.&lt;/em&gt;&lt;br&gt;&#xA;&lt;em&gt;Get the latest version of this article here: &lt;a href=&#34;https://gist.github.com/9408793&#34;&gt;https://gist.github.com/9408793&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;&#xA;&lt;h1 id=&#34;introduction&#34;&gt;Introduction&lt;/h1&gt;&#xA;&lt;p&gt;This best practice shows you the most advanced SSL configurations for your Nginx website.&#xA;For productive usage it&amp;rsquo;s recommended to use only public-signed certificates.&lt;/p&gt;&#xA;&lt;h1 id=&#34;requirements&#34;&gt;Requirements&lt;/h1&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://janikvonrotz.ch/2014/03/13/deploy-ubuntu-server/&#34;&gt;Ubuntu server&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://janikvonrotz.ch/2014/03/26/get-a-free-verified-ssl-certificate-from-startssl/&#34;&gt;Get a free verified SSL certificate from StartSSL (optional)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://janikvonrotz.ch/2014/03/27/convert-ssl-certificates/&#34;&gt;Converted SSL certificates (optional)&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://janikvonrotz.ch/2014/03/31/install-nginx/&#34;&gt;Nginx&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://janikvonrotz.ch/2014/04/01/nginx-minimal-website/&#34;&gt;Nginx minimal website&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h1 id=&#34;installation&#34;&gt;Installation&lt;/h1&gt;&#xA;&lt;p&gt;Create a ssl folder to store key and cert files&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sudo mkdir /etc/nginx/ssl&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Upload your key and cert files into this folder.&lt;/p&gt;&#xA;&lt;p&gt;Now we need to generate stronger DHE parameter:&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;cd /etc/ssl/certs&#xA;sudo openssl dhparam -out dhparam.pem 4096&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Add this Nginx configuration to your website config.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;server{&#xA;&#xA;        # set ssl port&#xA;        listen 443;&#xA;        &#xA;        ...&#xA;        &#xA;        # basic ssl configuration&#xA;        ssl on;&#xA;        ssl_certificate /etc/nginx/ssl/[certificate.crt.ca.bundle];&#xA;        ssl_certificate_key /etc/nginx/ssl/[host].key;&#xA;&#xA;        # Force to use stronger DHE parameters &#xA;        ssl_dhparam /etc/ssl/certs/dhparam.pem;&#xA;        &#xA;        # limitation of ssl protocols and algortyhtms&#xA;        &#xA;        # we don&amp;#39;t want to support SSL v2 and SSL v3, it&amp;#39;s known to be insecure&#xA;        # FIPS 140-2 compliance, TLS1+ only&#xA;        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&#xA;        &#xA;        # don&amp;#39;t let the client decide what ciphers to use, we&amp;#39;ve told the server which to allow&#xA;        ssl_ciphers &amp;#39;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;#39;;&#xA;        ssl_prefer_server_ciphers on;&#xA;        &#xA;        # reduce ssl cpu load&#xA;        &#xA;        # we want to enable ssl session resumption to avoid&#xA;        # having to start the handshake from scratch each page load&#xA;        # so first we enable a shared cache, named SSL (creative!) that is 10mb large&#xA;        ssl_session_cache shared:SSL:10m;&#xA;        &#xA;        # save things in the cache for10 minutes&#xA;        # if you&amp;#39;re not making a request at least every 10 minutes, this isn&amp;#39;t going&#xA;        # to accomplish anything anyway&#xA;        ssl_session_timeout 10m;&#xA;        &#xA;        ...&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you wish to redirect all http traffic to https you can add this additional Nginx server configuration.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;server{&#xA;&#xA;      listen 80;&#xA;      &#xA;      server_name [host];&#xA;&#xA;      return 301 https://[host]$request_uri;&#xA;}&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Test config and reload Nginx service.&lt;/p&gt;&#xA;&lt;pre&gt;&lt;code&gt;sudo nginx -t &amp;amp;&amp;amp; sudo service nginx reload&#xA;&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;h1 id=&#34;source&#34;&gt;Source&lt;/h1&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://nginx.org/en/docs/http/converting_rewrite_rules.html&#34;&gt;Nginx converting rewrite rules&lt;/a&gt;&#xA;&lt;a href=&#34;http://nginx.org/en/docs/http/configuring_https_servers.html&#34;&gt;Configuring HTTPS servers&lt;/a&gt;&#xA;&lt;a href=&#34;https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html&#34;&gt;Strong SSL Security on nginx by Raymii&lt;/a&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
