2016-03-07 144 views
1

问题,交叉动态网站的验证码.. :( 问题链接动作形式https://edu.uast.ac.ir .. 对不起我的英文不好动态网站的file_get_contents

请测试我的代码:

我源代码:

a.php只会

<?php 
echo file_get_contents("https://edu.uast.ac.ir"); 
?> 

b.php

<?php 
$a = $_POST["captcha_first_page"]; 

$postdata = http_build_query(
    array(
     'captcha_first_page' => $a 
    ) 
); 

$opts = array('http' => 
    array(
     'method' => 'POST', 
     'header' => 'Content-type: application/x-www-form-urlencoded', 
     'content' => $postdata 
    ) 
); 

$context = stream_context_create($opts);  
$result = file_get_contents('https://edu.uast.ac.ir/user/user_manage/userLogin/', false, $context); 
echo $result; 
?> 

请帮我

回答

0

你必须更换形式的行动,也导致如果不提交表单想要发布到您的b.php。

的captcha-a.php只会

<?php 

$content = file_get_contents("https://edu.uast.ac.ir"); 
$content = str_replace('https://edu.uast.ac.ir/user/user_manage/userLogin/','captcha-b.php', $content); 
echo $content; 

验证码,b.php

<?php 
function redirect_post($url, array $data, array $headers = null) { 
    $params = array(
     'http' => array(
      'method' => 'POST', 
      'content' => http_build_query($data) 
     ) 
    ); 

    // replace 
    $headers['Host'] = "edu.uast.ac.ir"; 
    $headers['Origin'] = "https://edu.uast.ac.ir"; 
    $headers['Referer'] = "https://edu.uast.ac.ir"; 

    if (!is_null($headers)) { 
     $params['http']['header'] = ''; 
     foreach ($headers as $k => $v) { 
      $params['http']['header'] .= "$k: $v\n"; 
     } 
    } 
    $ctx = stream_context_create($params); 
    $fp = fopen($url, 'rb', false, $ctx); 
    if ($fp) { 
     return stream_get_contents($fp); 
    } else { 
     // Error 
     throw new Exception("Error loading '$url', $php_errormsg"); 
    } 
} 

setlocale(LC_ALL, "en_US.UTF8"); 
echo redirect_post("https://edu.uast.ac.ir/user/user_manage/userLogin/" ,$_POST, getallheaders()); 

这应该是一个很好的起点。不知道它是否有效,因为我不会说阿拉伯语。

+0

谢谢。但它没有奏效。它们是:http://uploadkon.ir/fl/dd/83339 – j14

+0

@ J14我会看它..是验证码,b.php的内容? – Kordi

+0

是.. 应显示: [链接] https://edu.uast.ac.ir/user/user_manage/userLogin 但它自带的图像... 我在赶时间,我friend.Please测试你的代码.. TNX – j14