How to use socket to login MS ISA server?

As mentioned, I spent 2 days but couldn’t get away to work.

These are the browsers request header :
[tt]Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:111
Content-Type:application/x-www-form-urlencoded
Host:tytt2.vtc.edu.hk
Origin:https://tytt2.vtc.edu.hk
Referer:https://tytt2.vtc.edu.hk/CookieAuth.dll?GetLogon?curl=Z2F&reason=0&formdir=3
User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.25 (KHTML, like Gecko) Chrome/12.0.708.0 Safari/534.25[/tt]
Form data:
[tt]curl:Z2F
flags:0
forcedownlevel:0
formdir:3
trusted:0
username:hidden
password:hidden
SubmitCreds:Log On[/tt]

Normal Response headers:
[tt]Connection:keep-alive
Content-Length:0
Location:https://tytt2.vtc.edu.hk/
Set-Cookie:cadataE434790A10374AFEBA2372BA0B37C961=“1b2435c09-a94c-4148-87b2-2bf1c1aacf9alGyEiWFRfi56q1OyH5Qm04qQqhLLMmmZwPvDUG2O7yk3jjG3PBcOAUCssVk0VN0Afz69G+EmUpDkMASoCZCE7Uhv+Cc+w+iWq80oRuMkebavHM682XUn+neRyzUrl9St9CuE10+hwouP7wfTgFOy0Q==”; HttpOnly; secure; path=/
Via:1.0 rproxy1.vtc.edu.hk:80 (squid/2.6.STABLE7)
X-Cache:MISS from rproxy1.vtc.edu.hk[/tt]

My php code:
[php]# working vars
$host = ‘tytt2.vtc.edu.hk’;
$service_uri = ‘/’;
$vars =‘username=hidden&password=hidden&trusted=4&formdir=3&forcedownlevel=0&curl=Z2F&flags=0&SubmitCreds=Log+On’;

compose HTTP request header

$header = “”;
$header .= “Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8\r\n”;
$header .= "Accept-Charset:ISO-8859-1,utf-8;q=0.7,;q=0.3\r\n";
$header .= “Accept-Encoding:gzip,deflate,sdch\r\n”;
$header .= “Accept-Language:en-US,en;q=0.8\r\n”;
$header .= “Cache-Control:max-age=0\r\n”;
$header .= “Connection:keep-alive\r\n”;
$header .= “Content-Length: “.strlen($vars).”\r\n”;
$header .= “Content-Type:application/x-www-form-urlencoded\r\n”;
$header .= “Host: $host\r\n”;
$header .= “Origin:https://tytt2.vtc.edu.hk\r\n”;
$header .= “Referer:https://tytt2.vtc.edu.hk/CookieAuth.dll?GetLogon?curl=Z2F&reason=0&formdir=3\r\n”;
$header .= “User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/534.25 (KHTML, like Gecko) Chrome/12.0.708.0 Safari/534.25\r\n\r\n”;
$fp = pfsockopen(“ssl://”.$host, 443, $errno, $errstr);
echo ‘

’;
if (!$fp) {
echo “$errstr ($errno)
\n”;
echo $fp;
} else {
fputs($fp, “POST $service_uri HTTP/1.1\r\n”);
fputs($fp, $header.$vars);
fwrite($fp, $out);
$i = 0;
while (!feof($fp)) {
$line = fgets($fp, 128);
echo “$line\n”;
if(preg_match(’/^Set-Cookie.
/’, $line, $matched)) {
$s = explode(’;’, $matched[0]);
$s = explode(’: ', $s[0]);
$s = $s[1];
//break;
};
if($i ++ > 6)break;
}
fclose($fp);
}[/php]

Return headers:
[tt]HTTP/1.0 302 Moved Temporarily

Location: https://tytt2.vtc.edu.hk/CookieAuth.dll?GetLogon?curl=Z2FCookieAuth.dllZ3FGetLogonZ3FcurlZ3DZ5A2FZ26reasonZ3D0Z26form
dirZ3D3&reason=0&formdir=3

Set-Cookie: cadataE434790A10374AFEBA2372BA0B37C961=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT

Content-Length: 0

X-Cache: MISS from rproxy1.vtc.edu.hk

Via: 1.0 rproxy1.vtc.edu.hk:80 (squid/2.6.STABLE7)

Connection: keep-alive
[/tt]

The problem is the set-cookie cookie’s seems not match with the browsers does.
Help please!

DOne!!!

Sponsor our Newsletter | Privacy Policy | Terms of Service