M-A

Path checker

M-A
Jul 7th, 2015
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.39 KB | None | 0 0
  1. #!/usr/bin/perl
  2. # install parallel::forkmanager module sudo apt-get install libparallel-forkmanager-perl
  3. # or cpan Parallel::ForkManager
  4. # @version 1.0
  5. # @author M-A
  6. # Perl Lov3r :)
  7. use LWP::UserAgent;
  8. use Getopt::Long;
  9. use Parallel::ForkManager;
  10.  
  11.  
  12. my $datestring = localtime();
  13. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
  14.  
  15. our($url,$file,$keyward,$thread);
  16. sub randomagent {
  17. my @array = ('Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0',
  18. 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20120101 Firefox/29.0',
  19. 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)',
  20. 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36',
  21. 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.67 Safari/537.36',
  22. 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31'
  23. );
  24. my $random = $array[rand @array];
  25. return($random);
  26. }
  27.  
  28. GetOptions(
  29.     'url|u=s' => \$url,
  30.     'file|f=s' => \$file,
  31.     'keyward|w=s' => \$keyward,
  32.     'threads|t=i'   => \$thread,
  33. ) || &flag();
  34.  
  35. if(!defined($url) || !defined($file)|| !defined($keyward) || !defined($thread) ){
  36.     &flag();
  37.         exit;
  38. }
  39.  
  40. print "[+] Started : $datestring\n";
  41.  
  42. open(my $arq,'<'.$file) || die($!);
  43. my @paths = <$arq>;
  44. @paths = grep { !/^$/ } @paths;
  45. close($arq);
  46. print "[".($#paths+1)."] URL to test upload\n\n";
  47.  
  48. my $pm = new Parallel::ForkManager($thread);# preparing fork
  49. foreach my $path (@paths){#loop => working
  50.     my $pid = $pm->start and next;
  51.     chomp($path);
  52.     if($url !~ /^(http|https):\/\//){
  53.         $url = 'http://'.$url;
  54.     }
  55.    
  56.     expqq($url,$path);
  57.     $pm->finish;
  58. }
  59. $pm->wait_all_children();
  60.  
  61. sub expqq{
  62.     my $useragent = randomagent();#Get a Random User Agent
  63.     my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 0 });#Https websites accept
  64.     $ua->timeout(10);
  65.     $ua->agent($useragent);
  66.     my ($url,$path) = @_;
  67.     #print "[Testing] $url\n";
  68.     my $web = $url."/".$path;
  69.     my $notfound = $ua->get($url."/notfound");
  70.     my $notfound_length = length($notfound->content);
  71.     my $response = $ua->get($web);
  72.     if ($response->code == 200){
  73.         #print "[OK] Path can be exist check with second methode\n";
  74.         #print "[*] testing with length page\n";
  75.         my $length = length($response->content);
  76.         if ($length != $notfound_length) {
  77.             #print "[OK] Path can be exist check with last methode\n";
  78.             if ($notfound->content=~/$keyward/) {
  79.                 if ($response->content!=/$keyward/){
  80.                     print "[OK] Found : $web\n";
  81.                     save ("log.txt",$web);
  82.                 }
  83.             }    
  84.         }  
  85.     }    
  86. }
  87.  
  88.  
  89. sub flag {
  90.     print "\n[*] Path Checker \n";
  91.     print "[*] Coder : M-A\n";
  92.     print "[+] Idea : Uzundz & s4e\n";
  93.     print "[+] Usage :\n";
  94.     print "[REQUIRED] -u | website (Target to test).\n";
  95.     print "[REQUIRED] -f | file  (Path to check).\n";
  96.     print "[REQUIRED] -w | Keyward (Key to check into page).\n";
  97.     print "[REQUIRED] -t | forknumber (Namber of fork).\n";
  98.     print "\nExample: check.pl -u site.com -f path.txt -w Keyward -t 5 \n\n";
  99.    
  100. }
  101.  
  102. sub save {
  103.     my ($file,$item) = @_;
  104.     open(SAVE,">>".$file);
  105.     print SAVE $item."\n";
  106.     close(SAVE);
  107. }
Advertisement
Add Comment
Please, Sign In to add comment