<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Rift]]></title><description><![CDATA[Security, Research, Tooling]]></description><link>https://rift.stacktitan.com/</link><image><url>https://rift.stacktitan.com/favicon.png</url><title>Rift</title><link>https://rift.stacktitan.com/</link></image><generator>Ghost 5.16</generator><lastBuildDate>Tue, 14 Apr 2026 23:25:29 GMT</lastBuildDate><atom:link href="https://rift.stacktitan.com/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Wardriving Introduction & Kismet 6 GHz]]></title><description><![CDATA[As we continue on our wireless journey, let's explore WiFi6/E, learn about wardriving and configure supporting toolchains.]]></description><link>https://rift.stacktitan.com/wardriving-6e-kismet/</link><guid isPermaLink="false">668c51dd0f38281a29a6784a</guid><category><![CDATA[adversary]]></category><category><![CDATA[hacking]]></category><category><![CDATA[pentest]]></category><category><![CDATA[security]]></category><category><![CDATA[wireless]]></category><category><![CDATA[hardware]]></category><category><![CDATA[stacktitan]]></category><category><![CDATA[rift]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Mon, 08 Jul 2024 23:31:08 GMT</pubDate><content:encoded><![CDATA[<p>Welcome back to the wireless series! As a continuation from our <a href="https://rift.stacktitan.com/explorations-into-wi-fi6e/">Explorations into Wi-Fi6/E</a>, we&apos;re going to discuss wardriving. Wardriving has its roots in wardialing - scanning the numeric space of a set of telephone numbers to identify connections to equipment such as modems, fax machines, or other systems that may be interesting to manipulate for various purposes. Warwalking, warchalking, and wardriving all began as ways to identify and map the location of unsecured Wi-Fi networks or networks with vulnerabilities for later exploitation. These days, there is an entire community around wardriving that has turned it into a hobby to map not only Wi-Fi, but also Bluetooth, BLE, and cellular signals.</p><h2 id="a-little-wigle">A Little Wigle</h2><p>Thanks to the proliferation of wardriving as a hobby, we now have a large database publicly available which allows us to search for signals in a given location. This database, known as <a href="https://wigle.net/">Wigle</a>, is user-friendly and community supported. Anyone can upload signal data - there&apos;s even an <a href="https://play.google.com/store/apps/details?id=net.wigle.wigleandroid&amp;hl=en_US&amp;pli=1">Android app</a>. Now, we won&apos;t be providing an instructional section on using the platform. However, we would like to point out a couple of interesting features that can assist with your next wireless pentest, red team, or any other assessment involving signal data.</p><p>First up is the <code>Only Nets I Was the First to See</code> feature. This, as it says, allows you to search for networks that you discovered in a given area.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/07/image.png" class="kg-image" alt loading="lazy" width="1919" height="954"></figure><p>Now, this data is not aggregated by name since two unrelated individuals on two different sides of the world can call their network &quot;FBI Surveillance Van&quot;. However, information for the same BSSID is aggregated. If a BSSID is captured and uploaded more than once over a period of time, this information is stored under the same ID, which allows you to view changes to a network over time. For example, you may be able to track certain BSSIDs changing from WPA to WPA2, or switching from supporting WPS to having WPS disabled. You can also track name changes.</p><p>The next feature is the advanced search. You can use this to search an area for networks supporting older encryption. For instance, if you&apos;re targeting a manufacturing facility that you suspect has older Wi-Fi equipment in use, why not leverage it for network access?</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/07/image-1.png" class="kg-image" alt loading="lazy" width="1870" height="833"></figure><p></p><h2 id="some-pre-reqs">Some Pre-Reqs</h2><p>There are several ways one could accrue data to upload to Wigle or collect for offline analysis, such as a wireless site survey (a crucial part of a good Wi-Fi pentest). As mentioned above, it&apos;s possible to use an Android app. Airodump-ng is written to support working with GPSD for this purpose as well. However, one of the most powerful tools for collecting signal and location data simultaneously is Kismet. Kismet has support for all sorts of signals, however we are going to focus on Wi-Fi, specifically the 6 GHz band.</p><p>We won&apos;t cover installing Kismet, GPS tools, or installing drivers for adapters for now. However, we&apos;ll provide an inventory list to get started:</p><ul><li>A laptop with virtualization software</li><li>Alfa Networks AWUS036AXML &amp; compatible 6 GHz tuned antennas</li><li>A VNA if you did not purchase the antennas directly from Rokland or another legitimate Alfa reseller</li><li>A USB GPS dongle</li><li>Linux distribution with support for the mt7921au chipset, running in a VM. Kali is recommended at the current time of writing due to ease of use</li><li>Kismet and dependencies</li></ul><p>Once you have all of the necessary software installed, ensure your GPS dongle has downloaded it&apos;s almanac data and locked on to satellites. You can check this by running <code>gpsmon -n</code> and look for a message stating <code>3D Fix</code>. It&apos;s suggested to keep the GPS dongle outdoors or near an open window to download almanac data, as it can take 20 minutes or more. When this has finished, you&apos;re ready to configure Kismet for picking up 6 GHz signals.</p><h2 id="configuring-and-running-kismet">Configuring and Running Kismet</h2><p>Getting ready to capture 6 GHz signals is fairly straightforward. You&apos;ll need to ensure that the 6 GHz band is available to your system, run <code>sudo iw reg set US</code>. Modify the primary config file: <code>/etc/kismet/kismet.conf</code> and add the following line <code>source=wlan0:name=axe,band24ghz=false,band5ghz=false,band6ghz=true,channel=1w6e</code>. Here&apos;s a breakdown of these parameters:</p><ul><li>source - The NIC you&apos;re using to capture signals.</li><li>name - Whatever you would like to call the interface in Kismet.</li><li>bandxghz - Configures the frequency band to operate on. We&apos;re excluding 2.4 and 5 GHz to target 6 GHz only.</li><li>channel - This specifies channels the card will operate on. Each frequency band is divided into operating channels.</li></ul><p>There are other parameters available if you would like to tune this further, just check out the <a href="https://www.kismetwireless.net/docs/readme/datasources/wifi-linux/">Kismet documentation</a>. Now that this is configured, let&apos;s run Kismet in Wardrive mode. Essentially, this mode saves power as it&apos;s monitoring for less information and outputs captured information to a format we can upload directly to Wigle. We&apos;ll do this with <code>sudo kismet --override wardrive</code>.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/07/image-8.png" class="kg-image" alt loading="lazy" width="1270" height="828"></figure><p>There we have it! Now you&apos;re ready to start wardriving on the 6 GHz band. If you elect not to use the <code>--override wardrive</code> option and only get a <code>.kismet</code> file, there&apos;s a built-in tool to transform this to a usable format for Wigle. Just run <code>sudo kismetdb_to_wiglecsv --in xxx.kismet --out whatever.csv</code>.</p><h2 id="next-up">Next Up</h2><p>The plan was to cover some defensive Wi-Fi tooling in this post, but we don&apos;t want you to fall asleep reading! So keep an eye out for our next post in the wireless series where we&apos;ll introduce Nzyme.</p>]]></content:encoded></item><item><title><![CDATA[Explorations into Wi-Fi6/E]]></title><description><![CDATA[New Wi-Fi standards mean security pros need to know the nuances. Learn about Wi-Fi 6E, tuning to 6 GHz, packet capture, and quick analysis. Check out our new post!]]></description><link>https://rift.stacktitan.com/explorations-into-wi-fi6e/</link><guid isPermaLink="false">667ce07b0f38281a29a67823</guid><category><![CDATA[adversary]]></category><category><![CDATA[hacking]]></category><category><![CDATA[pentest]]></category><category><![CDATA[security]]></category><category><![CDATA[wireless]]></category><category><![CDATA[hardware]]></category><category><![CDATA[rift]]></category><category><![CDATA[stacktitan]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Thu, 27 Jun 2024 16:33:34 GMT</pubDate><content:encoded><![CDATA[<p>If you keep up at all with new connectivity standards, you may have noticed a few new Wi-Fi standards, with a new naming convention. Starting with 802.11ax, the Wi-Fi Alliance has decided to make everyone&apos;s life a little easier by just calling it Wi-Fi 6. Retroactively, they&apos;re calling 802.11ac &apos;Wi-Fi 5&apos;. That&apos;s better, right? Absolutely! Except Wi-Fi 6e was released shortly after, still under the 802.11ax standard. The <a href="https://en.wikipedia.org/wiki/Wi-Fi_6e">Wikipedia page</a> even redirects to &apos;Wi-Fi 6&apos;. So what&apos;s the difference? Well, about 1 GHz.</p><p>Wi-Fi 6E introduces the availability of the 6 GHz band, which spans 5925 - 7125 MHz (5.9 - 7.1 GHz). This turned tooling on its head. Not only would we need a new series of wireless NICs capable of monitor mode and packet injection, but many tools are set to check the 2.4 GHz band by default, with a flag for 5 GHz. Fortunately, as you&apos;ll see later on, developers had the forethought to allow specifying a frequency, or set of frequencies. In this post, we&apos;ll cover some tooling and take a look at how Wi-Fi 6E operates.</p><h2 id="alfa-to-the-rescue">Alfa to the Rescue</h2><p>As equipment started being available on the consumer market for Wi-Fi 6E, USB adapters supporting the standard were nonexistent. You had to use something with a built-in NIC supporting the standard. Netgear rushed to the finish to release the very first Wi-Fi 6E USB adapter: the Nighthawk AXE3000 (A8000). In my excitement, I pre-ordered it. I struggled for some time to get the mt7921au drivers to build on any system and eventually gave up as I had other priorities.</p><p>Then, Alfa stepped in. They released the AWUS036AXML alongside a specially tuned external antenna. I again pre-ordered this from Rokland and waited eagerly for its arrival. Since it has arrived, I&apos;ve gotten familiar with using it in a variety of applications.</p><h2 id="setup">Setup</h2><p>If you wish to follow along or build on my work here, you&apos;ll need the genuine Alfa adapter as well as antennas that are designed to handle Wi-Fi 6E. I recommend using the <a href="https://store.rokland.com/collections/wifi-6-6e/products/alfa-ars-wifi6e-m2-2-4ghz-5-ghz-6e-tri-band-omnidirectional-indoor-antenna">external antenna</a> I mentioned earlier. With these in hand, you&apos;ll probably want to just use Kali and install the <code>kali-tools-wireless</code> meta-package to save yourself any grief.</p><p>To actually have the 6 GHz band available to your system, you&apos;ll need to run <code>sudo iw reg set US</code>. From here, to see all frequencies the adapter can scan, run <code>iw phy</code>.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/04/image-8.png" class="kg-image" alt loading="lazy" width="414" height="968"></figure><p>Do not use <code>iwlist frequency</code> as this is deprecated and will not provide all channels.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/04/image-9.png" class="kg-image" alt loading="lazy" width="459" height="554"></figure><p>The next step for working with a 6E network is identifying what frequency your target access point transmits on. With your adapter still in managed mode, run <code>sudo iw dev wlan0 scan ap-force | grep -B 5 &quot;SSID_NAME_HERE&quot;</code> and you&apos;ll see the frequency.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/04/image-10.png" class="kg-image" alt loading="lazy" width="543" height="137"></figure><p>Now let&apos;s set the card to monitor mode and tune it to the specified frequency. We&apos;ll do this with the following commands:</p><ul><li><code>sudo ip link set wlan0 down</code></li><li><code>sudo iw dev wlan0 set type monitor</code></li><li><code>sudo iw wlan0 set freq 6375</code></li><li><code>sudo ip link set wlan0 up</code></li></ul><p>Then you can verify by running <code>iwconfig</code>.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/04/image-11.png" class="kg-image" alt loading="lazy" width="592" height="346"></figure><p></p><h2 id="reading-and-analyzing-packets">Reading and Analyzing Packets</h2><p>Now that our adapter is ready, we can capture some packets and actually perform analysis of packet structure if you would like. It&apos;s also important to ensure that you&apos;re using antennas that are properly tuned for the frequencies you&apos;d like to work with, if you&apos;re not using the antennas that came with the card or the one shared above, you&apos;ll want to get a VNA (Vector Network Analyzer).</p><p>At this point, I realized that the frequency set is ignored by airodump. Run <code>sudo airodump-ng wlan0 -C 6375 \--essid your-ap -w desired_filename</code> to scan on the specified frequency, filter by essid, and write to several different files of various formats. It&apos;s also important that you&apos;re using antennas that are properly tuned for the frequencies you&apos;d like to work with, if you&apos;re not using the antennas that came with the card or the one shared above, you&apos;ll want to get a VNA (Vector Network Analyzer). If you want to use every frequency available to the card, you can specify <code>-C 0</code> instead. Once you have a <code>.cap</code> file, you can open it in Wireshark.</p><p>Opening the first &quot;Broadcast&quot; packet from the target device, we see a few interesting parameters. Since we&apos;re here, I&apos;m going to analyze a couple of these parameters.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/05/image.png" class="kg-image" alt loading="lazy" width="854" height="623"></figure><p></p><h2 id="robust-security-networks-management-frame-protection">Robust Security Networks &amp; Management Frame Protection</h2><p>The first tag, &quot;RSN Information&quot; is not Wi-Fi 6E specific. This was actually introduced in WPA2 back in 2004. In this particular instance, there are two fields which are active.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/06/image.png" class="kg-image" alt loading="lazy" width="1452" height="218"></figure><p>The PTKSA (Pairwise Transient Key Association) replay counter assists in preventing, you guessed it, replay attacks. The next two fields are more recent and a highlight of WPA3. While these fields were present for some implementations of WPA2, this was an optional feature and required clients to support it. So what exactly is Management Frame Protection?<br><br>If you&apos;ve ever performed any analysis on Wi-Fi traffic or performed a Wi-Fi pentest, you&apos;ve probably seen management frames. Using airodump-ng, you can see clients associated to access points or probe requests from clients that are not associated to an access point. Additionally, most typical Wi-Fi pentests revolve around sending de-authentication or disassociation frames to force the four-way handshake to re-occur and capture it. These are all management frames. Management Frame Protection prevents these frames from being sent in cleartext - preventing reconnaissance or exploitation. WPA3 uses both MFPC and MFPR, however you may come across a WPA3 network where you can see associated clients. This occurs because of WPA3 Transition Mode. In this mode, clients that don&apos;t support WPA3 will connect using the WPA2 scheme.</p><h2 id="the-wi-fi-6e-high-efficiency-phy">The Wi-Fi 6/E High-Efficiency PHY</h2><p>The High-Efficiency PHY supports higher data rates as it can support modulation up to 1024-QAM as opposed to 256-QAM in the previous generation of Wi-Fi. However the specific portion of the frame we&apos;re analyzing consists of PHY capabilities that handle timing, frame aggregation, and power consumption.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/06/image-2.png" class="kg-image" alt loading="lazy" width="964" height="311"></figure><p>The first 3 parameters handle MAC Protocol Data Units (MPDUs) and Aggregate-MPDUs. Again, this all is to handle timing and frame aggregation. The last parameter, Spatial Multiplexing (SM) Power Save is a feature designed to help save power on devices that leverage Multi-Input/Multi-Output (MIMO), and in this case, has been disabled.</p><h2 id="coming-up-soon">Coming Up Soon</h2><p>In the next installment we&apos;ll cover wardriving, configuring Kismet to identify 6 GHz networks, and configuring the network defense tool Nzyme to monitor wireless networks.</p>]]></content:encoded></item><item><title><![CDATA[Android vs. The Terminator]]></title><description><![CDATA[We had a little bit of downtime and played a CTF at Kernelcon 24. Did pretty well and started writing up some of the challenges. This is one pertaining to Android.]]></description><link>https://rift.stacktitan.com/android-vs-the-terminator/</link><guid isPermaLink="false">661c48080f38281a29a67582</guid><category><![CDATA[development]]></category><category><![CDATA[hacking]]></category><category><![CDATA[pentest]]></category><category><![CDATA[redteam]]></category><category><![CDATA[stacktitan]]></category><category><![CDATA[mobsec]]></category><category><![CDATA[mobile]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Fri, 19 Apr 2024 15:52:40 GMT</pubDate><content:encoded><![CDATA[<p></p><p>Ahhh...Capture the Flag (CTF), and who doesn&apos;t like a formidable challenge? Security conferences are great and all, but it is always more fun to spend time with our team at STACKTITAN hacking on various CTF challenges. That is exactly what we recently did at Kernelcon 24.</p><p>The CTF ran through the con and was the typical jeopardy style with various categories and weighted challenges by difficulty. Solve the challenge, get the flag and post to the leaderboard. There was also a nice balance of challenges ranging from web application, mobile, hardware to reversing. The team was busy with presenting, so we didn&apos;t have a constant focus on the CTF but still ranked within the top 10. Not too bad. </p><h2 id="the-android-challenge">The Android Challenge</h2><p>Out of the many challenges, I tend to enjoy those about reversing and mobile applications. One such challenge, was The Terminator mobile application that said something to the likes of &quot;Attack the terminator before your time runs out and the clock resets&quot;. It seemed interesting enough so here is the writeup about how I solved the challenge and beat the Governator. </p><h2 id="the-terminator-android-application">The Terminator Android Application</h2><p> First thing is to get a working environment to load the Android application (i.e., APK), so we load up Android Studio and the Virtual Device Manager. I am running a Pixel 6 Pro with API 30. When launching the image it will use Qemu as the emulator environment. Side note, not that it matters in this situation, but images with the Play Store enabled are non-rooted and images without the Play Store provide root access, which would look something like this:</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/04/2024-04-14_17-53-27-3.png" class="kg-image" alt loading="lazy" width="800" height="293" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/04/2024-04-14_17-53-27-3.png 600w, https://rift.stacktitan.com/content/images/2024/04/2024-04-14_17-53-27-3.png 800w" sizes="(min-width: 720px) 720px"></figure><p>Anyway, the APK is actually named GPTerminator.apk and can simply be dragged onto the running emulator&apos;s view, which will install it automagically (err...using ADB as the actual method). Viola...we get this.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/04/2024-04-14_17-15-24.png" class="kg-image" alt loading="lazy" width="800" height="790" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/04/2024-04-14_17-15-24.png 600w, https://rift.stacktitan.com/content/images/2024/04/2024-04-14_17-15-24.png 800w" sizes="(min-width: 720px) 720px"></figure><p>After seeing the application and running it, we can see that it starts out with <code>HP Remaining: 1984</code> and a <code>Time Remaining: 15</code> seconds. So for every click of the <code>ATTACK</code> button, we decrement the <code>HP Remaining</code> counter. So yes, you will get tendonitis of the pointy finger before you can wear down the clock. </p><p>It should be pretty obvious that we either 1) make the time counter so high that we can click 1984 times (which sounds absolutely awful), or 2) we set the &quot;HP Remaining count so low that we can click within the alloted time (yes much better). </p><h2 id="approaching-the-solution">Approaching the Solution</h2><p>There are a couple of ways that we can solve this challenge. One would be to use an interposing/hooking solution, such as <a href="https://frida.re/">Frida</a>, to hook the respective class method and return the desired result. </p><p>The other, and the technique I chose, was to decompile the APK, modify the code to do the needful, and then repackage. As an aside, had the application code been obfuscated using something like ProGuard, we would have opted for the Frida route considering we would have been looking at functional memory and not source code.</p><h2 id="decompiling-the-apk">Decompiling the APK</h2><p>There are quite a few utilities that decompile APKs, but most all of them are using <a href="https://apktool.org/">apktool</a> to perform the heavy lifting. Note, on a Mac, you can just perform a <code>brew install apktool</code> to get it onto the system. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/04/2024-04-14_19-17-10.png" class="kg-image" alt loading="lazy" width="800" height="258" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/04/2024-04-14_19-17-10.png 600w, https://rift.stacktitan.com/content/images/2024/04/2024-04-14_19-17-10.png 800w" sizes="(min-width: 720px) 720px"></figure><p>Aside from the AndroidManifest.xml, which should always be reviewed for things like exported items, is the smali directories. So the deal with Smali is that it is really just an intermediary language that provides a human readable version of the compiled bytecode. &#xA0;We can get back to Java source if we need to, but knowing how to read Smali is a valuable skill, in and of itself. </p><h2 id="analyzing-the-source-code">Analyzing the Source Code</h2><p>Android applications typically leverage a reverse namespace convention such as <code>com.example.gpterminator</code>, which contains the application&apos;s primary functionality. With that, we have two directories of interest, smali and smali_classes2. The latter contains our namespace of interest and fortunately has very minimal functionality contained with the <code>MainActivity.smali</code> file. </p><p>Letting our eyes wash over the code, we can can see that there is a class constructor method (line 90) that returns void (i.e., <code>.method public constructor ()V</code>). There are also a couple of constants on lines 96 and 100. Imagine that, their hex to dec is 1984 and 15, which is the <code>HP Remaining</code> and <code>Time Remaining</code> values, respectively. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/04/2024-04-14_19-26-45.png" class="kg-image" alt loading="lazy" width="800" height="495" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/04/2024-04-14_19-26-45.png 600w, https://rift.stacktitan.com/content/images/2024/04/2024-04-14_19-26-45.png 800w" sizes="(min-width: 720px) 720px"></figure><p>Ok so the logical thing to do is change 1984 to 1 (i.e., 0x1). I am not changing it to 0x0 because I need the satisfaction of at least one click of the <code>ATTACK</code> button!!! </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/04/2024-04-14_19-45-02.png" class="kg-image" alt loading="lazy" width="800" height="448" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/04/2024-04-14_19-45-02.png 600w, https://rift.stacktitan.com/content/images/2024/04/2024-04-14_19-45-02.png 800w" sizes="(min-width: 720px) 720px"></figure><p>As an aside, had the functionality been more complicated, I often use Frida to view the loaded classes, class methods and then watch anything that might be suspect or of interest. This helps to narrow in on the applicable source code when it comes time to trace the logic. Maybe more of this in a future blog post. </p><h2 id="recompiling-the-code">Recompiling the Code</h2><p>The changes need to be recompiled which can also be done with <code>apktool b &lt;directory&gt; -o modified.apk</code>. At this point there might be a slight cleanup to <code>AndroidManifest.xml</code> due to a reference to an arbitrary non-existent debug resource, or similar. Easy enough to simply remove the troublesome statement from the Manifest and attempt to recompile again. I ran into this with the <code>error: attribute android:dataExtractionRules not found</code>. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/04/build-2.png" class="kg-image" alt loading="lazy" width="800" height="266" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/04/build-2.png 600w, https://rift.stacktitan.com/content/images/2024/04/build-2.png 800w" sizes="(min-width: 720px) 720px"></figure><h2 id="byte-aligning">Byte Aligning</h2><p>After successfully recompiling the APK, we need to make sure the APK is byte aligned so that various uncompressed files are aligned relative to the start of the file image. Doing this is similar to any other alignment in that it makes memory management more performant. </p><p>To accomplish this, we use the <code>zipalign</code> utility provided within the Android Studio SDK (located within the build-tools directory). The command is <code>zipalign -p 4 gpterm.apk gpterm-aligned.apk</code>. Android Studio aligns to 4 bytes on both 32 and 64 bit archs, so we are directing zipalign to do the same here. </p><h2 id="code-signing-the-apk">Code Signing the APK</h2><p>Well we have made some modifications to the code and recompiled it, so it will need to be resigned in order to get it back onto an emulator or physical device. This is a two-step process 1) create a self-signed code signing certificate and 2) sign the APK. </p><h3 id="create-the-code-signing-certificate">Create the Code-Signing Certificate</h3><p>To create the certificate pair, we use the <code>keytool</code> java utility. Use the following syntax:</p><p><code>keytool -genkey -v -keystore stackrelease.keystore -alias stackdroid-key -keyalg RSA -keysize 4096 -validity 10000</code></p><h3 id="sign-the-apk">Sign the APK</h3><p>Next, we will use the <code>apksigner</code> utility included as part of the Android Studio SDK. Use the following syntax:</p><p><code>apksigner sign --ks stackrelease.keystore --ks-key-alias stackdroid-key gpterm-aligned.apk</code></p><p>That&apos;s it. Now uninstall the old <code>gpterminator.apk</code> from the emulator and replace it with <code>gpterm-aligned.apk</code>. Launch and make sure it is functional. </p><h2 id="not-today-arnold">Not Today, Arnold!</h2><p>And now The Terminator isn&apos;t so tough! One click and no more SkyNet!!!! The lower right image provides the flag. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/04/beat_arnold--1-.png" class="kg-image" alt loading="lazy" width="740" height="768" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/04/beat_arnold--1-.png 600w, https://rift.stacktitan.com/content/images/2024/04/beat_arnold--1-.png 740w" sizes="(min-width: 720px) 720px"></figure><h2 id="conclusion">Conclusion</h2><p>This was a fun exercise, and also demonstrates a technique that is useful when performing Android mobile security assessments. This is also my hope that it provides those that aren&apos;t too familiar with venturing into mobile penetration testing with the perspective that this discipline is completely accessible. Until next post, keep on hacking!</p>]]></content:encoded></item><item><title><![CDATA[Practical Physical Exploitation Course Review]]></title><description><![CDATA["The Practical Physical Exploitation course is well worth the time, money, and effort. The instructors have built an excellent offering that is a true 'zero to hero' style course that not only new pentesters, but seasoned professionals would both gain value from attending."]]></description><link>https://rift.stacktitan.com/practical-physical-exploitation-course-review/</link><guid isPermaLink="false">66187d110f38281a29a6751c</guid><category><![CDATA[adversary]]></category><category><![CDATA[pentest]]></category><category><![CDATA[social engineering]]></category><category><![CDATA[stacktitan]]></category><category><![CDATA[security]]></category><category><![CDATA[redteam]]></category><category><![CDATA[physec]]></category><category><![CDATA[rift]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Fri, 12 Apr 2024 14:16:03 GMT</pubDate><content:encoded><![CDATA[<p></p><p>&quot;Physical access is total access&quot;. This is what my instructor at the Marine Corps Communications and Electronics School told us as he demonstrated the password recovery procedure on a Cisco Catalyst 2960 switch. We had just completed most of the curriculum learning about networking concepts, configuring Cisco equipment, deploying Windows Server operating systems, and more to set up communications. At this point, he was driving home the importance of keeping equipment secure and out of the hands of an adversary. For the uninitiated, gaining access to certain models of Cisco switches and routers without credentials is merely a means of power cycling the device, holding the mode button, and issuing a few commands.</p><p>Fast forward a few years and I&apos;m on my first engagement attempting to access a secure, multi-tenant facility completely on my own with minimal training. I perform a few basic checks; how many entrances/exits are there? Is anything aside from the lobby unlocked? Of the 3 or 4 doors on the outside of the building, none were unlocked aside from the lobby entrance. This was also early 2021 so there were a total of 3 vehicles in the parking lot, no opportunity to tailgate. That ended up being the end of my ideas and the end of the assessment. I walked away feeling like I hadn&apos;t given the client any value.</p><p>Now I&apos;ve completed the Practical Physical Exploitation course and can say without a doubt I&apos;m ready and equipped to breach some facilities. This course really has everything you need with no fluff.</p><h2 id="course-structure-and-pre-reqs">Course Structure and Pre-Reqs</h2><p></p><p>The Practical Physical Exploitation course, taught by Travis Weathers of Optiv and Ralph May of Black Hills Information Security, is exactly as advertised. Practical. As such, everything is set to mimic an efficiently run, real-world engagement. They spend very little time on theory and lots on hands-on learning. The course is 3 days long, with the first containing the most instruction and the last being the course capstone. Here&apos;s a quick breakdown:</p><ul><li>Day 1 - Introductions, in-class instruction, PEAK, recon</li><li>Day 2 - Recon pt. 2, Practical arts and crafts, night ops</li><li>Day 3 - More recon, CAPEX, after action report</li></ul><p>There are a few things you will need to have for the course to ensure you get the full hands-on experience.</p><ul><li>A laptop where you can run proxmark either in a VM or natively</li><li>A vehicle that can fit at least two other people and some equipment</li><li>Some kind of mobile hot-spot. Whether this is directly off your phone or a puck, is up to you</li></ul><h2 id="its-all-business">It&apos;s All Business</h2><p></p><p>The first day contains the most presentations. After this, very little time is spent looking at slides. One of the key aspects the instructors focus on during day 1 is the business side of engagements:</p><ul><li>Scoping and selling</li><li>Acquiring appropriate authorization</li><li>Client communication</li><li>Reporting</li></ul><p>Though not a foreign topic for most pentesters, red teamers, or other security professionals, Physical Penetration assessments have a unique perspective. If you&apos;re struggling to sell these assessments, or just getting started, this section of the course makes all the difference.</p><p>After you&apos;re done discussing the business aspects of engagements, you learn about practical remote recon. What&apos;s out there, publicly available, about a business? There are some key points in this section that are the foundation of your success now and for the rest of your career as a physical pentester. From here, you&apos;re introduced to PPE&apos;s PEAK equipment. After you&apos;re briefed on these tools of the trade, you begin your first real-world exercise.</p><h2 id="course-handouts">Course Handouts</h2><p></p><p>Aside from the practical skills and lessons learned, one of the things you walk away from this course with is a handful of document templates:</p><ul><li>Scoping questionnaire</li><li>Statement of Work</li><li>Kick-off call notes</li><li>Authorization Letter &amp; questionnaire</li><li>Report template</li><li>Badge templates</li></ul><p>You also get access to PPE&apos;s student portal, where you&apos;ll be able to review all course material.</p><h2 id="physical-exploitation-and-access-kit-peak">Physical Exploitation and Access Kit (PEAK)</h2><p></p><p>As part of this course, your team, or if you&apos;re like my small class of 3, each individual, will receive a PEAK during day 1 (to be returned at the end of the course). This is the Physical Exploitation and Access Kit. It contains everything you need to conduct an engagement with the exception of a computer and smart phone. If you&apos;ve looked at one of these kits before, the variant provided is the full kit that contains the surveillance and stealth equipment. By far my favorite piece of equipment was the Nikon P900 with it&apos;s long range zoom lens.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/04/2024-04-11_20-21-03.png" class="kg-image" alt loading="lazy" width="724" height="835" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/04/2024-04-11_20-21-03.png 600w, https://rift.stacktitan.com/content/images/2024/04/2024-04-11_20-21-03.png 724w" sizes="(min-width: 720px) 720px"></figure><p>If you&apos;re staying in a hotel or somewhere else with ADA compliant door handles, I highly recommend practicing with the under door tool. For those interested, they do sell these kits <a href="https://store.physicalexploit.com/products/physical-exploit-kit?variant=47804901065017">here</a>.</p><h2 id="quick-tips-for-success">Quick tips for success</h2><p></p><p>While the instructors give you everything you need to succeed, there are a few things you can do to make everything go smoother:</p><ul><li>Pay attention to the little details</li><li>Memorize the differences in badge readers</li><li>Elect a team captain. The team captain should divide work among the team and keep track of objectives, client communications, and who has what gear during an op. This will help ensure no overlap occurs without missing anything.</li></ul><p>With this hefty introduction completed, let&apos;s move on to what this is all about, what you do in the class.</p><h2 id="day-1">Day 1</h2><p>As mentioned previously, day 1 is where you&apos;ll look at slides the most. Once you&apos;ve been briefed on the business aspect of physical security engagements, the fun starts. The rest of day 1 is mostly hands on with debriefing after practical exercises.</p><h4 id="remote-reconnaissance">Remote Reconnaissance</h4><p>Your first exercise is performing remote reconnaissance against a fictitious company. In this stage, you&apos;ll want to gather as much information about the target from online sources. Primary areas you&apos;re concerned with are the building and employee online presence.</p><p>When searching for an address online, there are tons of resources that will provide additional information about a commercial space. It&apos;s a good idea to use multiple sources here, especially when looking at street views of buildings. Speaking of street view, this is your first opportunity to get eyes on cameras.</p><p>Employee presence comes to general social media intelligence, or SOCMINT, practices. What you&apos;re looking for here is names, roles, and have they posted their badge online somewhere. Real world tip here: people, especially new hires, love posting their badges on Instagram and TikTok.</p><h4 id="on-site-reconnaissance">On-Site Reconnaissance</h4><p>Walking through the next phase of the engagement, you&apos;re tasked with performing some on-site reconnaissance. At this phase, you&apos;re increasing operational risk. Everything you do from here could burn the op. You need to keep a low profile.</p><p>There are two primary types of on-site recon: mobile and close-proximity. Given the risky nature of on-site recon, close-proximity should be used only as a last resort. This is where you would walk the premises and gather necessary information. Our team did not do this, however the instructors did some close-proximity recon and shared results during the debrief.</p><p>During mobile recon, you&apos;re again faced with two choices: dynamic or static. With dynamic mobile recon, you&apos;re continuously on the move. Drive around the campus at a slow, but reasonable speed to capture video and/or images. Depart and review, and if needed, return after an extended cool-down period. Regarding static mobile recon, it&apos;s exactly what it sounds like. Park the vehicle and take your video and images from that position, being careful not to attract attention.</p><h4 id="making-ralphs">Making Ralphs</h4><p>After you&apos;ve debriefed the third exercise, it&apos;s time for some arts and crafts. You&apos;ll get hands-on practice with making badges. This is done with a blank badge, silhouette paper, packing tape, a hole punch, and patience. You&apos;ll probably mess up a few times, but Ralph has plenty pictures to spare.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/04/image-2.png" class="kg-image" alt loading="lazy" width="405" height="261"></figure><p>After you&apos;ve made your Ralphs and perfected the art of badge-making, you&apos;ll be briefed on some additional intel the team has gathered. The team will be informed that [REDACTED] employees often visit a local [REDACTED] before heading to work. They&apos;ve been spotted with their badges visible. Once you&apos;ve been provided the location, I recommend going with your team to plan out the next morning&apos;s operation.</p><h2 id="day-2">Day 2</h2><p>This is the longest day of the course, however, it&apos;s arguably the most fun. You start off the morning trying not to look suspicious at the breakfast location. Your team should be set up to capture video and images to get a clear reference image of the [REDACTED] employee badge. Then you&apos;ll need to modify the template to match this image, save it to a thumb drive, and print on silhouette paper at FedEx. You&apos;ll take this back to class and be briefed on some additional intel that was gathered. [REDACTED] employees have been identified regularly going to [REDACTED] for lunch. This is your chance to pull data from the badges to clone them.</p><h4 id="badge-cloning">Badge Cloning</h4><p>As I&apos;ve noted above, you&apos;ll want to make sure you paid attention to what type of badge readers the organization has deployed when performing your recon. This will determine what kind of reader you&apos;ll need to carry for cloning. Carry the wrong reader, and you won&apos;t get any data. You&apos;ll be briefly introduced to operating the readers, web interface, and proxmark in the classroom prior to departing. Once you&apos;re comfortable, it&apos;s time to head to the lunch location.</p><p>Everyone has their own approach to getting badge reads, whether it be navigating a tight space, using team members to herd, or going through a line to get somewhere. Directly approaching someone to ask for directions is perfectly valid as well, just be aware of the size of the target organization. In a real engagement, you need to consider the likelihood that you could compromise the operation taking this approach. However you decide to tackle this challenge, you need at least two badge reads to ensure you have adequate data - &quot;Two is one and one is none&quot;.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/04/image-3.png" class="kg-image" alt loading="lazy" width="291" height="572"></figure><p>With your newly acquired badge data, it&apos;ll be time to return to class, and make a working badge for [REDACTED]. The instructors have a test reader set up so that you can verify you&apos;ve done this correctly, and you&apos;ll be given a chance to compare your badge with the &quot;real&quot; badge for [REDACTED].</p><p>Once everyone has had a chance to test and compare badges, you&apos;re done with this first fictitious company. It&apos;s time to review some methodology, and be briefed on your final target.</p><h4 id="final-target-night-ops-bonus-points">Final Target, Night Ops, Bonus Points</h4><p>During this brief, you&apos;ll receive paperwork to sign and review as you are now targeting a real company, under a fictitious name for purposes of the course. You&apos;ll receive the scope and objectives, and go through a mock-up of normal engagement procedures starting with a kick-off call. The instructors will then disclose the location of the facility and provide you with similar intel to the practice target about a common breakfast stop for employees. You&apos;re given a buffer window before on-site reconnaissance is authorized. During this time I recommend traveling to the breakfast location, performing remote recon on the target, and formulating a plan for next steps.</p><p>Once you&apos;ve acquired adequate information, it&apos;s time to perform on-site reconnaissance. At this point, you may have realized it&apos;s helpful to have more than one vehicle at your disposal. Our team performed two rounds of dynamic mobile reconnaissance approximately 20 minutes apart. From there, one team member dropped myself and another team member at an off-site location where we walked to perform close-proximity mobile recon. If you take this route, this is your first chance to achieve a bonus objective and garner additional information to complete your remote recon. Just make sure you communicate with the &quot;client&quot; that you&apos;re preparing to do this.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/04/image-4.png" class="kg-image" alt loading="lazy" width="650" height="534" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/04/image-4.png 600w, https://rift.stacktitan.com/content/images/2024/04/image-4.png 650w"></figure><p></p><h2 id="day-3">Day 3</h2><p>The last day of the course consists of the CAPEX and debrief. This is where you will use everything you&apos;ve learned up to this point to perform a facility breach and achieve any bonus objectives that are still left.</p><h4 id="lessons-learned">Lessons Learned</h4><p>Have you noticed how I&apos;ve mentioned having the correct badge reader, taking note of the technologies in use, and paying attention to little details several times so far? At the breakfast location for the CAPEX target, our team was equipped with the wrong readers. However, some adaptability went a long way and we got the necessary reads to clone badges for the target company.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/04/image-5.png" class="kg-image" alt loading="lazy" width="1228" height="817"></figure><p>Once inside, I split off to tackle a bonus objective while the other two targeted the primary objective. This took longer than expected and we were getting frustrated with our designated tasks, so we switched. This is what led to our success. If you&apos;re struggling, let someone else take the reins.</p><h2 id="final-thoughts">Final Thoughts</h2><p>The Practical Physical Exploitation course is well worth the time, money, and effort. The instructors have built an excellent offering that is a true &quot;zero to hero&quot; style course that not only new pentesters, but seasoned professionals would both gain value from attending. Beyond the skills gained, you also get a certificate of completion and some gear. Specifically, you receive a REX gun, nozzle adapters, nozzles, a Doppelg&#xE4;nger breakout board, and some stickers.</p><figure class="kg-card kg-image-card"><img src="https://kaos-tech.ghost.io/content/images/2024/04/image-6.png" class="kg-image" alt loading="lazy" width="622" height="765"></figure>]]></content:encoded></item><item><title><![CDATA[Wireless for Red Teams]]></title><description><![CDATA[<p>STACKTITAN&apos;s own Alex Sanders gave a fantastic presentation on <strong>Wireless for Red Teams</strong>, touching on hardware, technologies, methodology, and more. He&apos;s a wireless geek (in the best possible way). Check out his talk...</p><figure class="kg-card kg-embed-card kg-card-hascaption"><iframe width="200" height="113" src="https://www.youtube.com/embed/4T0uY8ytYsk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen title="Wireless for Red Teams"></iframe><figcaption>Wireless for Red Teams - YouTube</figcaption></figure><p> </p>]]></description><link>https://rift.stacktitan.com/wireless-for-red-teams/</link><guid isPermaLink="false">660582680f38281a29a674f6</guid><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Thu, 28 Mar 2024 15:07:17 GMT</pubDate><content:encoded><![CDATA[<p>STACKTITAN&apos;s own Alex Sanders gave a fantastic presentation on <strong>Wireless for Red Teams</strong>, touching on hardware, technologies, methodology, and more. He&apos;s a wireless geek (in the best possible way). Check out his talk...</p><figure class="kg-card kg-embed-card kg-card-hascaption"><iframe width="200" height="113" src="https://www.youtube.com/embed/4T0uY8ytYsk?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen title="Wireless for Red Teams"></iframe><figcaption>Wireless for Red Teams - YouTube</figcaption></figure><p> </p>]]></content:encoded></item><item><title><![CDATA[The Covert Hardware Implant: Part 2]]></title><description><![CDATA[In Part 1 of this series, we took you through the hardware build. Now we work through making it operational for your next Red Team engagement. ]]></description><link>https://rift.stacktitan.com/chi_part_2/</link><guid isPermaLink="false">658c546b0f38281a29a66a17</guid><category><![CDATA[adversary]]></category><category><![CDATA[egress]]></category><category><![CDATA[hacking]]></category><category><![CDATA[security]]></category><category><![CDATA[rift]]></category><category><![CDATA[stacktitan]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Mon, 26 Feb 2024 19:23:16 GMT</pubDate><content:encoded><![CDATA[<p></p><h2 id="and-we-left-off-here">And We Left Off Here...</h2><p>If you haven&apos;t read <a href="https://rift.stacktitan.com/chi_part_1/">Part 1</a> of this series, then please do so and head back over here. For those that just want to jump in, the TLDR is that we bought a commodity APC surge protector and made it into a hollow shell that could house a Raspberry PI and LTE equipment. The most important aspect of the build was that the APC supports ethernet, so we rewired it as the LAN interface for our covert hardware implant (i.e., the APC). </p><p>In doing all of this, and nearly burning up our Dremel, we had a few remaining items to accomplish in order to get the Covert Hardware Implant (CHI) operational. In this post we will configure the Raspberry Pi to support the following:</p><ol><li><strong><em>Command and control communication that supports tool delivery and data exfiltration through out-of-band channels.</em></strong></li><li><strong><em>The enterprise logical footprint should be as minimal/non-existent as possible.</em></strong></li></ol><p>With that, we&apos;ll need to get the Raspberry Pi operational before applying any configurations or scripts. </p><h2 id="raspberry-pi-initial-operating-system-install">Raspberry Pi Initial Operating System Install</h2><p>First, we need to install the operating system, so navigate over to the official Raspberry Pi website and download the <a href="https://www.raspberrypi.com/software/">Raspberry Pi Imager</a> software. </p><p><strong>Note: </strong>The operating system is read from a MicroSD card, the same one as described in our first blog post of this series. So grab the MicroSD card, and make sure that the computer running the Raspberry Pi Imager utility is capable of writing to an SD card. </p><p>Once the Imager is running on your operating system, we are using OSX, then select Raspberry Pi 4 and the Raspberry Pi OS (64-bit) along with the storage device location of the SD card, which should mount and display within the /dev (*Nix) or /Volumes (OSX) directory.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/2024-01-31_13-18-16-1.png" class="kg-image" alt loading="lazy" width="800" height="504" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/2024-01-31_13-18-16-1.png 600w, https://rift.stacktitan.com/content/images/2024/01/2024-01-31_13-18-16-1.png 800w" sizes="(min-width: 720px) 720px"></figure><p>One thing that we don&apos;t want to contend with is connecting a keyboard and monitor to our Raspberry Pi just to configure the device. Fortunately, the Imager has a very useful feature which allows for adding configuration build settings. Specifically, we can provide a pre-configuration build setting that configures WiFi networking, which will be used to automatically connect to our local wireless network. The second item is configuring SSH key auth so that we can authenticate to the Raspberry Pi over the wireless network. To access these configurations you will click <strong><em>NEXT</em></strong> and <strong><em>EDIT SETTINGS</em></strong>. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/2024-01-31_14-14-08.png" class="kg-image" alt loading="lazy" width="800" height="971" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/2024-01-31_14-14-08.png 600w, https://rift.stacktitan.com/content/images/2024/01/2024-01-31_14-14-08.png 800w" sizes="(min-width: 720px) 720px"></figure><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/2024-01-31_14-15-56.png" class="kg-image" alt loading="lazy" width="800" height="381" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/2024-01-31_14-15-56.png 600w, https://rift.stacktitan.com/content/images/2024/01/2024-01-31_14-15-56.png 800w" sizes="(min-width: 720px) 720px"></figure><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/2024-01-31_16-44-47.png" class="kg-image" alt loading="lazy" width="800" height="562" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/2024-01-31_16-44-47.png 600w, https://rift.stacktitan.com/content/images/2024/01/2024-01-31_16-44-47.png 800w" sizes="(min-width: 720px) 720px"></figure><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/2024-01-31_16-46-31.png" class="kg-image" alt loading="lazy" width="800" height="562" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/2024-01-31_16-46-31.png 600w, https://rift.stacktitan.com/content/images/2024/01/2024-01-31_16-46-31.png 800w" sizes="(min-width: 720px) 720px"></figure><p>Once the writing has finished, put the SD Card back into the Pi and power it on. You should now see the PI, along with an IP, on the wireless network. Ensure that that it is accessible via SSH key auth, such as <code>ssh -i private_key username@pi_destination</code>.</p><h2 id="transport-considerations">Transport Considerations</h2><p>We explored several options when building out our infrastructure for handling device callbacks. Three methods of establishing reliable communication channels come to mind - SSH, OpenVPN, and Wireguard.</p><p>Using SSH, you can initialize an outbound connection from your hardware implant to a publicly-facing endpoint and specify a remote port forward. A typical command string would contain <code>-R &lt;desired listening port&gt;:localhost:22</code> and would result in &lt;desired listening port&gt; on the public endpoint presenting the hardware implant&apos;s SSH authentication interface. This solution is simple, but adds additional headaches when trying to dynamically forward traffic back through the hardware implant.</p><p>OpenVPN and Wireguard provide a more robust VPN solution. The PKI aspect of OpenVPN can be cumbersome to manage, and processing overhead can increase latency, which lead us to using Wireguard.</p><h3 id="the-wireguard-setup">The Wireguard Setup</h3><p>You&apos;ll want a publicly accessible endpoint to host your Wireguard server on. We deployed a small EC2 instance and configured a security group to allow inbound traffic on UDP 51820 (Wireguard&apos;s default listening port). For increased operational security, we&apos;re going to configure <a href="https://www.squid-cache.org/">Squid</a> on this server so that we can proxy traffic from the hardware implant to install tooling and more. Install the necessary utilities:</p><p><code>apt install -y wireguard wireguard-tools squid</code></p><p>Additionally, enable IPv4 forwarding and ensure it persists after reboot:</p><p><code>echo 1 &gt; /proc/sys/net/ipv4/ip_forward</code></p><p>Edit /etc/sysctl.conf (reference line 16):</p><!--kg-card-begin: html--><pre class="line-numbers language-c"><code># Functions previously found in netbase
#

# Uncomment the next two lines to enable Spoof protection (reverse-path filter)
# Turn on Source Address Verification in all interfaces to
# prevent some spoofing attacks
#net.ipv4.conf.default.rp_filter=1
#net.ipv4.conf.all.rp_filter=1

# Uncomment the next line to enable TCP/IP SYN cookies
# See http://lwn.net/Articles/277146/
# Note: This may impact IPv6 TCP sessions too
#net.ipv4.tcp_syncookies=1

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

# Uncomment the next line to enable packet forwarding for IPv6
#  Enabling this option disables Stateless Address Autoconfiguration
#  based on Router Advertisements for this host
#net.ipv6.conf.all.forwarding=1
</code></pre><!--kg-card-end: html--><p>Now, we&apos;ll set up Wireguard on the <strong>server</strong> side. Generate a new private key:</p><pre><code># wg genkey
gLzEJxpUBdAuas9ZRWR6lnJkteaTgFAIPOnFcXk5MUA=</code></pre><p>Provide the generated private key and other details in <code>/etc/wireguard/wg0.conf</code>. We&apos;re going to use the network range of 10.2.0.0/24 for client and server networking.</p><!--kg-card-begin: html--><pre class="line-numbers language-c"><code>[Interface]
Address = 10.2.0.1/24
ListenPort = 51820
PrivateKey = gLzEJxpUBdAuas9ZRWR6lnJkteaTgFAIPOnFcXk5MUA=
</code></pre><!--kg-card-end: html--><p>Start the Wireguard server with <code>systemctl wg-quick@wg0</code>. Verify that the service is up with the <code>wg</code> command:</p><pre><code># wg
interface: wg0
  public key: cpO6ZAy4se4871WpWlsLjavryUqjqWBBf2xvxG6Eihc=
  private key: (hidden)
  listening port: 51820</code></pre><p>We&apos;ll revisit the <code>wg0.conf</code> file once the client is set up. Let&apos;s get Squid configured to allow traffic from &apos;local&apos; networks. Edit <code>/etc/squid/squid.conf</code> and update lines 1408 and 1409:</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/02/2024-02-19_14-08-30.png" class="kg-image" alt loading="lazy" width="556" height="186"></figure><p>Restart Squid with <code>systemctl restart squid.service</code>. </p><p>On the hardware device, generate a private key (<code>wg genkey</code>) and create <code>/etc/wireguard/wg0.conf</code> with the following details:</p><!--kg-card-begin: html--><pre class="line-numbers language-c"><code>[Interface]
Address = 10.2.0.2/24
# Output from &apos;wg genkey&apos;
PrivateKey = cNzQvNKUe6eoNLhyX0YPmxi/xAx4UUIAQvZO2XWKLFg=

[Peer]
# This is the public address and port of your vpn endpoint
Endpoint = xxx.xxx.xxx.xxx:51820 
# And the public key 
PublicKey = cpO6ZAy4se4871WpWlsLjavryUqjqWBBf2xvxG6Eihc=
PersistentKeepalive = 30
AllowedIPs = 10.2.0.0/24
</code></pre><!--kg-card-end: html--><p>Let&apos;s grab the &#xA0;public key for the hardware device&apos;s configuration:</p><pre><code># echo &apos;cNzQvNKUe6eoNLhyX0YPmxi/xAx4UUIAQvZO2XWKLFg=&apos; | wg pubkey
1civ0MWfnrzF3crQQ6/LXT1yqIV1DpP08yubTuq1X2A=</code></pre><p>Now we can update the server&apos;s configuration, so that the hardware device is allowed to connect. Add the following [Peer] section to <code>/etc/wireguard/wg0.conf</code>:</p><!--kg-card-begin: html--><pre class="line-numbers language-c"><code>[Peer]
PublicKey = 1civ0MWfnrzF3crQQ6/LXT1yqIV1DpP08yubTuq1X2A=
AllowedIPs = 10.2.0.2/32
</code></pre><!--kg-card-end: html--><p>Restart wireguard on both client and server with <code>systemctl restart wg-quick@wg0</code>. Further, make sure the service is enabled at boot with <code>systemctl enable wg-quick@wg0</code>, and status of the connections can be checked with <code>wg</code>. </p><p>To take advantage of the proxy that we put in place, you can export the <code>http_proxy</code> and <code>https_proxy</code> variables in your shell to direct most tools to send traffic to Squid.</p><pre><code>export http_proxy=&apos;http://10.2.0.1:3128&apos;
export https_proxy=&apos;http://10.2.0.1:3128&apos;</code></pre><p>Tool installation via <code>apt</code> through the proxy can be achieved by creating a file located at <code>/etc/apt/apt.conf.d/proxy.conf</code> with the following contents:</p><!--kg-card-begin: html--><pre class="line-numbers language-c"><code>Acquire {
  HTTP::proxy &quot;http://10.2.0.1:3128/&quot;;
  HTTPS::proxy &quot;http://10.2.0.1:3128/&quot;;
}
</code></pre><!--kg-card-end: html--><p></p><h2 id="software-goals">Software Goals</h2><p>To recap, our goal is to deploy a resilient and silent (from a client&apos;s internal network standpoint) method of remote access. Any and all communication to our remote VPN endpoint should take place over the cellular network, NOT over the ethernet connection.</p><p>We&apos;re going to employ NetworkManager, as it&apos;s the default utility for managing network connections in PI OS. Originally, we had developed a set of service files and management scripts to handle initializing the connection and ensuring graceful recovery in the event of a failure. However, while putting together this blog post, we realized NetworkManager works perfectly well handling the connection status. Don&apos;t worry, nobody is bitter about the time spent learning hardware-specific AT commands and living inside minicom for a week.</p><p>Anyhow, the LTE modem needs to be in a certain configuration mode, so we need to install minicom for further changes:</p><pre><code># apt install -y minicom</code></pre><p>Let&apos;s connect to the LTE modem and set the USB mode to &apos;4&apos; (ECM mode).</p><pre><code># minicom -D /dev/ttyUSB2 -b 115200
AT
OK
AT#USBCFG=4
OK</code></pre><p>If you receive an error, check status with <code>AT#USBCFG?</code> - which should return &apos;4&apos;. You may also see other output in the minicom terminal, likely from commands ran by networkmanager to check the signal strength and device status.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/02/2024-02-14_14-13-26--2-.png" class="kg-image" alt loading="lazy" width="373" height="291"></figure><p>Disconnect with CTRL-a x &lt;enter&gt;. We can now create a new connection using nmcli and set the APN for Twilio (remember the SIM card from Part 1), and verify connectivity with ping.</p><pre><code>nmcli connection add con-name Twilio type gsm ifname ttyUSB2 apn wireless.twilio.com</code></pre><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/02/2024-02-14_15-16-00--2-.png" class="kg-image" alt loading="lazy" width="555" height="107"></figure><p>We need to set a static route so that VPN-related traffic is explicitly sent over the LTE connection. To do that, we&apos;ll modify the new connection and specify our VPN endpoint as follows (we&apos;ll use 8.8.8.8 as our pretend VPN endpoint):</p><pre><code>nmcli c modify cd0965fa-b93d-4c02-add4-441acda9b8b2 +ipv4.routes 8.8.8.8/32</code></pre><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/02/2024-02-14_15-20-33.png" class="kg-image" alt loading="lazy" width="446" height="225"></figure><p>Bring the connection down and back up to verify changes:</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/02/2024-02-14_15-22-41.png" class="kg-image" alt loading="lazy" width="821" height="227" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/02/2024-02-14_15-22-41.png 600w, https://rift.stacktitan.com/content/images/2024/02/2024-02-14_15-22-41.png 821w" sizes="(min-width: 720px) 720px"></figure><p>Comparing ping times shows that traffic sent to our &apos;VPN endpoint&apos; is traversing the cellular connection, as the latency is significantly higher.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/02/2024-02-14_15-30-34.png" class="kg-image" alt loading="lazy" width="449" height="300"></figure><p>One of the issues we ran in to during testing was configuring SSH to listen on the Wireguard interface&apos;s address only. Systemd would try and start the SSH service before the Wireguard interface was up, and resulted in the service failing to start and essentially locking us out of the device. Edit <code>/etc/systemd/system/sshd.service</code>, adding the service and device referenced on lines 4 and 5 below:</p><!--kg-card-begin: html--><pre class="line-numbers language-c"><code>[Unit]
Description=OpenBSD Secure Shell server
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target auditd.service wg-quick@wg0.service
Requires=sys-devices-virtual-net-wg0.device
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
</code></pre><!--kg-card-end: html--><p>Now we can configure SSH to listen on the Wireguard IP. Uncomment line 17 and replace <code>0.0.0.0</code> with the Wireguard interface&apos;s address.</p><!--kg-card-begin: html--><pre class="line-numbers language-c"><code>root@hotpacket:~# cat /etc/ssh/sshd_config

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin:/bin:/usr/games

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

Include /etc/ssh/sshd_config.d/*.conf

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none
</code></pre><!--kg-card-end: html--><p>At this point, if all went well, the raspberry Pi should be functional and accessible via the LTE cellular network. Once confirmed, the APC surge protector housing can be screwed back together and is ready to be used in your next Red Team engagement. </p><h2 id="conclusion">Conclusion</h2><p>Hopefully this was interesting and if you followed along, and possibly even built one of these, we want to hear from you. Always looking for methods to improve upon the build to include form-factor and additional features. The STACKTITAN team is working on the next version of the surge protector, and hopeful (time permitting) that it will be complete prior to release at upcoming security conferences. Keep on building and hacking!</p>]]></content:encoded></item><item><title><![CDATA[The Covert Hardware Implant: Part 1]]></title><description><![CDATA[Get your Dremel ready and hone your soldering skills. The STACKTITAN team is demonstrating the process to take a readily available surge protector and repurpose it into a covert hardware implant suitable for most any Red Team operation.]]></description><link>https://rift.stacktitan.com/chi_part_1/</link><guid isPermaLink="false">658c545a0f38281a29a66a13</guid><category><![CDATA[adversary]]></category><category><![CDATA[egress]]></category><category><![CDATA[hacking]]></category><category><![CDATA[security]]></category><category><![CDATA[rift]]></category><category><![CDATA[stacktitan]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Tue, 09 Jan 2024 21:11:14 GMT</pubDate><content:encoded><![CDATA[<p></p><h2 id="why-another-hardware-implant">Why Another Hardware Implant?</h2><p>Many hardware implants have already been created by hobbyists and commercial companies, alike. We are no different in that regard. However, we use our hardware implants in real-world Red Team operations while constantly evolving the form factor to align with the most effective solution for the mission. These are battle-tested and proven to work. Lessons are learned and changes are applied, as necessary. We thought it might be interesting to some that may be looking to up their field-kit, might not get an opportunity to perform uninhibited breaches of organizations, or simply enjoy learning by practical application. </p><p>What we aim to achieve in the next couple of blog posts is to help describe our solution, detail the bill-of-materials, exemplify the build process, and finally live-fire our covert hardware implant (CHI). &#xA0;</p><h2 id="the-guiding-criteria-for-the-build">The Guiding Criteria for the Build</h2><p>Ok let&apos;s get this out of the way. If you are building and placing a covert implant in an environment that looks like a computer development board (i.e., raspberry pi, Panda, etc.) then expect it to be observed as suspect. Things that look suspect get detected, and things that look less suspicious often times get overlooked. Which leads to the first criteria:</p><p><strong><em>The physical form-factor must be unassuming and must blend into the surrounding environment.</em></strong></p><p>The implant is going to be placed in a hostile environment where detection instrumentation is going to possibly and most likely inspect traffic. This means that relying on command and control (C2) over a traditional corporate enterprise network isn&apos;t the best solution. The second criteria:</p><p><strong><em>Command and control communications that supports tool delivery and data exfiltration through out-of-band channels.</em></strong></p><p>In a similar vein, the operational traffic, that which will explore and compromise enterprise systems will be seperate from the C2 communication channel (i.e., traverse a separate network interface on the implant). This comes with a number of other considerations. The most notable would be assuring that enterprise tooling that often proactively scan assets (e.g., vulnerability detection, asset inventory, excessive privilege, etc.) are rendered blind to our device.</p><p><strong><em>The enterprise logical footprint should be as minimal/non-existent as possible.</em></strong></p><p>Finally, the implant should be relatively free of complexity and should be serviceable with minimal effort.</p><p><strong><em>The implant should be able to support easily acquirable commodity hardware so that operators can perform field expedient repairs, as necessary.</em></strong></p><h2 id="hardware-bill-of-materials-bom">Hardware Bill of Materials (BOM)</h2><h3 id="1-apc-surge-protector-p11vnt3">1. APC Surge Protector (P11VNT3)</h3><p>A surge protector is an obvious choice that would work in most any corporate environment. Whether it is actually in use or not, nobody is going to question the presence of this form factor. We also set out to find one that supported wired Ethernet ports, as this is going to provide LAN side enterprise connectivity. </p><p>After a bit of searching through the endless Amazons, we came upon the APC P11VNT3 model, which seemed to have all the preliminary bones necessary to support our build. The price point was also well within reason at around $40 USD. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/12/2023-12-28_11-40-44-3.png" class="kg-image" alt loading="lazy" width="1000" height="582" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/12/2023-12-28_11-40-44-3.png 600w, https://rift.stacktitan.com/content/images/2023/12/2023-12-28_11-40-44-3.png 1000w" sizes="(min-width: 720px) 720px"></figure><p></p><h3 id="2-raspberry-pi-4-model-b">2. Raspberry Pi 4 Model B </h3><p>Either the Pi 3 or Pi 4 should work just fine. The supply and demand seems to have calmed down a bit, and can be located relatively close to MSRP (<a href="https://www.sparkfun.com/products/15447 ">Buy at Sparkfun</a>) . We are looking to reengineer the solution to use more readily available prototyping boards, but for now this is the proven adaptation. &#xA0;</p><h3 id="3-cellular-lte-components">3. Cellular LTE Components</h3><p><a href="https://sixfab.com/product/raspberry-pi-base-hat-3g-4g-lte-minipcie-cards/">SIXFAB Pi 4 LTE Hat</a> - This will act as the bridge between the Raspberry Pi and the Telit LTE modem.</p><p><a href="https://sixfab.com/product/lte-gnss-dual-u-fl-antenna/">SIXFAB LTE Antenna</a> - This is the u.FL connected antenna that supports both LTE and GNSS. </p><p><a href="https://sixfab.com/product/telit-le910c4-mini-pcie-cat4-lte-module/">Telit LE910C4 Mini PCIe LTE CAT4 Module</a> - &#xA0;The module serves as the actual LTE modem that will be attached to the SIXFAB LTE Base Hat.</p><p><a href="https://www.twilio.com/docs/iot/wireless">Twilio SIM Card Service</a> - Twilio has partnered with T-Mobile (US) to provide a general pay-as-you-go SIM service for IOT solutions.</p><h3 id="4-miscellaneous-connectors-cables-and-storage">4. Miscellaneous Connectors, Cables and Storage</h3><p><a href="https://www.amazon.com/dp/B08GYKNCCP">MicroSD Card</a> - Recommend using an SD card with a descent amount of storage and IO speeds. We chose to use both Lexar and Sandisk Ultra 128GB cards, which have met our field requirements.</p><p><a href="https://www.amazon.com/dp/B0BYCMMDTD">USB Cable (1 FT USB-C to USB-C)</a> - The inside of the surge protector is rather limited in space, so choose a 6 inch to 1 foot USB-C cable. One end should be a straight connector and the other should be a 90 degree connector. </p><p><a href="https://www.amazon.com/dp/B007QVW3MO">Leviton Power Cord Plug</a> - The surge protector&apos;s power cord will be terminated to this device. We chose to use the original APC power cord due to the cord fitting that secures the cord with the APC case. </p><p><a href="https://www.amazon.com/dp/B099F558S1">Anker USB-C Block Charger</a> - A block charger will provide power to the Raspberry Pi and it&apos;s inherent LTE components. </p><p><a href="https://www.amazon.com/dp/B0B4X48VTM">Adhesive Backed 1/16&quot; Silicon Rubber Sheet</a> - The silicone sheeting will be cut to adhere to the internal bottom side of the APC case. It is a tight fight, so the combination of the rubber anti-slip surface and snug fit of the closed case will prevent the internals from sliding around. </p><p><a href="https://www.amazon.com/dp/B01N41LXRK?ref_=cm_sw_r_cp_ud_dp_8Q29BDD499J315QBHJ0Q">Brass Spacer Standoff Kit</a> - This is just a general purpose kit to make it easier to fit the LTE hat onto the Raspberry Pi 4.</p><h2 id="dismantling-and-clearancing">Dismantling and Clearancing</h2><p>The first thing we want to do is dismantle the housing in order to see what we&apos;re dealing with, so that we can start to piece together our new internal components. Note that this particular APC uses security screws, so you will want to use a <a href="https://www.amazon.com/gp/product/B07TMLJ61L">&quot;spanner&quot; screwdriver</a> to decouple the back from the front pans.</p><p>At this point you can snip all the wires as we will only reuse the power cord. The large PCB in the lower left nearest to the power cord can be removed, along with all of the copper conductors, which are providing power to each power outlet. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/12/IMG_3285-1.JPG" class="kg-image" alt loading="lazy" width="1000" height="471" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/12/IMG_3285-1.JPG 600w, https://rift.stacktitan.com/content/images/2023/12/IMG_3285-1.JPG 1000w" sizes="(min-width: 720px) 720px"></figure><p>The next task is to get dirty using a Dremel rotary cutoff tool. &#xA0;Disregard the power cable and the USB adapter plugged into it, that is something we will add later. For now, the Dremel should be used to cut away and smooth down all of the excess plastic, similar to the following image. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/12/IMG_3293.jpg" class="kg-image" alt loading="lazy" width="1000" height="502" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/12/IMG_3293.jpg 600w, https://rift.stacktitan.com/content/images/2023/12/IMG_3293.jpg 1000w" sizes="(min-width: 720px) 720px"></figure><p>The bottom of the tray will also need the Dremel treatment. The idea is to spend some time really removing as much of the plastic material as possible and smoothing out the pan, but make sure not to remove the stantions (yellow arrows) that are used to secure the lower pan to the upper pan. </p><p><strong>Optional (Strongly Recommend)</strong>: Cut a piece of the adhesive backed rubber and fit it to the bottom of the pan. This will help to secure and prevent the Raspberry Pi from sliding around within the APC case. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/pan-1.png" class="kg-image" alt loading="lazy" width="1000" height="470" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/pan-1.png 600w, https://rift.stacktitan.com/content/images/2024/01/pan-1.png 1000w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="networking-and-communications">Networking and Communications</h2><p>The advantage of this particular APC is the onboard ethernet surge protection. This is also the module that will need to be rewired to support Ethernet for our intended purposes. First order is to locate the module that looks like the following (right-most image) and pull it from the APC housing. There is a small tab that holds it secure, so take your time and gently remove the component.</p><p>Once removed, you will want to use either a soldering iron or a hot-air rework gun to desolder and remove all of the diodes as shown in the highlighted box below. The finished product should resemble something similar to the left-most image below. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/IMG_3288.jpg" class="kg-image" alt loading="lazy" width="1000" height="532" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/IMG_3288.jpg 600w, https://rift.stacktitan.com/content/images/2024/01/IMG_3288.jpg 1000w" sizes="(min-width: 720px) 720px"></figure><p>Flipping the Ethernet PCB component over to expose the traces, we can observe the &quot;in&quot; port and the respective pinout. Although it is easy enough to follow the traces on the PCB, the pins and there respective destination solder points are clearly labeled below to remove any confusion. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/IMG_3286.jpg" class="kg-image" alt loading="lazy" width="1000" height="565" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/IMG_3286.jpg 600w, https://rift.stacktitan.com/content/images/2024/01/IMG_3286.jpg 1000w" sizes="(min-width: 720px) 720px"></figure><p>This is the point where soldering skills will come into play. We recommend using a 22 AWG solid core tinned copper hook-up wire (2-3 inches long) along with a bit of flux at the solder point to make wiring the ethernet connection to the PCB a bit less painful. Then grab an ethernet cable and cut it down to a 6 inch section with the RJ45 plug still intact, and strip the sheathing back about 1 inch. </p><p>The next task is to wire the ethernet connection to the solid core hook-up wires. The following diagram is for a 568B Ethernet wiring spec, but this is simply soldering pins 1,2,3 and 6 to their respective PCB solid-core hook-up wires. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/12/eth-1.png" class="kg-image" alt loading="lazy" width="1000" height="413" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/12/eth-1.png 600w, https://rift.stacktitan.com/content/images/2023/12/eth-1.png 1000w" sizes="(min-width: 720px) 720px"></figure><p>The final product should look similar to the following picture. Also not the gratuitous use of heat-wrap, both for the individual wire connections and the ethernet cable overall. Don&apos;t use electrical tape, it is a mess and doesn&apos;t instill confidence that your connections are protected adequately. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/12/IMG_3395.png" class="kg-image" alt loading="lazy" width="1000" height="539" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/12/IMG_3395.png 600w, https://rift.stacktitan.com/content/images/2023/12/IMG_3395.png 1000w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="wiring-the-power-cord">Wiring the Power Cord</h2><p>The power cord has a special fitting that holds it securely in the APC case. Unfortunately, it has to be reused and it is a P.I.T.A to repurpose. Specifically, cut the power cord right below the 90 degree fitting. Then strip about 6 inches of sheathing from the cable. </p><p>Now you will need to muscle the cut wires out of the 90 degree fitting. It will give way but it does require force to remove the wires. I had to Dremel the inside of the 90 degree fitting so that I could rework the 6 inches or so of wire back through the fitting. This will also take some finesse because it is a tight fit. Once complete, you should have a final product that is indistinguishable from the OEM power cord. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/power_cable.png" class="kg-image" alt loading="lazy" width="1000" height="620" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/power_cable.png 600w, https://rift.stacktitan.com/content/images/2024/01/power_cable.png 1000w" sizes="(min-width: 720px) 720px"></figure><p>The reason why we had to go through the trouble of reworking the power cord, is because cutting the wiring from the various PCBs during disassembly didn&apos;t leave much room to terminate the power, neutral and ground wires to our Leviton plug end. As you can observe in the following picture, we now have even lengths and secure connections. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/leviton.png" class="kg-image" alt loading="lazy" width="1000" height="603" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/leviton.png 600w, https://rift.stacktitan.com/content/images/2024/01/leviton.png 1000w" sizes="(min-width: 720px) 720px"></figure><p>The following is an illustration of the placement along with the Leviton plug end fitted back into the APC case. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/power_cord_tray.png" class="kg-image" alt loading="lazy" width="1000" height="865" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/power_cord_tray.png 600w, https://rift.stacktitan.com/content/images/2024/01/power_cord_tray.png 1000w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="assembling-the-raspberry-pi">Assembling the Raspberry Pi</h2><p>This will be a quick step-by-step of the assembly to demonstrate how all of the components fit together. Most readers that are familiar with the Raspberry Pi format should already find it intuitive. </p><p>The following is a list of components clockwise from upper-left to include the 128GB MicroSD card, the USB connection cable, the Raspberry Pi 4, the Telik mini-PCI LTE modem connected to the Pulse LTE antenna, and the Sixfab LTE base hat. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/pi_components.png" class="kg-image" alt loading="lazy" width="1000" height="1061" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/pi_components.png 600w, https://rift.stacktitan.com/content/images/2024/01/pi_components.png 1000w" sizes="(min-width: 720px) 720px"></figure><p>Initially, we want to start with the Raspberry Pi 4 and install the Sixfab LTE base hat using brass spacers and screws from the Brass Spacer Standoff Kit. Once secured, it should look like the following. &#xA0;</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/pi_1.png" class="kg-image" alt loading="lazy" width="1000" height="550" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/pi_1.png 600w, https://rift.stacktitan.com/content/images/2024/01/pi_1.png 1000w" sizes="(min-width: 720px) 720px"></figure><p>Note that the use of a header extension will be required, although it should have been included with the Sixfab LTE base hat kit. The following image illustrates the fitment when installed correctly.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/pi_2-1.png" class="kg-image" alt loading="lazy" width="1000" height="575" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/pi_2-1.png 600w, https://rift.stacktitan.com/content/images/2024/01/pi_2-1.png 1000w" sizes="(min-width: 720px) 720px"></figure><p>Now we are ready to install the actual Telik LTE modem. Connect the u.FL connectors from the Pulse LTE antenna to the Telik board. Ensure the GPS/GNSS and LTE connectors are attached in the correct order. Then simply snap the Telik board into the mini-PCI slot of the Sixfab LTE base hat. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/pi_3-1.png" class="kg-image" alt loading="lazy" width="1000" height="854" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/pi_3-1.png 600w, https://rift.stacktitan.com/content/images/2024/01/pi_3-1.png 1000w" sizes="(min-width: 720px) 720px"></figure><p>If using the Twilio wireless service, then you will have received a SIM card. This is what we use at STACKTITAN, and it has worked flawlessly with stable daily access running over months-long operations. Install the SIM as follows. &#xA0;</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/pi_4-1.png" class="kg-image" alt loading="lazy" width="1000" height="880" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/pi_4-1.png 600w, https://rift.stacktitan.com/content/images/2024/01/pi_4-1.png 1000w" sizes="(min-width: 720px) 720px"></figure><p>The final task, is to connect the USB cable from the Raspberry Pi&apos;s USB-3 port to the micro-USB connection on the Sixfab LTE base hat. The following depicts a completed build ready for placement into the APC.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/pi_5.png" class="kg-image" alt loading="lazy" width="1000" height="1063" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/pi_5.png 600w, https://rift.stacktitan.com/content/images/2024/01/pi_5.png 1000w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="final-hardware-assembly-of-the-apc">Final Hardware Assembly of the APC </h2><p>All of our hard work has paid off and now comes the time to piece it all together. One suggestion is to cut a couple of adhesive backed rubber strips and place them as depicted by the yellow arrows in the following image. This will help to secure the Raspberry Pi and keep it from sliding within the APC. Also, placing a couple of 3M adhesive pads as depicted by the blue arrows will provide a solid surface to adhere the LTE antenna. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/APC_1.png" class="kg-image" alt loading="lazy" width="1000" height="463" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/APC_1.png 600w, https://rift.stacktitan.com/content/images/2024/01/APC_1.png 1000w" sizes="(min-width: 720px) 720px"></figure><p>Assemble everything into the upper pan of the APC as shown below. Number 1 depicts the Anker block charger and the USB-C cable (straight-end) connections. Number 2 is the location for the ethernet cable connection. Finally, number 3 is the location for the opposing end of USB-C cable (90 degree) mated to the USB-C port on the Raspberry Pi. Make sure to adhere the Pulse LTE antenna, as well. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/APC_2.png" class="kg-image" alt loading="lazy" width="1000" height="470" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/APC_2.png 600w, https://rift.stacktitan.com/content/images/2024/01/APC_2.png 1000w" sizes="(min-width: 720px) 720px"></figure><p>Now fit the bottom pan to the upper pan and flip the entire APC over. Don&apos;t worry about securing the pans together with screws. This is just a test fitment to ensure clearances are adequate. If everything fits, you just successfully assembled your APC covert hardware implant. Flip it back over and remove the bottom pan, so that we can access the Raspberry Pi. &#xA0;</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2024/01/APC_3.png" class="kg-image" alt loading="lazy" width="1000" height="477" srcset="https://rift.stacktitan.com/content/images/size/w600/2024/01/APC_3.png 600w, https://rift.stacktitan.com/content/images/2024/01/APC_3.png 1000w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="next-stepspart-2-chi-os-and-scripting">Next Steps...Part 2: CHI OS and Scripting</h2><p>All of this may have seemed like quite a bit of work to get to this point. Agreed, it does take some time. We have built multiple CHIs; although, the effort is worth it as the CHI performs well in the field. This leads us to the next reason for building such devices.</p><p>Remember that Red Team customers are unique in the fact that they often have extended the necessary effort to build out their security programs (people, technology, and processes). A &quot;traditional penetration test&quot; simply is not adequate for such clients, as they want a solution that evolves and grows along with their detection and prevention capabilities. As such, they demand creativity, realistic threat emulations and skilled tradecraft necessary to assess risk from multiple perspectives. If you are an organization that is interested in this style of testing, reach out to STACKTITAN as we would welcome the opportunity to create a custom engagement and talk tradecraft.</p><p>We hope this has provided some inspiration for building hardware implants. In the next series of this post, we are going to install the operating system, create scripts to make everything work and finally verify that our CHI is operational. </p><p><strong><em> </em></strong></p>]]></content:encoded></item><item><title><![CDATA[Hardware-Hacking: Arduino R4 and a Microwire EEPROM]]></title><description><![CDATA[Let's explore how we might interface with a Microwire EEPROM and extract data using the newly released Arduino UNO R4 eval board.]]></description><link>https://rift.stacktitan.com/hardware-hacking-arduino-r4-eeprom-and-microwire/</link><guid isPermaLink="false">64b421cb0f38281a29a665e7</guid><category><![CDATA[adversary]]></category><category><![CDATA[hacking]]></category><category><![CDATA[hardware]]></category><category><![CDATA[firmware]]></category><category><![CDATA[rift]]></category><category><![CDATA[stacktitan]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Fri, 21 Jul 2023 16:50:34 GMT</pubDate><content:encoded><![CDATA[<p></p><h2 id="preface">Preface</h2><p>This was an interesting journey into what I thought was going to entail lifting data from a typical SPI or I2C chip, but alas it was neither, rather the Microwire protocol. Let&apos;s explore this protocol, how we might interface with a Microwire EEPROM and extract data using the newly released Arduino UNO R4 eval board. I mean...this was really just some weekend hacking and a chance to crack open this shiny new Arduino...right?! </p><h2 id="test-environment">Test Environment</h2><p>The board that we are targeting is a proprietary commercial USB programmer that is used to interface with Texas Instrument MSP430 microcontrollers, and specifically as a means to access SPY-BI-WIRE (SBW). Although, SBW is not the intent of this post but is something that will be a future post as it is an interesting method to multiplex JTAG over a two-wire protocol. </p><p>The other important part is selecting the correct GPIO interface for extracting data from the USB programmer&apos;s IC. I am just going to say that I started to reach for the Bus Pirate, then I thought about the GreatFet, but realized that I had an Arduino UNO R4 that is a perfectly capable ESP32 enabled eval board. This decision to use the latter actually turned into an ideal exercise to explore the Arduino IDE, write some C, and simply do some experimentation. This is what we are dealing with (Arduino lower side of picture and USB programmer near the top)...</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/07/arduino.png" class="kg-image" alt loading="lazy" width="1024" height="734" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/07/arduino.png 600w, https://rift.stacktitan.com/content/images/size/w1000/2023/07/arduino.png 1000w, https://rift.stacktitan.com/content/images/2023/07/arduino.png 1024w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="inspecting-the-usb-programmer">Inspecting the USB Programmer</h2><p>Looking at this device, we can see some interesting items. First, even though this was originally enclosed in a plastic case, is that the manufacturer/designer has not done anything to obfuscate the various interfaces. This is to be expected as it is a programmer and used to interface with target device GPIO, itself. The other obvious items are the M-Cortex and JTAG interfaces on the far right. </p><p>Why not just hook up a JTAGulator and bit bang the pins? Well, if we trace the VIAs (i.e., the copper substrate lines) through the PCB, we run into a bank of resistors. The resistors are shielding the components (i.e., MCU and EEPROM) from voltages on the target device. As such, the M-Cortex ( i.e., 10 pin JTAG) and the 14 pin JTAG are simply there as two options to interface with equivalent GPIO on the target device. It is unlikely that the JTAG interface will provide uninhibited access to the on-board component-chain as we might expect. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/07/arduino2--1-.png" class="kg-image" alt loading="lazy" width="1024" height="525" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/07/arduino2--1-.png 600w, https://rift.stacktitan.com/content/images/size/w1000/2023/07/arduino2--1-.png 1000w, https://rift.stacktitan.com/content/images/2023/07/arduino2--1-.png 1024w" sizes="(min-width: 720px) 720px"></figure><p>Alternatively, the EEPROM uses a Micro Small Outline Package with exposed legs and the pitch is perfect for a Pomona SOIC 5250 test clip. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/07/arduino3.png" class="kg-image" alt loading="lazy" width="1024" height="711" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/07/arduino3.png 600w, https://rift.stacktitan.com/content/images/size/w1000/2023/07/arduino3.png 1000w, https://rift.stacktitan.com/content/images/2023/07/arduino3.png 1024w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="inspecting-the-eeproms-data-sheet">Inspecting the EEPROM&apos;s Data Sheet</h2><p>The labeling on this EEPROM was a bit hard to read, so until our stereo microscope arrives, let&apos;s just say that it is a <a href="https://ww1.microchip.com/downloads/en/DeviceDoc/20001749K.pdf">Microchip 93LC46B</a> package. The respective data-sheet appears as follows:</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/07/2023-07-16_14-09-32.png" class="kg-image" alt loading="lazy" width="796" height="585" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/07/2023-07-16_14-09-32.png 600w, https://rift.stacktitan.com/content/images/2023/07/2023-07-16_14-09-32.png 796w" sizes="(min-width: 720px) 720px"></figure><p>Now most everyone has likely been introduced to the SPI or I2C protocols used in serial communications, but this is neither. Instead, this EEPROM uses Microwire. So what is Microwire? </p><h3 id="microwire">Microwire</h3><p>Microwire can be thought of as the predecessor to SPI. Whereas SPI utilizes a 4-wire circuit (i.e., MISO - master in slave out, MOSI - master out slave in, CLK/SCK - serial clock, CS/SS - chip select), Microwire uses a 3-wire circuit (i.e., MISO, MOSI, and CLK/SCK). Microwire permits variable length, but is dependent on the type of package and uses the ORG pin configuration to determine memory management (e.g., word size). The other notable item is that Microwire is slightly slower than SPI. Lastly, is that Microwire does not &quot;float&quot; the CS voltage (i.e., neither high nor low), meaning that the voltage is explicitly tied high or low to determine whether or not the chip is actively listening or not.</p><h3 id="more-about-the-93lc46b-eeprom">More about the 93LC46B EEPROM</h3><p>This particular EEPROM does not support the ORG pin, meaning that the memory Word Size is a fixed 16bit width. Additionally, we might want to know the address bus width, in other words, the number of addresses we have available. &#xA0;</p><!--kg-card-begin: markdown--><pre><code>The data sheet states: 64 x 16-bit Organization &apos;B&apos; Devices (no ORG)
</code></pre>
<!--kg-card-end: markdown--><p>If we have a fixed word size of 16bits and the memory layout is 64 rows, then we can do some quick math to get the address bus width of 6 bits. This will be useful later on. </p><!--kg-card-begin: markdown--><pre><code>log2(64) = 6 // 2x2x2x2x2x2 = 64
</code></pre>
<!--kg-card-end: markdown--><h2 id="wiring-the-arduino-uno-r4-and-eeprom">Wiring the Arduino UNO R4 and EEPROM</h2><p>The Arduino UNO series of boards have numerous prototyping capabilities and the latest ESP32 enabled R4 is much the same layout, but more powerful. The wiring should align with the following table, whereas an Arduino UNO and EEPROM schematic are provided for reference. The finished wiring will look similar to the first picture of this post.</p><!--kg-card-begin: html--><!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid white;
  border-collapse: collapse;
  color: black;
  font-weight:bold;
}
th, td {
  background-color: #96D4D4;  
}
</style>
</head>
<body>
<table>
  <tr>
    <th>Data-Sheet Pin</th>
    <th>Arduino UNO Pin</th>
    <th>Purpose</th>
  </tr>
  <tr>
    <td>CS</td>
    <td>13</td>
    <td>Chip Select</td>
  </tr>
  <tr>
    <td>DO/MISO</td>
    <td>2</td>
    <td>Master In Slave Out</td>
  </tr>
  <tr>
    <td>VSS</td>
    <td>GND</td>
    <td>Ground</td>
  </tr>
  <tr>
    <td>VCC</td>
    <td>3.3v</td>
    <td>Supply Voltage</td>
  </tr>
  <tr>
    <td>CLK</td>
    <td>12</td>
    <td>Serial Clock</td>
  </tr>
  <tr>
    <td>DI/MOSI</td>
    <td>7</td>
    <td>Master Out Slave In</td>
  </tr>
</table>
</body><!--kg-card-end: html--><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/07/arduino-uno-pinout.png" class="kg-image" alt loading="lazy" width="1089" height="779" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/07/arduino-uno-pinout.png 600w, https://rift.stacktitan.com/content/images/size/w1000/2023/07/arduino-uno-pinout.png 1000w, https://rift.stacktitan.com/content/images/2023/07/arduino-uno-pinout.png 1089w" sizes="(min-width: 720px) 720px"></figure><p></p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/07/arduino4.png" class="kg-image" alt loading="lazy" width="667" height="453" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/07/arduino4.png 600w, https://rift.stacktitan.com/content/images/2023/07/arduino4.png 667w"></figure><p></p><h2 id="the-arduino-ide-and-the-microwireeeprom-lib">The Arduino IDE and the MicrowireEEPROM lib</h2><p>I started down the path of reading the data sheet and coding Microwire functionality, but then came upon a couple of usable Microwire Arduino libraries. I don&apos;t want to take away from the importance of creating or building from the ground up, but already having an understanding of how the underlying protocol works makes using someone else&apos;s research a convenience. </p><p><a href="https://github.com/tim0s/MicrowireEEPROM">MicrowireEEPROM</a></p><p><a href="https://github.com/GyverLibs/microWire">microWire</a></p><p>I read through the code for the MicrowireEEPROM and decided that it would be enough to build a usable Arduino Sketch. However, I want to dig into a couple of MicrowireEEPROM.cpp functions as they will help to understand the code we will write, shortly. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/07/arduino5.png" class="kg-image" alt loading="lazy" width="751" height="513" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/07/arduino5.png 600w, https://rift.stacktitan.com/content/images/2023/07/arduino5.png 751w" sizes="(min-width: 720px) 720px"></figure><p>As we want to read the memory of the EEPROM, there are two primary functions, the MicrowireEEPROM::read() and the MicrowireEEPROM::send_opcode(). Note that the read() function requires information about the address width and the page size that we determined early on. As a result, we are going to cycle through all of the 64 memory addresses and read 16 bits of data from each. </p><p>Now, notice that the read() function calls &quot;send_opcode(2)&quot; and passes &quot;2&quot; as it&apos;s parameter. Reference the Instruction Set for the 93XX46B package. Notice that the READ instruction has a binary opcode of &quot;10&quot; which is a decimal &quot;2&quot;. Also, note how Microwire explicitly controls the state of chip select (CS) when writing and reading, which I had alluded to earlier. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/07/arduino6.png" class="kg-image" alt loading="lazy" width="669" height="205" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/07/arduino6.png 600w, https://rift.stacktitan.com/content/images/2023/07/arduino6.png 669w"></figure><p>Again, nothing really novel here, but my hope is that this instills an appreciation for the data sheets and how much information is afforded within their pages. They are a wealth of knowledge and extremely useful when reconciling your understanding alongside code. &#xA0;</p><h3 id="writing-the-sketch">Writing the Sketch</h3><p>Finally, we want to leverage the <a href="https://www.arduino.cc/en/software">Arduino-IDE</a> to create our code that will be used to read out the data of the EEPROM. The MicrowireEEPROM library has an example sketch called EEPROMTest.ino, which we will use as our foundation. I am going to fast-forward to our code and walk through the functionality. </p><p>First, we setup the Arduino UNO pins and map them to their respective functions on line 6. On line 12, we set the address page size and the address bus width, again those are both values we determined earlier on. The other value is serial clock speed which is set to a default 200 microseconds. </p><!--kg-card-begin: html--><pre class="line-numbers language-c"><code>#include &lt;MicrowireEEPROM.h&gt;

// Microwire needs four wires (apart from VCC/GND) DO,DI,CS,CLK
// configure them here, note that DO and DI are the pins of the
// EEPROM, so DI is an output of the uC, while DO is an input
int CSEL=13; int CLK=12; int DI=7; int DO=2;

// EEPROMS have different sizes. Also the number of bits per page varies.
// We need to configure the page size in bits (PGS) and address bus width
// in bits (ADW). The speed at which the clock is run is configured in
// microseconds.
int PGS=16; int ADW=6; int SPD=200;

// initialize the library
MicrowireEEPROM ME(CSEL, CLK, DI, DO, PGS, ADW, SPD); 

void setup() {
  Serial.begin(9600);
}

void loop() {
  for (int addr=0; addr &lt; (1&lt;&lt;ADW); addr++) {
    
    // read the value
    uint16_t readValue = ME.read(addr);
    
    // give some debug output
    Serial.print(&quot;Address &quot;); 
    Serial.println(addr, HEX);

    Serial.print(&quot;Read &quot;);
    unsigned char high_byte = readValue &gt;&gt; 8;
    unsigned char low_byte = readValue &amp; 0xFF;
    char h[7];
    char l[7];

    sprintf(h, &quot;%02x&quot;, high_byte);
    Serial.print(h);

    sprintf(l, &quot;%02x&quot;, low_byte);
    Serial.print(l);
    Serial.println();
    
    delay(1000);
  }  
}
</code></pre><!--kg-card-end: html--><p>The setup() function is simply to set the serial baud rate to a reasonable value of 9600. The loop() function is performing a bit-shift operation at line 22, which is walking through all of the possible addresses (i.e., 64 total). Line 25, we are using a unsigned 16 bit integer data type to store the data located at a specific memory address. </p><p>Lines 32 - 42 require some slight voodoo, which is essentially breaking apart our 16 bit stored value into a lower and upper 8 bit values, respectively. We are doing this so we can &quot;0-pad&quot; string format each byte and then present the lower and upper values as two cleanly formatted bytes. The following screenshot of Arduino-IDE&apos;s Serial Monitor illustrates the output produced by our code. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/07/arduino_addresses-2.png" class="kg-image" alt loading="lazy" width="902" height="788" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/07/arduino_addresses-2.png 600w, https://rift.stacktitan.com/content/images/2023/07/arduino_addresses-2.png 902w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="conclusion">Conclusion</h2><p>Obviously, there is more that can be done with the data output at this point, which will likely come about as part of a future post. For now, we set out to extract data from this Microwire EEPROM, which we accomplished. It may not be the most elegant solution, but this is hacking and sometimes we just need &quot;it&quot; to work. Having an arsenal of tools at our disposal, including the Arduino UNO R4, is essential to accomplishing our objective. Sure, we could have accomplished the same task with another eval board, but exploring often leads to new discoveries and keeps things interesting. With that, we hope you found this interesting and keep on the lookout for future hardware hacking posts. More on the way! </p></html>]]></content:encoded></item><item><title><![CDATA[SE: Build a Caller ID Spoofing Rig]]></title><description><![CDATA[Telephone Caller ID (CID) is often abused to manipulate the recipient's trust. Come explore the technology as STACKTITAN's Alex Sander's demonstrates building a CID spoofing rig. ]]></description><link>https://rift.stacktitan.com/cid-spoofing/</link><guid isPermaLink="false">647ce0900f38281a29a66322</guid><category><![CDATA[adversary]]></category><category><![CDATA[telephony]]></category><category><![CDATA[VoIP]]></category><category><![CDATA[hacking]]></category><category><![CDATA[pentest]]></category><category><![CDATA[redteam]]></category><category><![CDATA[security]]></category><category><![CDATA[stacktitan]]></category><category><![CDATA[rift]]></category><category><![CDATA[social engineering]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Fri, 09 Jun 2023 14:16:57 GMT</pubDate><content:encoded><![CDATA[<p></p><h2 id="introduction">Introduction</h2><p>After receiving multiple phone calls from what our caller ID reported as the rich and famous only to find out it was our own Alex Sanders on the other end, he is here to demonstrate the process associated with the tech and process used to do so. </p><p>When it comes to social engineering, voice phishing can make or break the engagement. A lot of people are trained to deal with suspicious emails and documents, very few have meaningful training on suspicious calls. In this article we&#x2019;re going to walk through the process of setting up self-hosted tooling to perform these calls.</p><p>Before getting started, it&#x2019;s important that you, the social engineer, think about what your ruse or pretext, along with the desired premise and outcome. Does your ruse require you to spoof a phone number? Do you only need the area code to originate from a location aligned with the target person or organization? If you want to save on costs and can get away with just a matching area code, a service like <a href="https://www.textnow.com/">TextNow</a> would suffice. Download the app, sign up with any email, deny location permissions, enter the area code you&#x2019;re matching, and choose a number. </p><p>If you need to spoof the entire phone number, you essentially have two options: services like <a href="https://www.spoofcard.com/">SpoofCard</a> or your own Private Branch Exchange (PBX). Spoofcard works well enough, but if you want to have reliable control over your services and an understanding of what&#x2019;s happening behind the scenes, you should stand up your own PBX. So what is a PBX? To answer that, we need to understand a little about Voice over IP (VoIP), in general.</p><h2 id="voip-overview">VoIP Overview</h2><p>Back, many years prior to the EV revolution of current day, phone calls were placed over somewhat &quot;closed&quot; networks and protocols. This network, similar to how we think of the Internet, was referred to as the Public Switched Telephone Network (PSTN). How did someone or something (e.g., analog modem) interface with the PSTN. Via Earthlink or America Online, of course! Albeit, there is some truth in that, the PSTN was accessed through PBXes that resided within a Central Office (CO). A CO was literally a collection of necessary equipment, which contained the PBX, switches, and all the rest of the goods housed within a large building in all major cities. </p><p>As you can probably ascertain, this was costly to maintain and copper &quot;land lines&quot; were geographically limited as compared to our modern expectations of liberated communications. With that, just as we put radio on the Internet, we did so with voice phone calls, as well. &#xA0;</p><p>VoIP is a protocol stack that permits placing phone calls over Internet (i.e., IP) based medium. VoIP can communicate directly and natively over IP with other VoIP devices, and interact with phone exchanges via the PSTN. The latter, use of the PSTN, is typically still a fundamental necessity when dialing by phone-number, for example. Additionally, VoIP devices and analog telephony devices can coexist through Analog-to-Digital | Digital-to-Analog converters (i.e. ATA). All of this interaction still leverages a PBX as the gatekeeper, of sorts. </p><p>Typical VoIP communication is comprised of two parts, 1. SIP (Session Initiation Protocol) and 2. RTP (Real Time Protocol). SIP establishes and manages the connection (i.e., call setup and teardown) while RTP delivers the payload (e.g., audio signals). The architecture for the infrastructure involved typically goes as follows &#x2013; a DID (Direct Inward Dialing) number is registered via a SIP trunk provider, the technician then configures a phone to register to a PBX (Private Branch Exchange) server and dial out through this DID number at the provider. So what is the SIP Provider, you might ask? There is still a requirement to be able to access the PSTN, as we described earlier, and the SIP Provider maintains their own litany of PBX devices that knows how to interface with the telecommunication conglomerate&apos;s closed PSTN. Anyway, enough of the history lesson, let&apos;s get our hands dirty with some tech...</p><h2 id="preparing-the-pbx-and-choosing-a-sip-provider">Preparing the PBX and Choosing a SIP Provider </h2><p>Now that we&#x2019;ve had an overview on how these systems work in theory, let&#x2019;s set up our self-hosted PBX. You&#x2019;ll want to download a copy of <a href="https://www.debian.org/download">Debian 11</a> and install the following packages: <code>wget tar vim jq</code>. </p><p>From here, ensure your terminal window is fullscreen, or the next script will fail to set up asterisk. Use <code>wget</code> to download the <a href="http://incrediblepbx.com/IncrediblePBX2027-D.sh">IncrediblePBX2027-D.sh</a> script that does most of the heavy lifting for us. Make sure to apply execute permissions, <code>chmod +x &lt;script&gt;</code>, to the script and then run it as root. This will set up all the necessary packages and configure them to play nicely, as well as create several additional scripts in the root home directory for management of the server. </p><p>Once this has finished, run the <code>admin-pw-change</code> and <code>apache-pw-change</code> scripts from the root home directory. At this point, we&#x2019;ll need to register with Skyetel (i.e., the SIP Provider) and purchase a DID phone number. Once this is done, configure an IP Group to allow communication to their servers. This can be done manually, but we&#x2019;ve used another <a href="https://www.debian.org/download">script</a> to automate this. Execute the script and follow the prompts. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/06/1-2.png" class="kg-image" alt loading="lazy" width="936" height="242" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/06/1-2.png 600w, https://rift.stacktitan.com/content/images/2023/06/1-2.png 936w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="configure-the-pbx-and-soft-phone-handset">Configure the PBX and Soft-Phone Handset</h2><p>Now that our public IP is allowed to communicate with Skyetel&#x2019;s servers, we need to manage our PBX and phone system. There are four (4) main components we need to concern ourselves with: </p><ul><li><strong>Extensions</strong> &#x2013; internal identification of phones</li><li><strong>IP addressing </strong></li><li><strong>SIP Trunks </strong>&#x2013; what servers our VoIP traffic communicates with and how to communicate with them</li><li><strong>Outbound Routes</strong> &#x2013; which trunks are in use, and Dial Patterns &#x2013; how the PBX parses dialed numbers</li></ul><p>For all changes in Incredible PBX, you must use the <code>Submit</code> button on the bottom right and apply changes using the red <code>Apply Config</code> button in the top right. First we&#x2019;ll navigate to <code>Settings</code> &gt; <code>Advanced SIP Settings</code> and use the <code>Detect Network Settings</code> button to auto-populate our LAN and WAN details.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/06/2--1-.png" class="kg-image" alt loading="lazy" width="983" height="701" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/06/2--1-.png 600w, https://rift.stacktitan.com/content/images/2023/06/2--1-.png 983w" sizes="(min-width: 720px) 720px"></figure><p>Next we&#x2019;ll create a SIP extension so that a local endpoint (e.g., SIP enabled phone handset) can communicate with the PBX using traditional SIP over TCP 5060 (note that TLS enabled SIP is typically TCP 5061). These extensions are unique to each endpoint, such as each employee often has their own desk phone and number. </p><p>Navigate to <code>Applications</code> &gt; <code>Extensions</code>, click the <code>Add Extensions</code> drop down, and select <code>+Add New SIP (Legacy0 [chan_sip] Extension</code>. Fill out the <code>User Extension</code>, <code>Display Name</code>, and <code>Secret</code> fields. A secret here should be treated similar to a password. It needs to be composed with enough length and complexity to prevent compromise of the extension. As an aside, this sort of attack is often referred to as registration hijacking, and we wrote some <a href="https://github.com/stacktitan/sipbrute">code</a> a while back as a proof-of-concept, if interested in exploring further. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/06/6.png" class="kg-image" alt loading="lazy" width="979" height="332" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/06/6.png 600w, https://rift.stacktitan.com/content/images/2023/06/6.png 979w" sizes="(min-width: 720px) 720px"></figure><p></p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/06/7.png" class="kg-image" alt loading="lazy" width="978" height="473" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/06/7.png 600w, https://rift.stacktitan.com/content/images/2023/06/7.png 978w" sizes="(min-width: 720px) 720px"></figure><p></p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/06/8.png" class="kg-image" alt loading="lazy" width="976" height="333" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/06/8.png 600w, https://rift.stacktitan.com/content/images/2023/06/8.png 976w" sizes="(min-width: 720px) 720px"></figure><p></p><p>With an extension configured, we need to set up an actual phone. We had mentioned desk phones, but many organizations have moved to software based phones (soft-phones). Soft-phones are arguably more feature rich, and many are integrated into operating systems or cloud subscriptions, already. If not, numerous open-source soft-phones are available, which provide everything necessary to gey up and running. &#xA0;With that said, we are going to configure the <a href="https://www.zoiper.com/">Zoiper</a> soft-phone. Jumping right in, the username field should be the extension you configured @ the hostname or IP of the PBX instance. The password field will be the secret you configured for the extension, hostname will be the hostname or IP of the PBX.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/06/10.png" class="kg-image" alt loading="lazy" width="983" height="598" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/06/10.png 600w, https://rift.stacktitan.com/content/images/2023/06/10.png 983w" sizes="(min-width: 720px) 720px"></figure><p>As long as this doesn&#x2019;t fail to register, we&#x2019;ll move on to configuring the outbound route for the PBX to communicate with Skyetel. Otherwise, if you&#x2019;ve chosen another provider, you will need to configure trunks and a dial plan for that provider as Incredible PBX 2027 is already set up to work with Skyetel. </p><p>Navigate to <code>Connectivity</code> &gt; <code>Outbound Routes</code> &gt; <code>Add Outbound Route</code>. Fill in the values for <code>Route Name</code> and <code>Route CID</code> (this is the phone number you&#x2019;ve purchased through Skyetel). The <code>Trunk Sequence for Matched Routes</code> will be the trunks that are pre-configured for Skyetel.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/06/11.png" class="kg-image" alt loading="lazy" width="977" height="464" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/06/11.png 600w, https://rift.stacktitan.com/content/images/2023/06/11.png 977w" sizes="(min-width: 720px) 720px"></figure><p>Next we&#x2019;ll navigate to the <code>Dial Patterns</code> tab and use the <code>Dial patterns wizards</code> button to make sure our calls will complete as dialed. De-select the <code>EU Emergency</code> option, and leave the other default selections in place. Click the <code>Generate Routes</code> button, then submit and apply the config.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/06/12.png" class="kg-image" alt loading="lazy" width="976" height="505" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/06/12.png 600w, https://rift.stacktitan.com/content/images/2023/06/12.png 976w" sizes="(min-width: 720px) 720px"></figure><p>With all of this configured, we can place a call from Zoiper to verify that everything works as intended. Once we have a regular call working, we can fill in the <code>Outbound CID</code> under the <code>Extensions</code> configuration with the number we intend to spoof and test that. Voila, here I am making a call to myself as the local casino...which has informed me that I have already lost at Texas hold-em! Better luck in Vegas. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/06/13--1-.png" class="kg-image" alt loading="lazy" width="799" height="768" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/06/13--1-.png 600w, https://rift.stacktitan.com/content/images/2023/06/13--1-.png 799w" sizes="(min-width: 720px) 720px"></figure><h2 id="conclusion">Conclusion</h2><p>We hope that you found this useful and has inspired you to explore VoIP technologies. Although, voice phishing may not be everyone&#x2019;s favorite social engineering vector, it can be effective with the right tools and planning. With a little additional configuration, this could even be used as part of a regular email phishing campaign: supply a phone number for users to call at the bottom of the email to verify the legitimacy of an email, get in touch with support over an invoice, or whatever ruse you can come up with. Have fun, spoof responsibly, and until next time.</p>]]></content:encoded></item><item><title><![CDATA[Hardware-Hacking: Lifting Firmware]]></title><description><![CDATA[Join us as we explore a technique to lift firmware from hardware. This is the first of many hardware hacking topics that the STACKTITAN team will be sharing and hope that it inspires you to crack open and investigate that perfectly functional router on your desk. ]]></description><link>https://rift.stacktitan.com/lifting-firmware-part-one/</link><guid isPermaLink="false">63e1820f0f38281a29a65958</guid><category><![CDATA[adversary]]></category><category><![CDATA[development]]></category><category><![CDATA[pentest]]></category><category><![CDATA[reversing]]></category><category><![CDATA[security]]></category><category><![CDATA[stacktitan]]></category><category><![CDATA[hardware]]></category><category><![CDATA[firmware]]></category><category><![CDATA[hacking]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Fri, 12 May 2023 18:57:47 GMT</pubDate><content:encoded><![CDATA[<h2 id="preface">Preface</h2><p>This post is going to cover one of many processes to lift firmware from an Integrated Circuit (IC) chip. There are many methods that can be used such as interfacing with General Purpose Input/Output (GPIO) interfaces (e.g., UART, JTAG, etc.). However, when confronted with the opportunity to extract firmware directly from an IC, the process can be rather uncomplicated as we will demonstrate. Don&apos;t worry, we will be demonstrating other techniques necessary to extract firmware in upcoming posts. </p><h2 id="test-environment">Test Environment</h2><p>Our sacrificial board is from a D-Link (i.e., D-Link DIR-817LW) donor device, which can be considered a residential class 802.11x wireless router. </p><p>We will use a <a href="https://www.digikey.com/en/products/detail/pomona-electronics/5250/745102">Pomona Electronics 5250 SOIC test clip</a> to provide direct access to the IC chip. Quality test clips, such as the Pomona brand, can be rather expensive compared to cheaper alternatives, but their dependability justifies the cost when others fail to align to tight IC tolerances. </p><p>Lastly, we will use the infamous <a href="http://dangerousprototypes.com/docs/Bus_Pirate">Bus Pirate</a> as the FTDI interface necessary to communicate with the IC chip&apos;s protocol, which is typically either I2C or SPI. </p><p>The following photo depicts our lab setup, but we can&apos;t make any of the connections until confirming IC chip manufacturer, protocol, pinouts, etc. So let&apos;s discuss next... </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/soic.png" class="kg-image" alt loading="lazy" width="800" height="600" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/soic.png 600w, https://rift.stacktitan.com/content/images/2023/02/soic.png 800w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="inspecting-the-ic-chip">Inspecting the IC Chip</h2><p>Circuit boards are usually architected with their components situated around quadrants. For example, ethernet components and chips may reside or may rather be compartmentalized in one section of the board, wireless radios and their components in another, and so on. This board follows that same design pattern, whereas the center of the board has what appears to be a multiprocessor package, a Dimm package and an IC. The IC is of interest as it supports non-volatile memory storage, which is perfect for a firmware location. </p><p>Inspecting the IC chip, we can see that it is a WinBond W25Q128FV. The reason for obtaining this information should be obvious, but if not, this will allow for further technical referencing via the manufacturer&apos;s data-sheet. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/IC.png" class="kg-image" alt loading="lazy" width="800" height="600" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/IC.png 600w, https://rift.stacktitan.com/content/images/2023/02/IC.png 800w" sizes="(min-width: 720px) 720px"></figure><p>Considering the WinBond chip is commodity hardware used in many boards, Digi-key or similar has publicly available data-sheets, which can be located <a href="https://www.winbond.com/resource-files/w25q128fv%20rev.m%2005132016%20kms.pdf">here</a>. Reading the first few pages of the data-sheet provides information that our IC chip is of type Serial Peripheral Interface (SPI) with an operating tolerance between 2.7V and 3.6V. This is enough information to move to the next phase, which consists of wiring the test equipment.</p><h2 id="wiring-the-components">Wiring the Components</h2><p>Again, referencing the WinBond data-sheet, we can find the pinout for the IC SPI chip. The naming conventions within the data-sheet and the pinout provided on the Bus Pirate are somewhat different, so we have created the following table to make the mapping easier. </p><!--kg-card-begin: html--><!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid white;
  border-collapse: collapse;
  color: black;
  font-weight:bold;
}
th, td {
  background-color: #96D4D4;  
}
</style>
</head>
<body>

<table>
  <tr>
    <th>Data-Sheet Pin</th>
    <th>Bus-Pirate Pin</th>
    <th>Purpose</th>
  </tr>
  <tr>
    <td>CS</td>
    <td>CS</td>
    <td>Chip Select</td>
  </tr>
  <tr>
    <td>DO</td>
    <td>MISO</td>
    <td>Master In Slave Out</td>
  </tr>
  <tr>
    <td>GND</td>
    <td>GND</td>
    <td>Ground</td>
  </tr>
  <tr>
    <td>VCC</td>
    <td>+3V3</td>
    <td>Supply Voltage</td>
  </tr>
  <tr>
    <td>CLK</td>
    <td>CLOCK</td>
    <td>Signal Clock</td>
  </tr>
  <tr>
    <td>DI</td>
    <td>MOSI</td>
    <td>Master Out Slave In</td>
  </tr>
</table>
</body><!--kg-card-end: html--><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/2023-02-12_12-25-31.png" class="kg-image" alt loading="lazy" width="800" height="347" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/2023-02-12_12-25-31.png 600w, https://rift.stacktitan.com/content/images/2023/02/2023-02-12_12-25-31.png 800w" sizes="(min-width: 720px) 720px"></figure><p>Note the circle on the upper left will indicate the top of the chip. This will also coincide with the indented or raised circle found on the actual physical chip, as to provide a common reference point when wiring for the pinout.</p><p><strong>A word of caution when wiring the Bus Pirate. Although DangerousPrototypes created the original Bus Pirate, various versions have been released since then. For example, Seeed Studio and Sparkfun each have their own version, and each have different colored wiring schemes, so take note of your version and wire accordingly.</strong></p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/bus_pinout.png" class="kg-image" alt loading="lazy" width="800" height="724" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/bus_pinout.png 600w, https://rift.stacktitan.com/content/images/2023/02/bus_pinout.png 800w" sizes="(min-width: 720px) 720px"></figure><p>Once wired, the Pomona SOIC test clip should look similar to that depicted within the image below. Again from a top-down view of the test clip, the upper-left should have CS and the lower-right should end with MOSI. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/top-down.png" class="kg-image" alt loading="lazy" width="800" height="573" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/top-down.png 600w, https://rift.stacktitan.com/content/images/2023/02/top-down.png 800w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="finishing-up">Finishing Up</h2><p>This section is provided to dispel one common question that I believe confuses most when getting into hardware, and that is <strong>to power on the board or not to power on the board</strong>. </p><p>Keep in mind that we are dealing with, and directly accessing, a single IC chip, which we can supply VCC (our own voltage supply). Further, the Bus Pirate can supply 3v3 power, which is well within the operating tolerances of the IC chip. Therefore, there is no need for us to power on the entire board when we can simply supply our own to the single component of interest. Further, providing power to only the IC chip, and not the board as a whole, prevents possible conflicts when reading from the chip as it will refrain from communicating I/O with surrounding peripherals/packages. Providing isolated power to the IC chip is the preferred method here.</p><p>However, a reason for powering the entire board may be when dealing with voltages outside of our Bus Pirate&apos;s tolerances, or using another method of lifting firmware, such as tying an MPU RESET pin to GROUND in order to introduce an I/O idle or hold state. Again, we will cover this in another post, but this is hacking so it is always good to have options. </p><p>With that, make the connection by securing the Pomona SOIC test clip so that the CS pin matches that of the IC chip (recall the circle indent). It should look similar to the following. </p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/test_clip.png" class="kg-image" alt loading="lazy" width="800" height="784" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/test_clip.png 600w, https://rift.stacktitan.com/content/images/2023/02/test_clip.png 800w" sizes="(min-width: 720px) 720px"></figure><p></p><h2 id="lifting-the-firmware">Lifting the Firmware</h2><p>If you stuck with us this far, we have finally arrived! It is time to extract the firmware from this IC chip. To get started we need to make sure that we have a system running the <a href="https://github.com/flashrom/flashrom">flashrom</a> program. Flashrom supports a myriad of test devices, protocols and chip manufacturers, thus reducing the heavy lifting associated with flash memory manipulation.</p><p>In the following we are telling flashrom to use the Bus Pirate and SPI protocol (i.e., buspirate_spi) and passing it the device location (e.g., /dev/ttyUSB0). The <strong>dmesg</strong> command can be helpful in locating the device when operating from a Linux system. If successful, the WinBond chip should have been found. </p><!--kg-card-begin: markdown--><pre><code>stack_lab$ sudo flashrom -p buspirate_spi:dev=/dev/ttyUSB0
flashrom v1.2 on Linux 5.4.0-136-generic (x86_64)
flashrom is free software, get the source code at https://flashrom.org

Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
Bus Pirate firmware 6.1 and older does not support SPI speeds above 2 MHz. Limiting speed to 2 MHz.
It is recommended to upgrade to firmware 6.2 or newer.
Found Winbond flash chip &quot;W25Q128.V&quot; (16384 kB, SPI) on buspirate_spi.
No operations were specified.</code></pre>
<!--kg-card-end: markdown--><p>The next step is similar to prior, however, this time we want to define the speed in which the memory I/O reads are performed. The speed ranges from 30k to 8M, and there is a tradeoff. The lower the read rate, the more accurate the results but at a cost of an extremely lengthy duration. Contrarily, the faster the read the less accurate the results. Providing a speed of 1M is typically a good compromise for both speed and accuracy, albeit still time to make a pot of coffee...slam it..and make another! The <strong>-c</strong> option simply declares the type of chip and the <strong>-r</strong> is the name of the file to be created that will contain the firmware.</p><!--kg-card-begin: markdown--><pre><code>stack_lab$ sudo flashrom -p buspirate_spi:dev=/dev/ttyUSB0,spispeed=1M -c W25Q128.V -r W25Q128.V.bin
flashrom v1.2 on Linux 5.4.0-136-generic (x86_64)
flashrom is free software, get the source code at https://flashrom.org

Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
Found Winbond flash chip &quot;W25Q128.V&quot; (16384 kB, SPI) on buspirate_spi.
Reading flash... done.
</code></pre>
<!--kg-card-end: markdown--><p>Running this after some time should have produced our firmware file, so we might assume success. Trust but verify.</p><!--kg-card-begin: markdown--><pre><code>stack_lab$ ls -alh W25Q128.V.bin 
-rw-r--r-- 1 root root 16M Jan 28 15:08 W25Q128.V.bin</code></pre>
<!--kg-card-end: markdown--><p>Just to confirm, we can use the glorious <a href="https://github.com/ReFirmLabs/binwalk">binwalk</a> utility to help parse the firmware file for known data types. The <strong>-M</strong> options simply tells binwalk to recurse during analysis. As we can see, the file is in fact a firmware that also contains a squashfs file-system. With that, you are left to your own devices to hack on!</p><!--kg-card-begin: markdown--><pre><code>stack_lab$ binwalk -M ext_firmware.bin 

Scan Time:     2023-02-12 14:03:26
Target File:   W25Q128.V.bin
MD5 Checksum:  b35279b4d39d377f47187ac847f43567
Signatures:    411

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
7104          0x1BC0          LZMA compressed data, properties: 0x5D, dictionary size: 8388608 bytes, uncompressed size: 75376 bytes
196660        0x30034         bzip2 compressed data, block size = 900k
524288        0x80000         TRX firmware header, little endian, image size: 5722112 bytes, CRC32: 0x365EA7FA, flags: 0x0, version: 1, header size: 28 bytes, loader offset: 0x1C, linux kernel offset: 0x1A2D80, rootfs offset: 0x0
524316        0x8001C         LZMA compressed data, properties: 0x5D, dictionary size: 65536 bytes, uncompressed size: 4225056 bytes
917504        0xE0000         SEAMA firmware header, big endian, meta size: 36, image size: 7622688
917536        0xE0020         Unix path: /dev/mtdblock/6
917568        0xE0040         LZMA compressed data, properties: 0x5D, dictionary size: 33554432 bytes, uncompressed size: 4970636 bytes
2490432       0x260040        PackImg section delimiter tag, little endian size: 5266432 bytes; big endian size: 6049792 bytes
2490464       0x260060        Squashfs filesystem, little endian, version 4.0, compression:lzma, size: 6049169 bytes, 2246 inodes, blocksize: 131072 bytes, created: 2014-03-06 09:37:02</code></pre>
<!--kg-card-end: markdown--><h2 id="conclusion">Conclusion</h2><p>We have demonstrated the tools required to lift firmware using a Pomona SOIC test clip, the Bus Pirate, and a few open-source tools. This was in contrast to accessing firmware using common techniques, such as interfacing with UART or JTAG. It is important to understand many methods and techniques when performing hardware hacking, as these technologies and board configurations can always be a challenge. We hope that this post may assist aspiring hardware hackers out there, and provide a common reference for others. Stay tuned, the STACKTITAN team will be posting on more hardware topics very soon. </p></html>]]></content:encoded></item><item><title><![CDATA[SMBExec: Red Side Analysis (Part 2)]]></title><description><![CDATA[STACKTITAN's Alex Mason is back with part II in this tradecraft series. This time around he demonstrates modifying SMBExec to bypass various detections.  ]]></description><link>https://rift.stacktitan.com/smbexec_part2/</link><guid isPermaLink="false">642a1cc80f38281a29a661d3</guid><category><![CDATA[adversary]]></category><category><![CDATA[pentest]]></category><category><![CDATA[redteam]]></category><category><![CDATA[rift]]></category><category><![CDATA[stacktitan]]></category><category><![CDATA[security]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Fri, 28 Apr 2023 23:45:06 GMT</pubDate><content:encoded><![CDATA[<p></p><h2 id="picking-back-up">Picking Back Up</h2><p>In the previous post of this series, we looked at smbexec.py from the Impacket library and how it works under the hood. This was done by using Procmon to observe what happens on a system when smbexec.py connects to it and executes commands. We also made some observations about ways a defender could build detections based on the nature of smbexec.py. </p><p>We had to disable Microsoft Defender to perform this exercise, as it was detecting and blocking our activities. Today we are turning Defender back on, validating some of those guesses on how Defender detects smbexec.py, and then bypassing those detections. Afterwards, we are going to repeat the process to accomplish the same results on a popular EDR product.</p><h3 id="reviewing-what-we-know">Reviewing What We Know</h3><p>The first logical place to start is by changing some of the static details about smbexec.py, such as the Service Name, filenames, and paths. You can find most of the static elements of the script on the lines below.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/1.png" class="kg-image" alt loading="lazy" width="936" height="730" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/1.png 600w, https://rift.stacktitan.com/content/images/2023/04/1.png 936w" sizes="(min-width: 720px) 720px"></figure><p>These are the default values in the latest version of Impacket&#x2019;s smbexec.py (as of today in February 2023). You will notice some of the values we saw during the last blog post -- &#x201C;BTOBTO&#x201D; was the service name created via a registry write, and &#x201C;execute.bat&#x201D; and &#x201C;__output&#x201D; are the temporary files for executing commands and writing their output. The &#x201C;SMBSERVER_DIR&#x201D; and &#x201C;DUMMY_SHARE&#x201D; are only leveraged during the &#x201C;server mode&#x201D; of smbexec.py, which we are not covering in this series.</p><h3 id="kicking-the-defender-tires">Kicking the Defender Tires</h3><p>Starting with changing the &#x201C;SERVICE_NAME&#x201D;, we re-ran smbexec.py and were met with the same Defender detection and alert.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/2.png" class="kg-image" alt loading="lazy" width="866" height="508" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/2.png 600w, https://rift.stacktitan.com/content/images/2023/04/2.png 866w" sizes="(min-width: 720px) 720px"></figure><p>Meanwhile, this was how things looked from the attacking box&#x2026; not a very revealing error.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/3.png" class="kg-image" alt loading="lazy" width="940" height="292" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/3.png 600w, https://rift.stacktitan.com/content/images/2023/04/3.png 940w" sizes="(min-width: 720px) 720px"></figure><p>Making changes to the &#x201C;BATCH_FILENAME&#x201D; and &#x201C;OUTPUT_FILENAME&#x201D; variables also didn&#x2019;t have any effect on Defender&#x2019;s detection and alerting. However, there are some additional static elements throughout the script, as seen below:</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/4.png" class="kg-image" alt loading="lazy" width="936" height="508" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/4.png 600w, https://rift.stacktitan.com/content/images/2023/04/4.png 936w" sizes="(min-width: 720px) 720px"></figure><p>Here we can see the full file paths being built for the output and batch files. We changed the batch file path to another which is often world-writeable, \Users\Public\Downloads, and reran smbexec.py:</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/5.png" class="kg-image" alt loading="lazy" width="936" height="256" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/5.png 600w, https://rift.stacktitan.com/content/images/2023/04/5.png 936w" sizes="(min-width: 720px) 720px"></figure><p>OK &#x2014; that worked! We already bypassed detection and alerting from Defender, by only changing four static values. There were still multiple other potential detection vectors that we hadn&#x2019;t touched yet, so this was surprising.</p><p>At this point, we went back and grabbed a fresh copy of smbexec.py and changed only the batch file path, to see if that was the only necessary change.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/6.png" class="kg-image" alt loading="lazy" width="936" height="246" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/6.png 600w, https://rift.stacktitan.com/content/images/2023/04/6.png 936w" sizes="(min-width: 720px) 720px"></figure><p>As we can see, it was! By changing only the path to the batch file, we had completely bypassed Defender. We should mention this is Defender in its default state with only Cloud Submission disabled. Defender was up to date on definitions and associated Windows Updates. With this in mind, let&#x2019;s pivot over to testing against a certain commercial EDR product. Surely the same approach won&#x2019;t work there&#x2026; :)</p><h3 id="kicking-the-edr-tiresa-bit-harder">Kicking the EDR Tires...A Bit Harder</h3><p>The EDR product was installed on a separate workstation, with Defender in a disabled state. This was to avoid any conflicts or overlaps in detection. The EDR product was fully enabled and in &#x201C;block&#x201D; mode, and it was up to date on the latest definitions.</p><p>The first thing we tested here was the same smbexec.py with only the batch file path changed. However, this was detected and blocked...bummer.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/7.png" class="kg-image" alt loading="lazy" width="828" height="412" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/7.png 600w, https://rift.stacktitan.com/content/images/2023/04/7.png 828w" sizes="(min-width: 720px) 720px"></figure><p>We then tinkered with the same attributes that were changed during the Defender testing (despite it not being necessary for bypassing Defender), such as paths and filenames, but to no avail&#x2014; still caught.</p><p>In thinking about when the script gets caught, we noticed that it happens immediately, before even typing a first command. This means we need to look at what is happening during initialization, before the first command execution.</p><p>In examining the &#x201C;RemoteShell&#x201D; class, we see numerous tasks happening within &#x201C;<strong>init</strong>&#x201D;. Most of it seems pretty self-explanatory, and again we can ignore anything related to SERVER mode. Towards the bottom before other functions are defined (line 209 for us) we see this self.do_cd(&#x2018;&#x2019;) take place.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/8.png" class="kg-image" alt loading="lazy" width="936" height="358" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/8.png 600w, https://rift.stacktitan.com/content/images/2023/04/8.png 936w" sizes="(min-width: 720px) 720px"></figure><p>What does this do? Let&#x2019;s find out.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/9.png" class="kg-image" alt loading="lazy" width="936" height="350" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/9.png 600w, https://rift.stacktitan.com/content/images/2023/04/9.png 936w" sizes="(min-width: 720px) 720px"></figure><p>Ahh, right. If you&#x2019;ve run smbexec.py before and tried to CD to a directory, you&#x2019;ve seen this error&#x2014; <strong>&#x201C;You can&#x2019;t CD under SMBEXEC&#x201D;</strong>. This is because, as we know from our previous blog posts, smbexec.py isn&#x2019;t a real interactive shell. Every command that we run results in a new execution of our Windows Service and command shell, with a new batch file, and a new output file. In the bottom half of the above screenshot, we see this &#x201C;execute_remote(&#x2018;cd &#x2018;), where the output is gathered, newline characters stripped, and a &#x201C;&gt;&#x201D; added to the end. This is our fake command &#x201C;prompt&#x201D; that is written out, imitating Windows Command Prompt&#x2019;s prompt:</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/10.png" class="kg-image" alt loading="lazy" width="864" height="340" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/10.png 600w, https://rift.stacktitan.com/content/images/2023/04/10.png 864w" sizes="(min-width: 720px) 720px"></figure><p>That thing. And it seems smbexec.py generates this prompt text before every single command that we run. You may have already gathered that from the previous blog post. This is the &#x201C;echo cd&#x201D; that we observed being executed (and detected) on an endpoint. Here it is again:</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/11.png" class="kg-image" alt loading="lazy" width="940" height="836" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/11.png 600w, https://rift.stacktitan.com/content/images/2023/04/11.png 940w" sizes="(min-width: 720px) 720px"></figure><p>If this static one-liner is executed every time we run smbexec.py, regardless of what commands we run&#x2026; that&#x2019;s a pretty good IOC, wouldn&#x2019;t you say?</p><p>Let&#x2019;s get rid of it. We don&#x2019;t care about our current working path anyway, because we can&#x2019;t change &#xA0;directory.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/12-2.png" class="kg-image" alt loading="lazy" width="910" height="212" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/12-2.png 600w, https://rift.stacktitan.com/content/images/2023/04/12-2.png 910w" sizes="(min-width: 720px) 720px"></figure><p>Let&apos;s rerun our custom.py with this change, and see what happens...</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/13.png" class="kg-image" alt loading="lazy" width="936" height="218" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/13.png 600w, https://rift.stacktitan.com/content/images/2023/04/13.png 936w" sizes="(min-width: 720px) 720px"></figure><p>This is progress! We now get to command execution before things are blocked. After the previous change, we now know EDR is looking at our full command line. We&#x2019;ve changed almost everything except our command shell. Let&#x2019;s change it.</p><p>One of our favorite methods of doing&#x2026;well anything, is Living-Off-the-Land. What better way to fly under the radar than to abuse the tools that are already installed on a target?</p><p>Head over to the LOLBAS project (<a href="https://lolbas-project.github.io/">https://lolbas-project.github.io/</a>) and pick out a binary that allows for execution. Then just pop it into your smbexec.py shell, and try again! NOTE: Pay attention to the command line usage. Each of these binaries is different, with different command line usage. Might need to tweak things to get it to work for your use case.</p><p>We chose <strong>conhost.exe </strong>at random, and plugged it into my smbexec.py. To our delight, <strong>some</strong> things ran successfully! We are getting ever so close.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/14.png" class="kg-image" alt loading="lazy" width="936" height="304" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/14.png 600w, https://rift.stacktitan.com/content/images/2023/04/14.png 936w" sizes="(min-width: 720px) 720px"></figure><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/15.png" class="kg-image" alt loading="lazy" width="936" height="280" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/15.png 600w, https://rift.stacktitan.com/content/images/2023/04/15.png 936w" sizes="(min-width: 720px) 720px"></figure><p>You will see above, however, that while running an &#x201C;echo&#x201D; worked, running &#x201C;whoami&#x201D; did not. We&#x2019;ve still got a little work to do to get all commands working. Let&#x2019;s try throwing PowerShell into our command execution chain (line 278 for us):</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/16.png" class="kg-image" alt loading="lazy" width="936" height="376" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/16.png 600w, https://rift.stacktitan.com/content/images/2023/04/16.png 936w" sizes="(min-width: 720px) 720px"></figure><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/04/17.png" class="kg-image" alt loading="lazy" width="936" height="354" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/04/17.png 600w, https://rift.stacktitan.com/content/images/2023/04/17.png 936w" sizes="(min-width: 720px) 720px"></figure><p>The eagle has landed! So by changing our full execution chain for running &#x201C;whoami&#x201D; from &#x201C;cmd.exe -&gt; whoami&#x201D; to &#x201C;conhost.exe -&gt; cmd.exe -&gt; powershell.exe -&gt; whoami&#x201D; we have fully bypassed detection by a certain EDR product!</p><h2 id="conclusion">Conclusion</h2><p>Yes, this was a very &#x201C;dirty&#x201D; and unscientific approach to EDR bypassing. Yes, the resulting code is pretty convoluted&#x2026; it could use some extra comments after what we&#x2019;ve done. But&#x2014; it works. And not just the specific LOLBAS binary that we chose at random. Even if everyone who reads this blogpost uses conhost.exe and gets it &#x201C;burned&#x201D; / added to EDR static signatures&#x2014; it&#x2019;s still just a single LOLBAS. Switch to another, and carry on hacking! We can even completely change up our command line. We still have &#x201C;cmd.exe /Q /c&#x201D; in our execution chain, which really isn&#x2019;t necessary. Maybe conhost -&gt; powershell is all we need to bypass. Maybe we even do some additional obfuscation, such as encoding things, etc. We have lots of options at this point.</p><p>This wraps up our series on SMBExec.py from Impacket. Thanks for reading along, and hopefully this has helped you dive deeper into how the tool works, how different endpoint security products detect it, and how we can bypass those detections.</p>]]></content:encoded></item><item><title><![CDATA[SMBExec: Red Side Analysis (Part 1)]]></title><description><![CDATA[Ride along as Alex Mason from STACKTITAN shares tradecraft of analyzing offensive toolchains to identify detection opportunities in part one of this blog series.]]></description><link>https://rift.stacktitan.com/smbexec/</link><guid isPermaLink="false">63f6743f0f38281a29a65ce2</guid><category><![CDATA[adversary]]></category><category><![CDATA[pentest]]></category><category><![CDATA[redteam]]></category><category><![CDATA[rift]]></category><category><![CDATA[stacktitan]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Fri, 14 Apr 2023 20:32:16 GMT</pubDate><content:encoded><![CDATA[<p></p><h2 id="overview">Overview</h2><p>SMBExec.py is a powerful tool in a pentester&#x2019;s arsenal. It has been analyzed and blogged about countless times. However, in my experience these posts are mostly from the standpoint of the defender&#x2014; what Event Logs are generated, what static IOCs exist, etc. This post will take a different approach, examining SMBExec.py from the standpoint of an attacker looking to gain a deeper understanding of their tooling. This will then enable us in future posts to look at ways that defenders detect this tool, and later to modify the tool to evade those detections.</p><h2 id="how-does-it-work">How Does it Work?</h2><p>There are a few different ways to go about examining this particular tool. While it is open source, and therefore we could just read through the code, we wanted to demonstrate analyzing the tool from a blackbox standpoint. Additionally, it is often beneficial to visually inspect and trace the actions taken by the binary during runtime. As such, we primarily leveraged Process Monitor (&#x201C;procmon&#x201D;) for this purpose, running it on the target Windows 10 device, while firing off smbexec.py against it from a Linux VM. Procmon recorded the actions taken, allowing us to further sort and filter to view the results we were interested in. Let&#x2019;s take a look.</p><p>First off, Windows Defender had to be disabled on the target host. It&#x2019;s a bit of a spoiler, but in the screenshot below you can see what payload it is concerned with.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/1.png" class="kg-image" alt loading="lazy" width="940" height="580" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/1.png 600w, https://rift.stacktitan.com/content/images/2023/02/1.png 940w" sizes="(min-width: 720px) 720px"></figure><p>And over on the Linux VM side, the following error was received when the tool was blocked by Defender. The error isn&#x2019;t very intuitive, so we figured this was worth sharing.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/2.png" class="kg-image" alt loading="lazy" width="940" height="164" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/2.png 600w, https://rift.stacktitan.com/content/images/2023/02/2.png 940w" sizes="(min-width: 720px) 720px"></figure><p>After disabling Defender and re-running smbexec.py, we were able to record the associated actions with Procmon. You can see the list of actions pertaining to starting the connection and authenticating below.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/3.png" class="kg-image" alt loading="lazy" width="940" height="862" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/3.png 600w, https://rift.stacktitan.com/content/images/2023/02/3.png 940w" sizes="(min-width: 720px) 720px"></figure><p>A TCP connection is initiated from the Linux VM to the &#x201C;microsoft-ds&#x201D; service (which is SMB on TCP port 445), followed by some TCP sends and receives. The authentication process begins, with some LSA-related registry keys being queried and local account look-up being performed. As this is a domain account, local account look-up fails, and the host queries the Domain Controller instead. After successfully authenticating, more traffic takes place with the Linux VM over SMB, and finally we get into the functionality unique to smbexec.py.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/4.png" class="kg-image" alt loading="lazy" width="940" height="444" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/4.png 600w, https://rift.stacktitan.com/content/images/2023/02/4.png 940w" sizes="(min-width: 720px) 720px"></figure><p>A new Windows Service is created with the name &#x201C;BTOBTO&#x201D;, and we can see some registry key values being set. One notable key value &#x201C;ImagePath&#x201D;, holds a command line one-liner.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/5.png" class="kg-image" alt loading="lazy" width="940" height="280" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/5.png 600w, https://rift.stacktitan.com/content/images/2023/02/5.png 940w" sizes="(min-width: 720px) 720px"></figure><p>The &#x201C;%COMSPEC%&#x201D; variable is the full system path to cmd.exe. We can see that this command will create an &#x201C;execute.bat&#x201D; in %TEMP% which will run &#x201C;cd&#x201D; and write its output to the local default C$ SMB share, execute it, and then delete it. This is how smbexec.py creates the text in the prompt that is displayed when it is awaiting commands (ex: &#x201C;C:\Windows\System32&gt;&#x201D;). Walking through the list of actions, we can see that all of this takes place. Cmd.exe is run, creating execute.bat.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/6.png" class="kg-image" alt loading="lazy" width="940" height="274" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/6.png 600w, https://rift.stacktitan.com/content/images/2023/02/6.png 940w" sizes="(min-width: 720px) 720px"></figure><p>Execute.bat is run, it runs &#x201C;cd&#x201D;, and writes its output to the &#x201C;__output&#x201D; file on the local C$ share.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/7.png" class="kg-image" alt loading="lazy" width="940" height="276" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/7.png 600w, https://rift.stacktitan.com/content/images/2023/02/7.png 940w" sizes="(min-width: 720px) 720px"></figure><p>A number of TCP sends and receives occur across the SMB connection, presumably sending the results from the &#x201C;__output&#x201D; file, and then execute.bat is deleted. This file delete activity was hard to find within Procmon, as it was not listed as a FileDelete operation or anything else aptly named. Instead, under a CreateFile operation you can see a &#x201C;Delete on Close&#x201D; option being set, followed by a CloseFile operation. This seems to be the deletion of execute.bat that is referenced in the command one-liner. If you need to search for this in Procmon, you can leverage the &#x201C;CTRL+F&#x201D; search feature to search for &#x201C;Delete on&#x201D;.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/8.png" class="kg-image" alt loading="lazy" width="940" height="162" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/8.png 600w, https://rift.stacktitan.com/content/images/2023/02/8.png 940w" sizes="(min-width: 720px) 720px"></figure><p>Finally, the BTOBTO Service is deleted.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/9.png" class="kg-image" alt loading="lazy" width="940" height="252" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/9.png 600w, https://rift.stacktitan.com/content/images/2023/02/9.png 940w" sizes="(min-width: 720px) 720px"></figure><p>This entire process chain happens as a result of the &#x201C;cd&#x201D; command that is run to generate the text prompt within the smbexec.py window. Luckily, the process of executing a command is nearly identical, where the command-to-be-run is echo&#x2019;d into execute.bat rather than the &#x201C;cd&#x201D; command. Below is an example of the &#x201C;whoami&#x201D; command being run via smbexec.py.</p><figure class="kg-card kg-image-card"><img src="https://rift.stacktitan.com/content/images/2023/02/10.png" class="kg-image" alt loading="lazy" width="940" height="182" srcset="https://rift.stacktitan.com/content/images/size/w600/2023/02/10.png 600w, https://rift.stacktitan.com/content/images/2023/02/10.png 940w" sizes="(min-width: 720px) 720px"></figure><p>As you can see, the &#x201C;BTOBTO&#x201D; Service name is reused, as well as the &#x201C;execute.bat&#x201D; file name. Furthermore, the &#x201C;echo cd&#x201D; command occurs in between every command run by a user via smbexec.py.</p><h2 id="execution-flow">Execution Flow</h2><p>After all of the above, the following general execution flow can be described for smbexec.py:</p><ol><li>TCP connection via SMB from attacker to target</li><li>Authentication (Local first, falling back to domain auth if local fails)</li><li>Execution of the &#x201C;cd&#x201D; command<br>a.&#x2003;Creation of BTOBTO service<br>b.&#x2003;Execution of BTOBTO service<br>&#x2003;i.&#x2003;Echoing command to %TEMP%\execute.bat<br>&#x2003;ii.&#x2003;Executing execute.bat<br>&#x2003;iii.&#x2003;Deleting execute.bat<br>c.&#x2003;Deletion of BTOBTO service</li><li>Execution of command entered by user<br>a.&#x2003;Same process as 3.a &#x2013; 3.c</li><li>Execution of the &#x201C;cd&#x201D; command<br>a.&#x2003;Identical to step 3</li><li>Execution of next command entered by user</li></ol><p>The pattern then continues for as long as a user continues to enter commands for smbexec.py. These steps now make a lot of sense, for anyone that has ever experienced smbexec.py terminating prematurely, and then being unable to run smbexec.py again&#x2014; the process chain must have terminated before execute.bat or BTOBTO was able to be deleted. As the code reuses these names over and over, conflicts with those filenames are very possible.</p><h2 id="detection">Detection</h2><p>This should also give us plenty to think about from a Detection standpoint. Let&#x2019;s look at some basic, static Indicators of Compromise (IOC) that we can list out from what we have observed.</p><p>&#x2022;&#x2003;The Service name created on a target endpoint is always &#x201C;BTOBTO&#x201D;<br>&#x2022;&#x2003;The path &#x201C;%TEMP%\execute.bat&#x201D; is always created on the target endpoint&#x2019;s filesystem<br>&#x2003;&#x2022;&#x2003;The actual unwrapped path may change, where the path pointed to by %TEMP% differs. In our case, it was C:\Windows\Temp<br>&#x2022;&#x2003;In between running user-provided commands via smbexec.py in its default mode of operation, the tool always executes a command beginning with the following:<br>&#x2003;&#x2022;&#x2003;%COMSPEC% /Q /c echo cd^&gt; \127.0.0.1\C$__output 2<sup>&gt;</sup>&amp;1 [snip]<br>&#x2003;&#x2003;&#x2003;&#x2022;&#x2003;Again, %COMSPEC% will unroll to the full path to cmd.exe. For the vast majority of all systems, this will point to C:\Windows\System32\cmd.exe<br>&#x2022;&#x2003;The C:__output file for retrieving command output always has this same name, and is at the same location (when smbexec.py is run with default options)</p><h2 id="conclusion">Conclusion</h2><p>That&#x2019;s a good place to start for understanding how smbexec.py works behind the scenes, and creating some basic detection via static IOCs. In the next post in this series we will go over bypassing endpoint security controls&#x2019; detection and blocking of smbexec.py. </p>]]></content:encoded></item><item><title><![CDATA[Security on a Budget]]></title><description><![CDATA[<!--kg-card-begin: markdown--><p>Following the completion of all our penetration tests and assessments we take time to review the findings and the deliverable with our customers. During this review, we almost always get asked the following:</p>
<blockquote>
<p>Of all the vulnerabilities you identified, which ones would you mitigate first? We&apos;re a small</p></blockquote>]]></description><link>https://rift.stacktitan.com/security-on-a-budget/</link><guid isPermaLink="false">63320e2549814f19910bd754</guid><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Fri, 02 Sep 2022 12:04:01 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><p>Following the completion of all our penetration tests and assessments we take time to review the findings and the deliverable with our customers. During this review, we almost always get asked the following:</p>
<blockquote>
<p>Of all the vulnerabilities you identified, which ones would you mitigate first? We&apos;re a small team and need to know where our time is best spent.</p>
</blockquote>
<p>This is the reality of security... While all organizations want to achieve &quot;perfect&quot; security, the truth is that (for most companies) limiting factors such as budget, human resources, and business needs decrease the likelihood of ever achieving that goal.</p>
<p>So, we did an exercise. We held a working session with all the STACKTITAN security consultants to determine three recommendations we&apos;d make to all customers. These recommendations, subjectively identified from our experience performing thousands of assessments over a 15 year timespan, meet the following requirements:</p>
<ul>
<li>Requires no additional (or very minimal) spend on product</li>
<li>Can be implemented by <em>most</em> organizations using current, internal staff</li>
<li>Requires minimal time and effort to perform</li>
<li>Achieves a remarkable improvement on security posture</li>
<li>Addresses an issue or bad practice that is <strong>very</strong> common</li>
</ul>
<p>So, with those requirements in mind, here&apos;s what we came up with over a pot of coffee and some heated brainstorming. By the way, we aren&apos;t discounting the importance of a comprehensive security program. We believe the most effective operating environment is one that relies on defense-in-depth. We simply tried to identify a few impactful actions that aren&apos;t extraordinarily expensive.</p>
<hr>
<h1 id="1perimeterattacksurfacereduction">1. Perimeter Attack Surface Reduction</h1>
<p><strong>TLDR</strong>: Reducing the attack surface with stringent access controls is a cost-effective method of protecting against external, Internet-based threat actors.</p>
<p><strong>The What</strong>:<br>
Reduce the publicly accessible services, systems, and applications. That is, update access controls (e.g., firewall, web server) to limit the available attack surface to only the minimal resources necessary for the business.</p>
<p><strong>The Why</strong>:<br>
Look, we can pick a handful of vulnerabilities we commonly identify on our customer&apos;s Internet-facing systems. Oftentimes, these issues are identified in superfluous services or application functionality. Further, some of these services are attractive targets for attackers (e.g., web management portals, Windows services such as RDP and SMB, etc.). While we will always advocate for patching and hardening your systems and software, it can be a difficult and costly practice that requires continual management, updated inventory, etc. Restricting access to or decommissioning these services can be a cheaper alternative that reduces the likelihood of a breach. It&apos;s not the perfect solution and may just kick the can down the road, but it&apos;s an effective method to controlling your risk exposure from the hostile Internet.</p>
<p><strong>The How</strong>:<br>
We recommend, amongst other practices, the following:</p>
<ul>
<li>Implement a Default-Deny firewall access control policy</li>
<li>Review firewall rulesets to identify overly promiscuous or unnecessary rules. After identifying any that are too broad, fix &apos;em.</li>
<li>Review your perimeter web applications. Use tools like nmap, aquatone, and gobuster to quickly survey the landscape. Whatchu got out there and is there a reason for it to be there? If not, 86 it!</li>
<li>Hunt for common management portals (e.g., devices, Java Web Application such as Tomcat, etc.). They&apos;re common targets. Restrict access to them. This will be dependent on the product in question but could be as simple as adding rules to an Apache <code>.htaccess</code> file.</li>
<li>Pay particular attention to auth. portals that use Active Directory as their identity provider. You&apos;ll want to be especially vigilant with these. They&apos;re high value targets that commonly lead to network breaches, business email compromise, etc. Oh, and don&apos;t just look at web forms. Find those pesky NTLM web authentication endpoints!</li>
</ul>
<hr>
<h1 id="2legacyandorunnecessarybroadcasttraffic">2. Legacy and/or Unnecessary Broadcast Traffic</h1>
<p><strong>TLDR</strong>: Internal networks are very chatty. A lot of this traffic is for legacy support, is unnecessary, and/or can be easily abused to compromise user accounts or workstations. Disabling this traffic will have significant impact on an attacker&apos;s ability to compromise the Active Directory environment (users and/or workstations) from within the network.</p>
<p><strong>The What</strong>:<br>
Protocols such as LLMNR and NBNS are used as a fallback method to resolve domain names, in the event that DNS fails. Additionally, protocols such as IPv6 and mDNS are generally unnecessary for internal, enterprise networks. These protocols are <em>widely</em> targeted during internal penetration tests due to their susceptibility to poisoning. Disabling these protocols is relatively easy and has a profound positive impact.</p>
<p><strong>The Why</strong>:<br>
In our experience, we abuse these legacy protocols on about 80% of our internal penetration tests. It&apos;s the most common method through which we gain initial domain credentials and almost always leads to domain escalation and lateral network movement. Fixing these issues will have a significant impact against insider threats and unauthorized internal threat actors.</p>
<p><strong>The How</strong>:<br>
We recommend, amongst other practices, the following:</p>
<ul>
<li>Update computer policy to <code>Turn OFF Multicast Name Resolution</code></li>
<li>Update Network Connections properties to <code>Disable NetBIOS over TCP/IP</code></li>
<li><a href="https://social.technet.microsoft.com/wiki/contents/articles/5927.how-to-disable-ipv6-through-group-policy.aspx">Disable IPv6 via GPO</a></li>
<li>Set a static proxy value for all browsers in the network</li>
<li><a href="https://techcommunity.microsoft.com/t5/networking-blog/mdns-in-the-enterprise/ba-p/3275777">Disable mDNS</a>, if possible</li>
<li>Added Bonus: Require SMB signing to prevent relaying</li>
</ul>
<hr>
<h1 id="3activedirectorypasswordblacklisting">3. Active Directory Password Blacklisting</h1>
<p><strong>TLDR</strong>: Passwords remain a highly sought after target; credential acquisition is often the first and most important stage in an attack chain. Password length and complexity alone may not be sufficient to protect accounts from compromise. Instead, blacklist common base words and patterns to prevent trivial recovery via online and offline attacks.</p>
<p><strong>The What</strong>:<br>
Most organizations enforce a password policy consisting of uppercase, lowercase, numeric, and special characters with a minimum length of 10. A forced password change cadence of 90-days is typical. Guess what? <code>Spring2022!</code> meets all those requirements. Users like patterns - they&apos;re easy to remember - so, they choose <code>Summer2022!</code> when required to change their password. Easy for them; easy for an attacker. Passwords selected using a simple baseword or a password that was publicly disclosed in a breach greatly increases the likelihood of an attacker guessing a user&apos;s password or, in the event that a hash is acquired, cracking it offline. We need better alternatives than length and complexity...</p>
<p><strong>The Why</strong>:<br>
One of the first things we try on a pentest is to guess a set of user credentials. One of the first passwords we&apos;ll try is of the format <code>SeasonYYYY!</code> or <code>MonthYYYY!</code>. We see all sorts of patterns based off company name, sports teams, cities, first names, etc. Restricting users from setting passwords based off certain basewords or words disclosed in password breaches greatly reduces the likelihood of account compromise, and it&apos;s fairly cheap!</p>
<p><strong>The How</strong>:<br>
We recommend, amongst other practices, the following:</p>
<ul>
<li>Implement it using <a href="https://docs.microsoft.com/en-us/azure/active-directory/authentication/concept-password-ban-bad">Azure AD Password Protection</a></li>
<li>Implement it with <a href="https://docs.microsoft.com/en-us/azure/active-directory/authentication/concept-password-ban-bad">bubble gum and duct tape</a></li>
</ul>
<hr>
<p>So, we genuinely had a difficult time narrowing the list to three, given there are so many &quot;what ifs&quot; and business-specific requirements. Here are a few additional on-a-budget wins we highly recommend.</p>
<h2 id="multifactorauth">Multi-Factor Auth.</h2>
<p>Ok, this might not be cheap or easy, but it needs to be included because of its importance. Protect, at the least, business email portals, VPN portals, and sensitive management portals with MFA.</p>
<h2 id="increasepasswordlength">Increase Password Length</h2>
<p>Increasing password length exponentially increases the keyspace and recovery times. Increase the length to further fortify accounts against compromise.</p>
<h2 id="printercredentials">Printer Credentials</h2>
<p>Printers are attractive targets. They commonly run with default or guessable passwords. Countless times we&apos;ve exploited this to retrieve Active Directory credentials and get a foothold on the domain. Just change the administrative password. Problem solved.</p>
<h2 id="localadmincontrols">Local Admin Controls</h2>
<p>Too often, we still encounter local administrator accounts with shared passwords across several hosts. That&apos;s bad. It turns it into a pseudo-domain-admin. Implement <a href="https://www.microsoft.com/en-us/download/details.aspx?id=46899">Microsoft&apos;s Local Account Password Solution</a> and disable remote logon for local administrators.</p>
<p>While you&apos;re at it, you should review the users with local admin rights in your organization. While it might be a fight, removing these rights and enforcing a &quot;least privilege&quot; policy will limit the opportunity of abuse should their account get compromised.</p>
<h2 id="activedirectorycertificateservicesadcs">Active Directory Certificate Services (&quot;ADCS&quot;)</h2>
<p>Microsoft&apos;s PKI is a complex beast. Recently disclosed vulnerabilities make ADCS a prime target for abuse. <a href="https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn786426(v=ws.11)">Harden</a> it. It&apos;s a common target that leads to privilege escalation, user impersonation, and persistence.</p>
<h2 id="enableconditionalaccess">Enable Conditional Access</h2>
<p>Whether you have MFA or not and whether you have strong passwords in place, enabling Conditional Access allows you to provide fine-grained controls over the user access based on a variety of factors. It can reduce the likelihood or impact of account compromise.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[LOG4J: Vulnerability Detection and Remediation]]></title><description><![CDATA[<!--kg-card-begin: markdown--><h2 id></h2>
<h2 id="gettothepoint">Get to the Point</h2>
<p>This is short and sweet because the info is out there, and we just want to direct people to the collective, without the &quot;jump to the recipe&quot; bloat. We are not going to reiterate what has already been provided numerous times elsewhere on the</p>]]></description><link>https://rift.stacktitan.com/log4j-vulnerability-detection-and-remediation/</link><guid isPermaLink="false">63320e2549814f19910bd753</guid><category><![CDATA[security]]></category><category><![CDATA[rift]]></category><category><![CDATA[stacktitan]]></category><category><![CDATA[log4j]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Fri, 17 Dec 2021 17:25:59 GMT</pubDate><content:encoded><![CDATA[<!--kg-card-begin: markdown--><h2 id></h2>
<h2 id="gettothepoint">Get to the Point</h2>
<p>This is short and sweet because the info is out there, and we just want to direct people to the collective, without the &quot;jump to the recipe&quot; bloat. We are not going to reiterate what has already been provided numerous times elsewhere on the interwebs. What we are going to state is the reinforcement that this particular vulnerability has a very large blast radius. The reach is going to be far and wide, so please perform the necessary due-diligence.</p>
<p>That is easier said than done, so we are providing a couple of references. Arguably the most prevalent resource is via the gov&apos;s CISA GITHUB repository. Leverage this resource for up-to-date guidance regarding CVE-2021-44228. They have done an excellent job with updating content as it becomes available.</p>
<p><a href="https://github.com/cisagov/log4j-affected-db" target="_blank">CVE-2021-44228</a></p>
<p>Further, there may be software in an organization where the use of Log4j is in use but unsure if it is vulnerable, or unsure if the overall software bill of materials includes the affected software. For this situation, leverage reputable Log4j detection tooling.</p>
<p>Local System Scanner</p>
<p><a href="https://github.com/fox-it/log4j-finder" target="_blank">Fox-IT Log4j Local Scanner</a></p>
<p>Remote System Scanner</p>
<p><a href="https://github.com/fullhunt/log4j-scan" target="_blank">Fullhunt Log4j Remote Scanner</a></p>
<p>YARA Rules</p>
<p><a href="https://github.com/Neo23x0/signature-base/blob/master/yara/expl_log4j_cve_2021_44228.yar" arget="_blank">Florian Roth Log4j YARA Rules</a></p>
<h2 id="conclusion">Conclusion</h2>
<p>This is going to be around for years. We are actively on numerous environments and every single one of them has Log4j. Please take the time to increase your awareness, implement the necessary remediation, and take the high road to safe-guarding persons and property.</p>
<p>Reach out if you need help detecting and protecting. At your service. Stay safe.</p>
<!--kg-card-end: markdown-->]]></content:encoded></item><item><title><![CDATA[Learn the Blue to Improve the Red (Part 2)]]></title><description><![CDATA[The only way to get better at offense is to understand the obstacles one may encounter. Learn how to navigate system log data to use it to your advantage. This second post will introduce the reader to ELK and Sysmon along with procedures to deploy these technologies within their own lab environment.]]></description><link>https://rift.stacktitan.com/learn-the-blue-to-improve-the-red-part-2/</link><guid isPermaLink="false">63320e2549814f19910bd74e</guid><category><![CDATA[security]]></category><category><![CDATA[rift]]></category><category><![CDATA[stacktitan]]></category><category><![CDATA[redteam]]></category><category><![CDATA[blueteam]]></category><category><![CDATA[sysmon]]></category><dc:creator><![CDATA[STACKTITAN Team]]></dc:creator><pubDate>Tue, 21 Jul 2020 22:15:56 GMT</pubDate><media:content url="https://rift.stacktitan.com/content/images/2020/07/arm_wrestling_2.png" medium="image"/><content:encoded><![CDATA[<!--kg-card-begin: markdown--><br>
<h2 id="preface">Preface</h2>
<img src="https://rift.stacktitan.com/content/images/2020/07/arm_wrestling_2.png" alt="Learn the Blue to Improve the Red (Part 2)"><p>In this second installment of our series, we&apos;ll run through installing and configuring the utilities necessary for building out a centralized logging system. As numerous how-to guides exist that explore the subject we&apos;ll approach a majority of things at a higher level, while exploring solutions to roadblocks we encountered along the way.</p>
<p>Note that the steps below are intended for a basic test lab environment and should not be used in large scale deployments unless they are thoroughly tested and understood. Furthermore, we haven&apos;t made any major attempts to secure the ELK infrastructure beyond what is provided as default. For more information on configuring ELK deployments securely, refer to the official Elastic documentation <a href="https://www.elastic.co/what-is/elastic-stack-security">here</a>.</p>
<h2 id="quickstepstogetupandrunning">Quick Steps To Get Up and Running</h2>
<p>We started with a fresh install of Ubuntu 20.04. The following code blocks demonstrate crucial steps and configuration details identified while following elastic.co&apos;s excellent <a href="https://www.elastic.co/guide/en/elastic-stack/current/installing-elastic-stack.html" target="_blank">installation guides</a>. We can start by adding and configuring elastic&apos;s apt repository and installing the ELK stack (as root):</p>
<pre><code class="language-D">wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
apt install apt-transport-https openjdk-14-jdk
echo &quot;deb https://artifacts.elastic.co/packages/7.x/apt stable main&quot; | tee -a /etc/apt/sources.list.d/elastic-7.x.list
apt update
apt install elasticsearch kibana logstash
</code></pre>
<p>Configure elasticsearch to listen on all network interfaces via changes to /etc/elasticsearch/elasticsearch.yml:</p>
<pre><code class="language-D"># ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0
discovery.type: single-node
</code></pre>
<p>Similarly, modify /etc/kibana/kibana.yml:</p>
<pre><code class="language-D"># Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is &apos;localhost&apos;, which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
server.host: &quot;&lt;HOST IP HERE&gt;&quot;
</code></pre>
<p>Finally, copy over the sample config to /etc/logstash/conf.d:</p>
<pre><code class="language-D">cp /etc/logstash/logstash-sample.conf /etc/logstash/conf.d/sample.conf
</code></pre>
<p>With the services configured, enable and then start them with the following systemd commands (as root):</p>
<pre><code class="language-D">systemctl enable elasticsearch
systemctl enable kibana
systemctl enable logstash
systemctl start elasticsearch
systemctl start kibana
systemctl start logstash
</code></pre>
<p>At this point you should be able to browse to http://YOUR_HOST:5601.</p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/2020-07-17_13-37-14.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<h2 id="deployingsysmon">Deploying Sysmon</h2>
<p>In an effort to simplify deploying Sysmon across a domain, we elected to modify a batch file (originally found <a href="https://www.syspanda.com/index.php/2017/02/28/deploying-sysmon-through-gpo/" target="_blank">here</a>) and create a scheduled task following the referenced post&apos;s recommendation.</p>
<p>Our lab domain (st-lab.local) consists of two domain controllers (DC01 and DC02), two Windows Server hosts (SPIDERS and GARBAGE) as well as three workstations (WK01-WK03). We created a network share on DC01, and placed the requisite files inside.</p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/2020-07-17_16-37-33-1.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<p>It is important to ensure that any script or batch file is owned by a domain admin, with only read and execute permissions allowed for all other users - since the batch file runs under the &apos;NT AUTHORITY\System&apos; context, this file could be used to execute an attacker&apos;s code if proper permissions aren&apos;t set.</p>
<p>As far as Sysmon rules go, <a href="https://github.com/SwiftOnSecurity/sysmon-config" target="_blank">SwiftOnSecurity</a> has aggregated a documented list that is quite thorough. We consider this an outstanding starting point, and is presented in a manner that allows for easy rule customization and creation.</p>
<p>The following screenshot details the modified batch file for Sysmon deployment. Stepping through the process, the script attempts to compare a local Sysmon configuration file with one residing on a fileshare. If the file doesn&apos;t exist or is different, it is copied from the fileshare. The remaining &apos;if&apos; statements either restart the service if it existed, or installs it altogether.</p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/2020-07-02_13-32-47.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<p>Script source can be found <a href="https://gist.github.com/Kyleslav/c7ed91a8699a0b5031eea79066063626" target="_blank">here</a>.</p>
<p>With the batch file accessible on the share, we then created a GPO to add a scheduled task. This task runs for twelve hours starting at 7:30am every day of the week. Without changes to the Sysmon configuration file on the fileshare, the batch file itself does nothing. Should changes be made to the Sysmon configuration, the &apos;fc&apos; component of the batch file will initiate retrieval of the updated configuration file and reconfigure Sysmon.</p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/2020-07-15_14-09-31.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/fuckyou.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/2020-07-15_14-12-06-1.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/2020-07-15_14-12-29-1.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<p>Once applied to the domain, wait a bit for hosts to update the group policy, or run <code>gpupdate /force</code> on the hosts. You can verify the addition of the scheduled task by opening the Task Scheduler as an administrative user.</p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/2020-07-17_14-12-34.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<h2 id="collectingresultswithwinlogbeat">Collecting Results With Winlogbeat</h2>
<p>At this point we have a place to aggregate and process logs, and we&apos;ve configured Sysmon to keep an eye on a few areas. The last piece of the puzzle is installing Winlogbeat so that we can push those logs back to our ELK stack. This process proved to be slightly tricky, but we have documented our challenges and solutions below.</p>
<p>We ended up expanding Winlogbeat&apos;s <a href="https://www.elastic.co/guide/en/beats/winlogbeat/current/winlogbeat-installation.html" target="_blank">install script</a>, written in PowerShell, to copy source files from our fileshare and write an updated config file.</p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/2020-07-15_12-26-12.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<p>Script source can be found <a href="https://gist.github.com/Kyleslav/e4fe2a61f9e6084e31bf0892f99937db" target="_blank">here</a>.</p>
<p>Line 1 details unzipping the Winlogbeat archive hosted on the fileshare to the local host. Subsequent lines define a working directory, remove the default Winlogbeat configuration file, and copy over an updated configuration from the fileserver. Lines 6 through 22 are borrowed from Winlogbeat&#x2019;s installation script, with line 23 starting the service itself.</p>
<p>In our testing environment, Winlogbeat was installed manually on a single host to verify configuration details. Since we utilize logstash in our log flow, additional first-time configuration was necessary. Elastic details this process in the documentation for Winlogbeat &#x2013; <a href="https://www.elastic.co/guide/en/beats/winlogbeat/current/winlogbeat-template.html" target="_blank">Load the index template in Elasticsearch</a>. Here&#x2019;s the relevant excerpt:</p>
<pre><code class="language-D">PS &gt; .\winlogbeat.exe setup --index-management -E output.logstash.enabled=false -E &apos;output.elasticsearch.hosts=[&quot;&lt;elastic host&gt;:9200&quot;]&apos;
</code></pre>
<p>With the template installed, we can deploy Winlogbeat across the target systems in the domain. PowerShell&#x2019;s Invoke-Command can be leveraged to run scripts or commands on remote domain-joined hosts; however, we ran into the Kerberos &#x201C;Double Hop&#x201D; issue as the install script itself is located on a network share that requires authentication. By default, authentication only extends to the first hop (from server to target) leaving the target&#x2019;s network call without accompanying credentials. After much Googling, details found in <a href="https://docs.microsoft.com/en-us/archive/blogs/ashleymcglone/powershell-remoting-kerberos-double-hop-solved-securely" target="_blank">this post</a> helped us to allow credential delegation.</p>
<p>With the following code example, we allow all hosts within the active directory environment to delegate credentials to the file server (in this case, DC01).</p>
<pre><code class="language-D">$FileServer = Get-ADComputer -Identity dc01
$Servers = Get-ADComputer -Filter {Name -ne $FileServer.Name} -SearchBase &apos;DC=st-lab,DC=local&apos; -SearchScope Subtree
Set-ADComputer -Identity $FileServer -PrincipalsAllowedToDelegateToAccount @($Servers)
</code></pre>
<p>Once the change has taken effect on the host (by either waiting for 15 minutes, or by running <code>KLIST PURGE -LI 0x3e7</code> on a target) we can test if a target can access the fileshare during script execution. First, we snag administrative credentials:</p>
<pre><code class="language-D">$cred = Get-Credential st-lab\super.duper
</code></pre>
<p>And then execute Invoke-Command:</p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/2020-07-20_14-38-28.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<p>Great success!</p>
<p>With authentication issues solved, we can utilize Invoke-Command to install winlogbeat on a target:</p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/2020-07-14_17-28-35.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<p>Here we can see the file comparison we set up for the Sysmon deployment (within the Kibana browser interface):</p>
<p><img src="https://rift.stacktitan.com/content/images/2020/07/2020-07-21_11-47-05.png" alt="Learn the Blue to Improve the Red (Part 2)" loading="lazy"></p>
<h2 id="finalthoughts">Final Thoughts</h2>
<p>Although cumbersome at times, leveraging these freely available utilities to bolster  endpoint monitoring capabilities may provide invaluable insight to your organization. On the red team side of the house, understanding how monitoring and log aggregation solutions may be deployed encourages us to learn our environment and avoid actions that may trigger alerts in an organization&apos;s SoC.</p>
<p>In our next installment, we&apos;ll dig deeper into configuring Sysmon and provide examples of what typical threat actor activities look like from a logging perspective.</p>
<h1 id="scripts">Scripts</h1>
<p>Below you can find the links for the batch file used to deploy Sysmon, as well as the PowerShell script used for deploying Winlogbeat. Replace instances of NETWORK_PATH with the appropriate share for your domain, and ensure your baseline winlogbeat.yml and sysmon_config.xml files exist.</p>
<p><a href="https://gist.github.com/Kyleslav/c7ed91a8699a0b5031eea79066063626" target="_blank">Sysmon Batch File</a><br>
<a href="https://gist.github.com/Kyleslav/e4fe2a61f9e6084e31bf0892f99937db" target="_blank">PowerShell Script for Winlogbeat</a></p>
<!--kg-card-end: markdown-->]]></content:encoded></item></channel></rss>