{"id":211,"date":"2023-03-02T04:40:16","date_gmt":"2023-03-02T04:40:16","guid":{"rendered":"https:\/\/infosecjake.net\/?p=211"},"modified":"2023-03-02T04:40:17","modified_gmt":"2023-03-02T04:40:17","slug":"tryhackme-lazyadmin-walkthrough","status":"publish","type":"post","link":"https:\/\/infosecjake.net\/?p=211","title":{"rendered":"Tryhackme &#8211; LazyAdmin Walkthrough"},"content":{"rendered":"\n<p>Up next is another machine on Tryhackme. This one is called LazyAdmin.<\/p>\n\n\n\n<p>First, we need to start up our Kali linux VM and then connect to the VPN for Tryhackme. If you haven\u2019t done this before, they have pretty good instructions on how to do this on the Tryhackme site.<br><br>After connecting to VPN, lets join the LazyAdmin room and start the victim machine.<br><br>As always, we need to start off with some scanning to figure out what ports are open and what other information we can gather to help us build our attack strategy.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"361\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image.png\" alt=\"nmap scan\" class=\"wp-image-212\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-300x111.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-768x284.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>So, we have SSH open and an HTTP service on port 80. We will start off by taking a look at the http service.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"425\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-1.png\" alt=\"Apache2\" class=\"wp-image-213\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-1.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-1-300x131.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-1-768x335.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>Default Apache2 page. Nothing much here. Let\u2019s check through Dirb, or another similar tool, to see if there are any directories of interest.<br><br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"349\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-2.png\" alt=\"mysql backup\" class=\"wp-image-214\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-2.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-2-300x107.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-2-768x275.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>After googling a hash identifier, I was able to identify that this is MD5. Lets try to crack it\u2026<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"609\" height=\"52\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-3.png\" alt=\"\" class=\"wp-image-215\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-3.png 609w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-3-300x26.png 300w\" sizes=\"auto, (max-width: 609px) 100vw, 609px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"594\" height=\"298\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-4.png\" alt=\"\" class=\"wp-image-216\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-4.png 594w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-4-300x151.png 300w\" sizes=\"auto, (max-width: 594px) 100vw, 594px\" \/><\/figure>\n\n\n\n<p>Well, that didn\u2019t take long. Now, we need to see if our Dirb has finished and see where we can use these credentials at on the site. Perusing some of the other discovered directories, I see that \/as appears to be an admin login page.<br><br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"627\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-5.png\" alt=\"login page\" class=\"wp-image-217\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-5.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-5-300x193.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-5-768x494.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>Lets see if we can login now\u2026<\/p>\n\n\n\n<p>Got it! Slight correction here, the username wasn\u2019t admin, it was manager. We are in though.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"630\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-6.png\" alt=\"admin page logged in\" class=\"wp-image-218\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-6.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-6-300x194.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-6-768x496.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>After some research on Google, I\u2019m seeing that SweetRice 1.5.1 is vulnerable to a Local File Inclusion and Arbitrary File Upload. The latter has gotten my attention, however. If I can upload a file, then I can potentially create a reverse shell, if the machine will execute the file (or script in this case).<br><br>So, lets grab a reverse shell script from Pentestmonkey here: <a href=\"https:\/\/pentestmonkey.net\/cheat-sheet\/shells\/reverse-shell-cheat-sheet\">https:\/\/pentestmonkey.net\/cheat-sheet\/shells\/reverse-shell-cheat-sheet<\/a>, we are going to use PHP.<br><br>After a bit of searching, it looks like you can run this on the Ads section below, so lets put\u00a0 our script in there with our IP and run it.<\/p>\n\n\n\n<p>Lets start our listener up first..<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"363\" height=\"138\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-7.png\" alt=\"listener\" class=\"wp-image-219\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-7.png 363w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-7-300x114.png 300w\" sizes=\"auto, (max-width: 363px) 100vw, 363px\" \/><\/figure>\n\n\n\n<p>Now, to run the script, after editing it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"603\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-8.png\" alt=\"script\" class=\"wp-image-220\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-8.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-8-300x186.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-8-768x475.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>Note that it now gives us this URL:<br><br><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-9.png\" alt=\"url\" class=\"wp-image-221\" width=\"880\" height=\"168\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-9.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-9-300x58.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-9-768x147.png 768w\" sizes=\"auto, (max-width: 880px) 100vw, 880px\" \/><\/figure>\n\n\n\n<p>Lets navigate to it to see if it executes\u2026<\/p>\n\n\n\n<p>Nope, nothing there\u2026.maybe it uploaded the file into the browsable directory we looked at earlier and we can click it there?<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"920\" height=\"473\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-10.png\" alt=\"File uploaded\" class=\"wp-image-222\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-10.png 920w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-10-300x154.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-10-768x395.png 768w\" sizes=\"auto, (max-width: 920px) 100vw, 920px\" \/><\/figure>\n\n\n\n<p>There it is! Now, we click it\u2026<\/p>\n\n\n\n<p>Welp, that didn\u2019t work\u2026seems our PHP reverse shell script isn\u2019t working. Lets find another one\u2026<\/p>\n\n\n\n<p>This time, I used <a href=\"https:\/\/raw.githubusercontent.com\/pentestmonkey\/php-reverse-shell\/master\/php-reverse-shell.php\">https:\/\/raw.githubusercontent.com\/pentestmonkey\/php-reverse-shell\/master\/php-reverse-shell.php<\/a><\/p>\n\n\n\n<p>Modified the file to include my IP address to connect back to and left the default 1234 port.<br><br>Restarted my listener on port 1234 and now uploading the file, I just copy\/pasted the entire thing in\u2026<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"703\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-11.png\" alt=\"file uploaded again\" class=\"wp-image-223\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-11.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-11-300x216.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-11-768x554.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>Let\u2019s try clicking it again\u2026<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"416\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-12.png\" alt=\"Shell finally\" class=\"wp-image-224\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-12.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-12-300x128.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-12-768x328.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>There we go! A shell!<\/p>\n\n\n\n<p>Now that we are in, just some simple searching and we found the user flag.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"445\" height=\"1024\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-13-445x1024.png\" alt=\"user flag\" class=\"wp-image-225\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-13-445x1024.png 445w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-13-130x300.png 130w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-13.png 495w\" sizes=\"auto, (max-width: 445px) 100vw, 445px\" \/><\/figure>\n\n\n\n<p>While we are in the itguy\u2019s directory, lets look around for more stuff. This mysql_login.txt file looks interesting.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"539\" height=\"106\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-14.png\" alt=\"mysql file\" class=\"wp-image-226\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-14.png 539w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-14-300x59.png 300w\" sizes=\"auto, (max-width: 539px) 100vw, 539px\" \/><\/figure>\n\n\n\n<p>Some credentials, but we need to find a way to escalate our privileges to root. So, lets keep looking\u2026<br>There\u2019s a backup file here\u2026lets look at it..<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"502\" height=\"156\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-15.png\" alt=\"backup file\" class=\"wp-image-227\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-15.png 502w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-15-300x93.png 300w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/figure>\n\n\n\n<p>Ok, so lets look at the copy.sh file\u2026<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"106\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-16.png\" alt=\"copy file\" class=\"wp-image-228\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-16.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-16-300x33.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-16-768x83.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>So\u2026it\u2019s running a listener. Well, since we\u2019re not connected with a suitable terminal interface, this is going to be harder than it appears. Trying to run vi on the file won\u2019t work.<br><br>So\u2026maybe we can just do an echo and pipe the output of that into the file? I\u2019m sure there\u2019s an easier way, but this is what I have at the moment.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"105\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-17.png\" alt=\"edited file\" class=\"wp-image-229\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-17.png 975w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-17-300x32.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-17-768x83.png 768w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/figure>\n\n\n\n<p>Well, that worked. Now we start a listener on that port. Yes, I know, I know. It\u2019s corny to use 1337.<\/p>\n\n\n\n<p>Now, we run the backup script and see what happens.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"595\" height=\"75\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-18.png\" alt=\"running file\" class=\"wp-image-230\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-18.png 595w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-18-300x38.png 300w\" sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/figure>\n\n\n\n<p>Connection came in. Look who we are!<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"222\" src=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-19.png\" alt=\"root access\" class=\"wp-image-231\" srcset=\"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-19.png 780w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-19-300x85.png 300w, https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-19-768x219.png 768w\" sizes=\"auto, (max-width: 780px) 100vw, 780px\" \/><\/figure>\n\n\n\n<p>From here, we just find the root flag and put it in, it was easy to find so I won\u2019t put a screenshot. Machine is now done.<\/p>\n\n\n\n<p><br>What I learned:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>There may be useful scripts on the system that run with elevated privileges that we can use to escalate our privileges.<\/li>\n\n\n\n<li>Not every PHP reverse shell is going to work the first time. If the first one fails, try again.<\/li>\n\n\n\n<li>Browsable directories can hold some very interesting files that can become very useful for a threat actor. In this case, a database file held some credentials we could use on our attack.<\/li>\n\n\n\n<li>Persistence is important. I got a bit frustrated with the file upload section because it wasn\u2019t working for me at first. This was mainly because the reverse shell I was attempting to use was not working. I wasn\u2019t sure the larger file that I ended up using would work, but it indeed did.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Up next is another machine on Tryhackme. This one is called LazyAdmin. First, we need to start up our Kali<\/p>\n<p><a href=\"https:\/\/infosecjake.net\/?p=211\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\">Tryhackme &#8211; LazyAdmin Walkthrough<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":218,"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":[33,32,34],"class_list":["post-211","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ctf-challenge-walkthroughs","tag-ctf","tag-tryhackme","tag-walkthrough"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/infosecjake.net\/wp-content\/uploads\/2023\/03\/image-6.png","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/infosecjake.net\/index.php?rest_route=\/wp\/v2\/posts\/211","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=211"}],"version-history":[{"count":1,"href":"https:\/\/infosecjake.net\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":232,"href":"https:\/\/infosecjake.net\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions\/232"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/infosecjake.net\/index.php?rest_route=\/wp\/v2\/media\/218"}],"wp:attachment":[{"href":"https:\/\/infosecjake.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infosecjake.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infosecjake.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}