2016-03-07 142 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