<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Steve Borosh on Medium]]></title>
        <description><![CDATA[Stories by Steve Borosh on Medium]]></description>
        <link>https://medium.com/@rvrsh3ll?source=rss-ee138d3dc52f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dLXbqq_0m-TTHH0E9OeXEg.jpeg</url>
            <title>Stories by Steve Borosh on Medium</title>
            <link>https://medium.com/@rvrsh3ll?source=rss-ee138d3dc52f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 00:54:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rvrsh3ll/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Offensive Internal HTTP(s) Agent Pivoting]]></title>
            <link>https://medium.com/@rvrsh3ll/offensive-internal-http-s-agent-pivoting-2e9b4b7e58d8?source=rss-ee138d3dc52f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e9b4b7e58d8</guid>
            <dc:creator><![CDATA[Steve Borosh]]></dc:creator>
            <pubDate>Sun, 12 Jul 2020 18:58:54 GMT</pubDate>
            <atom:updated>2020-07-12T20:55:14.903Z</atom:updated>
            <content:encoded><![CDATA[<h3>HTTP(s) C2 Pivoting</h3><h3>Introduction</h3><p>With this blog, I will be covering how to utilize Cobalt Strike, or other C2 frameworks to pivot via HTTP(s) after initial compromise.</p><p>As an offensive operator, we typically have a couple mainstream methods available to pivot our C2 traffic on internal networks. These include but, are not limited to:<br>· SMB Named Pipes<br>· TCP</p><p>Other protocols may be considered such as:<br>· mDNS (<a href="https://github.com/rvrsh3ll/Misc-Powershell-Scripts/blob/master/Start-MulticastAgent.ps1">https://github.com/rvrsh3ll/Misc-Powershell-Scripts/blob/master/Start-MulticastAgent.ps1</a>)<br>· Active Directory (<a href="https://www.harmj0y.net/blog/powershell/command-and-control-using-active-directory/">https://www.harmj0y.net/blog/powershell/command-and-control-using-active-directory/</a>)</p><p>As an offensive operator, why might we want to utilize HTTP(s) as an internal pivot C2 communications channel? Well, many vendors are starting to hone-in on SMB named-pipe communication channels for one. Also, it is best practice to limit the amount of outbound C2 channels you’re utilizing. A server you pivot to may not normally connect to the internet and your C2 traffic might stand out as well. It may be nice to have an internal communications channel that could blend-in with other network traffic or be completely out-of-sight of many detection capabilities.</p><p>Scenario: You’ve initially compromised a target via a phish, gathered privileged credentials, and are looking for a place to move laterally to and would like to blend in with the network. You decide to compromise the internal company web portal and utilize HTTP(s) traffic as your pivot communications channel. Once compromised, your C2 traffic flows from the web server over HTTP(s) to the initially compromised host, and is then finally tunneled through your initial access outbound C2 channel.</p><h3>Listener Creation</h3><p>Create a listener for your normal agent and a “fake” listener for your pivot listener.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*1OSyuZVOUauDrEGoVrvhjg.png" /><figcaption>Create Main Listener</figcaption></figure><p>My Cobalt Strike server is located at 10.232.80.90.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*dRNBQT_KUnxKOj1Rw_i-ZQ.png" /><figcaption>“Fake” Pivot Listener To Initially Compromised Host</figcaption></figure><p>Our fake pivot listener is pointed at 10.232.80.31. This is my initial access point where I compromised my first target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*rEuMTmqWuDWcolAlCUSQFQ.png" /><figcaption>Finished Listeners</figcaption></figure><h3>Payload Creation</h3><p>Create an artifact for your lateral movement. You could use Beacon RAW shellcode in your favorite shellcode launcher as well. the default Cobalt Strike payload will most-likely be intercepted by Antivirus. I’ll leave the AV bypasses up to the reader. Another option is the Beacon “jump” command utilizing your fake listener.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*948m337Urf0UjwttrJ8VRw.png" /><figcaption>Create Cobalt Strike Executable (S)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/399/1*qZaT0Fh4w35IkoxxsCHsBA.png" /><figcaption>Payload Options</figcaption></figure><p>You may use this payload during the lateral movement phase or use your favorite lateral movement payload to load your C2.</p><h3>Reverse Port Forward</h3><p>In order for this to work, we need to establish a reverse port forward. Cobalt Strike has this functionality built-in with the “rportfwd” command. What you’ll be doing here is telling your initial access host to forward any traffic it receives on port 7777 to the Cobalt Strike server at 10.232.80.90 port 80. The great part about this is that the traffic is tunneled through your Cobalt Strike Beacon to the team server! This looks something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*hxXoPRB4AyvqiOv6M3TaFA.png" /><figcaption>Example Lab Forwarding Traffic</figcaption></figure><h3>Lateral Movement</h3><p>This blog assumes you already have initial access command and control to a target host.</p><p>From this initial access point, you’ll be executing your newly created payload on the remote host or jump to the next target host.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*HNy9yVpvtz2hXGU-hqRpqQ.png" /><figcaption>Beacon Jump To Target</figcaption></figure><p>If your reverse port forward is working, barring any firewall interference, you should receive a new Beacon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*Z0ASozLEeYzybUA9QdFZGA.png" /><figcaption>Successful HTTP Tunnel</figcaption></figure><p>Note that our external IP address for the second-hop is that of our Cobalt Strike team server. This verifies that our traffic is being tunneled through the Cobalt Strike Beacon to our Cobalt Strike team server HTTP listener correctly.</p><h3>Prevention and Detection</h3><p>Defense-in-depth is key here. There’s plenty of prevention and detection points here as the attacker has gain initial access, setup the reverse port forward (open ports, disable or modify firewall rules), move laterally and establish a new communications channel between servers or workstations. Enabling and enforcing strict Windows firewall rules is a great start. Having and reviewing net flow and IDS/IPS data to determine if hosts are communicating via HTTP(s) to each other would be a great place to detect HTTP(s) pivoting.</p><p>I hope this blog post has brought some attention the potential for attackers to use HTTP(s) C2 channels not only for external C2 but, internal pivot communications as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e9b4b7e58d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Azure App Services For Offensive Operations]]></title>
            <link>https://medium.com/@rvrsh3ll/azure-app-services-for-offensive-operations-f1de99a83fa0?source=rss-ee138d3dc52f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1de99a83fa0</guid>
            <dc:creator><![CDATA[Steve Borosh]]></dc:creator>
            <pubDate>Thu, 14 May 2020 17:52:43 GMT</pubDate>
            <atom:updated>2020-05-14T17:52:43.530Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, I will be covering how to use Azure App Services for offensive purposes.</p><p>What are Azure App Services you may ask?</p><p>Azure App Services as defined by Microsoft:</p><p>“Quickly build, deploy, and scale web apps created with popular frameworks .NET, .NET Core, Node.js, Java, PHP, Ruby, or Python, in containers or running on any operating system. Meet rigorous, enterprise-grade performance, security, and compliance requirements by using the fully managed platform for your operational and monitoring tasks.” — <a href="https://azure.microsoft.com/en-us/services/app-service/">https://azure.microsoft.com/en-us/services/app-service/</a></p><p>What’s great beyond the ability to run many platforms such as .NET, Python, and Node.js, is that when you deploy an app, you receive a custom subdomain on “.azurewebsites.net”. Pretty nice! Deploying websites and applications is also a breeze with the Azure PowerShell modules.</p><p>What can we do with Azure Apps regarding offensive operations?</p><p>· Static HTML Pages</p><p>· PHP Phishing Pages</p><p>· C2 Redirection via Flask</p><p>Microsoft Examples:</p><p>Static HTML</p><p><a href="https://github.com/Azure-Samples/html-docs-hello-world">https://github.com/Azure-Samples/html-docs-hello-world</a></p><p>NodeJS</p><p><a href="https://github.com/Azure-Samples/nodejs-docs-hello-world">https://github.com/Azure-Samples/nodejs-docs-hello-world</a></p><p>Python</p><p><a href="https://github.com/Azure-Samples/python-docs-hello-world">https://github.com/Azure-Samples/python-docs-hello-world</a></p><p><strong>Prerequisites:</strong></p><p>· Azure PowerShell modules <a href="https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-3.8.0">https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-3.8.0</a></p><p>· Git</p><p><strong>Azure PowerShell static HTML deployment</strong></p><p>First, log into your Azure service with the az login command.</p><p>For help on all commands available use az webapp up help</p><p>For a static html deployment, start in your web application’s root folder and simply deploy your app with “az webapp up --location eastus --resource-group htmlphishtest --name htmlphishtest --html”</p><p>Note that when your deployment is finished, you’ll have a domain “htmlphishtest.azurewebsites.net”!</p><p>In this simple example where I am using a modified version of the “html-docs-hello-world” page which will serve up an executable to the target.</p><p>Here is what it looks like when browsed to:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*I-7PBPpuT0vO1kkHdI73Pw.png" /><figcaption>Static Phishing Page with JavaScript Downloader</figcaption></figure><p><strong>PHP Credential Phishing</strong></p><p>Using PHP applications from the zphisher platform, <a href="https://github.com/htr-tech/zphisher">https://github.com/htr-tech/zphisher</a> we can serve up credential harvesting pages via Azure Apps as well. This takes a little more effort and requires that Git be installed.</p><p>For the Microsoft docs regarding this deployment, visit <a href="https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-php">https://docs.microsoft.com/en-us/azure/app-service/app-service-web-get-started-php</a>.</p><p>First, create your deployment user and password. These credentials will be used to clone and push the Git repository you deploy.</p><p>az webapp deployment user set --user-name &lt;username&gt; --password &lt;password&gt;</p><p>Next, create a resource group.</p><p>az group create --name myResourceGroup --location eastus</p><p>Create an Azure App Service plan.</p><p>az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku FREE</p><p>Create your empty web application.</p><p># Bash</p><p>az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name &lt;app_name&gt; --runtime &quot;PHP|7.4&quot; --deployment-local-git</p><p># PowerShell</p><p>az --% webapp create --resource-group myResourceGroup --plan myAppServicePlan --name &lt;app_name&gt; --runtime &quot;PHP|7.4&quot; --deployment-local-git</p><p>This command will output the details of your app including the git URL to clone.</p><p>From a clean folder, clone your empty git repository using the username and password you set for the application.</p><p>Example: git clone <a href="https://myphptestapp2.scm.azurewebsites.net/myphptestapp2.git">https://myphptestapp2.scm.azurewebsites.net:443/myphptestapp2.git</a></p><p>Copy your PHP phishing application into the empty folder. In this instance I used the “Microsoft” folder from zphisher.</p><p>Add your files with git.</p><p>git add *</p><p>Commit your changes.</p><p>git commit -a -m &quot;Initial Commit&quot;</p><p>Push your repo to your application.</p><p>git push</p><p>Your phishing application should now be hosted at your azurewebsites.net URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*lZWva7EFgmdV_0CU-LptBQ.png" /><figcaption>Fake Login Page</figcaption></figure><p>Now, to access the logs, open a console via the application’s console page located in your Azure Portal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*qgrdJLVslOnkKm9fuzfnBA.png" /><figcaption>Accessing the Console</figcaption></figure><p>In this instance, cat the usernames.txt file for any captured credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*YcZpgNQXDIMr3oO1q-td8Q.png" /><figcaption>Viewing Captured Credentials</figcaption></figure><p><strong>Flask C2 Redirection</strong></p><p>Using a Python Flask app, allows you to also perform redirection to a Command and Control (C2) server. In this example, I am using a “magic header” as described in my previous blog about protecting redirectors.</p><p>In Cobalt Strike, this magic header may be set under the “client” portion of your profile. Also, be sure to comment the first HEADER variable and then uncomment HEADER and HEADER_KEY to use magic headers in application.py.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uC_fT6L5IsrlhLp_Dc5yzg.png" /><figcaption>application.py settings</figcaption></figure><p>From the Python-Flask-Redirector folder execute the following command with your custom variables.</p><p>az webapp up --location eastus --resource-group mynewresourcegroup --name mynewsubdomain --SKU FREE</p><p>After launching a beacon, the redirector checks that the magic header exists or else it will redirect to a site of your choosing. Note the external ip address of this beacon running through Azure Apps. It may be good to whitelist this range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y0xtdoRNAXbBNTF1F7BXIg.png" /><figcaption>Deploying the redirector and receiving a Cobalt Strike Beacon</figcaption></figure><p>If you would like to manage your app via Secure FTP, you may do so by enabling that in the Deployment Center in the settings of your App in Azure. For more information on this visit <a href="https://docs.microsoft.com/en-us/azure/app-service/deploy-ftp">https://docs.microsoft.com/en-us/azure/app-service/deploy-ftp</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*_AnZYL0k_VElZ2H0Qii6_Q.png" /><figcaption>FTPS Settings</figcaption></figure><p>That is all for now! Please visit my GitHub for the code used in this post at <a href="https://github.com/rvrsh3ll/Azure-App-Tools">https://github.com/rvrsh3ll/Azure-App-Tools</a>. I hope this blog post shed some light on how legitimate Azure services may be used for offensive purposes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1de99a83fa0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using the InterPlanetary File System For Offensive Operations]]></title>
            <link>https://medium.com/@rvrsh3ll/using-the-interplanetary-file-system-for-offensive-operations-2350f46240cf?source=rss-ee138d3dc52f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2350f46240cf</guid>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Steve Borosh]]></dc:creator>
            <pubDate>Thu, 02 Jan 2020 20:54:12 GMT</pubDate>
            <atom:updated>2020-01-02T20:55:20.080Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In this blog post, I intend to provide some insight into using the InterPlanetary File System for offensive purposes. I’ll cover what it is, why we may want to use it, some quick history, and walk through a few examples.</p><h3>What is the InterPlanetary File System?</h3><p>According to the InterPlanetary File System’s GitHub(LINK) account, IPFS is “A peer-to-peer hypermedia protocol designed to make the web faster, safer, and more open.” With IPFS, you can share files, host web applications, and much more over a decentralized peer-to-peer network. IPFS, at its core, is a distributed file-sharing system.</p><h3>Why use it?</h3><p>Another tool in the toolbox for starters. Every offensive engagement brings new challenges and some variations on what is required to meet the end-goals. Having more ways to host payloads, serve phishing pages, and even utilize a P2P botnet may tip the scales in your (offensive) favor in some instances.</p><p>Hiding your identity or payload resilience is another bonus. Storing payloads on your server, Pastebin, GitHub, or other public sharing means brings the risk of identification or a takedown of content.</p><h3>A bit of history</h3><p>IPFS was launched as an alpha version in February 2015. In 2018, a phishing attempt (<a href="https://www.bleepingcomputer.com/news/security/phishing-attacks-distributed-through-cloudflares-ipfs-gateway/">https://www.bleepingcomputer.com/news/security/phishing-attacks-distributed-through-cloudflares-</a> <a href="https://www.bleepingcomputer.com/news/security/phishing-attacks-distributed-through-cloudflares-ipfs-gateway/">ipfs-gateway/</a>) was reported using Cloudflare’s IPFS gateway. Later, in 2019, a new IPFS P2P botnet was discovered, <a href="https://www.anomali.com/blog/the-interplanetary-storm-new-malware-in-wild-using-interplanetary-file-systems-ipfs-p2p-network">https://www.anomali.com/blog/the-interplanetary-storm-new-malware-in-wild-using-</a> <a href="https://www.anomali.com/blog/the-interplanetary-storm-new-malware-in-wild-using-interplanetary-file-systems-ipfs-p2p-network">interplanetary-file-systems-ipfs-p2p-network</a>, bringing a new vector to Command and Control.</p><h3>Example 1: Hosting a payload</h3><p>For this installation, I’m using a fresh install of Kali 2019.4. Start by downloading the latest IPFS from <a href="https://dist.ipfs.io/#go-ipfs">https://dist.ipfs.io/#go-ipfs</a></p><p>Extract the files and run the install script as root.</p><p>tar -zxvf go-ipfs_v0.4.22_linux-amd64.tar.gz</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*TisuHmFCYl83wqyFRatFjQ.png" /></figure><p>Note that I’m running as root but, you probably should run IPFS as a non-root user. Create a directory for your files and create our “Get-Process” payload. This command could be replaced with any binary, PowerShell, or any other payload format.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*QPgCKU4fknrpQ_N508Uqtg.png" /></figure><p>Now, we initialize IPFS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*qH6NPwG_FgdC-c9Ft7SDmA.png" /></figure><p>Finally, we start the IPFS daemon. If you want to work with the configuration file, it’s located at</p><p>~/.ipfs/config</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*N2FvxuodBpZUlTKoYSVugQ.png" /></figure><p>The daemon will start syncing with the network. We’ll need to add our file to the network with the “ipfs add test.ps1” command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*zpEJZuCKfuOKdnlpjvSHmg.png" /></figure><p>The resulting Qm hash is the IPFS address of your file. IPFS is immutable, which means that once a file is hashed, it cannot be changed. If you change your file, you’ll need to re-add it, and you’ll receive a new hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*GCkhbKSd4PgtW8EQezyHzA.png" /></figure><p>There is also a graphical version the daemon starts at localhost:5001/webui if you’d rather use that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*HyLm81_KoGUP093Et1x3wg.png" /></figure><p>The bad part about IPFS is that it may take several minutes for any file changes to be broadcast to the IPFS network. Until this happens, the relay won’t know where to find your file. If you paste your hash in the browser at <a href="https://ipfs.io/ipfs/%3cQMhash">https://ipfs.io/ipfs/&lt;QMhash</a>&gt;, you should be able to browse to your payload once it’s been broadcast to the network. Another handy bit of knowledge is that Cloudflare also supports the IPFS network. You may also visit your payload at <a href="https://cloudflare-ipfs.com/ipfs/%3cQMhash">https://cloudflare-</a> <a href="https://cloudflare-ipfs.com/ipfs/%3cQMhash">ipfs.com/ipfs/&lt;QMhash</a>&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*amVaYNpgry8XKapJb-t0Vg.gif" /></figure><p><strong>Example 2: Hosting a phishing payload</strong></p><p>In this example, we’ll create and host a phishing payload over IPFS. Start by creating a simple index.html that serves a malicious HTA file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*XBGkzA-cZKIP8BIQ3CDo7w.png" /></figure><p>Next, we’ll create our payload. This one executes calc and closes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*VveOPLbGDaraD_7ZU_UusA.png" /></figure><p>As we’ve done before, we’ll need to add these files to IPFS. In this example, we’ve placed our files in the</p><p>/web directory that we created. Run the “ipfs add -r web” command to hash the files and place them on IPFS.</p><p>We’re going to go a step further and publish this site to IPNS. By publishing to IPNS, we set a static hash that can be re-used when we change files. If you modify your files after publishing, simply re-add and publish again. The same hash will be output and you can now browse to ipfs.io/ipns/qmhash. As you can see, all we had to do was replace ipfs/ with ipns/. For further reading on IPNS, check out <a href="https://docs.ipfs.io/guides/concepts/ipns/">https://docs.ipfs.io/guides/concepts/ipns/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*ciIWK0VZeHOdaAIPSWFRMQ.png" /></figure><p>After publishing, your site will be visible on ipns after syncing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*rW8LcnG-bijRhM6vU_bTiQ.png" /></figure><p>There we have it! We’ve created and deployed a phishing page that can be served through IPFS.io, CloudFlare, or direct through your own gateway (left up to the reader).</p><h3>Detection</h3><p>Well, detection here seems straight-forward. Since these examples require browsing of a gateway, that’s your chokepoint for detection. If you don’t want IPFS traffic on your network, start by blocking ipfs.io and cloudflare-ipfs.com. For self-hosted gateways, you’ll have to rely on creating some rules to detect/block Qm hashes.</p><h3>Conclusion</h3><p>In this blog post, I covered what IPFS is, a bit of history, why we may want to use it, some simple use- cases, and some detection. If you’re an offensive operator or defender, hopefully, this post has added another tool to your toolbox.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2350f46240cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digital Canaries in Coal Mines: Detecting Adversarial Enumeration with DNS and AD]]></title>
            <link>https://medium.com/@rvrsh3ll/digital-canaries-in-coal-mines-detecting-adversarial-enumeration-with-dns-and-ad-aff70c60fc8?source=rss-ee138d3dc52f------2</link>
            <guid isPermaLink="false">https://medium.com/p/aff70c60fc8</guid>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Steve Borosh]]></dc:creator>
            <pubDate>Thu, 26 Sep 2019 20:51:51 GMT</pubDate>
            <atom:updated>2019-09-26T20:51:51.279Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>A fundamental part of any network is the Domain Name Service (DNS). Adversaries will likely want to enumerate computers in Active Directory and connect to them, and at some point, they will likely interact with DNS doing so. A simple example is attempting to access a remote share and the resulting DNS query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*T7OkqWkTEfYazzrQ-oZIHw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/1*PuCd-eaYKCjmFT65Mz490A.png" /></figure><p>Since DNS is a critical service to internal networks and we know adversaries will use it, this provides an excellent “choke point” for detection. Since we control Active Directory and DNS, we can control what the adversary may see. We can accomplish this by placing a few Active Directory canaries and monitoring specific DNS queries.</p><p>In the early days of coal mining, miners would place a canary bird in the shaft of the mine as a detector for noxious gases. In this post, we’re going to create some active directory canaries that will aid us in detecting threat-actors enumerating our network using HELK, SilkETW, and DNS Analytical Logging.</p><p><strong>Getting Started</strong></p><p>Logging detailed DNS requests is a bit tricky and depending on the size of the organization, may require some additional storage or performance considerations. We currently have the options of either logging DNS queries at the DNS server or at the host-level. This post will cover the former while a follow-up post will cover host-level monitoring, detection and deception.</p><p>In order to obtain detailed DNS logs on the server, we’ll need to enable Windows DNS Analytical Logging. <a href="https://blogs.technet.microsoft.com/teamdhcp/2015/11/23/network-forensics-with-windows-dns-analytical-logging/">https://blogs.technet.microsoft.com/teamdhcp/2015/11/23/network-forensics-with-windows-dns-analytical-logging/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*nNq4qjTPHDs8wo779dYGSg.png" /></figure><p>Analytical logs are considered Event Tracing for Windows logs and output to an “.etl” file. Unfortunately, with event viewer, analytical logs cannot be viewed while they are actively logging. We could view these logs live with Microsoft Message Analyzer <a href="https://blogs.technet.microsoft.com/runcmd/viewing-analytic-logs-without-disabling-them/">https://blogs.technet.microsoft.com/runcmd/viewing-analytic-logs-without-disabling-them/</a>. Normally, to send windows logs to the SIEM, we may use winlogbeat. At the time of this writing, winlogbeat does not support event tracing logs so, we’ll need another solution. A great tool called SilkETW <a href="https://github.com/fireeye/SilkETW">https://github.com/fireeye/SilkETW</a> can accomplish what we need.</p><p>For this research I utilized the HELK <a href="https://github.com/Cyb3rWard0g/HELK">https://github.com/Cyb3rWard0g/HELK</a> as my SIEM solution. Follow the instructions for install in the wiki. After completing the installation of HELK we need to do some preparation for the data coming from SilkETW. Here’s what our network looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*vxLw98FxXcAsGYQMAg2bQw.png" /></figure><p>On our HELK instance, we’ll need to ensure that port 9200 is listening and mapped depending on which install was selected. If the DOCKER install was used, use “sudo docker ps” to see if port 9200 is mapped to 0.0.0.0 for the Elasticsearch docker container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*rv43vs3llEbvBt-svFMltA.png" /></figure><p>If this port is not listening, we’ll need to set that up. In your HELK/docker directory, open the helk-kibana-analysis-basic.yml file with an editor. Add the ports section as shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*VnFdKPRmuYMhWFNFPksCUA.png" /></figure><p>Save the file and close. Now, we can rebuild Elasticsearch. In your bash terminal execute the following:</p><p>export ADVERTISED_LISTENER=&lt;your helk ip&gt;<br> sudo -E docker-compose -f helk-kibana-analysis-basic.yml up — build –d</p><p>Once complete, re-run “sudo docker ps” to check your mapping.</p><p>Next, we need to create an index for our data coming from SilkETW. The data fields for DNS Analytical Logging can be found here <a href="https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/dn800669(v=ws.11)">https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/dn800669(v=ws.11)</a></p><p>In the Kibana console, create a post request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*SBD5T2vqMx-KHwL50GpV_w.png" /></figure><p>Now, we need to create the index pattern by navigating to the management portal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/663/1*KkzF4TZ20xYrQLPGc1JkCg.png" /></figure><p>Enter “dnsqueries*” to find the new index and select the “Next step” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*yzdfIpO2o3-MP8EOI58GSQ.png" /></figure><p>Select the Timestamp filter and finish by clicking “Create index pattern”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*G1ElVF4gHOfxlUcaD9j9rQ.png" /></figure><p>We should now be able to forward log data with SilkETW to our HELK instance. SilkETW requires the log GUID so that it knows where to pull from. I found this blog <a href="https://blogs.technet.microsoft.com/teamdhcp/2015/11/23/network-forensics-with-windows-dns-analytical-logging/">https://blogs.technet.microsoft.com/teamdhcp/2015/11/23/network-forensics-with-windows-dns-analytical-logging/</a> post referencing this GUID {EB79061A-A566–4698–9119–3ED2807060E7}.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rIA7JOWj-ZumUoFGAW_NDA.png" /></figure><p>We can test that our logs are correctly being sent to HELK by performing a basic nslookup from another host on the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*7lHoj9dV2WqzqrENaZJYWA.png" /></figure><p>Now, from the discover panel in Kibana, we can search for that DNS lookup.</p><p>Using the search filter ‘XmlEventData.QNAME:”www.hackers.com&quot;’, we can quickly find that specific lookup. Note the various fields and data within the _source field. We can identify that the query came from 10.232.80.11.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n2DL4AuK94ePqiyRB39asw.png" /></figure><p>Great! So far, we’ve setup HELK, DNS Analytical Logging, created our index and index pattern, started SilkETW and successfully captured a DNS query. Now, how do we utilize this setup to deceive and detect threat-actors in our network?</p><p><strong>Canaries</strong></p><p>We’ll start by creating a canary computer object. In a live environment, you’ll want to get as detailed as possible with your canaries. Mimicking real settings of other objects and naming schemes in active directory as to not tip off the attacker of your ruse. In these examples, I use obvious names for teaching purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*8e3JdSg_WHyzEINfvrh0ww.png" /></figure><p>This computer object will mimic one of our file servers. For DNS to perform lookups and look as legitimate as possible, we’ll need to create a DNS entry for fakefileserver.spiderweb.local.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*3bazdYFMazkGfzJKHmkrHw.png" /></figure><p>With our fake file server and DNS entry complete, we can create a canary user account as well. As with the other objects, be sure to set an enticing description, phone number, and so on, making the account seem as legitimate as possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*sk22XgtUAyIdgn0ANA3dnA.png" /></figure><p>Importantly, you’ll want to point the user’s “home folder” to the fake file server. The share does not have to exist for the property to exist.</p><p><strong>PowerView Overview</strong></p><p>PowerView <a href="https://github.com/PowerShellMafia/PowerSploit/blob/dev/Recon/PowerView.ps1">https://github.com/PowerShellMafia/PowerSploit/blob/dev/Recon/PowerView.ps1</a> is a PowerShell script that aids active directory enumeration and exploitation. It has many built-in functions that allow us to enumerate users, groups, SPN’s, user sessions and much more. This tool may be executed either from disk or in-memory. It is also possible to execute through a variety of Remote Access Trojans (RATs).</p><p>Many functions within PowerView will attempt to interact with a remote host. One such function is the “Find-DomainUserLocation” function. This function attempts to find where specific users are located on the network by enumerating sessions. For reference, this technique maps to MITRE ATT&amp;CK framework T1049 <a href="https://attack.mitre.org/techniques/T1049/">https://attack.mitre.org/techniques/T1049/</a>. First, it queries active directory for all computer objects. It then queries each computer for active sessions and lists where each user’s session is coming from. If we provide the –stealth flag, PowerView will only enumerate sessions from file servers. This is a great way to find user locations within the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*jN0zJbe20kpYvW_ExHCu1Q.png" /></figure><p>Here we see an example showing “Al_Pacino” has a session to the file server from 10.232.80.12.</p><p><strong>Enumeration Detection</strong></p><p>For Find-DominUserLocation –Stealth to work and check the sessions on each host, it needs know where the remote host is. When connecting to the remote host, a DNS query is performed. By itself, a DNS query to our HQFS01 isn’t abnormal but, a connection to our canary fake file server is. In this way, we can detect potential domain enumeration when fakefileserver.spiderweb.local is queried. The reason this works with the stealth flag, is that PowerView will look at each user account and enumerate the home directories, script paths, and profile paths. Those servers are considered high-traffic servers and will be scanned by default from the stealth flag. Our canary user has a home directory pointing to \\fakefileserver\share\users which causes Find-DomainUserLocation to attempt to gather sessions from it.</p><p>Now, let’s look at HELK after “Find-DomainUserLocation –Stealth –Showall” is executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dU8c-1y1B2O77LXU24gylA.png" /></figure><p>We see two events for fakefileserver when Find-DomainUserLocation queried for it. We can increase the fidelity of our detection a bit by either including more fake file servers.</p><p><strong>Enhancing detection with Sysmon and a fake SMB/SAMR server.</strong></p><p>We just covered performing deception and detection while logging at the server-level. Meaning, all our logging was performed by DNS Analytical Logging on the domain controller and forwarded to HELK with SilkETW. This setup works well but, we lose granularity with our data vs using a host-based solution.</p><p>You’ll need to setup Sysmon on your endpoints. First download Sysmon at <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon">https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon</a> and refer to <a href="https://github.com/SwiftOnSecurity/sysmon-config">https://github.com/SwiftOnSecurity/sysmon-config</a> to install the z-AlphaVersion.xml configuration to enable DNS logging.</p><p><strong>Canary Setup</strong></p><p>In this scenario, we’ll have some additional parts to our setup.</p><p>We’ll start by creating a couple canary computer objects. In a live environment, you’ll want to get as detailed as possible with your canaries. Mimicking real settings of other objects and naming schemes in active directory as to not tip off the attacker of your ruse. In these examples, I an obvious name for teaching purposes.</p><p>FAKEFILESERVER will be a linux box running our modified “smbserver.py” program to respond to session enumeration.</p><p>We also need to make another computer object where we’ll have our modified “smbserver.ph” fake SAMR server responding to local administrators group enumeration. We’ll call this one “HQCITRIX01”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*gn4FJ_LYHE9ZRYbpaniVfw.png" /></figure><p>This computer object will mimic one of our file servers. For DNS to perform lookups and look as legitimate as possible, we’ll need to create DNS entries for fakefileserver.spiderweb.local and HQCITRIX01.spiderweb.local.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*kMiWGxPHgEztNmKlilUi3g.png" /></figure><p>With our fake file server and DNS entry complete, we can create a canary user account as well. As with the other objects, be sure to set an enticing description, phone number, and so on, making the account seem as legitimate as possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*sk22XgtUAyIdgn0ANA3dnA.png" /></figure><p>Again, you’ll want to point the user’s “home folder” to the fake file server. The share does not have to exist for the property to exist.</p><p><strong>The Trap</strong></p><p>Our environment is setup so that if an attacker phishes an endpoint and begins enumerating sessions and local administrators on the network, they will be presented with an attack path of our choosing. Ideally, our fake SMB/SAMR server that responds to session and SAMR queries would also be sending alerts when queried.</p><p>On our canary hosts, we use a standard ubuntu server image, impacket, and our modified smbserver.py.</p><p>Clone impacket <a href="https://github.com/SecureAuthCorp/impacket">https://github.com/SecureAuthCorp/impacket</a></p><p>Clone <a href="https://github.com/rvrsh3ll/CanaryServer">https://github.com/rvrsh3ll/CanaryServer</a></p><p>Backup and replace “impacket/impacket/smbserver.py” with our modified version.</p><p>Run “pip install .” in impacket/ directory.</p><p>The modified version of impacket’s smbserver.py accepts two json files for data, session_data.json and samr_data.json.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*4aQLT0JLo9_oUzibu95Rfw.png" /></figure><p>We’ll set several fake sessions on fakefileserver and have them point to various workstations. The user will_smith is a real member of the domain admins group and has a fake session coming from HQCITRIXSRV01.</p><p>Next, we’ll want to set fake SAMR data on HQCITRIX01.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*KMD5jLuIwpR-nqsFbloDcQ.png" /></figure><p>Save the json files in whatever directory you’re going to run smbserver.py from. I placed them in the impacket/ directory. Then, just start smbserver.py. I use “” as a share name. This has the effect of returning nothing when Get-NetShare is ran against it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*wr-eZ6ERpB7xBflAynS3aw.png" /></figure><p>The Security Account Manager (SAM) Remote Protocol (Client-to-Server) provides management functionality for an account store or directory containing users and groups. <a href="https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/96952411-1d17-4fe4-879c-d5b48a264314">https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-samr/96952411-1d17-4fe4-879c-d5b48a264314</a></p><p>Our smbserver.py will respond to SAMR enumeration requests for local administrators and in this case, tell the enumerator that “Domain Users” are part of the local administrator’s group on HQCITRIX01.</p><p>In addition to fake data, our environment also has Sysmon forwarding DNS lookups to our HELK instance. All these parts together provide an excellent scheme for detecting adversaries enumerating our network resources.</p><p><strong>The Attack</strong></p><p>In this scenario, our adversary has landed a phish on HQWKSTN01. They want to find out if they have an attack path to domain administrator. Either using manual enumeration with tools such as PowerView’s “Find-LocalAdminAccess” and “Get-NetSession” or using a tool such as BloodHound <a href="https://github.com/BloodHoundAD/BloodHound">https://github.com/BloodHoundAD/BloodHound</a> to graphically map this path. In our scenario, the attacker decides to run BloodHound which will enumerate the users in Active Directory and determine where high-trafficked servers such as file servers are by looking at user properties such as the home directory. It will then attempt to enumerate sessions on those servers. Bloodhound will also enumerate the computers in Active Directory and query the SAMR service to enumerate local administrators.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*JOxe_78ucq9Rub_rjxXt7A.png" /></figure><p>While bloodhound is querying for session and local administrator data, we can see the queries hit our fake server. This would be a great point for detection and alerting!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*X8eFfEqRGA8XAWSubA0s8g.png" /></figure><p>Here’s what the attack flow looks like for each query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*CYKyyAnIlnew5LBI8XGchw.png" /></figure><p><strong>Detection</strong></p><p>As we discussed previously, the DNS lookup of our canary computers should set off some alarm bells. Now, we are using Sysmon with DNS logging on each host instead of SilkETW forwarding DNS logs form the DC. This gives us more detail as we can see which processes are performing the lookup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F-SODoINFx3A7aXEF7bXPg.png" /></figure><p>Here we see the field dns_query_name matches our canary server hostname “hqcitrix01.spiderweb.local”. Unlike DNS Transaction Logging and SilkETW, we see additional information about the query. Most notably, is the process_path field. We see two lookups for our canary. Curiously, the first lookup is from the msmpeng.exe process which is windows defender. Next, werfault.exe performs a DNS lookup, as that is the process that we have cobalt strike injecting into for post-exploitation action using execute-assembly in beacon.</p><p><strong>Conclusion</strong></p><p>The deception and detection techniques covered in this blog post are tool agnostic. Any queries for your canary file server should be investigated. This blog post covered detection by utilizing DNS Analytical Logs on the DNS server and forwarding those logs to a SIEM with SilkETW. I also covered how to utilize Sysmon, a fake SMB/SAMR server and HELK to fine-tune these canary DNS detections at the host-level. Happy hunting!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aff70c60fc8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started With AzureDevOps]]></title>
            <link>https://medium.com/@rvrsh3ll/getting-started-with-azuredevops-8bf0bf089bc3?source=rss-ee138d3dc52f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bf0bf089bc3</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Steve Borosh]]></dc:creator>
            <pubDate>Wed, 18 Sep 2019 21:15:03 GMT</pubDate>
            <atom:updated>2019-09-18T21:15:03.269Z</atom:updated>
            <content:encoded><![CDATA[<h3>Getting Started With Azure DevOps</h3><p><strong>Introduction</strong></p><p>Recently, I set out to find a simple solution to manage the building of all my offensive C# tools in a central location. The main goal I had for this project was to find a solution that didn’t require a ton of infrastructure to setup. I quickly came across the Azure DevOps platform. It didn’t take long for me to build a pipeline from my GitHub repository and compile my first binary.</p><p>This blog is intended to be a quick walk-through on how to setup your first C# build pipeline on Azure DevOps. In this tutorial, I am using the free tier. For more pricing options see <a href="https://azure.microsoft.com/en-us/pricing/details/devops/azure-devops-services/">https://azure.microsoft.com/en-us/pricing/details/devops/azure-devops-services/</a></p><p><strong>Building Your First Project</strong></p><p>Getting started is as easy as authenticating with your GitHub account. You don’t need a GitHub account though, as you may opt to store your code in an Azure repository. Once you’ve authenticated, click the “New project” button to create your first project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/201/1*9rg6Iz0I23TjFEa3i6XweQ.png" /></figure><p>Enter the details of your new project and select whether you want it public or private. You can still invite people to the project if it is private.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*ZR-b9JNGPvJbHNEOkiYruQ.png" /></figure><p>After you create your project, you’ll be presented with your overview page. On this page, you can link to a wiki or readme, display project stats and invite members to your team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p7oOdLTbPc_u0ZbAolTURw.png" /></figure><p>In the “About this project” section, you may use the pencil icon to edit details of the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*dhSSHkhO4CPjtug_1ZOYrw.png" /></figure><p>The “About” radio button choices must be present prior to editing the description. In my case, I created a simple wiki page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0yZy5WCku873vBKZwS3hOw.png" /></figure><p>Now, you’re all set to start your first pipeline. Navigate to the pipeline section and click “New Pipeline”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*ayMwAUi27fRXSsC0acHi0Q.png" /></figure><p>The next page is where you have the option of manually modifying your pipeline with YAML files. Or, you may choose the simple route and select “Use classic editor” at the bottom of the page. In my examples, I’ll be using the classic editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*ChpROmrHR8TnC7Lct70mTw.png" /></figure><p>Now, you have the option to select where your code resides. In this instance, I’ll choose a GitHub repository from my account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JlsPd2Np53iL6dRdrSYB3w.png" /></figure><p>Simply search for and select the repository where the code is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*eMgeSFX8Oi5FVAXCsJv9PQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*A6mmVlsBw_3-XJY-6UqMog.png" /></figure><p>Next, select your template. I’m using the “.NET Desktop” template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*JXbTQMhOvYRorQMjm6I8Gw.png" /></figure><p>The nice part about the classic method is that it fills in the Agent tasks for you. However, it defaults to an Agent specification of Visual Studio 2017. You may want to change that to “windows-2019” on the right-hand side of the menu. Select “Save &amp; Queue” to save your settings and begin the build process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gnJdy7g6bixTmga5YBr6OA.png" /></figure><p>If you want your builds to execute anytime a change is committed to the selected branch, select the “Triggers” tab and check the “Enable continuous integration” box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*IJEIRqqjc32zmX47Y8gFmg.png" /></figure><p>After saving, you’ll receive one final prompt before building. Review your settings, add a save comment and then click “save and run”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*9EfAcfhnQ6achlc7B6t75Q.png" /></figure><p>Your Pipeline will display a blue spinning circle as the agent queues and runs the job. If it fails, you’ll see a red “x”. When it succeeds, a green check mark will appear. Click on the build to see the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*7FxiW7cb2XfUpi0XgqFqGA.png" /></figure><p>Here we see that our build completed in 54 seconds and 1 artifact was created. Artifacts are your completed project builds. Click on the “published” link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GvTLcRtFz9vJ5aTqpGLwZw.png" /></figure><p>Select each drop-down until you reach your compiled binary as shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bmVJ6vjXo4AQdks1raFCpA.png" /></figure><p>You may click the binary and choose to download it to your local system. I am not currently aware of a method to select all pipelines and download every binary in one package using the free tier of the Azure DevOps service.</p><p><strong>Conclusion</strong></p><p>In this blog post, I covered the basics of using Azure DevOps pipelines to build your .NET tools in a central location. The ability to invite people to your projects is a great way to easily share builds within your team. The ability to collaborate, test, perform continuous integration and build your tools in one easy-to-use platform makes Azure DevOps a great option to try.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bf0bf089bc3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction]]></title>
            <link>https://medium.com/@rvrsh3ll/introduction-1d327afaf22d?source=rss-ee138d3dc52f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d327afaf22d</guid>
            <category><![CDATA[microsoft]]></category>
            <dc:creator><![CDATA[Steve Borosh]]></dc:creator>
            <pubDate>Mon, 24 Jun 2019 16:14:15 GMT</pubDate>
            <atom:updated>2019-09-05T15:00:13.899Z</atom:updated>
            <content:encoded><![CDATA[<h3>UNC Path Injection with Microsoft Access</h3><p><strong>Introduction</strong></p><p>Steve Borosh is a Principal Security Consultant for Trustwave and Trustwave Government Solutions, specializing in offensive security service for both commercial and federal customers.</p><p>I’ve previously created a couple of blog post’s focused around phishing with Microsoft Access <a href="https://medium.com/@rvrsh3ll">https://medium.com/@rvrsh3ll</a>. This blog post continues down the path of utilizing features in Microsoft Access that an attacker or penetration tester may utilize to gain further access into an organization.</p><p>Capturing NTLMv2 hashes over a network or the Internet has been a common attack vector for many years. Researchers are continuously coming up with new and clever ways of performing this type of attack. Currently, Microsoft Access allows you to craft a database that attempts to authenticate over the network or Internet, allowing for NTLMv2 hash capturing. Let’s get started crafting our own database to perform this type of attack!</p><p>Note: I am using Microsoft Access version 1905 Build 11629.20214 from Office 365.</p><p><strong>Crafting a Database</strong></p><p>We’re going to start by creating a blank database and naming it something enticing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/0*Z_UAToLDWh5-o6Fq" /></figure><p>Our blank database should look something like what you see here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/0*13cAspQo-_xZj4my" /></figure><p>To coax our database into reaching out and sending us a password hash, we’ll need to link it to an Excel file. Open Microsoft Excel and create a simple table of data to link to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/0*_P4SNSqZeE7uonyY" /></figure><p>Save our workbook in Excel 97–2003 format and keep our naming scheme inline with our phishing pretext.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/221/0*Dl20H2kIhcr18VpJ" /></figure><p>Now, we want to host our xls file wherever we are going to capture hashes from. This could be hosted on a Virtual Private Server (VPS) (assuming the target network allows outbound SMB traffic) or on a host we control on the Local Area Network (LAN).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/0*1ThXHeOz0tzvF4vl" /></figure><p>Returning to our Microsoft Access database, navigate to the “External Data” ribbon and select “Linked Table Manager”. This is where we will create our link to the remote Excel workbook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/0*z0rW7Oi0kJQEUSdf" /></figure><p>Now, name the data source, select Excel, and click Next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/0*RF56QEnwBHQKaVkx" /></figure><p>Point the file name to the hosted xls file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/0*j_Q6wa8lzbQbh3wt" /></figure><p>Once this step is completed, the “Link Spreadsheet Wizard” will open. Here, we want to select the checkbox for column headings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/0*bAeqLatNnpjASbVI" /></figure><p>Name the linked table something juicy as this will be visible to the target user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/0*XmAXG9R9fEt-hTuA" /></figure><p>This will complete the linking process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/0*hg0OCiPHf8XtwVjJ" /></figure><p>Let’s clean up the original table that was added by default. Right-click Table1 and select Delete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/0*qxiYYXZwZ8ErHmAN" /></figure><p>Next, we create a form that links to our data source. In Microsoft Access, it is possible to set a Form to auto-display when a user opens the database. We can use this to our advantage. Start by creating a blank form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/0*s08HSEq7zAwpQ7NJ" /></figure><p>Right-click Form1 and save as an enticing name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/0*NMRdaCKqXra1bMhG" /></figure><p>Switch to design view on the form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/233/0*3KR2muCCZdqOSWK7" /></figure><p>Right-click inside the form and select Form Properties from the list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/0*CjoNXYu4kCyQ0yxQ" /></figure><p>Navigate to the Data tab and change the Record Source to that of the linked table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/0*zAqsyAZDm82Xh83w" /></figure><p>Once that is complete, we can change the automatically displayed form. Navigate to the File ribbon and select options. Within access options, select the current database and change the display form to the newly created form. For added flair, change the application title.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/0*1_TtpRgTjSLmhXui" /></figure><p>Close and re-open the database, saving along the way. Our database should now attempt to connect and authenticate to the hosted xls file! Note that enable content shows but, our hash is captured without having to enable the content in the form!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*7ax4GjJxMZ_kovyn" /></figure><p>Here’s the demo of this in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bmyvnf6b1qOOZHPtaj0wIg.gif" /></figure><p><strong>Conclusion</strong></p><p>While this type of attack has been around for a long time, it is still viable in many environments and should work regardless of egress restrictions on internal assessments. To protect your organization from hash-capturing attacks originating from phishing attempts requires restricting outbound SMB traffic at egress points. Internally, taking measures to mitigate relay attacks will also help mitigate these attacks per <a href="https://technet.microsoft.com/en-us/library/cc180803.aspx">https://technet.microsoft.com/en-us/library/cc180803.aspx</a>. While Microsoft Access may not have as much of a footprint in previous office versions, Microsoft Access is installed by default with Office 365. I hope this blog post helps bring awareness to additional attack vectors present in Microsoft Access.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d327afaf22d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hardening Your Azure Domain Front]]></title>
            <link>https://medium.com/@rvrsh3ll/hardening-your-azure-domain-front-7423b5ab4f64?source=rss-ee138d3dc52f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7423b5ab4f64</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[infrastructure]]></category>
            <category><![CDATA[cobalt-strike]]></category>
            <category><![CDATA[domain-fronting]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Steve Borosh]]></dc:creator>
            <pubDate>Tue, 19 Feb 2019 14:37:28 GMT</pubDate>
            <atom:updated>2019-09-05T23:07:55.492Z</atom:updated>
            <content:encoded><![CDATA[<p>UPDATE: 9/5/2019</p><p>Instead of using a “Cookie” parameter which WinINet does not like, utilize a magic header instead. Follow the post and replace ‘header “Cookie” “Something”;’ with a different header value. You can find a list of HTTP headers to utilize here <a href="https://www.whitehatsec.com/blog/list-of-http-response-headers/">https://www.whitehatsec.com/blog/list-of-http-response-headers/</a></p><pre>Example in cobalt strike malleable c2:<br>client {<br>header &quot;Host&quot; &quot;mycdn.azureedge.net&quot;;<br>header &quot;X-Aspnet-Version&quot; &quot;1.3&quot;;<br>}</pre><h3>Introduction</h3><p>While domain fronting isn’t a new technique for offensive infrastructure, it continues to be a valid method for bypassing network restrictions, hiding from defenders, and protecting your infrastructure.</p><p>Recently, I’ve discovered the power of Azure CDN Rules Engine related to team server infrastructure. As offensive operators, it’s important to have many tools in your belt and tricks up your sleeve when battling hardened defenses and active threat-hunters. The Azure CDN Rules Engine is one more layer we can implement to make our infrastructure safe from prying eyes and active defenses.</p><p>I hope both offensive operators and threat hunters walk away from this blog with new ideas and a fresh perspective on the abilities of domain fronting.</p><p>In this blog I’m using Cobalt Strike as a C2 platform however, the techniques used here are C2 agnostic.</p><h3>CDN Setup</h3><p>First, we need to create our resource group in Azure. Start by navigating to Home&gt;Resource Groups and use the Add button to create a resource group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBxIQM5RuFYqAp9T51EORw.png" /></figure><p>Next, we create a CDN profile. This will tell the CDN where to pull content from (our team server). It’s easiest to find the CDN page by searching for CDN in the search bar. Be sure to select “Premium Verizon” as this will be required to manage our redirects. Point your origin hostname directly to your team server. The CDN is doing the redirecting for you so, no need for an additional team server in the middle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*G0lDQVChJe-rFHwMZqVNKA.png" /></figure><p>One you create your CDN endpoint, it may take a few minutes to an hour to configure and propagate completely.</p><h3>Basic Redirection Rule Creation</h3><p>Once your CDN is running, you can open the profile page and click the “Manage” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*qsUgXsUsZISC-rSeRSXA5A.png" /></figure><p>Here you can select “HTTP Large &gt; Rules Engine”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*q-ZzB6Q3LM1Kp0gRBHErZg.png" /></figure><p>This page allows you to create conditions to match your desired rule. We’ll start with a simple literal URL path rule for payload hosting. This rule states that if the path matches your payload URI, redirect to a google. The rules engine allows you to stack rules so you can filter to allow/disallow more based on your profile or hosting pleasure. Note the warning: “Approval of new Rules takes up to 4 hours”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N0boy1sSLSVgYFxSApA86w.png" /></figure><p>When someone navigates to the payload at “https://rvrsh3ll.azureedge.net/payload/mypayload.txt” they are redirected to google. Just a trivial example to show you how basic redirection works.</p><p>This is great for hosting payloads but, what about hardening our team server listener and only allowing our beacons through? In the next example, we’ll add a cookie value to our malleable c2 profile as our “key” to allow only beacon traffic to hit our listener.</p><h3>Beacon Payload Filtering</h3><p>First, we modify our malleable C2 profile to point to our CDN at rvrsh3ll.azureedge.net and add our cookie value. For this test we’ll use the cookie “cdn=testing;” This will need to be entered under client under both GET and POST sections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*YD0eZ4pn8D7Dsxn-f7qHyA.png" /></figure><p>Next, we’ll modify our CDN rules to allow only traffic with this cookie through to our team server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2or7c5g6rEF5isHYkNuMkA.png" /></figure><p>Once this rule is in effect, we can create our fully-staged payload and launch it on our target. If all goes well, our CDN rules should redirect any non-matching traffic to <a href="https://media.giphy.com/media/DBfYJqH5AokgM/giphy.gif">https://media.giphy.com/media/DBfYJqH5AokgM/giphy.gif</a> and allow matching traffic through to our team server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZhdYMnQAPo39rA2bTiQ7w.gif" /></figure><h3>Conclusion</h3><p>We’ve successfully allowed a beacon through our CDN and re-directed prying eyes to a gif. These scenarios are easy to implement and pretty basic. With the ability to stack rules, you have plenty of flexibility with Azure CDN Rules Engine to really lock down your infrastructure. I encourage offensive operators to check out all the possibilities the Rules Engine affords and implement CDN rules in your offensive engagements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7423b5ab4f64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Phishing tales: Microsoft Access Macro (.MAM) shortcuts]]></title>
            <link>https://medium.com/specter-ops-posts/phishing-tales-microsoft-access-macro-mam-shortcuts-c0bc3f90ed62?source=rss-ee138d3dc52f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0bc3f90ed62</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[phishing]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Steve Borosh]]></dc:creator>
            <pubDate>Tue, 03 Jul 2018 17:49:30 GMT</pubDate>
            <atom:updated>2018-07-03T17:49:30.628Z</atom:updated>
            <content:encoded><![CDATA[<p>Previously, I <a href="https://medium.com/rvrsh3ll/phishing-for-access-554105b0901e">blogged </a>about the ability to create malicious .ACCDE Microsoft Access Database files and using them as a phishing vector. This post expands on using the ACCDE format and will be introducing Microsoft Access Macro “MAM” shortcuts to gain access via phishing. The MAM file is basically a shortcut that links directly to a Microsoft Access macro. It has been around since at least Office 97.</p><h3>Creating a MAM</h3><p>For this exercise, we’ll be creating a simple Microsoft Access Database that pops calc.exe. We could, however, embed anything from a simple macro payload to a full-fledged <a href="https://github.com/tyranid/DotNetToJScript">DOTNET2JSCRIPT</a> payload., I’ll leave proper weaponizationthat to you. First, open MSAccess and create a blank database. You should then have something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/0*HSUkf9qr2SpQlt1x" /></figure><p>Now, navigate to the Create ribbon and select Module. This will open the Microsoft Visual Basic for Applications design editor.</p><p>In Microsoft Access, our module will contain our code base while the macro will just tell Access to run the VB code. You’ll see what I mean here shortly.</p><p>Ok, we need some code. A simple “pop calc” will do. I’ll leave taking this to a reverse shell up to the reader or refer to my previous blog post.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/0*MEsimvkiNDrFA2Ue" /></figure><p>Notice how I’ve added the Function call to this code. When we create our macro, it will look for a function call instead of a sub.</p><p>Now, save the module and exit the code editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/0*fWXZeHWNjNwa1coU" /></figure><p>With our module saved, we can create our macro to call the module. Open the Create ribbon and select Macro. Use the drop down box to select “Run Code” and point to your macro function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/0*eBvNz7Uxavtnc6zd" /></figure><p>Next, you should test your macro by clicking the Run menu option and Access will prompt you to save your macro. Be sure to save your macro as Autoexec<strong> </strong>if you want it to run automatically upon document open.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/0*dJxP4gLR_h-d27HP" /></figure><p>With our database complete, we can save the project. You’ll want to save in .accdb format first so you can modify your project later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/0*KcH9O92Z7qmRPoty" /></figure><p>Then, we’ll save our project again. This time, select the Make ACCDE option. This will create an “execute only” version of our database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/0*sOafDTyz4suHS6Lk" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*31-3MRVtV2qjwqks" /></figure><p>We could attach the ACCDE to an email or link to it if we want as our payload option when phishing. However, there’s more to this than sending the file. We can create our MAM shortcut that will link remotely to our ACCDE file and run the contents over the internet.</p><p>Make sure you have your ACCDE file open, left-click and drag the macro to your desktop. This will create your initial .MAM file that you can modify. Open it with your favorite editor or notepad to see what we can modify.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/77/0*HD2ZKqc7GD_9xQKZ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/0*XQFDrsuDAbDfYOc2" /></figure><p>As you can see, there’s not to much to the shortcut itself. We are mainly concerned with changing the DatabasePath variable as we will be hosting the execute only database remotely. With this variable, we have several options. We could host the ACCDE file over SMB or web. Hosting over SMB could serve dual purpose as we could capture credentials as well as long as port 445 is allowed out of your target network. In this blog post, I’ll be demonstrating how to do this over http. Lets host our ACCDE file remotely and modify our .MAM file.</p><h3>The Phish</h3><p>On a remote host, serve up the ACCDE file using your preferred web hosting method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/0*tPxgST_pislvMTqJ" /></figure><p>Edit the .MAM file to point to your ACCDE hosted on your web server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/433/0*pT9uoc9AWLWtamPL" /></figure><p>Now we are tasked with delivering our MAM payload to our target. Some providers block MAM files and Outlook does by default so, in this scenario we will send a phishing link to our target and will simply host our MAM file on our web server or you could do some funky redirects with Apache mod_rewrite as detailed <a href="https://bluescreenofjeff.com/2016-12-23-apache_mod_rewrite_grab_bag/">here</a> by <a href="https://twitter.com/bluscreenofjeff">@bluscreenofjeff</a>.</p><p>Once our user clicks our phishing link (using Edge Browser in this case) they are prompted to open or save the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZCQN8Ve8_8JH2rJR" /></figure><p>Next they are prompted to open the file again with a security warning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*mkbHr67nPF32n7dK" /></figure><p>Finally, the target user is prompted with the last security warning and your remote hosted IP address or domain name (hopefully convincing) is displayed to the user. The key point to note here is after this there is no macro or <a href="https://support.office.com/en-us/article/what-is-protected-view-d6f09ac7-e6b9-4495-8e43-2bbcdbcb6653">protected view</a> warning displayed or blocking this macro payload from running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/0*GdC88BxbdiMra-v5" /></figure><p>Once the user clicks Open, our code should run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EQPdwdmO-9nWA8Vm" /></figure><p>While there are several security prompts, we’re a little pretext and one unsuspecting user away from entering our target network.</p><h3>OPSEC</h3><p>This payload is nice for the fact that it’s a simple shortcut file and our payload can be invoked remotely. But, what artifacts are left after execution? Let’s check out the process and file system activity with procmon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/0*6bG2W1VN_UKX2Rif" /></figure><p>The first interesting entry is a “CreateFile” call that executes the command line seen in the picture above. Something for command line auditing to look for would be the “ShellOpenMacro” string.</p><p>Next, we observe the remote ACCDE file being saved and executed from our local machine. While it seems as though our payload is invoked remotely, it’s downloaded to “%APPDATA%\Local\Microsoft\Windows\INetCache\Content.MSO\95E62AFE.accde\PopCalc.accde”. For an offensive engagement, this file should be noted for cleanup.</p><p>0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/0*umOwr04AEThzixcT" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/0*ZLW0cCmsk9WWokCh" /></figure><h3>Mitigation</h3><p>In Microsoft Office 2016, you can enable the <a href="https://cloudblogs.microsoft.com/microsoftsecure/2016/03/22/new-feature-in-office-2016-can-block-macros-and-help-prevent-infection/">GPO</a> to block macro execution from the internet or set the following registry key for each office product.</p><p><strong>Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Access\Security\blockcontentexecutionfrominternet = 1</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*VIFHAFijZuzM3Q9x" /></figure><p>If a user is phished with this setting in place, they’ll be denied from executing the program. It should be noted that even though the macro is blocked, the MAM file still reaches out to pull down the Access file. So, there’s still an opportunity to know if your phish was received and executed or steal credentials via smb.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/0*jNCk4oCV17GnWTvx" /></figure><h3>Conclusion</h3><p>In this blog post I have walked you through the necessary steps to weaponize a Microsoft Access Macro shortcut to invoke a payload over HTTP. While this file type is commonly blocked by Microsoft Outlook, it is allowed in Gmail and may also be served via HTTP or SMB. I also showed you where to find artifacts and enable blocking of macros to prevent this type of attack.</p><p>It’s increasingly more important for defenders to be familiar with various phishing payloads and the artifacts they leave behind. I hope this post helps bring awareness about this specific attack vector and the Indicators of Compromise (IOC’s) associated with it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0bc3f90ed62" width="1" height="1" alt=""><hr><p><a href="https://medium.com/specter-ops-posts/phishing-tales-microsoft-access-macro-mam-shortcuts-c0bc3f90ed62">Phishing tales: Microsoft Access Macro (.MAM) shortcuts</a> was originally published in <a href="https://medium.com/specter-ops-posts">Posts By SpecterOps Team Members</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shelling Apache Felix With Java Bundles]]></title>
            <link>https://medium.com/specter-ops-posts/shelling-apache-felix-with-java-bundles-2450d3a099a?source=rss-ee138d3dc52f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2450d3a099a</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[red-teaming]]></category>
            <category><![CDATA[exploitation]]></category>
            <dc:creator><![CDATA[Steve Borosh]]></dc:creator>
            <pubDate>Wed, 20 Jun 2018 18:35:18 GMT</pubDate>
            <atom:updated>2018-06-20T18:35:18.031Z</atom:updated>
            <content:encoded><![CDATA[<p>Administrative portals remain one of the top “low hanging fruit” categories to be on the lookout for when performing bug bounties, penetration tests, or red teams. In this post, I will introduce you to another administrative portal that I believe may be quite overlooked.</p><p>On several bug hunts and penetration tests, I’ve encountered the Open Services Gateway (OSGi) console. What is OSGi? Think of it as a service handler for Java applications. Applications come in the form of bundles that can be deployed via the web interface. These applications can then be remotely installed, started, or stopped without requiring reboots of the web service itself.</p><p>OSGi consoles can come with many features, including a scripting console. I’ve covered abusing the OSGi scripting console in a previous <a href="https://www.google.com/url?q=https://medium.com/rvrsh3ll/leveraging-adobe-livecycle-202ce6772461&amp;sa=D&amp;ust=1529509008993000">post</a>. This post, however, will cover how to create and deploy a “malicious” bundle that we can invoke through the web interface. Let’s get started.</p><p>If you would like to setup your own test environment, I suggest following this great <a href="https://www.google.com/url?q=https://www.youtube.com/watch?v%3DKqhpgiFNQso&amp;sa=D&amp;ust=1529509008994000">tutorial</a>.</p><h3>Finding OSGi</h3><p>First, we need a console to target. If you’ve found something that looks like the console below, you’re on the right track.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/0*9UI76TOU2E13WjK-" /></figure><p>The OSGi console is typically located at /system/console. Though port 8080 is the default during install, the console may be hosted on other ports such as 80 and 443 commonly.</p><p>There are several methods I use when searching for this console. My favorite is the “<a href="https://www.google.com/url?q=https://raw.githubusercontent.com/rvrsh3ll/nmap/master/nselib/data/http-fingerprints.lua&amp;sa=D&amp;ust=1529509008995000">http-enum</a>” script with nmap. Just replace /usr/share/nmap/nselib/data/http-fingerprints.lua with the new version. Also, if you’re using PowerShell, you can try my <a href="https://www.google.com/url?q=https://github.com/rvrsh3ll/Misc-Powershell-Scripts/blob/master/Find-Fruit.ps1&amp;sa=D&amp;ust=1529509008995000">Find-Fruit</a> script, which is basically a simple threaded version of dirbuster for PowerShell.</p><p>As common with default installs, the username and password is admin:admin. Once logged in, you’ll be presented with the Apache Felix Web Console Bundles page as seen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*l0vtc8SEo80lmWi0" /></figure><p>This dashboard may look different on each install, depending on what bundles are installed. There’s not much to this dashboard and you can see how easy it is to install and start or stop a bundle. We’ll need to create a custom bundle to install via this web console.</p><h3>Creating and compiling a bundle</h3><p>Next, we’ll need the Felix framework in order to assist compiling our payload. You may download the latest Felix Framework Distribution and all required dependencies from <a href="https://www.google.com/url?q=http://felix.apache.org/downloads.cgi&amp;sa=D&amp;ust=1529509008996000">http://felix.apache.org/downloads.cgi</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*GemqDHwXSLb7TNoy" /></figure><p>I suggest creating a project folder to house your Felix Framework and other parts of your payload. For this exercise, let’s create a folder structure like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/0*tfMOtsB8gUhjLPWK" /></figure><p>The “lib” folder will contain “felix.jar”, which you should have in the bin/ directory after extracting the Felix Framework Distribution.</p><p>The “classes” folder will eventually contain your compiled class.</p><p>The “AFBundle” folder should contain the follow this structure unless you modify the manifest: “AFBundle/com/rvrsh3ll/osgi/shellme/Activator.java”</p><p>Activator.java is the main code that will run your payload on the remote system. Let’s take a look at that.</p><p>We could use something as simple as the exec function to execute a system command like so:</p><p>java.lang.Runtime.getRuntime().exec(“id”);</p><p>This does not handle errors well or operate very gracefully with the console. If your command is wrong or hangs, you’ll crash Apache Felix. In this instance, we’re going to use Java’s ProcessBuilder to execute a system command on the remote target in a stable manner. We want this code to tell that system to start a reverse shell with us and not crash the web console. I found <a href="https://gist.github.com/rvrsh3ll/e942a201a32b608bb90f7db1163fe29c">this</a> very handy Java reverse shell that I forked from <a href="https://www.google.com/url?q=https://gist.github.com/caseydunham&amp;sa=D&amp;ust=1529509008998000">caseydunham</a>, which does the trick very nicely. Of course, you could modify ProcessBuilder to execute whatever you like, but I highly suggest testing first.</p><p>So, we need a bundle template to get started. Fortunately, there’s not much to a basic bundle. We really only need three imports to get started.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9846fc298e24ae2b009ac9577c1b5d94/href">https://medium.com/media/9846fc298e24ae2b009ac9577c1b5d94/href</a></iframe><p>The first import should look familiar. It’s our directory structure we created earlier pointing to where this Activator.java file is. The next two imports are pretty simple. The <a href="https://www.google.com/url?q=https://osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleActivator.html&amp;sa=D&amp;ust=1529509008999000">BundleActivator</a> interface customizes the starting and stopping of bundles. The <a href="https://www.google.com/url?q=https://osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleContext.html&amp;sa=D&amp;ust=1529509008999000">BundleContext</a> interface allows the bundle to interact with the framework. That’s it! Now, we can modify this to handle our Java reverse shell rather easily.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26952028253872722ee9d0d39b2ab49d/href">https://medium.com/media/26952028253872722ee9d0d39b2ab49d/href</a></iframe><p>Now that that is done, we’ll need one more file that provides Felix the bundle details needed when we compile. This is our MANIFEST.MF file located in the root of your folder structure. If you’ve been following along that’s the AFBundle/MANIFEST.MF location.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/23008b87c56b210cf14215dd1eced22d/href">https://medium.com/media/23008b87c56b210cf14215dd1eced22d/href</a></iframe><p>The MANIFEST.MF file is rather simple. The most important two are the Import-Package instruction, which is a list of packages required by our bundle. This is simply the org.osgi.framework package for what we are doing. The Bundle-Activator contains the fully qualified name of our activator class. Again, in the form of our directory structure. For more information on what makes a bundle, <a href="https://www.google.com/url?q=http://spring.io/blog/2008/02/18/creating-osgi-bundles/&amp;sa=D&amp;ust=1529509009000000">readme</a>.</p><p>Now, we can build our bundle! Two easy compile commands is all that this process takes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb22b87aef6403d2d7627de59beb62cc/href">https://medium.com/media/fb22b87aef6403d2d7627de59beb62cc/href</a></iframe><h3>Deploying</h3><p>Now that our rvrsh3ll.jar file is complete, we can set up our listener and deploy the bundle. A simple netcat listener will do and it’s as easy as following the Install/Update button prompts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wCCY_HTQv8XsD7Nf" /></figure><h3>Wrapping Up</h3><p>That’s all there is to it! As always, management interfaces with default credentials remain one of the top dangers, both externally and internally, for organizations large or small. Simply changing the default password goes a long way in preventing this attack. Although, defenders should be aware that this portal has no lockout threshold or logging that I am aware of.</p><p>Administrative portals should be kept behind two-factor VPN’s when possible. For defenders, knowing what portals lurk on the Internet or even internally is crucial. Using these same tools, defenders can analyze their security posture for low hanging fruit and notify system owners of any unsecured administrative portals.</p><p>In this post, we’ve learned how to find the OSGi console, build and compile a bundle, and deploy it. I hope this blog post brings some awareness to another potentially dangerous interface if not secured correctly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2450d3a099a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/specter-ops-posts/shelling-apache-felix-with-java-bundles-2450d3a099a">Shelling Apache Felix With Java Bundles</a> was originally published in <a href="https://medium.com/specter-ops-posts">Posts By SpecterOps Team Members</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Phishing for “Access”]]></title>
            <link>https://medium.com/rvrsh3ll/phishing-for-access-554105b0901e?source=rss-ee138d3dc52f------2</link>
            <guid isPermaLink="false">https://medium.com/p/554105b0901e</guid>
            <category><![CDATA[phishing]]></category>
            <dc:creator><![CDATA[Steve Borosh]]></dc:creator>
            <pubDate>Sat, 02 Dec 2017 14:14:42 GMT</pubDate>
            <atom:updated>2018-04-11T22:34:21.683Z</atom:updated>
            <content:encoded><![CDATA[<h3>Changing Phishing Tactics Require Closer User and Defender Attention</h3><p>Steve Borosh</p><p>A few interesting and concerning phishing methods appeared this year. Just search Google for “DDE attack” or check out the <a href="https://github.com/InfoPhish/InfoPhish">InfoPath</a> payloads to see what I mean. It’s pretty cool stuff if you’re on the offensive side of the house, while giving those of us tasked with defense just one more thing to worry about.</p><p>This phishing buzz piqued my interest enough to search for more interesting payloads. I recently read Matt Nelson’s <a href="https://enigma0x3.net/2017/07/13/phishing-against-protected-view/">blog</a> on bypassing protected view and wondered if the same could be done elsewhere in Microsoft Office. Keeping the user to one-click code execution makes it even more challenging to defend against attacks through security awareness and best practices.</p><h4>Executable Database Approach</h4><p>After poking around a bit, I came to the always-delightful Microsoft Access. I started by looking at as the available “save as” filetypes, which brought me to this obvious option:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/0*iAK9am02-I_7Pn3n.png" /></figure><p>Those of us on offense like things that execute! But how does this file type differ from a standard database file? Maybe it has different security settings or options. Let’s find out!</p><p>First, I opened Microsoft Access 2016 and created a blank database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/0*4Bga265GEH23sUWY.png" /></figure><p>Next, I had to find a spot to place my Empire stager code. Microsoft Access macros are merely triggers that contain no code. The actual code to execute is stored in a module, <a href="https://www.techonthenet.com/access/modules/index.php">defined as</a> “a collection of user-defined functions, subroutines, and global variables written in VBA code. These objects can then be used/called from anywhere in your Access database.”</p><p>With my blank database open, I navigated to the “Create” tab and select “module” button next to the Macro button group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/160/0*F1EPDLQnRb8d3pdk.png" /></figure><p>This gave me a spot to place my code. For this demonstration, I used a standard <a href="https://github.com/EmpireProject/Empire">Empire </a>macro payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/0*VlxaW5GrJAxsFplX.png" /></figure><p>When I closed the new macro, I was prompted with the option to change the name of the module. Naming the module is important if you’re trying to further mask the suspiciousness of the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/0*7q4M_A64Y-9jYMM0.png" /></figure><p>With the stager placed in a module, my next step was to create the macro to trigger it. I started this by navigating to the “Create” tab and selecting the Macro button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/0*UwU00cZraF942DeS.png" /></figure><p>In here, I clicked the drop-down menu and selected “RunCode”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/0*8byjOqfZIN30YdBk.png" /></figure><p>This RunCode trigger requires a function name from your VBScript. It will handily auto-complete your function name. I chose to customize this in my VBScript and change the function name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/0*7YSN3AXtQswNo6oZ.png" /></figure><p>Again, when I closed my macro, I was prompted with the save as dialog box. I named it “autoexec.” This macro will run automatically when the recipient opens the document.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/315/0*3rala-n6_TFq_phP.png" /></figure><p>To make the document even more authentic, I modified the table names and put some enticing but fake data in there. Unfortunately for the target user, by the time they get to this screen, they’ve been infected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/0*RLaMhZHEmpYFHyWd.png" /></figure><p>To create the executable file, I saved the payload as a standard database file. Then, I navigated to the “Save As” menu option and selected “Make ACCDE.” This saved the database as a “locked-down” version of the original.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/0*MGT4DVaXGy0D-NyM.png" /></figure><p>This gave me two copies of the same file: A regular database file format and an “execute only” version of the same database. Both are loaded with the autoexec macro that triggers my VBScript, providing me with access to the target host. Here’s how the payloads look in action.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*grS0tn3oV3fJ66SE.gif" /></figure><p>Note the difference in security warnings between the two payloads. With the ACCDE format, we’re only one click away from code execution with no macro warnings — only a single warning about unsafe content.</p><p>PAGE_BREAK: PageBreak</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/0*VDsfpXcz97E0OSkQ.png" /></figure><p>When I uploaded the ACCDE format to virustotal.com, it received a perfect score.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/0*4liF_5UGZk0tqBlO.png" /></figure><p>Here we can see the process tree the agent is residing in. Note that Empire uses WMI to launch PowerShell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*M8PS3jMgyKxqubeH.png" /></figure><p>If I wanted to take this a step further, I could use the <a href="https://github.com/mdsecactivebreach/CACTUSTORCH">CACTUSTORCH </a>project to enhance the payload a bit. Instead of spawning powershell.exe, I could spawn another process and inject shellcode into it via the magic of <a href="https://github.com/tyranid/DotNetToJScript">DOTNETTOJSCRIPT</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/0*QHlN7oYiIq3LbrMq.gif" /></figure><p>Notice that the beacon payload in this instance is running in rundll32.exe.</p><h4><strong>Desired and Dangerous Results</strong></h4><p>I achieved my original goal of creating a phishing payload that requires only one click from the target user. I’ve also demonstrated the difference between our two weaponized file types. Containing a malicious macro and saved as a standard “.accdb” file, the document warns us that it contains macros. When saved as the “.accde” file format, the document does not warn the victim about its macro contents. Instead, they see one warning about unsafe content before the code executes.</p><p>Defending against phishing attacks is hard at best. Many defensive strategies rely heavily on the end user as the first line of defense. As we’ve seen, new phishing vectors continue to come to light frequently, making this a risky proposition.</p><p>In this case, monitoring or blocking inbound .accde files would be a good start for defenders. If you’ve implemented an endpoint solution to monitor Parent/Child process relationships, such as <a href="https://www.nuix.com/products/nuix-insight-adaptive-security">Nuix Adaptive Security</a>, you could monitor for Microsoft Office products spawning other processes such as powershell.exe and rundll32.exe. Remember to stay on top of new tactics used by attackers, and develop defensive methods to counter them accordingly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=554105b0901e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/rvrsh3ll/phishing-for-access-554105b0901e">Phishing for “Access”</a> was originally published in <a href="https://medium.com/rvrsh3ll">rvrsh3ll</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>