wrongpass1 <----- return 120
wrongpass2 <----- return 120
truepass <----- return 1000
wrongpass3 <----- return 120
------的login.php ---------
$file = fopen("1.txt","r");
while(! feof($file))
{
$line = fgets($file);
$leng = strlen($line);
//echo $leng;
//echo $line;
$ch = curl_init(); // initiate curl
$url = "http://localhost/login.php"; // where you want to post data
$pass = "pass=".$line;
$data_string = $pass;
$ch = curl_init('http://localhost/login.php');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//$result = curl_exec($ch);
while ($result = curl_exec($ch))
{
$data_len = strlen ($result);
if($data_len >120)
{
echo $data_len . "<br />";
echo $line;
break;
}
break;
}
}
fclose($file);
&#13;
总是返回120,120,120,120。 如何修复它以显示120,120,1000,120?
如果删除wrongpass3,它将返回120,120,1000。 但如果真正的通过是其中之一,它只返回120,120,120,120。
答案 0 :(得分:0)
还有其他方法可以确定发回的字节数。例如:
$file = fopen("1.txt","r");
while(! feof($file)) {
$line = fgets($file);
$leng = strlen($line);
$ch = curl_init();
$url = "http://localhost/login.php";
$pass = "pass=".$line;
$data_string = $pass;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
if($infp['size_download'] > 120){
echo "{$infp['size_download']}<br />";
echo $line;
break;
}
}
fclose($file);