Advertisement
m-a_labz

script type checker

Jul 30th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.36 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # (c) sec4ever.com
  3. use LWP::UserAgent;
  4. use strict;
  5. use warnings;
  6. use threads;
  7. use Getopt::Long;
  8.  
  9. our $ua = LWP::UserAgent->new;
  10. $ua->agent("msnbot/1.0 (+http://search.msn.com/msnbot.htm)");
  11. $ua->timeout(20);
  12.  
  13. our $options = GetOptions (
  14. 's|server=s'=> \my $ip,
  15. 't|threads=i'=> \my $threads,
  16. );
  17.  
  18. $| = 1;
  19. if($threads) {my $threads = $threads;}else{my $threads = 10;}
  20. my @threads = ();
  21. unless ($ip) {
  22. print "[+] Please enter server ip: ";
  23. my $ip = <stdin>;
  24. chomp($ip);
  25. }
  26. my @sites = rev_bing($ip);
  27. print "[+] Checking ".scalar(@sites)." sites from $ip\n";
  28. foreach my $site (@sites){
  29.     push(@threads, threads->create (sub {
  30.     my $type = type($site);
  31.     if($type){
  32.         print "[+] $site > $type\n";#"[-] $site > unknown";
  33.         my $out = "$type-$ip.txt";
  34.         save($out,$site);
  35.         }else{
  36.             print "[-] $site > unknown\n";
  37.             my $out = "unknown-$ip.txt";
  38.             save($out,$site);
  39.         }
  40.         save("sites-$ip.txt",$site);
  41.     }));
  42.     sleep(1) while(scalar threads->list(threads::running) >= $threads);
  43. }
  44. $_->join() foreach (threads->list());
  45.  
  46. sub save {
  47.     open ("SAVE",">>".$_[0]) or die $!."\n";
  48.     print SAVE $_[1]."\n";
  49.     close "SAVE";
  50. }
  51.  
  52. sub type {
  53.     my $site = shift;
  54. my $mainm = $ua->get("http://".$site."/") or die $!."\n";
  55. my $main = $mainm->content;
  56. my $mainh = $mainm->headers()->as_string;
  57. if ($main =~ /joomla|\/component\/|com\_/) {
  58. return "joomla";
  59. }elsif ($main =~ /wordpress|wp\-content|wp\-includes/)
  60. {
  61. return "wordpress";
  62. }
  63. elsif($mainh =~ /X-Meta-Generator: vBulletin/ || $main =~ /vbulletin_css/){
  64. return "vbulletin";
  65. }
  66. elsif($mainh =~ /Set-Cookie: mybb/ || $main =~ /wp\-content|\">MyBB<\/a>/){
  67. return "mybb";
  68. }
  69. elsif ($mainh =~ /Set-Cookie: WHMC/ || $main =~ /\">WHMCompleteSolution<\/a>/){
  70. return "whmcs";
  71. }
  72. else{
  73. return 0;
  74. }
  75. }
  76.  
  77. sub rev_bing {
  78.     my $ip = shift;
  79.     my $page = 0;
  80.     my (%group,@cont);
  81.  
  82.     while(1)
  83.     {
  84.     my $content = $ua->get("http://www.bing.com/search?q=ip::$ip&first=$page&FORM=PERE")->content;
  85.     my $status = keys %group;
  86.     while ( $content =~ /<cite>[:\/\/]*([\w\.\-]+)[\w+\/\.\-_:\?=]*<\/cite>/g) {
  87.     $group{$1} = undef;
  88.     }
  89.     last if ($status == keys %group);
  90.     $page += 10;
  91.     }
  92.     foreach my $s (keys %group) {push(@cont,sclean($s));}
  93.     return(uniq(@cont));
  94.  
  95. }
  96. sub sclean {
  97.     my $site = shift;
  98.     $site =~ s/^www\.//g if $site =~ /^www\./;
  99.     return $site;
  100. }
  101. sub uniq {
  102.     return keys %{{ map { $_ => 1 } @_ }};
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement