2011-01-27 4 views
0

로그인 할 수 없습니다하지만 난하지PHP 컬 내가 다음 웹에 로그인 할 성공적으로

http://www.hket.com/cas/login?service=http%3A%2F%2Fmobile.hket.com%2Fmobile%2Fj_spring_cas_security_check

다음은 PHP 컬 코드 수 있지만

$encode = "UTF-8"; 
    $agent = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 GTB7.1 (.NET CLR 3.5.30729)"; 
    $cookieMobile = "cookieMobile.txt"; // need to use 2 different cookies since it will overwrite the old one when curl store cookie. cookie file is store under apache folder 

// submit a login 
function cLogin($url, $post, $agent, $cookiefile) { 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_COOKIESESSION, 1); 
    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile); 
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 20); // follow the location if the web page refer to the other page automatically 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Get returned value as string (don’t put to screen) 
    curl_setopt($ch, CURLOPT_USERAGENT, $agent); // Spoof the user-agent to be the browser that the user is on (and accessing the php script) 
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile); // Use cookie.txt for STORING cookies 
    curl_setopt($ch, CURLOPT_POST, true);  // Tell curl that we are posting data 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post); // Post the data in the array above 
    $output = curl_exec($ch); // execute 
    curl_close($ch); 

    return $output; 
} 

// mobile page login 
$url = "http://www.hket.com/cas/login?service=http%3A%2F%2Fmobile.hket.com%2Fmobile%2Fj_spring_cas_security_check"; 
$post = "_spring_security_remember_me=true&username=abcdefg&password=123456&rememberMe=on&lt=e1s1&_eventId=submit"; 

cLogin($url, $post, $agent, $cookieMobile); 
성공적으로 로그인 할 수 없습니다

은 내가 로그인 파이어 폭스를 사용하고 라이브 HTTP 헤더 나에게 다음과 같은 정보 제공 :

내가 그것을 실패 로그인 생각을하기 때문에 "HTT이다 P/1.1 302 아래 메시지에 나열된 일시적으로 "이유를 이전

http://www.hket.com/cas/login 

POST /cas/login HTTP/1.1 
Host: www.hket.com 
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729) 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip,deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Keep-Alive: 115 
Connection: keep-alive 
Referer: http://www.hket.com/cas/login?service=http%3A%2F%2Fmobile.hket.com%2Fmobile%2Fj_spring_cas_security_check 
Cookie: JSESSIONID=0CED9E8EE4B45CF647D55B1D617C584E; __utma=240160410.1615466111.1278055560.1296028926.1296112093.36; __utmz=240160410.1296112093.36.31.utmcsr=abcdefg.myftp.org|utmccn=(referral)|utmcmd=referral|utmcct=/abc/; BIGipServerpool_http_hket_prod=2617354432.20480.0000; __utmc=240160410; __utmb=240160410.5.10.1296112093 
Content-Type: application/x-www-form-urlencoded 
Content-Length: 108 
_spring_security_remember_me=true&username=abcdefg&password=123456&rememberMe=on&lt=e1s1&_eventId=submit 

HTTP/1.1 302 Moved Temporarily 
Date: Thu, 27 Jan 2011 07:38:19 GMT 
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8b mod_jk/1.2.26 PHP/5.2.5 
Pragma: no-cache 
Expires: Thu, 01 Jan 1970 00:00:00 GMT 
Cache-Control: no-cache, no-store 
Set-Cookie: CASPRIVACY=; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/cas 
Set-Cookie: CASTGC=TGT-99869-nhDTBe4XNpmk7RmlHE1OIqZiOywPgiUfjphBadf4gK1IVOqZWN-cas; Expires=Thu, 28-Apr-2011 15:05:30 GMT; Path=/cas 
Location: http://mobile.hket.com/mobile/j_spring_cas_security_check?ticket=ST-289544-CvNYVhenGTSVMqZI5Ida-cas 
Content-Length: 0 
Keep-Alive: timeout=5, max=100 
Connection: Keep-Alive 
Content-Type: text/plain 
---------------------------------------------------------- 
http://mobile.hket.com/mobile/j_spring_cas_security_check?ticket=ST-289544-CvNYVhenGTSVMqZI5Ida-cas 

GET /mobile/j_spring_cas_security_check?ticket=ST-289544-CvNYVhenGTSVMqZI5Ida-cas HTTP/1.1 
Host: mobile.hket.com 
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729) 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip,deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Keep-Alive: 115 
Connection: keep-alive 
Referer: http://www.hket.com/cas/login?service=http%3A%2F%2Fmobile.hket.com%2Fmobile%2Fj_spring_cas_security_check 
Cookie: JSESSIONID=41364FBEC5E18BED43EE8F4C68CDC876; __utma=240160410.1615466111.1278055560.1296028926.1296112093.36; __utmz=240160410.1296112093.36.31.utmcsr=abcdefg.myftp.org|utmccn=(referral)|utmcmd=referral|utmcct=/abc/; __utmc=240160410; BIGipServerpool_http_hketmobile_prod=2634131648.8225.0000; __utmb=240160410.5.10.1296112093 

HTTP/1.1 302 Moved Temporarily 
Server: Apache-Coyote/1.1 
Location: http://mobile.hket.com/mobile/ 
Content-Length: 0 
Date: Thu, 27 Jan 2011 07:38:19 GMT 
---------------------------------------------------------- 
http://mobile.hket.com/mobile/ 

GET /mobile/ HTTP/1.1 
Host: mobile.hket.com 
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729) 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip,deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Keep-Alive: 115 
Connection: keep-alive 
Referer: http://www.hket.com/cas/login?service=http%3A%2F%2Fmobile.hket.com%2Fmobile%2Fj_spring_cas_security_check 
Cookie: JSESSIONID=41364FBEC5E18BED43EE8F4C68CDC876; __utma=240160410.1615466111.1278055560.1296028926.1296112093.36; __utmz=240160410.1296112093.36.31.utmcsr=abcdefg.myftp.org|utmccn=(referral)|utmcmd=referral|utmcct=/abc/; __utmc=240160410; BIGipServerpool_http_hketmobile_prod=2634131648.8225.0000; __utmb=240160410.5.10.1296112093 

HTTP/1.1 200 OK 
Server: Apache-Coyote/1.1 
Pragma: no-cache 
Expires: Thu, 01 Jan 1970 00:00:00 GMT 
Cache-Control: no-cache, no-store 
Content-Type: text/html;charset=UTF-8 
Content-Language: en-US 
Transfer-Encoding: chunked 
Date: Thu, 27 Jan 2011 07:38:19 GMT 
---------------------------------------------------------- 
http://toolbarqueries.google.com.hk/tbr?features=WH&sourceid=navclient-ff&client=navclient-auto-ff&googleip=O;218.189.25.83;56&swwk=-1&ch=878db86f2&q=info:http%3A%2F%2Fmobile.hket.com%2Fmobile%2F 

GET /tbr?features=WH&sourceid=navclient-ff&client=navclient-auto-ff&googleip=O;218.189.25.83;56&swwk=-1&ch=878db86f2&q=info:http%3A%2F%2Fmobile.hket.com%2Fmobile%2F HTTP/1.1 
Host: toolbarqueries.google.com.hk 
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 GTB7.1 (.NET CLR 3.5.30729) GoogleToolbarFF 7.1.20101113 
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
Accept-Language: en-us,en;q=0.5 
Accept-Encoding: gzip,deflate 
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 
Keep-Alive: 115 
Connection: keep-alive 
Cookie: PREF=ID=e873609e1d8c2fd1:U=943830ece3685904:FF=1:LD=en:NR=50:TM=1277941596:LM=1294985111:DV=wf1QTY4G654M:S=3XqpPzdDwh1BlAxK; NID=43=iWMTmWA3E74L8quRFJXxuVLKz7UUKyKygfUrgHkEPoNCowgbOIDvxYURj67o_weqWXFoYlXsBqizFWrwQQK-HHVI1tVFuJK07cAizXOSM3YzuTEdpv85L8CcmVWXNmfM; SID=DQAAAMkAAACQie9hIy81BSvSY2OX3Ma0Bw2FF4OAfAX8HhzXyZpOu7NNlZs4vOWrpcf9tuPMoNhZgyyQukG9JvfUFxypgMxwnbDKNsBeHH0hCV0J1s7ailDkYaE6JcGlXWVhseWu0A3l9AbP8uUDUEcwGTF_saOFgDX-Rk3CB6_heNuuipI_QQW7c3svvkTm2HTVvho1kka3rRgPqvkYVTfYwdb9uw0cWQN7IfduIt_Sq-4mLjKVnakrJowAZdWBLzCHkLHiCXiUbOlBfPW8PsuSbcjPj4L_; HSID=AIkn5yoz2LP1K49rP 

HTTP/1.1 200 OK 
Date: Thu, 27 Jan 2011 07:38:19 GMT 
Expires: -1 
Cache-Control: private, max-age=0 
Content-Type: text/html; charset=ISO-8859-1 
Server: gws 
Content-Length: 0 
X-XSS-Protection: 1; mode=block 
---------------------------------------------------------- 

나는 컬을 사용하지만 브라우저를 할 수 있습니다 사용하여 로그인 할 수 Howcome?

아이디어가 있으십니까? 감사!!

+0

이러한 경우는 실제 트래픽을 얻기 위해 스니퍼 또는 덤퍼 유틸리티를 사용하는 것이 좋습니다. tcpdump 및/또는 wireshark를 권하고 싶습니다. –

+1

[manual] (http://php.net/manual/fr/function.curl-setopt)의 'curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, 20);'은 curl_setopt ($ ch, CURLOPT_FOLLOWLOCATION, true) .php) – Shikiryu

답변

0

은 $ 포스트의 biginning에

service=http%3A%2F%2Fmobile.hket.com%2Fmobile%2Fj_spring_cas_security_check 

을 넣고 억제하려고 '을?'.

POST를 사용하여 컬을 전달하려고 할 때 대상 URL이 POSt 방식을 전달할 수 있습니까? 그렇지 않은 경우 GET으로 CURL을 시도하십시오.

0

감사 Shikiryu,

내가 true로 매개 변수를 수정하려고하지만 동일합니다.


덕분에 존,

는 대신의

내가 당신의 방법을 사용하려고

을 GET, POST를 사용하지만 난

는 내가 다음 URL을 사용하려고 할 수

http://mobile.hket.com/mobile/j_spring_cas_security_check?_spring_security_remember_me=true&username=abcdefg&password=123456&rememberMe=on%26lt=e1s1&_eventId=submit

그러나 이것은

HTTP 상태 401 - 인증 실패 : 검증하기 위해 CAS 서비스 티켓을 제공하는 데 실패

유형 상태 보고서

메시지 인증 실패 : 검증에 CAS 서비스 티켓을 제공하기 위해 실패

설명이 요청은 HTTP 인증이 필요합니다 (인증 실패 : 프로에 실패 함). 유효성을 검사하려면 CAS 서비스 티켓 을 방문하십시오. Apache Tomcat/6.0.14

관련 문제