<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Howto on Geek Cabinet</title>
    <link>https://geekcabi.net/tags/howto/</link>
    <description>Recent content in Howto on Geek Cabinet</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Sun, 27 Aug 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://geekcabi.net/tags/howto/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>But What if I HAVE to Encrypt with 7zip?</title>
      <link>https://geekcabi.net/posts/encrypt-with-7z/</link>
      <pubDate>Sun, 27 Aug 2023 00:00:00 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/encrypt-with-7z/</guid>
      <description>&lt;p&gt;Yes, I know I updated the &lt;a href=&#34;https://geekcabi.net/tools/#file-encryption&#34;&gt;tools page&lt;/a&gt; and now recommend &lt;strong&gt;against&lt;/strong&gt; encrypting with 7zip. But sometimes we have to do things we don&amp;rsquo;t &lt;strong&gt;want&lt;/strong&gt; to do.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Yes, I know I updated the <a href="/tools/#file-encryption">tools page</a> and now recommend <strong>against</strong> encrypting with 7zip. But sometimes we have to do things we don&rsquo;t <strong>want</strong> to do.</p>
<p>Like eat our vegetables. Wait. No, that&rsquo;s actually <strong>good</strong> for you.</p>
<p>Whatever.</p>
<p>You get the idea.</p>
<p>Encrypting a file with 7zip is simple. Use the <code>-p</code> option:</p>
<pre tabindex="0"><code>~$ 7z a archive.7z -pSTRONG_PASSWORD_THAT_IS_REALLY_LONG_HERE! folder/

7-Zip [64] 17.04 : Copyright (c) 1999-2021 Igor Pavlov : 2017-08-28
p7zip Version 17.04 (locale=utf8,Utf16=on,HugeFiles=on,64 bits,8 CPUs x64)

Scanning the drive:
1 folder, 4 files, 0 bytes

Creating archive: archive.7z

Items to compress: 5

    
Files read from disk: 0
Archive size: 186 bytes (1 KiB)
Everything is Ok
</code></pre><p>I have always loved 7zip&rsquo;s attempt to make me feel better.</p>
<p>&ldquo;Don&rsquo;t worry. Everything is Ok.&rdquo; :thumbs_up: :grinning_squinting_face:</p>
<blockquote>
<p><strong>Note:</strong>
There is <strong>no space</strong> between the option and the password. That&rsquo;s an oddity with 7z that I just don&rsquo;t see with many other CLI tools.</p>
</blockquote>
<p>You may notice, however, that when you go to list the contents of the archive, the folder and file names are listed <strong>without</strong> prompting for the password!</p>
<pre tabindex="0"><code>~$ 7z l archive.7z                   

7-Zip [64] 17.04 : Copyright (c) 1999-2021 Igor Pavlov : 2017-08-28
p7zip Version 17.04 (locale=utf8,Utf16=on,HugeFiles=on,64 bits,8 CPUs x64)

Scanning the drive for archives:
1 file, 186 bytes (1 KiB)

Listing archive: archive.7z

--
Path = archive.7z
Type = 7z
Physical Size = 186
Headers Size = 186
Solid = -
Blocks = 0

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2023-08-23 16:01:10 D....            0            0  folder
2023-08-23 16:01:10 ....A            0            0  folder/bank_info.xlsx
2023-08-23 16:01:10 ....A            0            0  folder/classified.txt
2023-08-23 16:01:10 ....A            0            0  folder/file1.txt
2023-08-23 16:01:10 ....A            0            0  folder/file2.txt
------------------- ----- ------------ ------------  ------------------------
2023-08-23 16:01:10                  0            0  4 files, 1 folders
</code></pre><p>Showing folder and file names without requiring the password is probably not acceptable for encrypted files. (Then again, ideally we wouldn&rsquo;t be using 7zip for encryption, but&hellip;.I already made that point.)</p>
<p>To encrypt the folder and file names, too, we need to use an option that only shows up on the <code>man</code> page of 7zip and not in the CLI help output:</p>
<pre tabindex="0"><code>-mhe=on|off
   7z format only : enables or disables archive header encryption (Default : off)
</code></pre><p>So all of this only works on the 7z format vs traditional zip, etc&hellip;</p>
<p>With this, our example changes to:</p>
<pre tabindex="0"><code>7z a archive.7z -mhe=on -pSTRONG_PASSWORD_THAT_IS_REALLY_LONG_HERE! folder/
</code></pre><p>The output is the same until the file contents are listed:</p>
<pre tabindex="0"><code>7z l archive.7z                           

7-Zip [64] 17.04 : Copyright (c) 1999-2021 Igor Pavlov : 2017-08-28
p7zip Version 17.04 (locale=utf8,Utf16=on,HugeFiles=on,64 bits,8 CPUs x64)

Scanning the drive for archives:
1 file, 221 bytes (1 KiB)

Listing archive: archive.7z


Enter password (will not be echoed):
--
Path = archive.7z
Type = 7z
Physical Size = 221
Headers Size = 221
Solid = -
Blocks = 0

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2023-08-23 16:01:10 D....            0            0  folder
2023-08-23 16:01:10 ....A            0            0  folder/bank_info.xlsx
2023-08-23 16:01:10 ....A            0            0  folder/classified.txt
2023-08-23 16:01:10 ....A            0            0  folder/file1.txt
2023-08-23 16:01:10 ....A            0            0  folder/file2.txt
------------------- ----- ------------ ------------  ------------------------
2023-08-23 16:01:10                  0            0  4 files, 1 folders
</code></pre><p>One other thing to note: encrypting a file in this manner will leave the password in your shell history file. I will leave as an exercise to the reader the following search: &ldquo;<a href="https://duckduckgo.com/?q=histcontrol%3Dignorespace" rel="noopener" target="_blank" class="external">HISTCONTROL=ignorespace</a>&rdquo; &#x1f60f;</p>]]></content:encoded>
    </item>
    
    <item>
      <title>Check for Updates to OPNSense from the Command Line</title>
      <link>https://geekcabi.net/posts/opnsense-check-update/</link>
      <pubDate>Tue, 14 Feb 2023 00:00:00 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/opnsense-check-update/</guid>
      <description>&lt;p&gt;As part of my morning routine, I have a few scripts I run to make sure my laptop and servers are up to date.&lt;/p&gt;
&lt;p&gt;Rather than login to the web GUI of my OPNSense firewall, I created an alias to check for updates from the CLI.&lt;/p&gt;
&lt;p&gt;Add the following line to &lt;code&gt;.bash_aliases&lt;/code&gt; or directly to &lt;code&gt;.bashrc&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;alias check-update=&amp;#39;sudo /usr/local/opnsense/scripts/firmware/launcher.sh check&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;There are a few small, but interesting, additional steps required for the alias to work over a &amp;ldquo;non-interactive&amp;rdquo; SSH session.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>As part of my morning routine, I have a few scripts I run to make sure my laptop and servers are up to date.</p>
<p>Rather than login to the web GUI of my OPNSense firewall, I created an alias to check for updates from the CLI.</p>
<p>Add the following line to <code>.bash_aliases</code> or directly to <code>.bashrc</code>:</p>
<pre tabindex="0"><code>alias check-update=&#39;sudo /usr/local/opnsense/scripts/firmware/launcher.sh check&#39;
</code></pre><p>There are a few small, but interesting, additional steps required for the alias to work over a &ldquo;non-interactive&rdquo; SSH session.</p>
<p>First, include the <code>-t</code> parameter with ssh to force the use of a psuedo-tty (so sudo will work). And instead of calling the alias directly, invoke bash and pass the alias as the command. The combined flags of <code>-ic</code> to bash make all that work together. (Credit goes to <a href="https://www.cyberciti.biz/faq/use-bash-aliases-ssh-based-session/" rel="noopener" target="_blank" class="external">Cyberciti.biz</a> for explaining these options to me.)</p>
<p>All of the above results in allowing me to run this from my terminal:</p>
<pre tabindex="0"><code>me@macbookpro:~ ssh -t opnsense /usr/local/bin/bash -ic &#39;check-update&#39;
</code></pre><p>resulting in output similar to the following:</p>
<pre tabindex="0"><code>Updating OPNsense repository catalogue...
Fetching meta.conf: . done
Fetching packagesite.pkg: .......... done
Processing entries: .......... done
OPNsense repository update completed. 822 packages processed.
All repositories are up to date.
Checking integrity... done (0 conflicting)
Your packages are up to date.
Checking for upgrades (0 candidates): . done
Processing candidates (0 candidates): . done
Checking integrity... done (0 conflicting)
Your packages are up to date.
</code></pre>]]></content:encoded>
    </item>
    
    <item>
      <title>Fixing Firefox&#39;s Time Confusion</title>
      <link>https://geekcabi.net/posts/fix-firefox-time-confusion/</link>
      <pubDate>Tue, 15 Nov 2022 00:00:00 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/fix-firefox-time-confusion/</guid>
      <description>&lt;h2 id=&#34;the-problem&#34;&gt;The Problem&lt;/h2&gt;
&lt;p&gt;I am re-evaluating Firefox as my everyday browser (moving back from Brave) and was reminded of the &lt;a href=&#34;https://support.mozilla.org/en-US/kb/containers&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;Multi-account container&lt;/a&gt; functionality today. That is a killer feature, IMHO. I&amp;rsquo;d been running several instances of Brave under different profiles to keep things separate, but this is so much easier (and better with RAM, maybe?).&lt;/p&gt;
&lt;p&gt;However, I was &lt;strong&gt;also&lt;/strong&gt; reminded of an incredibly annoying and frustrating side-effect of Firefox&amp;rsquo;s now-default privacy feature to prevent &lt;a href=&#34;https://en.wikipedia.org/wiki/Device_fingerprint&#34; title=&#34;Wikipedia - &amp;amp;quot;Device Fingerprint&amp;amp;quot;&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;browser/device fingerprinting&lt;/a&gt;: the timezone for my device is mis-reported to websites, so the displayed timestamps of messages are off by hours. It&amp;rsquo;s incredibly disorienting to look at your email inbox and see messages arrive from the future!&lt;/p&gt;</description>
      <content:encoded><![CDATA[<h2 id="the-problem">The Problem</h2>
<p>I am re-evaluating Firefox as my everyday browser (moving back from Brave) and was reminded of the <a href="https://support.mozilla.org/en-US/kb/containers" rel="noopener" target="_blank" class="external">Multi-account container</a> functionality today. That is a killer feature, IMHO. I&rsquo;d been running several instances of Brave under different profiles to keep things separate, but this is so much easier (and better with RAM, maybe?).</p>
<p>However, I was <strong>also</strong> reminded of an incredibly annoying and frustrating side-effect of Firefox&rsquo;s now-default privacy feature to prevent <a href="https://en.wikipedia.org/wiki/Device_fingerprint" title="Wikipedia - &amp;quot;Device Fingerprint&amp;quot;" rel="noopener" target="_blank" class="external">browser/device fingerprinting</a>: the timezone for my device is mis-reported to websites, so the displayed timestamps of messages are off by hours. It&rsquo;s incredibly disorienting to look at your email inbox and see messages arrive from the future!</p>
<figure>
    <img loading="lazy" src="back-to-the-future.webp"
         alt="Great Scott!"/> 
</figure>

<p>Spoofing the client&rsquo;s timezone is only one part of <a href="https://www.mozilla.org/en-US/firefox/features/block-fingerprinting/" rel="noopener" target="_blank" class="external">Mozilla&rsquo;s attempt</a> to prevent browser fingerprinting. Fingerprinting is (probably?) a <a href="https://geekflare.com/browser-fingerprinting" title="Geekflare - &amp;quot;Browser Fingerprinting 101: What, How, and Why [A Guide]&amp;quot;" rel="noopener" target="_blank" class="external">genuine privacy/tracking concern</a>, but I just can&rsquo;t handle incorrect timestamps in my emails and other web-based message clients (e.g. Facebook, Twitter, Mastodon, GroupMe, and whatever else). Mozilla reports this is a feature under &ldquo;heavy development&rdquo; right now and even they <a href="https://support.mozilla.org/en-US/kb/firefox-protection-against-fingerprinting" rel="noopener" target="_blank" class="external">recommend disabling it if it&rsquo;s causing problems</a>.</p>
<p>So as a reminder/shortcut to myself, here is how to fix it.</p>
<h2 id="the-fix">The Fix</h2>
<ol>
<li>Navigate to <code>about:config</code> and reassure Firefox that you &ldquo;know what you&rsquo;re doing&rdquo;</li>
</ol>
<figure>
    <img loading="lazy" src="Firefox-Advanced-Config-Acknowledgement.png"
         alt="Firefox Advanced Config Warning Banner"/> 
</figure>

<ol start="2">
<li>Then set the <code>privacy.resistFingerprinting</code> option to <code>False</code>.</li>
</ol>
<figure>
    <img loading="lazy" src="firefox-prefs-resistfingerprinting.png"
         alt="Firefox preference pane"/> 
</figure>

<ol start="3">
<li>Reload the impacted tabs (or just restart the whole browser) and you&rsquo;re done.</li>
</ol>
<p>I spent some time looking to see if there was an option to limit my changes to only not meddle with the timezone rather than taking a sledge-hammer to the whole thing. But it doesn&rsquo;t look like it&rsquo;s configurable at the moment. I even tried to whitelist specific sites. Granted it is entirely possible I didn&rsquo;t implement the whitelist correctly or simply muffed up the test some other way.</p>
<p>Hopefully, Mozilla will introduce flexibility with this privacy feature in the future.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Using Touch ID with sudo on macOS</title>
      <link>https://geekcabi.net/posts/using-touchid-sudo-macos/</link>
      <pubDate>Thu, 10 Nov 2022 00:00:00 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/using-touchid-sudo-macos/</guid>
      <description>&lt;p&gt;Here&amp;rsquo;s a quick cheat sheet for my own reference.&lt;/p&gt;
&lt;p&gt;macOS supports the use of &lt;a href=&#34;https://support.apple.com/guide/mac-help/use-touch-id-mchl16fbf90a/mac&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;Touch ID&lt;/a&gt; for sudo authentication. Yes, I still love to live in the terminal, so this is an everyday, multiple times a day thing for me.&lt;/p&gt;
&lt;p&gt;Fortunately, it&amp;rsquo;s a very quick edit to enable the functionality and it saves a TON of time (vs entering your password each time you run the sudo command - or worse, &lt;a href=&#34;https://linuxhandbook.com/sudo-without-password/&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;setting the NOPASSWD option&lt;/a&gt;.)&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Here&rsquo;s a quick cheat sheet for my own reference.</p>
<p>macOS supports the use of <a href="https://support.apple.com/guide/mac-help/use-touch-id-mchl16fbf90a/mac" rel="noopener" target="_blank" class="external">Touch ID</a> for sudo authentication. Yes, I still love to live in the terminal, so this is an everyday, multiple times a day thing for me.</p>
<p>Fortunately, it&rsquo;s a very quick edit to enable the functionality and it saves a TON of time (vs entering your password each time you run the sudo command - or worse, <a href="https://linuxhandbook.com/sudo-without-password/" rel="noopener" target="_blank" class="external">setting the NOPASSWD option</a>.)</p>
<h2 id="edit-pam">Edit PAM</h2>
<p>Initial file contents</p>
<pre tabindex="0"><code># sudo: auth account password session
auth       sufficient     pam_smartcard.so
auth       required       pam_opendirectory.so
account    required       pam_permit.so
password   required       pam_deny.so
session    required       pam_permit.so
</code></pre><p><code>me@macbookpro:~ # sudo vi /etc/pam.d/sudo</code></p>
<p>Insert as the first uncommented line: <code>auth sufficient pam_tid.so</code></p>
<p>Resulting file contents</p>
<pre tabindex="0"><code># sudo: auth account password session
auth       sufficient     pam_tid.so
auth       sufficient     pam_smartcard.so
auth       required       pam_opendirectory.so
account    required       pam_permit.so
password   required       pam_deny.so
session    required       pam_permit.so
</code></pre><p>Force save (<code>:w!</code>) then quit (<code>:q</code>)</p>
<p>And you&rsquo;re done!</p>
<h2 id="but-there-is-a-minor-caveat">But there is a <em>minor</em> caveat&hellip;.</h2>
<p>In macOS, PAM cofiguration files are protected by <a href="https://support.apple.com/guide/security/system-integrity-protection-secb7ea06b49/web" rel="noopener" target="_blank" class="external">System Integrity Protection (SIP)</a> so they will be overwritten with every OS upgrade - <strong>by design</strong>.</p>
<p>It&rsquo;s a bit annyoing and maybe some day I&rsquo;ll dig into better options. But for now it&rsquo;s a quick and generally painless edit after an OS update.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>OPNSense and BSD Boot Environments</title>
      <link>https://geekcabi.net/posts/opnsense-boot-environments/</link>
      <pubDate>Fri, 04 Nov 2022 00:00:00 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/opnsense-boot-environments/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve been using OPNSense for my home firewall for many years now, and I previously ran it as a VM in a Proxmox virtual server. That worked great for my purposes, but I&amp;rsquo;ve since upgraded to a dedicated physical device (Protectli) running OPNSense and I love it.&lt;/p&gt;
&lt;p&gt;However, with the migration away from a VM, I lost the ability to create a snapshot of the system prior to an upgrade - just in case something went wrong I could easily roll back.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I&rsquo;ve been using OPNSense for my home firewall for many years now, and I previously ran it as a VM in a Proxmox virtual server. That worked great for my purposes, but I&rsquo;ve since upgraded to a dedicated physical device (Protectli) running OPNSense and I love it.</p>
<p>However, with the migration away from a VM, I lost the ability to create a snapshot of the system prior to an upgrade - just in case something went wrong I could easily roll back.</p>
<p>Recently I learned about BSD Boot Environments and the <a href="https://www.gsp.com/cgi-bin/man.cgi?topic=BECTL" rel="noopener" target="_blank" class="external">bectl utility</a> and how they can help fill that gap!</p>
<ol>
<li>
<p>Login via SSH and start a shell session</p>
</li>
<li>
<p>List any current/previoius boot environment (BE) snapshots</p>
</li>
</ol>
<pre tabindex="0"><code>root@opnsense-fw:~ # bectl list
BE     Active Mountpoint Space Created
22.7.2 -      -          1.04G 2021-09-05 10:57
22.7.4 -      -          388M  2022-09-02 09:28
22.7.5 NR     /          4.09G 2022-10-05 08:58
</code></pre><p>In the &ldquo;Active&rdquo; column, the &ldquo;N&rdquo; stands for &ldquo;Now&rdquo; and &ldquo;R&rdquo; is &ldquo;Reboot&rdquo;, showing which BE is active now vs after the next reboot.</p>
<ol start="3">
<li>Create and activate a new BE</li>
</ol>
<pre tabindex="0"><code>root@opnsense-fw:~ # bectl create [new_version]
root@opnsense-fw:~ # bectl activate [new_version]
</code></pre><ol start="4">
<li>Reboot and upgrade</li>
<li>Validate BE; Remove oldest BE</li>
</ol>
<pre tabindex="0"><code>root@opnsense-fw:~ # bectl list
BE     Active Mountpoint Space Created
22.7.2 -      -          1.04G 2021-09-05 10:57
22.7.4 -      -          896M  2022-09-02 09:28
22.7.5 NR     /          4.84G 2022-10-05 08:58
root@opnsense-fw:~ # bectl destroy 22.7.2
root@opnsense-fw:~ # bectl list
BE     Active Mountpoint Space Created
22.7.4 -      -          1.13G 2022-09-02 09:28
22.7.5 NR     /          3.80G 2022-10-05 08:58
</code></pre>]]></content:encoded>
    </item>
    
    <item>
      <title>Serving Directory Index Files With CloudFront Functions</title>
      <link>https://geekcabi.net/posts/serving-directory-index-files-with-cloudfront-functions/</link>
      <pubDate>Sat, 18 Dec 2021 00:00:00 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/serving-directory-index-files-with-cloudfront-functions/</guid>
      <description>&lt;p&gt;I recently migrated from hosting this site on Gitlab pages (still an excellent option, BTW) to hosting on AWS S3 via CloudFront. This solution isn&amp;rsquo;t cheaper, but I&amp;rsquo;ve been working on AWS concepts of late and thought this would be a good exercise - and I was right! :-)&lt;/p&gt;
&lt;p&gt;I expect to write more about what I learned in that exercise, but I wanted to start with the problem of directory index files, since this solution didn&amp;rsquo;t come up often in my search for solutions. There are &lt;strong&gt;lots&lt;/strong&gt; of pages out there talking about hosting static pages on S3 and CloudFront has a &lt;code&gt;Default root object&lt;/code&gt; setting for each Distribution. But I discovered that only works for the root of the &lt;strong&gt;distribution&lt;/strong&gt; - not any subdirectories.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I recently migrated from hosting this site on Gitlab pages (still an excellent option, BTW) to hosting on AWS S3 via CloudFront. This solution isn&rsquo;t cheaper, but I&rsquo;ve been working on AWS concepts of late and thought this would be a good exercise - and I was right! :-)</p>
<p>I expect to write more about what I learned in that exercise, but I wanted to start with the problem of directory index files, since this solution didn&rsquo;t come up often in my search for solutions. There are <strong>lots</strong> of pages out there talking about hosting static pages on S3 and CloudFront has a <code>Default root object</code> setting for each Distribution. But I discovered that only works for the root of the <strong>distribution</strong> - not any subdirectories.</p>
<p>The simplest solution I found (there may be others) was the use of CloudFront functions.</p>
<h2 id="what-is-it">What is it?</h2>
<p>As described in the <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CloudFront-functions.html" rel="noopener" target="_blank" class="external">AWS documentation</a>:</p>
<blockquote>
<p>CloudFront Functions is ideal for lightweight, short-running functions for use cases like the following:</p>
<ul>
<li><strong>Cache key normalization</strong> – You can transform HTTP request attributes (headers, query strings, cookies, even the URL path) to create an optimal cache key, which can improve your cache hit ratio.</li>
<li><strong>Header manipulation</strong> – You can insert, modify, or delete HTTP headers in the request or response. For example, you can add a True-Client-IP header to every request.</li>
<li><strong>URL redirects or rewrites</strong> – You can redirect viewers to other pages based on information in the request, or rewrite all requests from one path to another.</li>
<li><strong>Request authorization</strong> – You can validate hashed authorization tokens, such as JSON web tokens (JWT), by inspecting authorization headers or other request metadata.</li>
</ul>
</blockquote>
<p>CloudFront Functions support two types of event:</p>
<ul>
<li>Viewer request</li>
<li>Viewer response</li>
</ul>
<p>CloudFront also supports lambda functions via <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-edge.html" rel="noopener" target="_blank" class="external">Labmda@Edge</a> executions. Lambda@Edge supports the viewer request and response events as well as Origin requests and response events. But a directory index redirect is simple enough that Lambda@Edge wasn&rsquo;t needed.</p>
<p>Of note, CloudFront Functions cannot include response body content. Hence, the Lambda@Edge options.</p>
<p>CloudFront functions are written in Javascript. I am no Javascript expert (to put it mildly), but fortunately this particular use case was <a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/example-function-add-index.html" rel="noopener" target="_blank" class="external">included in the CloudFront documentation as an example</a>! (<strong>Unfortunately</strong>, this use case didn&rsquo;t come up much in my support queries, so I was glad to have finally found it!)</p>
<h2 id="cloudfront-function">CloudFront Function</h2>
<p>Name: folder_index</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-Javascript" data-lang="Javascript"><span style="display:flex;"><span><span style="color:#66d9ef">function</span> <span style="color:#a6e22e">handler</span>(<span style="color:#a6e22e">event</span>) {
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// Copied from https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/example-function-add-index.html
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#75715e">// Retrieved on 2021-12-18
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">request</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">event</span>.<span style="color:#a6e22e">request</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">uri</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">request</span>.<span style="color:#a6e22e">uri</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// Check whether the URI is missing a file name.
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">uri</span>.<span style="color:#a6e22e">endsWith</span>(<span style="color:#e6db74">&#39;/&#39;</span>)) {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">request</span>.<span style="color:#a6e22e">uri</span> <span style="color:#f92672">+=</span> <span style="color:#e6db74">&#39;index.html&#39;</span>;
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// Check whether the URI is missing a file extension.
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#66d9ef">else</span> <span style="color:#66d9ef">if</span> (<span style="color:#f92672">!</span><span style="color:#a6e22e">uri</span>.<span style="color:#a6e22e">includes</span>(<span style="color:#e6db74">&#39;.&#39;</span>)) {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">request</span>.<span style="color:#a6e22e">uri</span> <span style="color:#f92672">+=</span> <span style="color:#e6db74">&#39;/index.html&#39;</span>;
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> <span style="color:#a6e22e">request</span>;
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Once this function is saved, it must be tested and then published before attaching it to the CloudFront distribution.</p>
<h2 id="testing-and-deployment">Testing and Deployment</h2>
<p>Testing is <strong>very</strong> straightforward in the CloudFront Functions page:</p>
<figure>
    <img loading="lazy" src="cloudfront_function_test.png"
         alt="CloudFront Test page"/> <figcaption>
            <p>There are other options available for testing not shown in that screenshot, but the above is sufficient for this function.</p>
        </figcaption>
</figure>

<p>Press &ldquo;Test Function&rdquo; and look for results simliar to below.</p>
<figure>
    <img loading="lazy" src="cloudfront_function_test_result.png"
         alt="CloudFront test results"/> 
</figure>

<p>Once you&rsquo;ve validated the function returns the expected results, it can be associated to the Distribution from the Functions page, or back on the Distribution Behaviors tab:</p>
<figure>
    <img loading="lazy" src="cloudfront_distribution_behavior_association.png"
         alt="CloudFront Distribution Behavior association"/> 
</figure>

<p>Once that was done, all the pretty URL functionality worked perfectly.</p>
<h2 id="cost">Cost</h2>
<p>As with all things AWS, CloudFront is (generally) a pay-as-you-go service. But GeekCabinet is a fairly low traffic site, so I should be able to stay well within the <a href="https://aws.amazon.com/cloudfront/pricing/" rel="noopener" target="_blank" class="external">Free Tier for CloudFront</a>:</p>
<ul>
<li>1 TB of data transfer out</li>
<li>10,000,000 HTTP or HTTPS Requests</li>
<li>2,000,000 CloudFront Function Invocations</li>
</ul>
<p>But even if GeekCabinet had more traffic, pricing on CloudFront and Functions wouldn&rsquo;t break the bank.</p>
<blockquote>
<p>You are charged for the total number of invocations across all your functions. CloudFront Functions counts an invocation each time it starts executing in response to a CloudFront event globally. Invocation pricing is $0.10 per 1 million invocations ($0.0000001 per invocation).</p>
</blockquote>
<h2 id="conclusion">Conclusion</h2>
<p>I&rsquo;m pleased with what I&rsquo;ve learned and CloudFront Functions ended up being a simple solution to my problem. And a solution I was suprised wasn&rsquo;t highlighted in other forums, since I&rsquo;d imagine this is a common problem.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Getting Started in Security</title>
      <link>https://geekcabi.net/posts/getting-started/</link>
      <pubDate>Mon, 23 Jul 2018 15:30:01 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/getting-started/</guid>
      <description>&lt;p&gt;I meet IT folks fairly frequently who want to know how to get started in Security. But Security is a &lt;strong&gt;huge&lt;/strong&gt; field! What &lt;strong&gt;kind&lt;/strong&gt; of security are you intersted in? Or what kind of Security do you &lt;strong&gt;think&lt;/strong&gt; you&amp;rsquo;re interested in? And how do you find out?&lt;/p&gt;
&lt;h2 id=&#34;disclaimer&#34;&gt;Disclaimer&lt;/h2&gt;
&lt;p&gt;Personally, I&amp;rsquo;m biased toward &lt;strong&gt;not&lt;/strong&gt; starting in Security, but starting in System Administration or Network Administration or development or&amp;hellip;.&lt;/p&gt;
&lt;p&gt;The reason is that if you haven&amp;rsquo;t actually spent time &lt;strong&gt;running&lt;/strong&gt; an IT shop, you won&amp;rsquo;t really have an idea of what you&amp;rsquo;re defending or the balance between keeping things running smoothly and patching (for example).&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I meet IT folks fairly frequently who want to know how to get started in Security. But Security is a <strong>huge</strong> field! What <strong>kind</strong> of security are you intersted in? Or what kind of Security do you <strong>think</strong> you&rsquo;re interested in? And how do you find out?</p>
<h2 id="disclaimer">Disclaimer</h2>
<p>Personally, I&rsquo;m biased toward <strong>not</strong> starting in Security, but starting in System Administration or Network Administration or development or&hellip;.</p>
<p>The reason is that if you haven&rsquo;t actually spent time <strong>running</strong> an IT shop, you won&rsquo;t really have an idea of what you&rsquo;re defending or the balance between keeping things running smoothly and patching (for example).</p>
<p>When a Security professional &ldquo;demands&rdquo; that a patch be applied, we should understand the implications of those demands and be able to work with the Operations teams to ensure the patches are tested properly - again, just as an example.</p>
<p>So with that disclaimer out of the way&hellip;</p>
<h2 id="home-lab">Home Lab</h2>
<p>First of all, you need a home lab. You need a place to test out new tools and technologies - <strong>WITH PERMISSION</strong> - and a home lab is probably the best place to do that.</p>
<p><a href="https://www.virtualbox.org" rel="noopener" target="_blank" class="external">VirtualBox</a> is a great, free way to start a home lab. <a href="https://www.vmware.com/" rel="noopener" target="_blank" class="external">VMWare</a> is fine if you have some money to start with, but I still use VirtualBox on a regular basis, and I have a license for VMWare, too.</p>
<p>Both virtualziation platforms allow you to create internal, virtual networks where you can see the interaction between attack tools and defense tools, and get familiar with how to configure both.</p>
<p>What should go in your lab? I&rsquo;m glad you asked!</p>
<p>Below, I&rsquo;ve started a list of tools and technologies I&rsquo;ve used in production and/or learning environments that will give you plenty to explore. Many of these resources are free and/or Open Source, though obviously not all of them. These are also not listed in order of preference or performance. For most of these, I&rsquo;ve included a brief description or thoughts around the tool, but I&rsquo;m sure this will be a bit of a living list.</p>
<p>And who knows? Maybe I&rsquo;ll get around to writing up some more in-depth info on these as time goes on. :-)</p>
<h1 id="tools--resources">Tools / Resources</h1>
<p>*Last updated: 2021-09-09</p>
<h2 id="virtualization">Virtualization</h2>
<ul>
<li><a href="https://www.virtualbox.org" rel="noopener" target="_blank" class="external">VirtualBox</a>
<ul>
<li>Great for running virtual machines on your laptop / small server</li>
</ul>
</li>
<li><a href="https://www.proxmox.com/en/" rel="noopener" target="_blank" class="external">Proxmox</a>
<ul>
<li>Run a virtual data center in a single server</li>
<li>This is really the next step up for home labs and suitable for larger labs (or even home production use)</li>
</ul>
</li>
<li><a href="https://www.vmware.com/" rel="noopener" target="_blank" class="external">VMWare</a>
<ul>
<li>The defacto standard for local virtual machines. Not free.</li>
</ul>
</li>
<li><a href="https://aws.amazon.com/" rel="noopener" target="_blank" class="external">AWS</a>
<ul>
<li>um&hellip;..duh.</li>
<li>Not as expensive as you think it might be, once you get the hang of it.</li>
</ul>
</li>
<li><a href="https://www.vultr.com/" rel="noopener" target="_blank" class="external">Vultr</a> and/or <a href="https://www.digitalocean.com" rel="noopener" target="_blank" class="external">DigitalOcean</a>
<ul>
<li>Good places to run a virtual server for $5 / month</li>
<li>Perfect if you don&rsquo;t want to dive into AWS just yet.</li>
</ul>
</li>
</ul>
<h2 id="network-routing-and-firewalls">Network Routing and Firewalls</h2>
<ul>
<li><a href="https://wiki.centos.org/HowTos/Network/IPTables" rel="noopener" target="_blank" class="external">iptables</a>
<ul>
<li>The famous Linux firewall.</li>
<li>There are a ton of resources and tutorials out there on this, but I included the one for CentOS.</li>
<li>It&rsquo;s not necessarily the best, but it&rsquo;s a start.</li>
</ul>
</li>
<li><a href="https://opnsense.org/" rel="noopener" target="_blank" class="external">OPNSense</a>
<ul>
<li>BSD-based Open Source firewall.</li>
<li>Includes a web GUI for management.</li>
<li>Fork of PFSense, but probably my pick between the two.</li>
</ul>
</li>
<li><a href="https://www.pfsense.org/" rel="noopener" target="_blank" class="external">PFSense</a>
<ul>
<li>Still a solid, supported Web GUI-based BSD firewall.</li>
</ul>
</li>
<li><a href="https://mikrotik.com/download" rel="noopener" target="_blank" class="external">MicroTik</a>
<ul>
<li>Not free, but their Cloud Hosted Router (CHR) is excellently priced.</li>
<li>There are also cheap(er) hardware devices that can be purchased to run this production-supported solution.</li>
</ul>
</li>
<li><a href="https://vyos.io/" rel="noopener" target="_blank" class="external">VyOS</a>
<ul>
<li>Command line Linux-based router and firewall. Love this software, but it doesn&rsquo;t have a frequent update cycle.</li>
</ul>
</li>
</ul>
<h2 id="utilities">Utilities</h2>
<ul>
<li>grep / Regular Expressions
<ul>
<li>Learn regular expressions. You&rsquo;ll need them.</li>
<li>And you&rsquo;ll hate them.</li>
</ul>
</li>
<li><a href="https://letsencrypt.org/" rel="noopener" target="_blank" class="external">Let&rsquo;s Encrypt</a>
<ul>
<li>Free, programmable TLS certificates.</li>
<li>No reason not to have a cert on any website you create.</li>
</ul>
</li>
<li><a href="https://nmap.org/" rel="noopener" target="_blank" class="external">nmap</a> - Network Mapper
<ul>
<li>The defacto standard for network scanners.</li>
<li>The NSE (Nmap Scripting Engine) has added quite a bit to this and you can do some basic vulnerability scanning here.</li>
<li>My go-to for initial local network reconnaissance.</li>
</ul>
</li>
<li><a href="https://docs.microsoft.com/en-us/powershell/" rel="noopener" target="_blank" class="external">PowerShell</a>
<ul>
<li>I strongly prefer Linux or Mac over Windows, but the rest of the world runs Windows and you need to know how to manage and secure these boxen.</li>
<li>PowerShell is actually pretty awesome and <strong>definitely</strong> worth learning!</li>
</ul>
</li>
<li><a href="https://www.python.org/" rel="noopener" target="_blank" class="external">python</a>
<ul>
<li>My personal preference for script languages. There are others, and you can choose them if you like. I promise it won&rsquo;t hurt my feelings.</li>
</ul>
</li>
<li>Shell scripts (bash / zsh)
<ul>
<li>Know your way around a command line.</li>
<li>Waay too many tutorials out there right now. Google it.</li>
</ul>
</li>
<li><a href="http://www.tcpdump.org/" rel="noopener" target="_blank" class="external">tcpdump</a>
<ul>
<li>The original tool to capture network traffic. Still awesome.</li>
</ul>
</li>
<li><a href="https://www.wireshark.org/" rel="noopener" target="_blank" class="external">Wireshark</a>
<ul>
<li>The simplest way to examine the packets you captured with tcpdump.</li>
<li>Of course, Wireshark can capture on it&rsquo;s own (use tshark on the command line).</li>
</ul>
</li>
</ul>
<h2 id="forensics">Forensics</h2>
<ul>
<li><a href="https://digital-forensics.sans.org/community/downloads" rel="noopener" target="_blank" class="external">SANS SIFTKit</a>
<ul>
<li>Created and maintained by <a href="https://www.sans.org" rel="noopener" target="_blank" class="external">SANS</a>, the SIFT Kit is an excellent forensics-machine-in-a-box and includes a ton of fantastic tools and documentation.</li>
</ul>
</li>
<li><a href="https://www.sleuthkit.org/" rel="noopener" target="_blank" class="external">Sleuthkit</a>
<ul>
<li>Included in the SIFT Kit and is a basic tool in file system forensics.</li>
</ul>
</li>
</ul>
<h2 id="configuration-management">Configuration Management</h2>
<ul>
<li><a href="https://boxstarter.org/" rel="noopener" target="_blank" class="external">Boxstarter</a> (Built on Chocolatey)
<ul>
<li>&ldquo;Repeatable, reboot resilient windows environment installations made easy using Chocolatey packages&rdquo; (from their site).</li>
<li>Honestly, I haven&rsquo;t mastered this one yet, but it looks <strong>really</strong> interesting.</li>
</ul>
</li>
<li><a href="https://chocolatey.org/" rel="noopener" target="_blank" class="external">Chocolatey</a> (Windows)
<ul>
<li>Like yum or apt-get for Windows.</li>
<li>I even created a scheduled task on my family&rsquo;s computers to automatically patch all their software on a regular basis.</li>
</ul>
</li>
<li><a href="https://www.docker.com/" rel="noopener" target="_blank" class="external">Docker</a>
<ul>
<li>Allows you to use pre-packaged applications, alone or together with other &ldquo;containers&rdquo; to quickly build and manage applications in a standard fashion.</li>
</ul>
</li>
<li><a href="https://github.com" rel="noopener" target="_blank" class="external">Github</a>
<ul>
<li>Version control.</li>
<li>Super important to maintain versions of your scripts, configuration, notes, whatever.</li>
<li>You will love this. And hate it.</li>
</ul>
</li>
<li><a href="https://gitlab.com" rel="noopener" target="_blank" class="external">Gitlab</a>
<ul>
<li>See above.</li>
<li>Gitlab also supports private repositories on their free plan (something <del>you have to pay for</del> also now available on Github, since Microsoft bought them out).</li>
<li>Using a private repo, you could keep your configurations on all your workstations in a version control system.</li>
<li>All you need to do to make your new computer setup just like your old one is to clone the repo!</li>
<li>Gitlab (and Github) also support hosting static sites - <a href="https://geekcabi.net" rel="noopener" target="_blank" class="external">Geek Cabinet</a> <!-- raw HTML omitted -->is<!-- raw HTML omitted --> was hosted here on Gitlab, for example. Gitlab even supports custom certifcates (e.g. Let&rsquo;s Encrypt) where Github does not (yet?).</li>
</ul>
</li>
<li><a href="https://puppet.com/" rel="noopener" target="_blank" class="external">Puppet</a>
<ul>
<li>Using Puppet (or Salt Stack - see below), you can ensure servers and workstations are configured consistently and correctly from one central place.</li>
<li>This changes the way you administer your network.</li>
<li>Runs on Ruby, but you don&rsquo;t need to know that (or the language) in order to use it.</li>
</ul>
</li>
<li><a href="https://saltstack.com/" rel="noopener" target="_blank" class="external">Salt Stack</a>
<ul>
<li>See Above</li>
<li>Python-based version of Puppet.</li>
</ul>
</li>
</ul>
<h2 id="offense">Offense</h2>
<ul>
<li><a href="https://www.kali.org/" rel="noopener" target="_blank" class="external">Kali Linux</a>
<ul>
<li>Network Penetration Testing in a box.</li>
<li>When you&rsquo;re ready to start practice attacking systems (<strong>with permission</strong>), this is a great place to start.</li>
</ul>
</li>
<li><a href="https://www.tenable.com/products/nessus-home" rel="noopener" target="_blank" class="external">Tenable Nessus Home Scanner</a>
<ul>
<li>Maybe should&rsquo;ve even put this in the &ldquo;Defense&rdquo; section&hellip;¯\_(ツ)_/¯</li>
<li>Free for home use, a quality network vulnerability scanner to find and (lightly) test the systems in your lab</li>
<li><strong>Or</strong> make sure your IDS is working&hellip;</li>
<li>Again, <strong>use only with permission</strong>. If you own what you&rsquo;re scanning, you&rsquo;re fine. If you don&rsquo;t - ask first. Or just skip it.</li>
</ul>
</li>
</ul>
<h2 id="defense">Defense</h2>
<ul>
<li><a href="https://zeek.org/" rel="noopener" target="_blank" class="external">Zeek IDS</a></li>
<li><a href="https://www.ossec.net/" rel="noopener" target="_blank" class="external">OSSEC HIDS</a></li>
<li><a href="https://securityonion.net/" rel="noopener" target="_blank" class="external">Security Onion</a>
<ul>
<li>Network Intrusion Detection System in a box.</li>
<li>Includes Snort, Suricata, Zeek, OSSEC, + &hellip;..</li>
</ul>
</li>
<li><a href="https://www.snort.org/" rel="noopener" target="_blank" class="external">Snort</a></li>
<li><a href="https://suricata-ids.org/" rel="noopener" target="_blank" class="external">Suricata</a></li>
</ul>
<h2 id="learning">Learning</h2>
<ul>
<li>Local Community Meetups</li>
<li><a href="https://www.sans.org/reading-room/" rel="noopener" target="_blank" class="external">SANS Reading Room</a></li>
<li><a href="https://www.sans.org/work-study" rel="noopener" target="_blank" class="external">SANS Facilitator Program</a></li>
</ul>
]]></content:encoded>
    </item>
    
    <item>
      <title>Whitelisting IPs in OSSEC</title>
      <link>https://geekcabi.net/posts/ossec-whitelisting/</link>
      <pubDate>Mon, 22 May 2017 09:00:01 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/ossec-whitelisting/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;All of this was prior to the latest versions of Security Onion which now run inside docker instances. I&amp;rsquo;ve not yet looked to see how this would be replicated there. But I&amp;rsquo;m leaving this up for historical purposes.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Another tool in the arsenal of &lt;a href=&#34;https://securityonion.net&#34; title=&#34;Official Security Onion website&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;Security Onion&lt;/a&gt; is &lt;a href=&#34;https://ossec.github.io&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;OSSEC&lt;/a&gt;, a &amp;ldquo;scalable, multi-platform, open source Host-based Intrusion Detection System (HIDS).&amp;rdquo; OSSEC examines log and alert events and correlates them against pre-built (or custom) rules and sends alerts as configured. When installed on the &lt;a href=&#34;https://geekcabi.net/tags/securityonion.html&#34; title=&#34;Other Geek Cabinet articles on Security Onion&#34;&gt;Security Onion&lt;/a&gt; server, OSSEC alerts are logged in the sguil database and managed alongside alerts from the network IDS.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<blockquote>
<p>All of this was prior to the latest versions of Security Onion which now run inside docker instances. I&rsquo;ve not yet looked to see how this would be replicated there. But I&rsquo;m leaving this up for historical purposes.</p>
</blockquote>
<p>Another tool in the arsenal of <a href="https://securityonion.net" title="Official Security Onion website" rel="noopener" target="_blank" class="external">Security Onion</a> is <a href="https://ossec.github.io" rel="noopener" target="_blank" class="external">OSSEC</a>, a &ldquo;scalable, multi-platform, open source Host-based Intrusion Detection System (HIDS).&rdquo; OSSEC examines log and alert events and correlates them against pre-built (or custom) rules and sends alerts as configured. When installed on the <a href="/tags/securityonion.html" title="Other Geek Cabinet articles on Security Onion">Security Onion</a> server, OSSEC alerts are logged in the sguil database and managed alongside alerts from the network IDS.</p>
<p>An important aspect of any NIDS/HIDS is the ability to tune out expected traffic, to keep noise to a minimum so that <strong>real</strong> alerts can be triaged and mitigated. Whitelisting the IP address of known and approved vulnerability scanners can reduce the analyst&rsquo;s workload tremendously. For the Snort/Suricata NIDS, those IPs can be whitelisted through local rules or even completely ignored via BPF filtering (something I&rsquo;ll cover another time).</p>
<p>Since OSSEC generates alerts by reviewing log entries, the NIDS filters won&rsquo;t apply to OSSEC. Instead, a reference list must be created/maintained for OSSEC to utilize.</p>
<blockquote>
<p>There is a <code>&lt;white_list&gt;</code> directive in the <code>ossec.conf</code> file, but that directive only controls the Active Response module of OSSEC. Hosts identified in the <code>&lt;white_list&gt;</code> tags will not be blocked by any Active Response script, but alerts may still be generated for activity from those sources.</p>
<p>The procedure documented here instead prevents alerts from being generated by specified IPs.</p>
</blockquote>
<h2 id="creating-the-list-file">Creating the list file</h2>
<p>Create a file to store the key-value paired IPs and labels in the <code>/var/ossec/lists</code> directory. For my example, I will use <code>approved_scanners_list</code> as the file name.</p>
<p>Reference lists in OSSEC must be entered in the format:</p>
<pre tabindex="0"><code>key1:value
key2:value
key3:value
</code></pre><p>Each key must be unique, but the values can be duplicated.</p>
<p>Individual hosts can be entered like so:</p>
<pre tabindex="0"><code>10.5.0.99:KaliScanner
10.15.0.120:NessusScanner
</code></pre><p>IP ranges that break on classes are also supported, like this:</p>
<pre tabindex="0"><code>192.168.23.:SecurityToolNetwork
172.12.:InternalNetwork
</code></pre><p>CIDR entries are not supported, so ranges that do <strong>not</strong> end on a class border must be either combined with a class entry or listed individually.</p>
<h2 id="update-ossec-config-to-reference-the-list">Update OSSEC config to reference the list</h2>
<p>Once the list has been created, <code>ossec.conf</code> must be updated to reference the list:</p>
<pre tabindex="0"><code>&lt;rules&gt;
   [...trimmed output...]
   &lt;list&gt;lists/approved_scanners_list&lt;/list&gt;
&lt;/rules&gt;
</code></pre><p>When the list has been created and referenced in the ossec.conf file, the <a href="http://ossec-docs.readthedocs.io/en/latest/programs/ossec-makelists.html" rel="noopener" target="_blank" class="external">ossec-makelists</a> command must be run to compile the list into a readable format for OSSEC.</p>
<p>The output below shows the result when a reference list needs to be updated:</p>
<pre tabindex="0"><code>root@so-onion:/var/ossec/bin# ./ossec-makelists
 * File lists/ip_list.cdb does not need to be compiled
 * File lists/approved_scanners_list.cdb needs to be updated
</code></pre><p>The output below shows the result when no lists need to be updated:</p>
<pre tabindex="0"><code>root@so-onion:/var/ossec/bin# ./ossec-makelists
 * File lists/ip_list.cdb does not need to be compiled
 * File lists/approved_scanners_list.cdb does not need to be compiled
</code></pre><p>The OSSEC service should be restarted after adding a completely new list to the configuration, but does <strong>not</strong> need to be restarted if an existing list has been updated. Restarting the OSSEC service is as simple as:</p>
<pre tabindex="0"><code>root@so-onion:/var/ossec/bin# ./ossec-control restart
</code></pre><h2 id="referencing-a-list-file-in-the-rules">Referencing a list file in the rules</h2>
<p>Whitelisting an IP address in OSSEC is accomplished by setting the alert level to &ldquo;0&rdquo; for a given rule. We can piggy back on previous rules that have triggered, so that not <strong>all</strong> traffic from an IP is whitelisted, but only that traffic that matches expected behavior.</p>
<p>A review of the <code>/var/ossec/rules/web_rules.xml</code> file shows that SID group 31100 indicates web access logs:</p>
<pre tabindex="0"><code>&lt;group name=&#34;web,accesslog,&#34;&gt;
   &lt;rule id=&#34;31100&#34; level=&#34;0&#34;&gt;
    &lt;category&gt;web-log&lt;/category&gt;
      &lt;description&gt;Access log messages grouped.&lt;/description&gt;
   &lt;/rule&gt;
</code></pre><p>Using that information, we can whitelist the scanners for all web-based traffic like so:</p>
<pre tabindex="0"><code>&lt;rule id=&#34;131100&#34; level=&#34;0&#34;&gt;
   &lt;if_sid&gt;31100&lt;/if_sid&gt;
   &lt;list field=&#34;srcip&#34; lookup=&#34;address_match_key&#34;&gt;lists/approved_scanners_list&lt;/list&gt;
   &lt;description&gt;Quiet: Approved security scanners&lt;/description&gt;
&lt;/rule&gt;
</code></pre><p>More than one SID group can be referenced in the same rule by separating them with a comma:</p>
<pre tabindex="0"><code>&lt;rule id=&#34;131100&#34; level=&#34;0&#34;&gt;
   &lt;!--
      5706    [OSSEC] SSH insecure connection attempt (scan).
      5710    [OSSEC] Attempt to login using a non-existent user
      5712    [OSSEC] SSHD brute force trying to get access to the system.
      31100   web_rules.xml Alerts
   --&gt;
   &lt;if_sid&gt;5706, 5710, 5712, 31100&lt;/if_sid&gt;
   &lt;list field=&#34;srcip&#34; lookup=&#34;address_match_key&#34;&gt;lists/approved_scanners_list&lt;/list&gt;
   &lt;description&gt;Quiet: Approved security scanners&lt;/description&gt;
&lt;/rule&gt;
</code></pre><h2 id="further-reading">Further Reading</h2>
<p>For more information regarding OSSEC reference lists, please see the <a href="http://ossec-docs.readthedocs.io/en/latest/manual/rules-decoders/rule-lists.html" rel="noopener" target="_blank" class="external">full OSSEC documentation page</a>.</p>
<p>OSSEC, in general, has been written about <a href="https://www.google.com/?q=ossec&#43;site:sans.org&#43;inurl:reading-room" title="Google Search for OSSEC in the SANS Reading Room" rel="noopener" target="_blank" class="external">rather extensively</a> in the <a href="https://www.sans.org/reading-room" rel="noopener" target="_blank" class="external">SANS Reading Room</a>, and <a href="/publications/">my paper</a> can <a href="https://www.sans.org/reading-room/whitepapers/detection/ossec-netinvm-33473" rel="noopener" target="_blank" class="external">be found there</a> as well.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Security Onion - Validating EXE/DLL Download Alerts</title>
      <link>https://geekcabi.net/posts/security-onion-validate-exe-download-alerts/</link>
      <pubDate>Wed, 17 May 2017 14:40:01 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/security-onion-validate-exe-download-alerts/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;All of this was prior to the latest versions of Security Onion which now run inside docker instances. I&amp;rsquo;ve not yet looked to see how this would be replicated there. But I&amp;rsquo;m leaving this up for historical purposes.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;As I&amp;rsquo;ve &lt;a href=&#34;https://geekcabi.net/tag/securityonion.html&#34;&gt;mentioned before&lt;/a&gt;, Security Onion is a fantastic network security-focused Linux distribution which can monitor your network and/or hosts for malicious activity.&lt;/p&gt;
&lt;p&gt;The Onion can run &lt;a href=&#34;https://snort.org&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;Snort&lt;/a&gt; or &lt;a href=&#34;https://suricata-ids.org/&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;Suricata&lt;/a&gt; as a network IDS, and it can also run &lt;!-- raw HTML omitted --&gt;bro&lt;!-- raw HTML omitted --&gt; &lt;a href=&#34;https://zeek.org&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;Zeek&lt;/a&gt; alongside those traditional IDS engines to add another layer of intelligence. This article will highlight one way in which these two engines can be combined to quickly triage IDS alerts.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<blockquote>
<p>All of this was prior to the latest versions of Security Onion which now run inside docker instances. I&rsquo;ve not yet looked to see how this would be replicated there. But I&rsquo;m leaving this up for historical purposes.</p>
</blockquote>
<p>As I&rsquo;ve <a href="/tag/securityonion.html">mentioned before</a>, Security Onion is a fantastic network security-focused Linux distribution which can monitor your network and/or hosts for malicious activity.</p>
<p>The Onion can run <a href="https://snort.org" rel="noopener" target="_blank" class="external">Snort</a> or <a href="https://suricata-ids.org/" rel="noopener" target="_blank" class="external">Suricata</a> as a network IDS, and it can also run <!-- raw HTML omitted -->bro<!-- raw HTML omitted --> <a href="https://zeek.org" rel="noopener" target="_blank" class="external">Zeek</a> alongside those traditional IDS engines to add another layer of intelligence. This article will highlight one way in which these two engines can be combined to quickly triage IDS alerts.</p>
<p>Snort and Suricata both make use of the Talos rule set, and can also use the Emerging Threats (aka ET) rule set. Both of those IDS rulesets include rules to generate alerts when an executable file is downloaded. On a network of nearly any size, those rules can get to be &hellip;. noisy. I don&rsquo;t want to remove the rules, since they can be valuable, but I do want to quickly determine if any of the executables downloaded might pose a risk.</p>
<p>One way to evaluate the risk a file might introduce is to look at where it was downloaded from. By default in the Onion, Snort and Suricata don&rsquo;t show the server host information, but we can query the sguil DB and then take the resulting set and grep the bro logs for hostnames.</p>
<p>First, we need to generate the list of rule signature ID&rsquo;s (or SIDs) that indicate the download of an exe or dll file:</p>
<pre tabindex="0"><code>jma@onion-server:~$ grep -Ei &#39;(exe|dll).*download&#39; /etc/nsm/rules/*.rules | grep -Po &#39;sid:[0-9]+&#39; | cut -f2 -d: &gt; ~/sids
</code></pre><p>I imagine there are more elegant ways to accomplish this, but the above works well enough for me. :-)</p>
<p>Someday, maybe I&rsquo;ll incorporate the above command into the script below so that the entire process is fully automated. But for now, take the SIDs that are stored in the <code>~/sids</code> file and update the <code>ET_EXE_SIDS</code> variable in the script. I&rsquo;ve stored the script in the <code>/usr/local/bin/</code> folder on the onion server and saved it as <code>check-exe-downloads.sh</code>.</p>
<h2 id="stand-alone-installation">Stand Alone Installation</h2>
<p>Security Onion can be installed as a stand-alone system or as a distributed environment. We&rsquo;ll start with the basic, simpler stand-alone installation. In this scenario, the bro logs are stored on the same server as the DB, which makes them easy to query.</p>
<blockquote>
<p>Links to the full script can be found at the end of the article</p>
</blockquote>
<pre tabindex="0"><code>#!/bin/bash

# Update this list with any SIDs that indicate EXE or dll
# or other file downloads
#
# grep -Ei &#39;(exe|dll).*download&#39; /etc/nsm/rules/*.rules | grep -Po &#39;sid:[0-9]+&#39; | cut -f2 -d: &gt; ~/sids
#

# NOTE: This should really all be on one line, but is broken up here for display

ET_EXE_SIDS=&#34;2000419, 2018959, 2014518, 2014819, 2007998, 2008407,
2008408, 2008409, 2010011, 2010190, 2015537, 2015566, 2015567,
2016197, 2009568, 2009651, 2012610, 2014909, 2015688, 2016696,
2017057, 2017093, 2017297, 2017318, 2017672, 2017673, 2017674,
2017675, 2017676, 2017677, 2017679, 2017680, 2017681, 2017682,
2017683, 2018103, 2018104, 2018191, 2018556, 2018963, 2019714,
2020573, 2022050, 2022051, 2022053, 2022653, 2022884, 2023745,
2023817, 2000423, 2000424, 2000425, 2000427, 2010342, 2010447,
2010716, 2010869, 2011900, 2011919, 2011923, 2011980, 2011981,
2011983, 2011984, 2011985, 2011986, 2011990, 2013442, 2014181,
2015752, 2017678, 2017795, 2017961, 2022052, 2002068, 2008438,
2014514, 2014515, 2014516, 2014517, 2014518, 2014567, 2014819,
2016141, 2016538, 2016767, 2021216, 2023454, 2023455, 2023456,
2023457, 2023458, 2023459, 2023460, 2023461, 2023462, 2023463,
2023464, 2000371, 2001533, 2009091, 2014735, 2014810, 2018324,
2018333, 2018339, 2018367, 2000418, 2000419, 2000426, 2003179,
2003595, 2012523, 2012524, 2013037, 2014059, 2014313, 2014471,
2016856, 2018959, 2019240, 2020202, 2020914, 2009174, 2010050,
2010059, 2010741, 2011495, 2011496, 2011982, 2011989, 2011991,
2012208, 2012227, 2012389, 2013036, 2013291, 2013352, 2013441,
2013560, 2013770, 2013826, 2013827, 2014150, 2014230, 2014525,
2015547, 2015862, 2016029, 2016475, 2016844, 2017190, 2017583,
2017598, 2017617, 2017962, 2018241, 2018254, 2018395, 2018403,
2018464, 2018572, 2018581, 2018982, 2019103, 2020198, 2020199,
2020200, 2020201, 2021697, 2021774, 2021952, 2021954, 2022037,
2022207, 2022239, 2022482, 2022483, 2022640, 2022692, 2001048, 27982,
28000, 8737, 8738, 8740, 24501, 24791, 25140, 26040, 26041, 26043,
26526, 26534, 26891, 26962, 27005, 27069, 27082, 27083, 27084,
27936, 11192, 16313, 21173, 16425, 25513, 25514, 32947, 27255,
28806, 28945, 35737, 35738, 16096, 16670, 21425, 21554, 26880,
28983, 28984, 28985, 39856, 39857, 24259, 24260, 25782, 26470, 31487,
31488, 33941, 33942, 33943, 26257, 32951, 38033, 38034, 18648, 23209,
23210, 29501, 31091, 7129, 7849, 36454, 36455, 2067, 24520, 27862&#34;

IP_FILE=&#34;${HOME}/ip&#34;

if [ -e ${IP_FILE} ]; then
  rm ${IP_FILE} 2&amp;&gt;/dev/null
fi

# Build the SELECT statement using the SIDs above
QUERY=&#34;SELECT INET_NTOA(src_ip) as sip FROM event WHERE signature_id IN (${ET_EXE_SIDS}) AND status=&#34;0&#34; GROUP BY sip;&#34;

# The grep command strips the results of the header line 
# store the results in a file for grep to reference
mysql --defaults-file=/etc/mysql/debian.cnf -Dsecurityonion_db -e &#34;${QUERY}&#34; | grep -v sip &gt; ${IP_FILE}

# This is ugly and not opitmized. But it works
zcat -f /nsm/bro/logs/*/http_eth1.* | bro-cut id.resp_h host | grep -f ${IP_FILE} | awk &#39;{print $2}&#39; | sort | uniq -c | sort -rn

rm ${IP_FILE}
</code></pre><p>The results will look something like this:</p>
<pre tabindex="0"><code>jma@onion-server:~$ /usr/local/bin/check-exe-downloads.sh
3501 13.107.4.50     au.download.windowsupdate.com
 236 13.107.4.50     download.windowsupdate.com
  74 8.254.242.142   download.windowsupdate.com
  44 8.254.242.174   download.windowsupdate.com
  19 8.254.242.142   au.download.windowsupdate.com
  15 209.116.186.211 r8---sn-mv-qxoe.gvt1.com
   2 8.254.242.174   au.download.windowsupdate.com
</code></pre><h2 id="distributed-onion-environment">Distributed Onion Environment</h2>
<p>In a distributed environment, the sensors forward the Snort/Suricata alerts back to the central server, but keep the Bro logs locally. That means that the SQL query is run from the central server and the Bro logs are grep&rsquo;d via SSH to report back the findings. A few tweaks to the script will allow you to still gather the results, as seen below.</p>
<pre tabindex="0"><code>#!/bin/bash

# Update this list with any SIDs that indicate EXE or dll or other file
# downloads
#
# grep -Ei &#39;(exe|dll).*download&#39; /etc/nsm/rules/*.rules | grep -Po &#39;sid:[0-9]+&#39; | cut -f2 -d: &gt; ~/sids
#

# NOTE: This should really all be on one line, but is broken up here for display
ET_EXE_SIDS=&#34;2000419, 2018959, 2014518, 2014819, 2007998, 2008407,
2008408, 2008409, 2010011, 2010190, 2015537, 2015566, 2015567,
2016197, 2009568, 2009651, 2012610, 2014909, 2015688, 2016696,
2017057, 2017093, 2017297, 2017318, 2017672, 2017673, 2017674,
2017675, 2017676, 2017677, 2017679, 2017680, 2017681, 2017682,
2017683, 2018103, 2018104, 2018191, 2018556, 2018963, 2019714,
2020573, 2022050, 2022051, 2022053, 2022653, 2022884, 2023745,
2023817, 2000423, 2000424, 2000425, 2000427, 2010342, 2010447,
2010716, 2010869, 2011900, 2011919, 2011923, 2011980, 2011981,
2011983, 2011984, 2011985, 2011986, 2011990, 2013442, 2014181,
2015752, 2017678, 2017795, 2017961, 2022052, 2002068, 2008438,
2014514, 2014515, 2014516, 2014517, 2014518, 2014567, 2014819,
2016141, 2016538, 2016767, 2021216, 2023454, 2023455, 2023456,
2023457, 2023458, 2023459, 2023460, 2023461, 2023462, 2023463,
2023464, 2000371, 2001533, 2009091, 2014735, 2014810, 2018324,
2018333, 2018339, 2018367, 2000418, 2000419, 2000426, 2003179,
2003595, 2012523, 2012524, 2013037, 2014059, 2014313, 2014471,
2016856, 2018959, 2019240, 2020202, 2020914, 2009174, 2010050,
2010059, 2010741, 2011495, 2011496, 2011982, 2011989, 2011991,
2012208, 2012227, 2012389, 2013036, 2013291, 2013352, 2013441,
2013560, 2013770, 2013826, 2013827, 2014150, 2014230, 2014525,
2015547, 2015862, 2016029, 2016475, 2016844, 2017190, 2017583,
2017598, 2017617, 2017962, 2018241, 2018254, 2018395, 2018403,
2018464, 2018572, 2018581, 2018982, 2019103, 2020198, 2020199,
2020200, 2020201, 2021697, 2021774, 2021952, 2021954, 2022037,
2022207, 2022239, 2022482, 2022483, 2022640, 2022692, 2001048, 27982,
28000, 8737, 8738, 8740, 24501, 24791, 25140, 26040, 26041, 26043,
26526, 26534, 26891, 26962, 27005, 27069, 27082, 27083, 27084,
27936, 11192, 16313, 21173, 16425, 25513, 25514, 32947, 27255,
28806, 28945, 35737, 35738, 16096, 16670, 21425, 21554, 26880,
28983, 28984, 28985, 39856, 39857, 24259, 24260, 25782, 26470, 31487,
31488, 33941, 33942, 33943, 26257, 32951, 38033, 38034, 18648, 23209,
23210, 29501, 31091, 7129, 7849, 36454, 36455, 2067, 24520, 27862&#34;

IP_FILE=&#34;${HOME}/ip&#34;

if [ -e ${IP_FILE} ]; then
  rm ${IP_FILE} 2&amp;&gt;/dev/null
fi

# Build the SELECT statement using the SIDs above
QUERY=&#34;SELECT INET_NTOA(src_ip) as sip FROM event WHERE signature_id IN (${ET_EXE_SIDS}) AND status=&#34;0&#34; GROUP BY sip;&#34;

# The grep command strips the results of the header line 
# store the results in a file for grep to reference

# This is the first change to the remote version of the script. Since the
# output must be read into an environment variable, we send it through awk
# for additional formatting suitable to the environment.
sudo mysql --defaults-file=/etc/mysql/debian.cnf -Dsecurityonion_db -e &#34;${QUERY}&#34; | awk &#39;/^[0-9]/ { ORS=&#34;|&#34;; print $1 } END { ORS=&#34;&#34;; print $0 }&#39; &gt; ${IP_FILE}

# The grep regex can&#39;t be read from a local file, since the grep process is
# actually being run remotely. Instead, read the results into the environment
# variable which can be passed on the command line to grep through the SSH
# session.
REGEX=&#34;(`cat ${IP_FILE}`)&#34;

# This is ugly and not opitmized (at all!). But it works
# SSH to each sensor and run the grep command against the bro logs on the
# sensor
echo
echo &#34;Sensor1 results&#34;
ssh sensor1 &#34;zcat -f /nsm/bro/logs/*/http* | /opt/bro/bin/bro-cut id.resp_h host | grep -E \&#34;${REGEX}\&#34;| awk &#39;{print $2}&#39; | sort | uniq -c | sort -rn&#34;
echo
echo &#34;Sensor2 results&#34;
ssh sensor2 &#34;zcat -f /nsm/bro/logs/*/http* | /opt/bro/bin/bro-cut id.resp_h host | grep -E \&#34;${REGEX}\&#34;| awk &#39;{print $2}&#39; | sort | uniq -c | sort -rn&#34;

rm ${IP_FILE}
</code></pre><p>The results would now look something like this:</p>
<pre tabindex="0"><code>jma@onion-server:~$ /usr/local/bin/check-exe-downloads.sh

Sensor1 results
24224 208.111.171.148  d1.sophosupd.com
11781 208.111.171.148  d2.sophosupd.com
 4706 208.111.171.148  dci.sophosupd.com
 3702 13.107.4.50      au.download.windowsupdate.com
 1614 208.111.171.148  d3.sophosupd.com
  237 13.107.4.50      download.windowsupdate.com
  61 8.253.104.30      download.windowsupdate.com
   48 8.254.242.158    download.windowsupdate.com
   27 38.100.7.132     00100d-1.l.windowsupdate.com
   24 209.116.186.210  r7---sn-mv-qxoe.gvt1.com
   13 208.111.170.216  000ee3-1.l.windowsupdate.com
   13 208.111.168.89   00138b-1.l.windowsupdate.com
   13 208.111.168.78   001b40-1.l.windowsupdate.com
   13 208.111.168.72   001b40-1.l.windowsupdate.com
    8 8.253.104.30     au.download.windowsupdate.com
    2 69.164.19.161    000866-1.l.windowsupdate.com
    2 38.100.7.163     001389-1.l.windowsupdate.com
    2 208.111.170.203  000ed5-1.l.windowsupdate.com

Sensor2 results
6838 208.111.171.148  d1.sophosupd.com
3409 208.111.171.148  d2.sophosupd.com
2945 13.107.4.50      au.download.windowsupdate.com
1293 208.111.171.148  dci.sophosupd.com
 429 208.111.171.148  d3.sophosupd.com
 170 13.107.4.50      download.windowsupdate.com
  86 208.111.161.190  00100d-1.l.windowsupdate.com
  75 38.100.7.149     0015b0-1.l.windowsupdate.com
  58 208.111.161.146  000793-1.l.windowsupdate.com
  55 8.254.242.158    download.windowsupdate.com
  35 8.253.104.30     download.windowsupdate.com
  34 208.111.161.206  000793-1.l.windowsupdate.com
  25 69.164.19.161    0007c2-1.l.windowsupdate.com
  24 8.254.242.158    au.download.windowsupdate.com
  24 208.111.161.206  000238-1.l.windowsupdate.com
  24 208.111.161.154  0004d3-1.l.windowsupdate.com
  23 69.28.159.143    00100d-1.l.windowsupdate.com
  14 74.125.155.199   r1---sn-p5qs7n7z.gvt1.com
  13 38.100.7.177     00100d-1.l.windowsupdate.com
  13 208.111.168.72   000793-1.l.windowsupdate.com
  10 69.28.159.200    001c17-1.l.windowsupdate.com
   6 208.111.161.146  00100d-1.l.windowsupdate.com
   4 208.111.161.138  000935-1.l.windowsupdate.com
   3 38.100.7.132     000935-1.l.windowsupdate.com
   2 8.253.104.30     au.download.windowsupdate.com
   2 69.28.159.20     000935-1.l.windowsupdate.com
   2 208.111.161.206  000ed5-1.l.windowsupdate.com
   2 208.111.161.203  00246b-1.l.windowsupdate.com
   1 208.111.161.206  00115a-1.l.windowsupdate.com
</code></pre><p>It&rsquo;s not guaranteed that malicious files won&rsquo;t be downloaded from &ldquo;normal-looking&rdquo; sites, but this is a good quick sanity check for anything that might stick out from the norm.</p>
<h2 id="script-downloads">Script Downloads</h2>
<p><a href="/static/files/check-exe-downloads-standalone.sh">Standalone check-exe-downloads.sh</a></p>
<p><a href="/static/files/check-exe-downloads-distributed.sh">Distributed check-exe-downloads.sh</a></p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Filtering Home Internet with Circle</title>
      <link>https://geekcabi.net/posts/filtering-home-internet-with-circle/</link>
      <pubDate>Thu, 11 May 2017 16:50:00 -0600</pubDate>
      
      <guid>https://geekcabi.net/posts/filtering-home-internet-with-circle/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://meetcircle.com/&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;Meet Circle&lt;/a&gt; from Disney. According to Disney, using Circle you can &amp;ldquo;manage all of your home’s connected devices&amp;rdquo; and &amp;ldquo;parents can filter content, limit screen time and set a bedtime for every device in the home.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;Circle is an extremely easy and simple to use home web filter, and one which is at least relatively effective with time controls, since I can hear my kids groan every time their alloted time has been spent.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><a href="https://meetcircle.com/" rel="noopener" target="_blank" class="external">Meet Circle</a> from Disney. According to Disney, using Circle you can &ldquo;manage all of your home’s connected devices&rdquo; and &ldquo;parents can filter content, limit screen time and set a bedtime for every device in the home.&rdquo;</p>
<p>Circle is an extremely easy and simple to use home web filter, and one which is at least relatively effective with time controls, since I can hear my kids groan every time their alloted time has been spent.</p>
<h3 id="installation">Installation</h3>
<p>Installation is super simple:</p>
<ol>
<li>Download the phone app</li>
<li>Plugin the device</li>
<li>Use the phone app to tell Circle which network to pair with (wired or wireless)</li>
</ol>
<h3 id="profiles">Profiles</h3>
<p>That&rsquo;s really it. But unless you want to have the same Internet limitations as your kids (including time spent), you should setup User Profiles on the phone app and assign devices to those profiles. That&rsquo;s also super easy within the app.</p>
<p>With those profiles, you can specify time limits or website categories that are permitted or denied per profile. But there&rsquo;s not a lot of customization available here. Circle comes with several family friendly websites listed as &ldquo;apps&rdquo; that you can allow or deny per profile. You can also whitelist a given domain or URL per profile. Not much else there, really.</p>
<p>Unfortunately, any network activity counts as Internet time used. So even running Windows Updates takes up the time alloted to that profile. If you&rsquo;re an advanced home user, and you have any sort of centralized management software in place, that will get blocked once the profile&rsquo;s Internet time is up for the day.</p>
<h3 id="reporting">Reporting</h3>
<p>Ick.</p>
<p>You can see how much time a profile has spent on the Internet (today, this week, or this month) via the phone app. You can also see the list of recent connections. But there&rsquo;s no good way to export that data.</p>
<h3 id="pros">Pros</h3>
<ul>
<li>Installation
<ul>
<li>No agent required</li>
</ul>
</li>
<li>Excellent mobile notifications
<ul>
<li>When a new device shows up on your network</li>
<li>When a user reached his/her activity timelimit</li>
</ul>
</li>
<li>Works for wired and wireless devices seemlessly</li>
</ul>
<h3 id="cons">Cons</h3>
<ul>
<li>Must be managed via the phone app - no web interface available</li>
<li>Filtering is done via ARP spoofing, so it&rsquo;s <strong>VERY</strong> noisy on the network</li>
<li>Customization of the filter is limited</li>
<li>Detailed reporting is lacking</li>
<li>Devices must belong to one user/profile</li>
<li>ARP spoofing(?!)</li>
<li>Infrequent device updates (has it updated at all since I received it?)</li>
<li>Can be bypassed via static ARP entry on the host</li>
<li>Can only manage one network segment (e.g. one wireless network)
<ul>
<li>This obviously only comes into play if you have more than one VLAN on your home network, which most people don&rsquo;t have. But for geeks, this can be a problem.</li>
</ul>
</li>
</ul>
<h3 id="conclusion">Conclusion</h3>
<p>Circle could be a fine fit for your home, provided you don&rsquo;t have a complicated home network, and don&rsquo;t require detailed logging of activity.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Using ncat in Broker Mode</title>
      <link>https://geekcabi.net/posts/ncat-broker/</link>
      <pubDate>Wed, 09 Nov 2016 09:00:01 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/ncat-broker/</guid>
      <description>&lt;!-- raw HTML omitted --&gt;
&lt;p&gt;I was looking through the various options for &lt;a href=&#34;https://nmap.org/ncat/&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;ncat&lt;/a&gt; and came across an option I hadn&amp;rsquo;t seen before: &lt;a href=&#34;https://nmap.org/ncat/guide/ncat-broker.html&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;Broker mode&lt;/a&gt;. After reading through the examples, I learned that the &lt;code&gt;--chat&lt;/code&gt; mode is really just a special mode of connection brokering.&lt;/p&gt;
&lt;p&gt;In ncat, &amp;ldquo;brokering&amp;rdquo; a connection allows multiple connections to the same listening instance, and takes the input from one connection and send it as output to all the other connections. The &lt;a href=&#34;https://geekcabi.net/posts/using-ncat-as-a-chat-server/&#34;&gt;ncat chat server&lt;/a&gt; adds labels to who said what to help keep the confusion down, but in every other way, it is simply a brokered connection.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<!-- raw HTML omitted -->
<p>I was looking through the various options for <a href="https://nmap.org/ncat/" rel="noopener" target="_blank" class="external">ncat</a> and came across an option I hadn&rsquo;t seen before: <a href="https://nmap.org/ncat/guide/ncat-broker.html" rel="noopener" target="_blank" class="external">Broker mode</a>. After reading through the examples, I learned that the <code>--chat</code> mode is really just a special mode of connection brokering.</p>
<p>In ncat, &ldquo;brokering&rdquo; a connection allows multiple connections to the same listening instance, and takes the input from one connection and send it as output to all the other connections. The <a href="https://geekcabi.net/posts/using-ncat-as-a-chat-server/">ncat chat server</a> adds labels to who said what to help keep the confusion down, but in every other way, it is simply a brokered connection.</p>
<p>This mode of operation could come in handy when two systems cannot connect directly to each other, perhaps due to NAT&rsquo;ing or other firewall restrictions. Utilizing a third system can help move data efficiently between systems.</p>
<p>Use of the <code>--broker</code> flag implies the <code>-l</code> flag:</p>
<pre><code>    ubahmapk@laptop:~ &gt; ncat --broker -v 
    Ncat: Version 7.25SVN ( https://nmap.org/ncat )
    Ncat: Listening on :::31337
    Ncat: Listening on 0.0.0.0:31337
</code></pre>
<p>If no listening port is specified, the highly popular port of 31337 is used as the default.</p>
<p>Using broker mode, we can transfer files from one host to another (or multiple!) through an intermediate host.
First set up the listening broker on port 443 (since that was the only other port open on my firewall):</p>
<pre><code>    ubahmapk@broker-host:~$ sudo ncat -l -v --broker -p 443
    Ncat: Version 7.25SVN ( https://nmap.org/ncat )
    Ncat: Listening on :::443
    Ncat: Listening on 0.0.0.0:443
</code></pre>
<p>Get ready to receive the file:</p>
<pre><code>    ubahmapk@receiving-host:~$ ncat --recv-only 192.168.2.99 443 | tee outputfile
</code></pre>
<p>By piping the output through tee, we can see the data as it comes in while also saving it to the file.</p>
<p>We can see on the broker that the receiving host connected:</p>
<pre><code>    Ncat: Connection from 192.168.1.6.
    Ncat: Connection from 192.168.1.6:40868.
</code></pre>
<p>Now that everything&rsquo;s setup, we can send our precious data! Just for fun, I&rsquo;m using the HTTP headers from the SANS <a href="https://isc.sans.edu" rel="noopener" target="_blank" class="external">Internet Storm Center</a> website:</p>
<pre><code>    ubahmapk@sending-host:~$ cat headers
    HTTP/1.1 200 OK
    Date: Wed, 09 Nov 2016 21:42:25 GMT
    Content-Type: text/html; charset=UTF-8
    Connection: keep-alive
    Server: nc -6 -l 80
    X-Content-Type-Options: nosniff
    X-XSS-Protection: 1; mode=block
    X-HeyJason: DEV522 rocks
    Permitted-Cross-Domain-Policies: none
    Public-Key-Pins: pin-sha256=&quot;yPygUehClEHV8rvCx38NfHm7VA6IQN65Jkp2W4czLl4=&quot;;pin-sha256=&quot;ujF0jpR9Bfbrlj2annpMzkLl1DZr1y80DAqNkoAw9IA=&quot;;pin-sha256=&quot;oBPvhtvElQwtqQAFCzmHX7iaOgvmPfYDRPEMP5zVMBQ=&quot;;pin-sha256=&quot;Ofki57ad70COg0ke3x80cbJ62Tt3c/f3skTimJdpnTw=&quot;; pin-sha256=&quot;kS2Xhr6z68kfHmJMGRYw5Gept+QuLctgg7RQaHUfYHc=&quot;; max-age=2592000; report-uri=&quot;https://sansisc.report-uri.io/r/default/hpkp/enforce&quot;
    Strict-Transport-Security: max-age=63072000
    X-Do-Not-Hack: 18 U.S.C. Parag 1030
    X-Frame-Options: SAMEORIGIN
    Content-Security-Policy-Report-Only: default-src 'self' www.sans.org; report-uri https://sansisc.report-uri.io/r/default/csp/reportOnly; script-src 'unsafe-inline' 'unsafe-eval' 'self'; style-src 'unsafe-inline' 'self'; frame-src www.sans.org
    Cache-Control: max-age=0, public
    Expires: Wed, 09 Nov 2016 21:42:25 GMT
    X-IPv6-Geekiness: FALSE
</code></pre>
<p>So, let&rsquo;s send the file:</p>
<pre><code>    ubahmapk@sending-host:~$ ncat --send-only 192.168.2.99 443 &lt; headers
</code></pre>
<p>The broker console confirms the sending host&rsquo;s connection:</p>
<pre><code>    Ncat: Connection from 10.1.0.4.
    Ncat: Connection from 10.1.0.4:59048.
</code></pre>
<p>and the resulting file is stored in &lsquo;outfile&rsquo;.</p>
<p>Broker mode is certainly not the only way to send a file, and probably not even the most common. But it is certainly interesting. Not to mention the fact that it is always good to know all the available options. :-)</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>How to Use miniLock - a Simple Way to Encrypt Files</title>
      <link>https://geekcabi.net/posts/how-to-use-minilock/</link>
      <pubDate>Fri, 22 Apr 2016 09:00:01 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/how-to-use-minilock/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I originally posted this entry on our family&amp;rsquo;s Wordpress blog, back in 2015. I decided to update and repost the content here, since &lt;del&gt;it&amp;rsquo;s still relevant and&lt;/del&gt; it fits better here anyway&amp;hellip;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;miniLock is no longer actively maintained and is no longer recommended as an encrypton option.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;There are lots of different ways to encrypt a file and today I want to cover one of the more obscure, and I believe more unique methods.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<blockquote>
<p>I originally posted this entry on our family&rsquo;s Wordpress blog, back in 2015. I decided to update and repost the content here, since <del>it&rsquo;s still relevant and</del> it fits better here anyway&hellip;</p>
</blockquote>
<blockquote>
<p><strong>miniLock is no longer actively maintained and is no longer recommended as an encrypton option.</strong></p>
</blockquote>
<p>There are lots of different ways to encrypt a file and today I want to cover one of the more obscure, and I believe more unique methods.</p>
<p>miniLock <del>is</del> was a Chrome app and relies on the combination of an email address and a strong passphrase as the key. This is both a positive and a negative.</p>
<p>That&rsquo;s great because it means you can encrypt and decrypt files on a Chromebook, or any other machine without storing the private key locally. It&rsquo;s bad because most people don&rsquo;t have good passwords – much less <strong>passphrases</strong>.</p>
<p>Still, it&rsquo;s a simple way to encrypt files, and I like to have options.</p>
<p>At the risk of making the process more complicated than it really is, I took some screenshots and walked through the installation and encryption process below.</p>
<h2 id="installation">Installation</h2>
<p>Step 1: Install</p>
<p>Installation is super simple. Visit <a href="http://minilock.io" rel="noopener" target="_blank" class="external">minilock.io</a> and click the link to the Chrome App Store</p>
<p><img loading="lazy" src="/posts/how-to-use-minilock/minilock-01-install-from-website.png" type="" alt="01 - Install from website"  /></p>
<p>Click &ldquo;Add to Chrome&rdquo;</p>
<p><img loading="lazy" src="/posts/how-to-use-minilock/minilock-02-add-to-chrome.png" type="" alt="02 - Add to Chrome"  /></p>
<p>Step 2: Launch</p>
<p>Go to the installed Apps in Chrome and click on the light blue padlock</p>
<p><img loading="lazy" src="/posts/how-to-use-minilock/minilock-03-launch-from-apps.png" type="" alt="Yes, I&rsquo;m a baseball fan&hellip;"  /></p>
<p>Step 3: Create key</p>
<p>This is done by entering your email address and a strong passphrase.</p>
<p><img loading="lazy" src="/posts/how-to-use-minilock/minilock-04-login.png" type="" alt="04 - Login"  /></p>
<h2 id="encryption">Encryption</h2>
<p>Step 4: Select file</p>
<p>Your miniLock ID is shown at the bottom of this window. This key can be posted or sent anywhere – and should be if you want others to be able to send you encrypted files with miniLock. I <del>currently have</del> even had my ID in <a href="https://twitter.com/ubahmapk" rel="noopener" target="_blank" class="external">my Twitter bio line</a> - and in fact, the entire key ID fits in a single tweet.</p>
<p>My miniLock ID is UXTFUyqcoM3spXNMtqpZGqqNzjZyZsGiQQwezVH1UYNR5.</p>
<p>Now you can either drag the file you want to encrypt, or click the big square box to find your file.</p>
<p><img loading="lazy" src="/posts/how-to-use-minilock/minilock-05-add-files.png" type="" alt="05 - Add files"  /></p>
<p>Step 5: Encrypt</p>
<p>Paste in the miniLock IDs of the file recipients. I strongly recommend keeping these in a text file or email or Evernote or something similar. Again, they are not sensitive, so it really doesn&rsquo;t matter where you keep them. A file in <a href="https://www.dropbox.com/referrals/NTE1NDEzMDk?src=global9" title="Referral link" rel="noopener" target="_blank" class="external">Dropbox</a> would work just fine. :-)</p>
<p><img loading="lazy" src="/posts/how-to-use-minilock/minilock-06-add-minilock-ids-and-encrypt.png" type="" alt="06 - Add miniLock IDs and encrypt"  /></p>
<p>You can add more miniLock IDs if you need to.</p>
<p>Step 7: Save encrypted file</p>
<p>Once complete, you can download the encrypted file by clicking on the down arrow. This &ldquo;.minilock&rdquo; file can be attached to an email or sent via Dropbox or put on a USB stick or stored and distributed anywhere, really.</p>
<p><img loading="lazy" src="/posts/how-to-use-minilock/minilock-07-download-encrypted-file.png" type="" alt="07 - Download encrypted file"  /></p>
<h2 id="decryption">Decryption</h2>
<p>Decrypting a &ldquo;.minilock&rdquo; file is just as easy. Simply drag and drop the file onto the window from Step 4. The file will decrypt (assuming it was encrypted to your miniLock ID) and you can download and save the original file.</p>
<p><img loading="lazy" src="/posts/how-to-use-minilock/minilock-08-download-decrypted-file.png" type="" alt="08 - Download decrypted file"  /></p>
<h2 id="conclusion">Conclusion</h2>
<p>That&rsquo;s really all there is to it.</p>
<p>I believe the greatest weakness and strength of the entire miniLock system is the keys. (Of course, that should be said of any good encryption system - and this solution hasn&rsquo;t been elevated to that status yet.)</p>
<p>It&rsquo;s a strength because the private key isn&rsquo;t stored anywhere - it&rsquo;s generated by the login process. It&rsquo;s a weakness because there isn&rsquo;t a good way to store the keys for others. Which means key distribution with miniLock has the same problem as PGP. Except there isn&rsquo;t a way to sign the keys of others, so there&rsquo;s no good way to establish trust, making the miniLock less ideal than PGP.</p>
<p>I still prefer <a href="https://en.wikipedia.org/wiki/Pretty_Good_Privacy" rel="noopener" target="_blank" class="external">PGP</a>  (or <a href="https://gnupg.org" title="Gnu Privacy Guard - Open Source PGP implementation" rel="noopener" target="_blank" class="external">GnuPG</a>) for encryption, but it&rsquo;s good to have alternatives to work with. <del>So I consider this just another option.</del></p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Restricting Connections to ncat</title>
      <link>https://geekcabi.net/posts/ncat-access-control/</link>
      <pubDate>Fri, 08 Apr 2016 09:00:01 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/ncat-access-control/</guid>
      <description>&lt;p&gt;We&amp;rsquo;ve already seen the usefulness of &lt;a href=&#34;https://nmap.org/ncat/&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;ncat&lt;/a&gt;, including &lt;a href=&#34;https://geekcabi.net/posts/using-ssl-connections-over-ncat/&#34;&gt;ncat SSL sessions&lt;/a&gt; and &lt;a href=&#34;https://geekcabi.net/posts/using-ncat-as-a-chat-server/&#34;&gt;running chat servers&lt;/a&gt;. Now we address the potential issue of unintended users of our listening ncat sessions.&lt;/p&gt;
&lt;p&gt;Why would you want to limit access to an ncat listener?&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re competing in a Capture the Flag event and you&amp;rsquo;ve managed to establish an ncat listener, it would be no good to take a host you worked so hard to gain and gice it away to the other competitors.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>We&rsquo;ve already seen the usefulness of <a href="https://nmap.org/ncat/" rel="noopener" target="_blank" class="external">ncat</a>, including <a href="https://geekcabi.net/posts/using-ssl-connections-over-ncat/">ncat SSL sessions</a> and <a href="https://geekcabi.net/posts/using-ncat-as-a-chat-server/">running chat servers</a>. Now we address the potential issue of unintended users of our listening ncat sessions.</p>
<p>Why would you want to limit access to an ncat listener?</p>
<p>If you&rsquo;re competing in a Capture the Flag event and you&rsquo;ve managed to establish an ncat listener, it would be no good to take a host you worked so hard to gain and gice it away to the other competitors.</p>
<p>Worse still if it was <strong>not</strong> a Capture the Flag event but a live pentest, in which you opened a hole to a live shell console to <strong>real</strong> attackers while simply conducting your test!</p>
<p>Connections to the ncat session can be restricted via the use of the following flags:</p>
<ul>
<li><code>--allow</code></li>
<li><code>--deny</code></li>
<li><code>--allowfile</code></li>
<li><code>--denyfile</code></li>
</ul>
<p>These largely work as you might expect. Per the ncat man page, each of these options support the standard host specification as used by <a href="http://nmap.org" rel="noopener" target="_blank" class="external">Nmap</a>.</p>
<pre><code>    ubahmapk@laptop:~ &gt; ncat -v --chat -l -p 8888 --deny 192.168.0.30
    Ncat: Version 7.12 ( https://nmap.org/ncat )
    Ncat: Listening on :::8888
    Ncat: Listening on 0.0.0.0:8888
    Ncat: Connection from 192.168.0.30 on file descriptor 5.
    Ncat: Connection from 192.168.0.30:64554.
    Ncat: New connection denied: not allowed
</code></pre>
<p>When the client attempts to connect, the only message received is:</p>
<pre><code>    C:\USERS\ubahmapk&gt; ncat 192.168.0.10 8888
    close: No error
</code></pre>
<p>Which actually differs from when the port isn&rsquo;t open:</p>
<pre><code>    C:\USERS\ubahmapk&gt; ncat 192.168.0.10 8888
    Ncat: No connection could be made because the target machine actively refused it. .
</code></pre>
<p>(The extra period at the end is not a typo on my part. It&rsquo;s really included in the output&hellip;)</p>
<p>Obviously, in most cases permitting or restricting a single IP is not so helpful. So you can also use the <code>--allowfile</code> or <code>--denyfile</code> options. The files specified here should contain one entry (either IP, hostname, or CIDR range) per line.</p>
<p>Combining all the techniques we&rsquo;ve seen so far, we can very quickly and easily set up a private, encrypted chat server for use in&hellip;.well doing almost anything you want. It could be used as a poor man&rsquo;s red team dumping ground, so that all members of the team have access to all the accounts and hosts compromised so far, for example.</p>
<pre><code>    ncat -v --ssl --allowfile allowed-ips -l -p 8443 --chat
</code></pre>
<p>I used port 8443 here to help the encrypted chat traffic possibly blend in with other potential traffic.</p>
<p>We still have a few more options to cover in the coming weeks, but we&rsquo;re off to a great start! :-)</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Using ncat as a Chat Server</title>
      <link>https://geekcabi.net/posts/using-ncat-as-a-chat-server/</link>
      <pubDate>Tue, 05 Apr 2016 09:00:01 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/using-ncat-as-a-chat-server/</guid>
      <description>&lt;p&gt;Sometimes a quick and easy channel for communication can come in handy. &lt;a href=&#34;https://nmap.org/ncat/&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;ncat&lt;/a&gt; has a nice option for just such a chat server.&lt;/p&gt;
&lt;h2 id=&#34;start-it-up&#34;&gt;Start it up&lt;/h2&gt;
&lt;p&gt;Start the server using the &lt;code&gt;-l&lt;/code&gt; and &lt;code&gt;--chat&lt;/code&gt; flags:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    ubahmapk@laptop:~ &amp;gt; ncat --chat -l -p 8888
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note that you will not see any of the chat traffic in this window, but if you add the &lt;code&gt;-v&lt;/code&gt; flag, you will at least see the connections as they are established:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Sometimes a quick and easy channel for communication can come in handy. <a href="https://nmap.org/ncat/" rel="noopener" target="_blank" class="external">ncat</a> has a nice option for just such a chat server.</p>
<h2 id="start-it-up">Start it up</h2>
<p>Start the server using the <code>-l</code> and <code>--chat</code> flags:</p>
<pre><code>    ubahmapk@laptop:~ &gt; ncat --chat -l -p 8888
</code></pre>
<p>Note that you will not see any of the chat traffic in this window, but if you add the <code>-v</code> flag, you will at least see the connections as they are established:</p>
<pre><code>    ubahmapk@laptop:~ &gt; ncat -v -l --chat -p 8888
    Ncat: Version 7.12 ( https://nmap.org/ncat )
    Ncat: Listening on :::8888
    Ncat: Listening on 0.0.0.0:8888
</code></pre>
<p>Since this server console does not actively participate in the conversation, adding the <code>-v</code> flag does not send the verbose info to the participants.</p>
<p>Open up a new terminal window and make a standard ncat (or even a traditional nc) connection to the chat server:</p>
<pre><code>    ubahmapk@laptop:~ &gt; ncat 192.168.0.10 8888
    &lt;announce&gt; 192.168.0.10 is connected as &lt;user5&gt;.
    &lt;announce&gt; already connected: nobody.
</code></pre>
<p>ncat informs you of the previously connected users, in this case there were no others. Since this is an ncat session, when new users connect and the previously existing connections are announced, you will see your own connection listed as new uers arrive:</p>
<pre><code>    &lt;announce&gt; 192.168.0.20 is connected as &lt;user6&gt;.
    &lt;announce&gt; already connected: 192.168.0.10 as &lt;user5&gt;.
</code></pre>
<p>ncat reports the connections on the server console thusly:</p>
<pre><code>    Ncat: Connection from 192.168.0.10 on file descriptor 5.
    Ncat: Connection from 192.168.0.10:57850.
    Ncat: Connection from 192.168.0.20 on file descriptor 6.
    Ncat: Connection from 192.168.0.20:83853.
</code></pre>
<p>As participants chat, the content is prepended by the user ID so everyone knows who said what:</p>
<pre><code>    &lt;user7&gt; It's me, it's me, it's Ernest T!
</code></pre>
<p>And lastly, departures from the chat room are also announced:</p>
<pre><code>    &lt;announce&gt; &lt;user7&gt; is disconnected.
</code></pre>
<h2 id="encryption">Encryption</h2>
<p>As described above, all of this traffic would traverse the network in plain text by default. But, as you may remember, <a href="https://geekcabi.net/posts/using-ssl-connections-over-ncat/">ncat can establish SSL connections</a>, too!</p>
<pre><code>    ubahmapk@laptop:~ &gt; ncat -v -l --ssl --chat -p 8888
    Ncat: Version 7.12 ( https://nmap.org/ncat )
    Ncat: Generating a temporary 1024-bit RSA key. Use --ssl-key and --ssl-cert to use a permanent one.
    Ncat: SHA-1 fingerprint: FB24 84E8 D3F2 F77D DB1B 9C8B 00A4 7C89 E5D0 4A69
    Ncat: Listening on :::8888
    Ncat: Listening on 0.0.0.0:8888
</code></pre>
<p>Note that ncat will generate a temporary SSL certificate unless you specify a key and cert to use.</p>
<p>Client connections would just need to include the <code>--ssl</code> flag and everything else works the same as before:</p>
<pre><code>    Ncat: Connection from 192.168.0.10 on file descriptor 5.
    Ncat: Connection from 192.168.0.10:58874.
    Ncat: Connection from 192.168.0.20 on file descriptor 6.
    Ncat: Connection from 192.168.0.20:85876
</code></pre>
<h2 id="access-control">Access Control</h2>
<p>But what if you don&rsquo;t want just <strong>anyone</strong> to be able to connect to this chat server? Well, it turns out that ncat also supports IP restrictions, which can be applied to listening chat servers. <del>But we&rsquo;ll save that for another day.</del> Or, you can check out <a href="https://geekcabi.net/posts/ncat-access-control/">ncat Access Control</a> here.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Using SSL Connections Over ncat</title>
      <link>https://geekcabi.net/posts/using-ssl-connections-over-ncat/</link>
      <pubDate>Sun, 20 Mar 2016 09:00:01 +0000</pubDate>
      
      <guid>https://geekcabi.net/posts/using-ssl-connections-over-ncat/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://nmap.org/ncat/&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;ncat&lt;/a&gt; is a full rewrite from the nmap team of the traditional &lt;a href=&#34;http://nc110.sourceforge.net/&#34; rel=&#34;noopener&#34; target=&#34;_blank&#34; class=&#34;external&#34;&gt;netcat&lt;/a&gt; (nc) network &amp;ldquo;Swiss Army Knife&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;ncat is full of really slick new features, but the one I will cover here is the ability to do all the wonderful things nc could do, but over an SSL connection. (Yes, yes, yes: I should call it a TLS connection instead, but since the ncat documentation still refers to it as &amp;ldquo;SSL&amp;rdquo;, I will do the same here.)&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><a href="https://nmap.org/ncat/" rel="noopener" target="_blank" class="external">ncat</a> is a full rewrite from the nmap team of the traditional <a href="http://nc110.sourceforge.net/" rel="noopener" target="_blank" class="external">netcat</a> (nc) network &ldquo;Swiss Army Knife&rdquo;.</p>
<p>ncat is full of really slick new features, but the one I will cover here is the ability to do all the wonderful things nc could do, but over an SSL connection. (Yes, yes, yes: I should call it a TLS connection instead, but since the ncat documentation still refers to it as &ldquo;SSL&rdquo;, I will do the same here.)</p>
<p>To establish an encrypted ncat session, simply pass the &ldquo;&ndash;ssl&rdquo; option to ncat, along with the hostname or IP and destination port, like you would with any other connection:</p>
<pre><code>ubahmapk@laptop:~ &gt; echo -e &quot;GET / HTTP/1.1\r\nHost: \
ubahmapk.github.io\r\nUser-Agent: ncat\r\nAccept: */*\r\nReferer: \
https://www.google.com/?gws_rd=ssl#q=ncat+ssl\r\n\r\n&quot; \ 
| ncat --ssl -v ubahmapk.github.io 443
Ncat: Version 6.49SVN ( http://nmap.org/ncat )
Ncat: SSL connection to 23.235.44.133:443. Fastly, Inc.
Ncat: SHA-1 fingerprint: 2199 1384 6372 1713 B9ED 0E8F 00A5 9B73 0DD0 5658
HTTP/1.1 200 OK
Server: GitHub.com
Content-Type: text/html; charset=utf-8
Last-Modified: Mon, 21 Mar 2016 02:14:16 GMT
Access-Control-Allow-Origin: *
Expires: Mon, 21 Mar 2016 03:42:50 GMT
Cache-Control: max-age=600
X-GitHub-Request-Id: 17EB2C2C:38FF:984CD29:56EF6B60
Content-Length: 12733
Accept-Ranges: bytes
Date: Mon, 21 Mar 2016 03:32:50 GMT
Via: 1.1 varnish
Age: 0
Connection: keep-alive
X-Served-By: cache-dfw1826-DFW
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1458531170.944139,VS0,VE49
Vary: Accept-Encoding
X-Fastly-Request-ID: f9a65b919e4649f5ef6f24397ecdf953fee840dd

[trimmed output]
</code></pre>
<p>The &lsquo;-v&rsquo; option above caused ncat to include the three lines at the top beginning with &ldquo;Ncat: &ldquo;, which confirm the version running, along with the SSL connection connection information. Adding three &lsquo;-v&rsquo; options would add information like this:</p>
<pre><code> NCAT DEBUG: Using system default trusted CA certificates and those in /usr/local/share/ncat/ca-bundle.crt.
 Ncat: Subject: C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert High Assurance EV Root CA
 Ncat: Issuer: C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert High Assurance EV Root CA
 Ncat: SHA-1 fingerprint: 5FB7 EE06 33E2 59DB AD0C 4C9A E6D3 8F1A 61C7 DC25
 Ncat: Subject: C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert SHA2 High Assurance Server CA
 Ncat: Issuer: C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert High Assurance EV Root CA
 Ncat: SHA-1 fingerprint: A031 C467 82E6 E6C6 62C2 C87C 76DA 9AA6 2CCA BD8E
 Ncat: Subject: C=US, ST=California, L=San Francisco, O=Fastly, Inc., CN=www.github.com
 Ncat: Issuer: C=US, O=DigiCert Inc, OU=www.digicert.com, CN=DigiCert SHA2 High Assurance Server CA
 Ncat: SHA-1 fingerprint: 2199 1384 6372 1713 B9ED 0E8F 00A5 9B73 0DD0 5658
 NCAT DEBUG: Checking certificate DNS name &quot;www.github.com&quot; against &quot;ubahmapk.github.io&quot;.
 NCAT DEBUG: Checking certificate DNS name &quot;*.github.com&quot; against &quot;ubahmapk.github.io&quot;.
 NCAT DEBUG: Checking certificate DNS name &quot;github.com&quot; against &quot;ubahmapk.github.io&quot;.
 NCAT DEBUG: Checking certificate DNS name &quot;*.github.io&quot; against &quot;ubahmapk.github.io&quot;.
 Ncat: SSL connection to 23.235.40.133:443. Fastly, Inc.
 Ncat: SHA-1 fingerprint: 2199 1384 6372 1713 B9ED 0E8F 00A5 9B73 0DD0 5658
</code></pre>
<p>But it also includes a great deal of other details from the libnsock library and can greatly clutter up the output.</p>
<p>Inbound connections with ncat can also utilize the ssl option:</p>
<pre><code>ncat --ssl -l -p 443 -e /bin/bash
</code></pre>
<p>(The above is a <em>terrible</em> thing to run. Do <em>NOT</em> do that&hellip;)</p>
<p>The code snippet below shows the options used to specify public and private SSL keys; certificate validation behavior and which file should be used to validate certificates; and which SSL ciphers to accept (or reject):</p>
<pre><code>--ssl-cert             Specify SSL certificate file (PEM) for listening
--ssl-key              Specify SSL private key (PEM) for listening
--ssl-verify           Verify trust and domain name of certificates
--ssl-trustfile        PEM file containing trusted SSL certificates
--ssl-ciphers          Cipherlist containing SSL ciphers to use
</code></pre>
<p>If you needed to make SSL connections with the traditional nc client, you could either create an stunnel connection or utilize the openssl s_client command as a ncat client:</p>
<pre><code>ubahmapk@laptop:~ &gt; openssl s_client -host ubahmapk.github.io -port 443 
CONNECTED(00000003)
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert High Assurance EV Root CA
verify return:1
depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert SHA2 High Assurance Server CA
verify return:1
depth=0 C = US, ST = California, L = San Francisco, O = &quot;Fastly, Inc.&quot;, CN = www.github.com
verify return:1
---
Certificate chain
0 s:/C=US/ST=California/L=San Francisco/O=Fastly, Inc./CN=www.github.com
i:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA
1 s:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA
i:/C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA
---
Server certificate

[output trimmed]
</code></pre>
<p>But this method isn&rsquo;t nearly as clean, and doesn&rsquo;t allow for all the other functionality of netcat!</p>
<p>In fact, I&rsquo;ll probably start a series on the different ncat options just for fun&hellip; :-)</p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
