{"id":294,"date":"2023-04-22T15:39:52","date_gmt":"2023-04-22T20:39:52","guid":{"rendered":"https:\/\/binaryblisters.com\/?p=294"},"modified":"2023-04-22T15:39:52","modified_gmt":"2023-04-22T20:39:52","slug":"try-hack-me-simple-ctf","status":"publish","type":"post","link":"https:\/\/binaryblisters.com\/?p=294","title":{"rendered":"Try Hack Me &#8211; Simple CTF"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"263\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-62-1024x263.png\" alt=\"\" class=\"wp-image-295\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-62-1024x263.png 1024w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-62-300x77.png 300w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-62-768x197.png 768w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-62.png 1399w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This CTF was a pretty good one that I ended up solving in a different means other than what I believe the creator intended. I&#8217;ll go into more detail on that later but as always, if you want to see my original notes from the lab go <a href=\"https:\/\/sgtdiddlywink.gitbook.io\/thm\/\">here<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Task 1: How many services are running under port 1000?<\/h2>\n\n\n\n<p>This was a pretty quick one as all you need to do is run a simple <strong>NMAP<\/strong> scan. Running NMAP with no flags will go through the most common ports, which include ports less than 1000.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nmap &#91;TARGET IP]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"934\" height=\"380\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-63.png\" alt=\"\" class=\"wp-image-296\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-63.png 934w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-63-300x122.png 300w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-63-768x312.png 768w\" sizes=\"auto, (max-width: 934px) 100vw, 934px\" \/><\/figure>\n\n\n\n<p>This shows that both FTP and HTTP are running. There is also another service running on Port 2222.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Task 2: What is running on the higher port?<\/h2>\n\n\n\n<p>It appears that a service called <strong>EtherNetIP-1<\/strong> is running on Port 2222. However, let&#8217;s see if we can see some more information on it with a more detailed NMAP scan.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nmap -sV -sC &#91;TARGET IP]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"890\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-64-1024x890.png\" alt=\"\" class=\"wp-image-297\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-64-1024x890.png 1024w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-64-300x261.png 300w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-64-768x668.png 768w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-64.png 1370w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This gave us a lot of good information on the services being run but the important thing to note is the Service being run on Port 2222 is a typical one found on Port 22.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Task 3: What&#8217;s the CVE you&#8217;re using against the application?<\/h2>\n\n\n\n<p>Tasks 3 and 4 took me quite some time to figure out and I actually ended up looking at another person&#8217;s <a href=\"https:\/\/kartibok.github.io\/Capture-the-Flag\/tryhackme\/simpleCTF.html\">write-up<\/a> for a clue. I was actually able to get root privileges another way that didn&#8217;t require this, which is why it took me a bit of time. I&#8217;ll give you a brief overview of how to answer this question.<\/p>\n\n\n\n<p>Since we can see that Port 80 is open from the NMAP scan, that means there is a pretty good chance that a web server is currently being run. Visiting the page shows us that there is a default Apache web server running.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-65-1024x1021.png\" alt=\"\" class=\"wp-image-298\" width=\"460\" height=\"458\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-65-1024x1021.png 1024w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-65-300x300.png 300w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-65-150x150.png 150w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-65-768x766.png 768w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-65.png 1131w\" sizes=\"auto, (max-width: 460px) 100vw, 460px\" \/><\/figure><\/div>\n\n\n<p>Performing some enumeration with <strong>Gobuster<\/strong> will show a few other directories available, including one for a standard CMS login page using the <strong>\/admin<\/strong> directory. I&#8217;m not going to go into too much detail here as I did not go down this route to get credentials but you&#8217;ll need to do this to answer the question.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"458\" height=\"338\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-66.png\" alt=\"\" class=\"wp-image-299\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-66.png 458w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-66-300x221.png 300w\" sizes=\"auto, (max-width: 458px) 100vw, 458px\" \/><\/figure><\/div>\n\n\n<p>On the page, you&#8217;ll see that the application is running CMS Made Simple Ver. 2.2.8. We can take this and run a quick Google search to see what possible vulnerabilities exist. Checking out the link for <a href=\"https:\/\/www.exploit-db.com\/exploits\/46635\">Exploit DB<\/a> will give us a pretty clean means of exploiting a vulnerability for the application.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"220\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-67-1024x220.png\" alt=\"\" class=\"wp-image-300\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-67-1024x220.png 1024w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-67-300x64.png 300w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-67-768x165.png 768w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-67-1536x330.png 1536w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-67.png 1844w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>It will also give us the answer to this task.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Task 4: What kind of vulnerability is the application vulnerable to?<\/h2>\n\n\n\n<p>Looking at the Exploit shown above will also give us the answer for this task.<\/p>\n\n\n\n<p>I&#8217;ll go into a bit more detail here but it&#8217;s not the path I took to gain root access. To further pursue this exploit, you&#8217;ll need to grab the script included with this exploit and run it against the <strong>URL\/admin<\/strong> page.<\/p>\n\n\n\n<p>This will produce a hashed and salted password. After gaining this, you can use a tool like <strong>Hashcat<\/strong> to crack it and gain credentials for one of the users.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Task 5 What&#8217;s the password?<\/h2>\n\n\n\n<p>The means I took were a bit different. I decided to explore some other routes prior to running Gobuster.<\/p>\n\n\n\n<p>During the more detailed NMAP scan, I noticed that Port 21 had anonymous login available so I started there.<\/p>\n\n\n\n<p>On my host machine, I logged into the FTP account for the target machine.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ftp &#91;TARGET IP]<\/code><\/pre>\n\n\n\n<p>Using the username <strong>anonymous<\/strong> will allow us to log in as a guest. If we list out the contents of the directory available to us, we will find a file in there called <strong>ForMitch.txt<\/strong>. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"994\" height=\"190\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-68.png\" alt=\"\" class=\"wp-image-301\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-68.png 994w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-68-300x57.png 300w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-68-768x147.png 768w\" sizes=\"auto, (max-width: 994px) 100vw, 994px\" \/><\/figure>\n\n\n\n<p>We can use the following command to download the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>get ForMitch.txt<\/code><\/pre>\n\n\n\n<p>After we have downloaded the file to our host machine, we can use <strong>cat<\/strong> to view the contents.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat ForMitch.txt<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"49\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-69-1024x49.png\" alt=\"\" class=\"wp-image-302\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-69-1024x49.png 1024w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-69-300x14.png 300w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-69-768x37.png 768w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-69-1536x73.png 1536w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-69-2048x98.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We learn two things from this file. <\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>There is most likely a user named <strong>mitch<\/strong>.<\/li>\n\n\n\n<li>That user has weak credentials.<\/li>\n<\/ol>\n\n\n\n<p>Now that we have a possible username and know the password is probably something fairly weak, let&#8217;s do a brute-force attack on the SSH server running on Port 2222. In this instance, we&#8217;ll use one of my favorite tools, <strong>Hydra<\/strong>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hydra -V -l mitch -P &#91;PATH TO WORDLIST] ssh:\/\/&#91;TARGET IP]:2222<\/code><\/pre>\n\n\n\n<p>Remember to specify the port in this case since the SSH server isn&#8217;t running on the typical Port 22.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"95\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-70-1024x95.png\" alt=\"\" class=\"wp-image-303\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-70-1024x95.png 1024w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-70-300x28.png 300w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-70-768x71.png 768w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-70.png 1193w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>It looks like we now have credentials for the user <strong>mitch<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Task 6: Where can you log in with the details obtained?<\/h2>\n\n\n\n<p>Since we just ran the Hydra attack on Port 2222. We already know what service is running on that port.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Task 7: What&#8217;s the user&#8217;s flag?<\/h2>\n\n\n\n<p>Now that we have credentials for <strong>mitch<\/strong>, let&#8217;s login through SSH to their account.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh -p 2222 mitch@&#91;TARGET IP]<\/code><\/pre>\n\n\n\n<p>Similar to the Hydra attack, we need to specify the port in this instance since it is not on the standard port of 22.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"467\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-71-1024x467.png\" alt=\"\" class=\"wp-image-304\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-71-1024x467.png 1024w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-71-300x137.png 300w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-71-768x350.png 768w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-71.png 1312w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Once we are logged into the user&#8217;s account we can find the <strong>user.txt<\/strong> file in the home directory for <strong>mitch<\/strong>. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/home\/mitch\/user.txt<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Task 8: Is there any other user in the home directory? What&#8217;s its name?<\/h2>\n\n\n\n<p>This one should be pretty easy as well since we are logged into the target machine. We can check the <strong>\/home<\/strong> directory for other possible users. We could also check the <strong>\/etc\/passwd<\/strong> file to see what other users are on the system since. This won&#8217;t always be possible but in this case <strong>mitch<\/strong> has read access to the file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -l \/home<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/etc\/passwd<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Task 9: What can you leverage to spawn a privileged shell?<\/h2>\n\n\n\n<p>While logged into the <strong>mitch<\/strong> account, you can run the <strong>sudo<\/strong> command to see what privileges they have.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -l<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"784\" height=\"210\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-72.png\" alt=\"\" class=\"wp-image-305\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-72.png 784w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-72-300x80.png 300w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-72-768x206.png 768w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/figure><\/div>\n\n\n<p>This is great information as it shows a possible route to privilege escalation in the machine and also the answer to this task.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Task 10: What&#8217;s the root flag?<\/h2>\n\n\n\n<p>Now that we know what program we have <strong>sudo<\/strong> privileges to, we can search for possible means to escalate those privileges to the entire machine. Let&#8217;s start by visiting <a href=\"https:\/\/gtfobins.github.io\/gtfobins\/vim\/#sudo\">GTFOBins<\/a> and looking for possible avenues of attack for <strong>vim<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"189\" src=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-73-1024x189.png\" alt=\"\" class=\"wp-image-306\" srcset=\"https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-73-1024x189.png 1024w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-73-300x55.png 300w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-73-768x142.png 768w, https:\/\/binaryblisters.com\/wp-content\/uploads\/2023\/04\/image-73.png 1181w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>It looks like there are a few options but let&#8217;s start with the first. Copy and paste that into your SSH session with the target machine.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vim -c ':!\/bin\/sh'<\/code><\/pre>\n\n\n\n<p>You should now have root privileges for the entire machine. Navigate over to the root directory for the flag.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vim -c ':!\/bin\/sh'<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>This machine frustrated me for a while. Mainly because I had obtained the root flag but still couldn&#8217;t answer the questions to Task 3 and 4. I actually dug through the <strong>\/var\/www\/html<\/strong> directory once I had access to the system but dismissed further enumerating. <\/p>\n\n\n\n<p>Lesson learned.<\/p>\n\n\n\n<p>However, it was still pretty neat to see multiple ways into this system. I <a href=\"https:\/\/www.twitch.tv\/videos\/1800636627\">streamed<\/a> this hack if you are interested in watching me work through it.<\/p>\n\n\n\n<p>As always, thanks for reading and catch you all later.<\/p>\n\n\n\n<p>-sgtdiddlywink<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This CTF was a pretty good one that I ended up solving in a different means other than what I believe the creator intended. I&#8217;ll go into more detail on that later but as always, if you want to see my original notes from the lab go here. Task 1: How many services are running [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":307,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48,49],"tags":[18,28,51,66],"class_list":["post-294","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hacking","category-thm","tag-hacking","tag-studying","tag-thm","tag-try-hack-me"],"_links":{"self":[{"href":"https:\/\/binaryblisters.com\/index.php?rest_route=\/wp\/v2\/posts\/294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/binaryblisters.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/binaryblisters.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/binaryblisters.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/binaryblisters.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=294"}],"version-history":[{"count":1,"href":"https:\/\/binaryblisters.com\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions"}],"predecessor-version":[{"id":308,"href":"https:\/\/binaryblisters.com\/index.php?rest_route=\/wp\/v2\/posts\/294\/revisions\/308"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/binaryblisters.com\/index.php?rest_route=\/wp\/v2\/media\/307"}],"wp:attachment":[{"href":"https:\/\/binaryblisters.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/binaryblisters.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/binaryblisters.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}