Author Topic: Cloudflare IP Resolver[PHP]  (Read 7699 times)

0 Members and 2 Guests are viewing this topic.

Online The Alchemist

  • Peasant
  • *
  • Posts: 100
  • Cookies: 19
  • Cult Of Personality
    • View Profile
    • Scriptings - Paste Tool
Cloudflare IP Resolver[PHP]
« on: January 19, 2013, 08:33:53 am »

Hello Evil Zone,
So, this is a Cloudflare IP Resolver coded by me in PHP.


Cloudflare IP Resolvers are bots that helps us to find out the original IP address of the server of a website protected by Cloudflare.


Save the file with a .php extension and upload it to your hosting account or your localhost and then, surf the php file.
Code: PHP
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4.    <title>Cloudflare Resolver</title>
  5.  
  6.  
  7.    <style type="text/css">
  8.    
  9.       body
  10.       {
  11.          color: #F60;
  12.          text-shadow: 2px 1px #333;
  13.          background-color: #000;
  14.          font-family: Arial, Helvetica, sans-serif;
  15.       }
  16.      
  17.       input
  18.       {
  19.          font-family: Arial, Helvetica, sans-serif;
  20.       }
  21.      
  22.       .Button
  23.       {
  24.          padding: 5px 10px;
  25.          background: #333;
  26.          border: solid #101010 2px;
  27.          color: #F60;
  28.          cursor: pointer;
  29.          font-weight: bold;
  30.          border-radius: 5px;
  31.          -moz-border-radius: 5px;
  32.          -webkit-border-radius: 5px;
  33.          text-shadow: 1px 1px #000;
  34.       }
  35.      
  36.       .Input
  37.       {
  38.          border: solid #101010 1px;
  39.          color: white;
  40.          font-weight: bold;
  41.          padding: 3px;
  42.          background-color: #252525;
  43.       }
  44.     </style>
  45. </head>
  46. <body>
  47. <div align="center">
  48. <pre>
  49. _________ .__                   .___ _____.__                         __________                    .__                    
  50. \_   ___ \|  |   ____  __ __  __| _// ____\  | _____ _______   ____   \______   \ ____   __________ |  |___  __ ___________
  51. /    \  \/|  |  /  _ \|  |  \/ __ |\   __\|  | \__  \\_  __ \_/ __ \   |       _// __ \ /  ___/  _ \|  |\  \/ // __ \_  __ \
  52. \     \___|  |_(  <_> )  |  / /_/ | |  |  |  |__/ __ \|  | \/\  ___/   |    |   \  ___/ \___ (  <_> )  |_\   /\  ___/|  | \/
  53.  \______  /____/\____/|____/\____ | |__|  |____(____  /__|    \___  >  |____|_  /\___  >____  >____/|____/\_/  \___  >__|  
  54.         \/                       \/                 \/            \/          \/     \/     \/                     \/      
  55. Coded By The Alchemist                                                                                       www.EvilZone.org
  56. </pre>
  57. <form method="POST" action="">
  58. Enter URL :
  59. <input type="text" name="url" class="Input" value="<?php if(isset($_POST['url'])){ echo htmlentities($_POST['url']); } else { echo 'http://example.com';}?>" />
  60. <input type="submit" name="submit" class="Button" value="Resolve" />
  61. </form>
  62. <>
  63. <div align="left">
  64. <?php
  65.  
  66.  
  67. //Cloudflare Resolver coded by The Alchemist
  68. //www.evilzone.org
  69.  
  70.  
  71. class Cloudflareresolve
  72. {
  73.    private $arr = array(  'mail.',
  74.                          'direct.',
  75.                          'direct-connect.',
  76.                          'cpanel.',
  77.                          'ftp.',
  78.                          'forum.',
  79.                          'blog.',
  80.                          'm.',
  81.                          'dev.',
  82.                          'webmail.',
  83.                          'record.',
  84.                          'ssl.',
  85.                          'dns.',
  86.                          'help.',
  87.                          'www.');
  88.    
  89.    private function is_valid($url)
  90.    {
  91.       if(filter_var($url, FILTER_VALIDATE_URL))
  92.           return true;
  93.       return false;
  94.    }
  95.    
  96.    private function is_ip($url)
  97.    {
  98.       if(filter_var($url, FILTER_VALIDATE_IP))
  99.           return true;
  100.       return false;
  101.    }
  102.    
  103.    private function detect_cloudflare($url)
  104.    {
  105.       $headers = @get_headers($url);
  106.       if(strstr($headers[1],"cloudflare"))
  107.           return true;
  108.       return false;
  109.    }
  110.    
  111.    private function getip($url)
  112.    {
  113.       return gethostbyname($url);
  114.    }
  115.    
  116.    public function resolve($url)
  117.    {
  118.       if(!$this->is_valid($url))
  119.       {
  120.           echo '<span style="color: #F60;">The entered URL is not a vaild URL</span>';
  121.          exit();
  122.       }
  123.       if(!$this->detect_cloudflare($url))
  124.       {
  125.       $urll = parse_url($url);
  126.       $url = $urll['host'];
  127.       $ip = $this->getip($url);
  128.          echo '<span style="color: #F60;">No cloudflare detected<br /><br />';
  129.          echo 'IP of '.htmlentities($url).' is ';
  130.       if($this->is_ip($ip))
  131.       {
  132.           echo $ip.'</span>';
  133.       }
  134.       else
  135.       {
  136.           echo 'N/A</span>';
  137.       }
  138.          exit();
  139.       }
  140.       echo '<span style="color: #F60;">Cloudflare detected! Trying to resolve<br /><br /></span>';
  141.         $url_p = parse_url($url);
  142.       $url_h = $url_p['host'];
  143.       if(strstr($url_h,'www.'))
  144.       {
  145.          $temp = explode('www.',$url_h);
  146.          $url_h = $temp[1];
  147.       }
  148.       foreach($this->arr as $val)
  149.       {
  150.          $check_url = $val.$url_h;
  151.          echo '<span style="color: #F60;">IP for : '.htmlentities($check_url).' is : ';
  152.          $ip = $this->getip($check_url);
  153.          if($this->is_ip($ip))
  154.          {
  155.              echo $ip;
  156.          }
  157.          else
  158.          {
  159.              echo 'N/A';
  160.          }
  161.          echo '<br /></span>';
  162.       }
  163.    }
  164. }
  165.  
  166.  
  167. if(isset($_POST['url'],$_POST['submit']))
  168. {
  169.    $obj = new Cloudflareresolve();
  170.    $obj->resolve($_POST['url']);
  171. }
  172. ?>
  173. <>
  174. </body>
  175. </html>


The array I've used is :
Code: [Select]
mail.
direct.
direct-connect.
cpanel.
ftp.
forum.
blog.
m.
dev.
webmail.
record.
ssl.
dns.
help.
www.


You may add more if you like or remove some.


PLEASE GIVE FEEDBACK!!
« Last Edit: January 19, 2013, 08:44:46 am by The Alchemist »
Defeat the best... To be the best...

Offline m0rph

  • VIP
  • Knight
  • *
  • Posts: 392
  • Cookies: 87
  • Master Debator
    • View Profile
Re: Cloudflare IP Resolver[PHP]
« Reply #1 on: January 19, 2013, 10:27:32 am »
Nice script! Brief google search shows it is highly likely the code is original. Did you ever consider using actual dns queries when you wrote this?
The code is strong with this one.

Online The Alchemist

  • Peasant
  • *
  • Posts: 100
  • Cookies: 19
  • Cult Of Personality
    • View Profile
    • Scriptings - Paste Tool
Re: Cloudflare IP Resolver[PHP]
« Reply #2 on: January 19, 2013, 01:21:41 pm »
Nice script! Brief google search shows it is highly likely the code is original. Did you ever consider using actual dns queries when you wrote this?
Thanks.
Yes, I made it all by myself.


And about the DNS query, its done using the gethostbyname() as seen in my script.
Defeat the best... To be the best...

Offline Factionwars

  • Administrator
  • King
  • *
  • Posts: 2217
  • Cookies: 182
    • View Profile
Re: Cloudflare IP Resolver[PHP]
« Reply #3 on: January 19, 2013, 01:26:12 pm »
Good code. Good use of functions, i would only suggest to create a class object for this :)

Online The Alchemist

  • Peasant
  • *
  • Posts: 100
  • Cookies: 19
  • Cult Of Personality
    • View Profile
    • Scriptings - Paste Tool
Re: Cloudflare IP Resolver[PHP]
« Reply #4 on: January 19, 2013, 01:43:08 pm »
Good code. Good use of functions, i would only suggest to create a class object for this :)

Thanks.I've already made a class for the functions. ;D
All the functions are in the class named Cloudflareresolve.
« Last Edit: January 19, 2013, 01:46:43 pm by The Alchemist »
Defeat the best... To be the best...

Offline h4xx0r

  • NULL
  • Posts: 8
  • Cookies: -6
    • View Profile
Re: Cloudflare IP Resolver[PHP]
« Reply #5 on: February 13, 2013, 07:32:39 am »
This script won't be able to resolve the IP if you're using the following method:
http://r00t3r.com/preventing-cloudflare-ip-resolution/

Online The Alchemist

  • Peasant
  • *
  • Posts: 100
  • Cookies: 19
  • Cult Of Personality
    • View Profile
    • Scriptings - Paste Tool
Re: Cloudflare IP Resolver[PHP]
« Reply #6 on: February 13, 2013, 08:32:47 am »
This script won't be able to resolve the IP if you're using the following method:
http://r00t3r.com/preventing-cloudflare-ip-resolution/
Yup. But everyone doesn't use that method. ;D
All these thinks get updated regularly.
Defeat the best... To be the best...

 



Intern0t SoldierX SecurityOverride programisiai
Want to be here? Contact Ande, Bluechill or Kulverstukas on the forum or at IRC.