Advertisement
RieqyNS13

Untitled

Aug 5th, 2013
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.48 KB | None | 0 0
  1. <?php
  2. set_time_limit(0);
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8. <title>Subdomain Scanner</title>
  9. <style type="text/css">
  10.  
  11.   body
  12.   {
  13.   color: #ff;
  14.   text-shadow: 2px 2px black;
  15.   background-color: #282828;
  16.   font-family: Arial, Helvetica, sans-serif;
  17.   }
  18.  
  19.   pre
  20.   {
  21.   background-color: #353535;
  22.   border: solid 1px #505050;
  23.   }
  24.  
  25.   input
  26.   {
  27.   font-family: Arial, Helvetica, sans-serif;
  28.   }
  29.  
  30.   .Button
  31.   {
  32.   padding: 5px 10px;
  33.   background: #303030;
  34.   border: solid #101010 1px;
  35.   color: #fff;
  36.   cursor: pointer;
  37.   font-weight: bold;
  38.   border-radius: 5px;
  39.   -moz-border-radius: 5px;
  40.   -webkit-border-radius: 5px;
  41.   text-shadow: 1px 1px #000;
  42.   }
  43.  
  44.   .Input
  45.   {
  46.   border: solid #101010 1px;
  47.   color: white;
  48.   font-weight: bold;
  49.   padding: 3px;
  50.   background-color: #252525;
  51.   }
  52.     </style>
  53. </head>
  54.  
  55. <body>
  56. <div align="center">
  57. <pre>
  58.   _________    ___.        .___                    .__           _________                                        
  59.  /   _____/__ _\_ |__    __| _/____   _____ _____  |__| ____    /   _____/ ____ _____    ____   ____   ___________
  60.  \_____  \|  |  \ __ \  / __ |/  _ \ /     \\__  \ |  |/    \   \_____  \_/ ___\\__  \  /    \ /    \_/ __ \_  __ \
  61.  /        \  |  / \_\ \/ /_/ (  <_> )  Y Y  \/ __ \|  |   |  \  /        \  \___ / __ \|   |  \   |  \  ___/|  | \/
  62. /_______  /____/|___  /\____ |\____/|__|_|  (____  /__|___|  / /_______  /\___  >____  /___|  /___|  /\___  >__|  
  63.         \/          \/      \/            \/     \/        \/          \/     \/     \/     \/     \/     \/      
  64. Coded By The Alchemist                                                                        www.HackCommunity.com</pre>
  65. <br />
  66. <br />
  67. <?php
  68. ## Coded by The Alchemist
  69. //if file subdomains.inc does not exist, inform user
  70. if(!file_exists('subdomains.inc'))
  71. //here we inform the user to upload the file to include.
  72. {
  73.     echo 'Please upload the list of subdomains as <span style="color: #F00;">subdomains.inc</span>';
  74.     exit();
  75. }
  76. ?>
  77. //action is blank and its POST method
  78. <form action="" method="POST">
  79.  
  80. // form that user sees and fills in once subdomains.inc has been uploaded to same directory as scanner.
  81. //"target" is the name of $_POST value, if its been set remove any malicious characters from it with htmlentities().
  82. // place holder is what the user sees as an example to follow:
  83. Enter URL : <input type="text" class="Input" name="target" value="<?php if(isset($_POST['target']))
  84. {echo htmlentities($_POST['target']);}?>" placeholder="http://example.com" size="50" />
  85.  
  86. //submit button saying "scan" to user
  87. <input type="submit" name="submit" class="Button" value="Scan" />
  88. </form>
  89. <br />
  90. <br />
  91.  
  92. <?php
  93. //validate the target URL (security), and if all has been set do instruction below it.
  94.  
  95. if(isset($_POST['target'],$_POST['submit']) && filter_var($_POST['target'],FILTER_VALIDATE_URL))
  96.  
  97. //require/include the subdomains.inc file
  98. {
  99.     require('subdomains.inc');
  100.  
  101.  //parse_url() function breaks url into different parts, for instance <?php print_r(parse_url('http://cindycullen.com/example/test.php?id=255#faq1'))
  102.  //will return, Array ( [scheme] => http [host] => cindycullen.com [path] => /example/test.php [query] => id=255 [fragment] => faq1 )  
  103.  
  104.  $targ = parse_url($_POST['target']);
  105.  
  106. //will take only the host name as the $targ variable has been parced and assign it to new $target variable
  107.    
  108. $target = $targ['host'];
  109.  
  110.  //str_replace function removes the www from the hostname assigned to the $target variable
  111.  
  112.  $target = str_replace("www.","",$target);
  113.    
  114. //assign value of 0 to $i variable
  115.  $i = 0;
  116.    
  117. //assign the names in $subdomains to $val variable and loop
  118.  
  119. foreach($Subdomains as $val)
  120.    
  121.     //using curl now, assign a $url variables thatgoes like this
  122.     //http://$val (containing our subdomain names), with $target appended to it which is the user supplied host.
  123.     {
  124.         $url = "http://".$val.".".$target;
  125.         $ch[$i] = curl_init($url); //setup a new curl session
  126.         curl_setopt($ch[$i], CURLOPT_PORT, 80); // set curl option to connect to port 80
  127.   curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true); //get contents
  128.         $i++; //implement $i by 1
  129.     }
  130.     $numberof = $i;                                
  131.     $mh = curl_multi_init(); // initialize a multi curl session
  132.     for($i=0 ; $i < $numberof ; $i++) //I DONT UNDERSTAND THIS, AS $numberof and $i appear to hav ethe same value as they were assigned to each other 2 lines ago with,   $numberof = $i;  
  133.     {
  134.   curl_multi_add_handle($mh,$ch[$i]); //adding each individual curl session to multi curl handler
  135.     }
  136.     $null = NULL;
  137.     try {
  138.         curl_multi_exec($mh,$null);// execute multi curl sessions
  139.     } catch(Exception $e) {
  140.     echo "Could Not Execute"; //inform user of error
  141.     }
  142.     for($i = 0 ; $i < $numberof ; $i++) //SAME HERE AGAIN, I DO NOT UNDERSTAND DUE TO THEM HAVING THE SAME VALUE
  143.     {
  144.   if(!curl_error($ch[$i]) && !strstr(curl_multi_getcontent($ch[$i]))) //check if no error is given
  145.   {  
  146.     echo '<span style="color: #F00;"> http://'.htmlentities($Subdomains[$i].".".$target).'</span> exists<br />';
  147.     //give result to user in color
  148.   }
  149.   curl_multi_remove_handle($mh,$ch[$i]);
  150.   curl_close($ch[$i]);   //close curl
  151.     }
  152.     curl_multi_close($mh); //close the multi curl sessions
  153. }
  154. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement