<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="4.2.2">Jekyll</generator><link href="https://disrel.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://disrel.com/" rel="alternate" type="text/html" /><updated>2022-10-24T11:28:28-04:00</updated><id>https://disrel.com/feed.xml</id><title type="html">Tech Froggo’s Rants</title><author><name>Nat</name><email>nathan@disrel.com</email></author><entry><title type="html">Ring0VBA - Getting Ring0 Using a Goddamn Word Document</title><link href="https://disrel.com/posts/Ring0VBA-Getting-Ring0-Using-a-Goddamn-Word-Document/" rel="alternate" type="text/html" title="Ring0VBA - Getting Ring0 Using a Goddamn Word Document" /><published>2022-10-24T00:00:00-04:00</published><updated>2022-10-24T00:00:00-04:00</updated><id>https://disrel.com/posts/Ring0VBA-Getting-Ring0-Using-a-Goddamn-Word-Document</id><content type="html" xml:base="https://disrel.com/posts/Ring0VBA-Getting-Ring0-Using-a-Goddamn-Word-Document/"><![CDATA[<blockquote class="twitter-tweet"><p lang="en" dir="ltr">Look at this and tell me you still believe in a God</p>&mdash; vx-underground (@vxunderground) <a href="https://twitter.com/vxunderground/status/1544640762834522112?ref_src=twsrc%5Etfw">July 6, 2022</a></blockquote>
<script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

<h2 id="what">What?</h2>
<p>Yeah you saw that right. Reaching Ring0 with a word document.</p>

<h2 id="when">When?</h2>
<p>Back in June 2022, while discussing Lockbit 3.0’s utilization of <code class="language-plaintext highlighter-rouge">DeviceIoControl</code> with smelly from VX-Underground, I had an idea - what if somebody exploited drivers using VBA Macros? He thought it was a cool idea and wanted a paper on it, so I accepted it as a challenge.
<img src="/assets/images/Discord_EeGUBX4EMr.png" alt="Challenge Accepted" /></p>

<h2 id="why">Why?</h2>
<p>Because why not? This is just a god-tier shitpost that I made in 10 days LOL</p>

<p>Okay okay here’s the actual reason. I wanted to demonstrate how devastating VBA can be when it comes down to offensive operations. But to tackle this challenge, I also had to learn how driver exploitation on Windows worked. This was a perfect opportunity to make something and learn about it in the process!
VBA comes default installed with any Office application, and it has the capabilities to call the Windows API. So calling <code class="language-plaintext highlighter-rouge">DeviceIoControl</code> should be easy, right?</p>

<p><strong>Turns out, yes.</strong></p>

<h2 id="how">How?</h2>
<p>If you want a TL;DR - I basically ported <a href="https://github.com/SouhailHammou/Exploits/blob/master/CVE-2018-6606%20-%20MalwareFox%20AntiMalware%20LPE/Malwarefox_privescl_1.c">CVE-2018-6606</a> to VBA.</p>

<p>But here’s my process :P</p>

<h3 id="environment">Environment</h3>
<ul>
  <li>Windows 10 21H2 (64-Bit)</li>
  <li>Microsoft Office Professional Plus 2019 (64-bit)
The VBA Macro only works on 64-bit Office, as using 32-bit Office would involve using Heaven’s Gate, to escape WOW64.
Heaven’s Gate in VBA? Sounds interesting ;)</li>
</ul>

<h3 id="selecting-the-driver">Selecting the Driver</h3>
<p>As a person who is novice to the driver exploitation scene, I was in a search for a driver which is very-easy to exploit. While on the search, I encountered Souhail Hammou’s really well written <a href="http://rce4fun.blogspot.com/2018/02/malwarefox-antimalware-zam64sys.html">blogpost</a> about how he exploited MalwareFox AntiMalware’s driver (zam64.sys) to escalate privileges.</p>

<h3 id="exploiting-the-driver">Exploiting the Driver</h3>
<p>I would recommend reading the blogpost, but here is the gist of it.</p>
<ul>
  <li>The driver has a IOCTL call which can register a process as trusted by the driver.</li>
  <li>Then we use a special IOCTL call which is only accessible by a driver-trusted process.</li>
  <li>The call helps us to get a full access user-mode handle from the kernel.</li>
</ul>

<h3 id="visual-basic-for-applications-memery">Visual Basic for <del>Applications</del> Memery</h3>
<p><a href="https://github.com/DISREL/Ring0VBA">Here</a> is the VBA Macro. Quick rundown of what the code does:</p>
<ol>
  <li>Creates a handle for the driver, so we can issue IOCTL calls</li>
  <li>Use IOCTL call 0x80002010 to register the <code class="language-plaintext highlighter-rouge">word.exe</code> process with the driver</li>
  <li>Get the PID for winlogon.exe</li>
  <li>Use the IOCTL call 0x8000204c to get a full access handle on winlogon.exe</li>
  <li>Allocate memory in the process and write shellcode to the memory</li>
  <li>Create a remote thread using the written memory</li>
</ol>

<p>The code is pretty self explanatory and can be easily read. Although I would recommend reading about <a href="https://learn.microsoft.com/en-us/office/vba/language/concepts/getting-started/64-bit-visual-basic-for-applications-overview">“64-bit VBA Overview”</a> to understand the extended datatypes and how it differs from 32-bit VBA.</p>

<p>Here are some things to note:</p>
<ul>
  <li>In VBA, you can import functions from DLLs using <code class="language-plaintext highlighter-rouge">Private Declare PtrSafe Function &lt;Function&gt; Lib "&lt;DLL&gt;"</code>. The <code class="language-plaintext highlighter-rouge">PtrSafe</code> is important as we are dealing with 64-bit Office. Mentalis.org’s <a href="http://allapi.mentalis.org/apilist/apilist.php">Apilist</a> has example function imports for reference.</li>
  <li>To make structures in VBA, we use <code class="language-plaintext highlighter-rouge">Type</code>. Using that we make structures for <a href="https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa379560(v=vs.85)">SECURITY_ATTRIBUTES</a> and <a href="https://learn.microsoft.com/en-us/windows/win32/api/tlhelp32/ns-tlhelp32-processentry32">PROCESSENTRY32</a>. These structures are essential for making sure that the Windows API functions are called properly and essential data is stored properly.</li>
</ul>

<h1 id="conclusion">Conclusion</h1>
<p>As smelly from VX-Undeground said, <em>“Look at this and tell me you still believe in a God”</em>.</p>

<p>This was a very fun project and I learned a lot about driver exploitation and how the Windows API worked. I would like to thank <a href="https://twitter.com/Coldzer0x0">Coldzer0</a> and <a href="https://twitter.com/kasua02">kasua</a> for their encouragement and help.</p>

<p>Also thanks to <a href="https://twitter.com/ShitSecure">ShitSecure</a> for their fabulous repo <a href="https://github.com/S3cur3Th1sSh1t/OffensiveVBA">OffensiveVBA</a>. Helped me figure out how to work with <code class="language-plaintext highlighter-rouge">CreateToolhelp32Snapshot</code> in VBA.</p>]]></content><author><name>Nat</name><email>nathan@disrel.com</email></author><category term="research" /><category term="vba" /><category term="driver-exploitation" /><summary type="html"><![CDATA[Look at this and tell me you still believe in a God&mdash; vx-underground (@vxunderground) July 6, 2022]]></summary></entry><entry><title type="html">Sonorous Warcry of a Very Angry Frog</title><link href="https://disrel.com/posts/Sonorous-Warcry-of-a-Very-Angry-Frog/" rel="alternate" type="text/html" title="Sonorous Warcry of a Very Angry Frog" /><published>2022-07-09T00:00:00-04:00</published><updated>2022-07-09T00:00:00-04:00</updated><id>https://disrel.com/posts/Sonorous-Warcry-of-a-Very-Angry-Frog</id><content type="html" xml:base="https://disrel.com/posts/Sonorous-Warcry-of-a-Very-Angry-Frog/"><![CDATA[<p>Welcome to my blog, young frogawan…</p>

<p><em>Get it? Frog Padawan? Haha.. I’ll see myself out.</em></p>

<p>Blog posts incoming soon, for now here’s the sonorous warcry of a very angry frog.</p>

<iframe src="https://www.youtube.com/embed/HBxn56l9WcU" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe>]]></content><author><name>Nat</name><email>nathan@disrel.com</email></author><category term="frogpost" /><category term="wednesday" /><category term="bruh moment" /><summary type="html"><![CDATA[Welcome to my blog, young frogawan…]]></summary></entry></feed>