日期:2014-05-17 浏览次数:20517 次
<?php define( "COOKIEJAR", tempnam( ini_get( "upload_tmp_dir" ), "cookie" ) ); //定义COOKIES存放的路径,要有操作的权限 define( "TIMEOUT", 1000 ); //超时设定 error_reporting(E_ALL); class MSN { function getAddressList($username, $password) { //第一步:模拟抓取登入页面的数据,并记下cookies $cookies = array(); $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_URL, "http://login.live.com/login.srf?wa=wsignin1.0&rpsnv=11&ct=".time()."&rver=6.1.6206.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&lc=2052&id=64855&mkt=zh-cn&cbcxt=mail&snsc=1"); curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR); curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $str = curl_exec($ch); curl_close($ch); //数据文件 模拟JS生成的cookie $CkTst = 'G'.time() * 1000; $wlidperf = "throughput=3&latency=948&FR=L&ST=".(time() * 1000 + 1254); $fp = fopen(COOKIEJAR, "a+"); $str_new = "login.live.com\tTRUE\t/\tFALSE\t0\tCkTst\t$CkTst\r\n"; $str_new .= "login.live.com\tTRUE\t/\tFALSE\t0\twlidperf\t$wlidperf\r\n"; fwrite($fp,$str_new); fclose($fp); //参数的分析 $matches = array(); preg_match('/<input\s*type="hidden"\s*name="PPFT"\s*id="(.*?)"\s*value="(.*?)"\s*\/>/i', $str, $matches); $PPFT = $matches[2]; $type = 11; $LoginOptions = 3; $Newuser = 1; $idsbho = 1; $i2 = 1; $i12 = 1; $i3 = '562390'; $i14 = '868'; $i15 = '1338'; $PPSX = 'Pa'; //合并参数 $postfiles = "login=".$username."&passwd=".$password."&type=".$type."&LoginOptions=".$LoginOptions."&Newuser=".$Newuser."&idsbho=".$idsbho."&i2=".$i2."&i3=".$i3."&PPFT=".$PPFT."&PPSX=".$PPSX."&i12=1&i14=$i14&i15=$i15"; //第二步:开始登入 $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIEJAR); curl_setopt($ch, CURLOPT_URL, 'https://login.live.com/ppsecure/post.srf?wa=wsignin1.0&rpsnv=11&ct='.(time()+5).'&rver=6.1.6206.0&wp=MBI&wreply=http:%2F%2Fmail.live.com%2Fdefault.aspx&lc=2052&id=64855&mkt=zh-cn&cbcxt=mail&snsc=1&bk='.(time()+715)); //此处的两个time()是为了模拟随机的时间 curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfiles); curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIEJAR); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, TIMEOUT); curl_s