Controller

[PHP] SQL Scanner

Jun 3rd, 2013
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.77 KB | None | 0 0
  1. PHP SQL SCANNER
  2.  
  3. --------------------------
  4.  
  5. 34
  6. 35
  7. 36
  8. 37
  9. 38
  10. 39
  11. 40
  12. 41
  13. 42
  14. 43
  15. 44
  16. 45
  17. 46
  18. 47
  19. 48
  20. 49
  21. 50
  22. 51
  23. 52
  24. 53
  25. 54
  26. 55
  27. 56
  28. 57
  29. 58
  30. 59
  31. 60
  32. 61
  33. 62
  34. 63
  35. 64
  36. 65
  37. 66
  38. 67
  39. 68
  40. 69
  41. 70
  42. 71
  43. 72
  44. 73
  45. 74
  46. 75
  47. 76
  48. 77
  49. 78
  50. 79
  51. 80
  52. 81
  53. 82
  54. 83
  55. 84
  56. 85
  57. 86
  58. 87
  59. 88
  60. 89
  61. 90
  62. 91
  63. 92
  64. 93
  65. 94
  66. 95
  67. 96
  68. 97
  69. 98
  70. 99
  71. 100
  72. 101
  73. 102
  74. 103
  75. 104
  76. 105
  77. 106
  78. 107
  79. 108
  80. 109
  81. 110
  82. 111
  83. 112
  84. 113
  85. <?php
  86. @set_time_limit(0);
  87. @error_reporting(E_ALL | E_NOTICE);
  88.  
  89. if(!$argv[1] or !$argv[2]){
  90.  
  91. print_r("
  92. ================================================================================
  93. USAGE : php sql.php [IP] [FILENAME]
  94. Ex    : php sql.php 127.0.0.1 sql.txt
  95.  
  96. ================================================================================
  97. ");
  98. die();
  99.  
  100. }
  101.  
  102.  
  103. function check_url($url,$source,$filename){ // By Lagripe-Dz !?
  104. 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",$source))  {
  105. echo "[+] Found -> $url\n";
  106. $rr=fopen($filename,"a+");
  107. fwrite($rr,$url."\n");
  108. }
  109. else{ echo "[~] Not Found -> $url\n"; }
  110. }
  111.  
  112. function check_sql_inj($site,$filename2){
  113.     $result = @file_get_contents("$site%27");
  114.     check_url($site,$result,$filename2);
  115.     }
  116.  
  117. function mystripos($haystack, $needle){
  118.     return strpos($haystack, stristr( $haystack, $needle ));
  119.     }
  120.      
  121. function sec($ent)
  122. {
  123. $bb = str_replace("http://", "", $ent);
  124. $Credit Card = str_replace("www.", "", $bb);
  125. $dd = substr($Credit Card, 0, mystripos($Credit Card, "/"));
  126. return $dd;
  127. }
  128. $npages = 50000;
  129.  
  130.   $npage = 1;
  131.   $allLinks = array();
  132.                 $ip = $argv[1];
  133.          
  134.   while($npage <= $npages)
  135.   {
  136.     $ch = curl_init();
  137.                                  
  138.     curl_setopt($ch, CURLOPT_URL, 'http://www.bing.com/search?q=ip%3A' . $ip . '+id=&first=' . $npage);
  139.     curl_setopt($ch, CURLOPT_HEADER, 1);
  140.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  141.     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
  142.     curl_setopt($ch, CURLOPT_REFERER, 'http://www.bing.com/');
  143.     curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8');
  144.  
  145.     $result['EXE'] = curl_exec($ch);
  146.     $result['ERR'] = curl_error($ch);
  147.  
  148.     curl_close($ch);
  149.  
  150.     if ( empty( $result['ERR'] ) )
  151.     {
  152.         preg_match_all('(<div class="sb_tlst">.*<h3>.*<a href="(.*)".*>(.*)</a>.*</h3>.*</div>)siU', $result['EXE'], $findlink);
  153.         for ($i = 0; $i < count($findlink[1]); $i++)
  154.         array_push($allLinks,$findlink[1][$i]);
  155.  
  156.  
  157.         $npage = $npage + 10;
  158.         if (preg_match('(first=' . $npage . '&amp)siU', $result['EXE'], $linksuiv) == 0)
  159.             break;            
  160.     }
  161.     else
  162.         break;
  163.   }
  164.  
  165. $allDmns = array();
  166.  
  167.  
  168.  
  169.     foreach ($allLinks as $kk => $vv){
  170.     $allDmns[] = $vv;
  171.     }
  172.     $resultPages = array_unique($allDmns);
  173.     sort($resultPages) ;
  174.      
  175. print_r("
  176. ================================================================================
  177.                       SQL Injection Server ScaNNer v1.0
  178.                           (c)oded By Lagripe-Dz !?
  179.                                ALGERIA 2010 (r)
  180.                                
  181. ================================================================================
  182. ");
  183.  
  184. for ($x = 0; $x < count($resultPages); $x++){
  185. $h3h3 = $resultPages[$x];
  186. check_sql_inj($h3h3,$argv[2]);
  187. }
  188.  
  189. print_r("
  190. ================================================================================
  191.            INFO / IP : ".$ip." / Domine ScaNNed : ".count($resultPages)."
  192.          
  193.                         FINISHED
  194.                            
  195. ================================================================================
  196. ");
  197. ?>
Advertisement
Add Comment
Please, Sign In to add comment