{"id":489,"date":"2024-09-28T20:29:31","date_gmt":"2024-09-28T20:29:31","guid":{"rendered":"https:\/\/infosecjake.net\/?p=489"},"modified":"2025-02-05T02:32:02","modified_gmt":"2025-02-05T02:32:02","slug":"hackthebox-permx-walkthrough","status":"publish","type":"post","link":"https:\/\/infosecjake.net\/?p=489","title":{"rendered":"HackTheBox &#8211; PermX Walkthrough"},"content":{"rendered":"\n<p>Hey everyone, it&#8217;s been a minute since I&#8217;ve dropped a walkthrough. Life has kept me busy lately and I just haven&#8217;t had the time to do one. Additionally, I have started to focus more on HackTheBox machines than TryHackMe. I would encourage either, for those interested. However, HTB does tend to be a little more difficult with less guidance. HackTheBox does have some helpful information on their VPN system that you will need to use to work on these machines.<\/p>\n\n\n\n<p>Today, we are doing an easy machine called PermX.<\/p>\n\n\n\n<p>Without further ado, let&#8217;s get to it!<\/p>\n\n\n\n<p>As usual, we will kick off with a port scan.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"492\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image.png\" alt=\"Port scan\" class=\"wp-image-490\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-300x151.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-768x388.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>Port scan shows that we have SSH open and HTTP on port 80. As is typical with these HTB boxes, it\u2019s a bit apparent that our avenue into the box will have to do with the http service on port 80. So, let\u2019s take a look at that.<\/p>\n\n\n\n<p>First, we want to add this IP\/hostname to our hosts file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"659\" height=\"309\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-1.png\" alt=\"Adding host to hosts file\" class=\"wp-image-491\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-1.png 659w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-1-300x141.png 300w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/figure>\n\n\n\n<p>Which reminds me that I need to clean up my hosts file from previous boxes \ud83d\ude0a.<\/p>\n\n\n\n<p>Now, we can navigate to the site. Here\u2019s what we get.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"458\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-2.png\" alt=\"permx site\" class=\"wp-image-492\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-2.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-2-300x141.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-2-768x361.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>After some quick site browsing, I\u2019m not seeing anything that stands out just yet. So, let\u2019s do some directory browsing with dirb.<\/p>\n\n\n\n<p>Not much from dirb, not seeing anything in these directories that sticks out.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"380\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-3.png\" alt=\"Dirb results\" class=\"wp-image-493\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-3.png 700w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-3-300x163.png 300w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/figure>\n\n\n\n<p>Dirb is decent but not the best at finding things, so let\u2019s use ffuf.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"567\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-4.png\" alt=\"ffuf results\" class=\"wp-image-494\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-4.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-4-300x174.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-4-768x447.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>Now, we have found a couple subdomains for the site. First thing, we gotta add these to our \/etc\/hosts file as well.<\/p>\n\n\n\n<p>After that, let\u2019s look at them.<\/p>\n\n\n\n<p>Navigating to lms.permx.htb gets us a login page to Chamilo.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"831\" height=\"716\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-5.png\" alt=\"Chamilo LMS\" class=\"wp-image-495\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-5.png 831w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-5-300x258.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-5-768x662.png 768w\" sizes=\"auto, (max-width: 831px) 100vw, 831px\" \/><\/figure>\n\n\n\n<p>After doing some quick searching for Chamilo vulnerabilities I found that it has a file upload RCE vulnerability for <strong>CVE-2023-4220<\/strong>. After further research, it does appear that there are POC exploits and a manual exploit listed here: <a href=\"https:\/\/starlabs.sg\/advisories\/23\/23-4220\/\">https:\/\/starlabs.sg\/advisories\/23\/23-4220\/<\/a><\/p>\n\n\n\n<p>I first started off with attempting the manual exploit, I was able to get the \u2018id\u2019 command to work, so I know it does work. However, I found a nifty script that seems to do it all. That script is here: <a href=\"https:\/\/github.com\/m3m0o\/chamilo-lms-unauthenticated-big-upload-rce-poc\">https:\/\/github.com\/m3m0o\/chamilo-lms-unauthenticated-big-upload-rce-poc<\/a><br><br>Following the documentation, I ran the main.py script with the \u2018-a scan\u2019 flag, then the \u2018-a webshell\u2019 flag, and finally with the \u2018-a revshell\u2019 flag. Of course, I had my netcat listener running. Finally, we have a reverse shell.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"206\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-6.png\" alt=\"Reverse shell\" class=\"wp-image-496\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-6.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-6-300x63.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-6-768x162.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>Next, let\u2019s look around and see what we can find\u2026and then elevate privileges.<\/p>\n\n\n\n<p>When in doubt\u2026.linpeas it out?<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"313\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-7.png\" alt=\"launch linpeas\" class=\"wp-image-497\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-7.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-7-300x96.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-7-768x247.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"719\" height=\"281\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-8.png\" alt=\"finding a password\" class=\"wp-image-498\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-8.png 719w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-8-300x117.png 300w\" sizes=\"auto, (max-width: 719px) 100vw, 719px\" \/><\/figure>\n\n\n\n<p>After a bit of searching through the results, I noticed that I was able to find a password. A little more searching and I noticed a user named \u2018mtz\u2019 and a \/home directory for mtz. So\u2026taking a long shot. I tried to SSH into the box with the username mtz and password I found in linpeas.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"226\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-9.png\" alt=\"SSH login\" class=\"wp-image-499\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-9.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-9-300x70.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-9-768x178.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>Well then, I was not expecting that to be the correct password. However, here we are!<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"453\" height=\"141\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-10.png\" alt=\"user flag\" class=\"wp-image-500\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-10.png 453w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-10-300x93.png 300w\" sizes=\"auto, (max-width: 453px) 100vw, 453px\" \/><\/figure>\n\n\n\n<p>User flag captured!<\/p>\n\n\n\n<p>I once again ran linpeas and found the below that stuck out to me.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"177\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-11.png\" alt=\"acl.sh finding\" class=\"wp-image-501\" style=\"width:880px;height:auto\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-11.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-11-300x54.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-11-768x139.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>A quick look at acl.sh and this looks pretty interesting. I\u2019m thinking that this is the way to root.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"927\" height=\"616\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-12.png\" alt=\"acl.sh code\" class=\"wp-image-502\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-12.png 927w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-12-300x199.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-12-768x510.png 768w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-12-507x338.png 507w\" sizes=\"auto, (max-width: 927px) 100vw, 927px\" \/><\/figure>\n\n\n\n<p>I\u2019m not familiar with this but after some more googling fun, it looks like this will allow me to change permissions on any file for any user as long as it\u2019s in mtz\u2019s home directory. Now, my first question was \u201cwell how would I do that when I know it wont let me move a \u2018root\u2019 owned file?\u201d. Well, after a bit MORE research, I dug into \u2018smlink\u2019. This provides a way to create references or pointers to files or directories. So, I could have a \u2018shortcut\u2019, in essence, in mtz\u2019s directory that links to another file somewhere else. Symlinks are \u2018symbolic links\u2019 and that is exactly what they do. Having never used a symbolic link for privilege escalation, this would be interesting.<\/p>\n\n\n\n<p>Onwards we go.<\/p>\n\n\n\n<p>After much toiling\u2026.we created a symlink to \/etc\/passwd<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"694\" height=\"108\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-13.png\" alt=\"Creating symlink to \/etc\/passwd\" class=\"wp-image-503\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-13.png 694w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-13-300x47.png 300w\" sizes=\"auto, (max-width: 694px) 100vw, 694px\" \/><\/figure>\n\n\n\n<p>Now, we can see \/etc\/passwd. How to change the root password?<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"403\" height=\"53\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-14.png\" alt=\"\/etc\/passwd\" class=\"wp-image-504\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-14.png 403w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-14-300x39.png 300w\" sizes=\"auto, (max-width: 403px) 100vw, 403px\" \/><\/figure>\n\n\n\n<p>Currently we see that it is set, indicated by the x.<\/p>\n\n\n\n<p>Well, what if instead of the passwd file, we create a link to \/etc\/shadow? Well, I tried this and it was encrypted with yescrypt and I could not find an easy way to decrypt the root password. If you can, I\u2019d like to hear how you did it!<\/p>\n\n\n\n<p>So, back to the \/etc\/passwd file instead. Since we know that probably can\u2019t decrypt the password, what if we either clear the password or even create a new root user?<\/p>\n\n\n\n<p>Let\u2019s try the latter option\u2026<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"827\" height=\"33\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-15.png\" alt=\"creating root2\" class=\"wp-image-505\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-15.png 827w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-15-300x12.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-15-768x31.png 768w\" sizes=\"auto, (max-width: 827px) 100vw, 827px\" \/><\/figure>\n\n\n\n<p>Created a new root user in the file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"445\" height=\"27\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-16.png\" alt=\"root2 created\" class=\"wp-image-506\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-16.png 445w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-16-300x18.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-16-440x27.png 440w\" sizes=\"auto, (max-width: 445px) 100vw, 445px\" \/><\/figure>\n\n\n\n<p>Validated that it is there. Now to switch over to root2.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"305\" height=\"66\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-17.png\" alt=\"Changing user to root2\" class=\"wp-image-507\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-17.png 305w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-17-300x65.png 300w\" sizes=\"auto, (max-width: 305px) 100vw, 305px\" \/><\/figure>\n\n\n\n<p>Voila!<\/p>\n\n\n\n<p>We now have root access.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"428\" height=\"127\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-18.png\" alt=\"root flag\" class=\"wp-image-508\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-18.png 428w, https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-18-300x89.png 300w\" sizes=\"auto, (max-width: 428px) 100vw, 428px\" \/><\/figure>\n\n\n\n<p>And there we go! Root flag captured!<\/p>\n\n\n\n<p>Hope you enjoyed this one, some new stuff to learn and it was pretty fun. Until next time!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hey everyone, it&#8217;s been a minute since I&#8217;ve dropped a walkthrough. Life has kept me busy lately and I just<\/p>\n<p><a href=\"https:\/\/infosecjake.net\/?p=489\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\">HackTheBox &#8211; PermX Walkthrough<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":492,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[31],"tags":[42,43,34],"class_list":["post-489","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ctf-challenge-walkthroughs","tag-hackthebox","tag-permx","tag-walkthrough"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/infosecjake.net\/wp-content\/uploads\/2024\/09\/image-2.png","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/infosecjake.net\/index.php?rest_route=\/wp\/v2\/posts\/489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infosecjake.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infosecjake.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infosecjake.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/infosecjake.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=489"}],"version-history":[{"count":2,"href":"https:\/\/infosecjake.net\/index.php?rest_route=\/wp\/v2\/posts\/489\/revisions"}],"predecessor-version":[{"id":549,"href":"https:\/\/infosecjake.net\/index.php?rest_route=\/wp\/v2\/posts\/489\/revisions\/549"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/infosecjake.net\/index.php?rest_route=\/wp\/v2\/media\/492"}],"wp:attachment":[{"href":"https:\/\/infosecjake.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infosecjake.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infosecjake.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}