<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="https://aaroncf2008.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://aaroncf2008.github.io/" rel="alternate" type="text/html" /><updated>2021-11-28T23:03:01+00:00</updated><id>https://aaroncf2008.github.io/feed.xml</id><title type="html">Aaron’s Blog</title><subtitle>Jr. Software Engineer x Jr. Penetration Tester</subtitle><entry><title type="html">Road Writeup</title><link href="https://aaroncf2008.github.io/Road-Writeup/" rel="alternate" type="text/html" title="Road Writeup" /><published>2021-11-28T00:00:00+00:00</published><updated>2021-11-28T00:00:00+00:00</updated><id>https://aaroncf2008.github.io/Road-Writeup</id><content type="html" xml:base="https://aaroncf2008.github.io/Road-Writeup/">&lt;p&gt;The following writeup is for a room on TryHackMe that aims to be an ultra-realistic pentesting scenario. It is a basic machine and can be found &lt;a href=&quot;https://tryhackme.com/room/road&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To start this room, (any room really) we can begin by pinging the target to see if the machine is online. When we get packets back, we can move on. After checking if our target is online, we can run a quick nmap scan to see if any basic services are online. We can do that by running the command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nmap -sV -sC -T5 -oA initial-scan MACHINE-IP&lt;/code&gt;. 
&lt;img src=&quot;/images/road/nmapscan.png&quot; alt=&quot;NMAP Scan Results&quot; title=&quot;NMAP Scan Results&quot; /&gt;
From the results of our first scan we can see two services running, ssh on port 22 and a webserver on port 80. When we visit this web server we can see that it is a shipping / packaging company. To discover more about this site we can run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feroxbuster -u http://MACHINE-IP/ -t 600 -w /usr/share/seclists/Discovery/Web-Content/raft-large-directories.txt&lt;/code&gt;. This will find any unlisted directories or pages. As you can see the scan finds two things, “/v2/admin” and “/v2”. When we visit /v2 we are prompted with a login page. 
&lt;img src=&quot;/images/road/webserver.png&quot; alt=&quot;Webserver&quot; title=&quot;Webserver&quot; /&gt;
We can register our own account after hitting the register button and filling out info. Once we sign into our newly registered account we can see a user interface. There are two useful functions in this interface. They are “Reset User” and “Profile” (to reach the profile click on your username in the top corner and it will be in a dropdown menu). We can reset our password and capture the request using burp suite proxy. Forward the request to burp suite repeater and change the username to “admin@sky.thm”, the email found on the main page. This also happens to be the username of the administrator account on the website.
&lt;img src=&quot;/images/road/requestdata.png&quot; alt=&quot;Request Data&quot; title=&quot;Request Data&quot; /&gt;
When you send that edited request it will return a positive response. This means that there is no user validation and we can change the password and “hijack” any account we want. We can go back to the login page and sign into the admin account using the admin username and our specific password. When we go to the edit profile section we have the option to upload a file. We can upload any file we want due to no file filtering. I am using a reverse shell found &lt;a href=&quot;https://github.com/pentestmonkey/php-reverse-shell/blob/master/php-reverse-shell.php&quot;&gt;here&lt;/a&gt;. Specify your ip and listening port in the shell.
&lt;img src=&quot;/images/road/webserver.png&quot; alt=&quot;Webserver&quot; title=&quot;Webserver&quot; /&gt;
We can see where they store the profile picture files in an html comment (/v2/profileimages).
Now we can run a netcat listener using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nc -lvnp PORT&lt;/code&gt;. Then we can visit the url “http://MACHINE-IP/v2/profileimages/yourfilename.php”. You should see a shell pop up in your listener. We can get our user flag by running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat /home/webdeveloper/user.txt&lt;/code&gt;.
&lt;img src=&quot;/images/road/usershell.png&quot; alt=&quot;User Shell&quot; title=&quot;User Shell&quot; /&gt;
The user webdeveloper has sudo rights and can help us escalate our privileges so it would be useful to gain access to them. There are mysql and mongod servers running. We can use the command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mongo&lt;/code&gt; to access the mongo shell. We can then list the databases using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show dbs&lt;/code&gt;. Then access the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;backup&lt;/code&gt; database using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;use backup&lt;/code&gt;. We can check the collections in this database using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;show collections&lt;/code&gt;, there are “user” and “collection”. We can check the credentials / data in the “user” collection using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;db.user.find()&lt;/code&gt;. Now that we have the “webdeveloper” user’s credentials we can ssh over to the machine using those credentials. 
&lt;img src=&quot;/images/road/ssh.png&quot; alt=&quot;SSH&quot; title=&quot;SSH&quot; /&gt;
We now have sudo access, when running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo -l&lt;/code&gt; we can see we have permissions to run “/usr/bin/sky_backup_utility” without a password, this won’t do us any good though. We can use our sudo permissions to run pkexec. Pkexec is a program that lets you run commands as other users, in this case we want to run commands as root. We can use this to our advantage. There is a common known issue where when trying to use the command, an error pops up saying “pkexec fails in a non-graphical environment”, more information can be found &lt;a href=&quot;https://bugs.launchpad.net/ubuntu/+source/policykit-1/+bug/1821415&quot;&gt;here&lt;/a&gt;. To solve this we need to open up another SSH connection and run some commands on it. Connect on your 2nd ssh connection and on your first shell run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;echo $$&lt;/code&gt;, you will need this soon. Then run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pkttyagent -p PID&lt;/code&gt;, the PID is the result of your first command. Then run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pkexec /bin/bash&lt;/code&gt; on your first shell, enter the webdeveloper user’s password on your second shell. Now you should have root on your first shell. Use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat /root/root.txt&lt;/code&gt; to get your root flag.
&lt;img src=&quot;/images/road/shell1.png&quot; alt=&quot;First Shell&quot; title=&quot;Shell 1&quot; /&gt; &lt;img src=&quot;/images/road/shell2.png&quot; alt=&quot;Second Shell&quot; title=&quot;Second Shell&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We were able to get root on this machine and complete the room. Thank you for reading my writeup, there will be many more to come. Until next time.&lt;/p&gt;</content><author><name></name></author><summary type="html">The following writeup is for a room on TryHackMe that aims to be an ultra-realistic pentesting scenario. It is a basic machine and can be found here.</summary></entry><entry><title type="html">My First Post</title><link href="https://aaroncf2008.github.io/My-First-Post/" rel="alternate" type="text/html" title="My First Post" /><published>2021-11-21T00:00:00+00:00</published><updated>2021-11-21T00:00:00+00:00</updated><id>https://aaroncf2008.github.io/My%20First%20Post</id><content type="html" xml:base="https://aaroncf2008.github.io/My-First-Post/">&lt;p&gt;This is my first post on my blog!&lt;/p&gt;

&lt;p&gt;It was very quick to make and there is a lot more content to come on this blog!&lt;/p&gt;

&lt;p&gt;The easiest way to set up a blog is to use the &lt;a href=&quot;https://github.com/barryclark/jekyll-now&quot;&gt;Jekyll Now repository&lt;/a&gt; found on GitHub.&lt;/p&gt;

&lt;p&gt;Thanks for reading my first post!&lt;/p&gt;</content><author><name></name></author><summary type="html">This is my first post on my blog!</summary></entry></feed>