PHP 模擬登陸MSN並取得使用者資訊

WBOY
發布: 2016-07-29 08:39:50
原創
775 人瀏覽過

复制代码 代码如下:


/*
* PHP100中文网,整体提供,测试通过
*/
$msn = new myMSN(php100@php100.com, "123");
// MSNv9
class myMSN {
private $server = "messenger.hotmail.com";
private $port = 1863;
private $nexus = "https://nexus.passport.com/rdr/pprdr.asp";
private $sshLogin = "login.live.com/login2.srf"; //loginnet.passport.com/login2.srf
private $getCode = null;
private $_ip = null;
private $_port = null;
private $connect = null;
private $trID = 1;
private $maxMessage = 4096;
private $userName = null;
private $passWord = null;
private $debug = true;
function myMSN($userName="", $passWord="") {
if (!empty($userName) && !empty($passWord)) {
$this->userName = $userName;
//$this->passWord = urlencode($passWord);
$this->passWord = $passWord;
$this->startTalk();
}
}
function put($data) {
if ($this->isConnect()) {
fputs($this->connect, $data);
$this->trID ;
if ($this->debug)
print("

>>>{$data}
");
}
}
function get() {
if ($data = @fgets($this->connect, $this->maxMessage)) {
if ($this->debug)
print("
<<<{$data}
");
return $data;
} else {
return false;
}
}
function isConnect() {
if (!is_null($this-this >connect))
回傳true
否則
回傳false
}
函數close() {
@fclose($this->connect) }
function startTalk( ) {
if ($this->connect = fsockopen($this->server, $this->port, $errno, $errstr, 2))
$ this->verTalk(); }
function verTalk() // MSN 協定協商{
$this->put("VER {$this->trID} MSNP9 CVR0 rn")
$data = $this->get( )
/ /echo $data;
if (false !== strripos($data, "VER"))
$this->envTalk()
}
function envTalk( ) // 環境協商{
$this->put("CVR {$this->trID} 0x0409 winnt 5.0 i386 MSNMSGR 7.0.0816 MSMSGS {$this->userName} rn"); $this->get();
/ /echo $data;
if (false !== strripos($data) , "CVR"))
$this->reqTalk()
}
function reqTalk() // 請求確認{
$this->put("USR {$this-; >trID} TWN I {$this->userName} rn"); = $this->get(); // XFR 3 NS 207.46.107.41 :1863 0 65.54.239.210:1863 XFR 3 NS 207.46.107.25:1863 U D
//回顯$data;
if (false !== strripos($data, "XFR)> list(, , , $serv) = Explode(" ", $data); // 分析伺服器
list($ip, $port) =explode(":", $serv); // 分析IP與連接埠
$this->_ip = $ip;
$this->_port = $port;
$this->reLink($ip, $port);
} else {
//echo $data; // USR 3 TWN S ct=1205292058,rver=5.0.3270.0,wp=FS_40SEC_0_COMPACT,lc=1033,id=507,ru=http://messenger.msn.com,tw=0,kpp=1,kv= 4,ver=2.1.6000.1,rn=1lgjBfIL,tpf=b0735e3a873dfb5e75054465196398e0
list(, , , , $this->getCode) =expexplode(", trim($));
//回顯$data;
if (empty($this->sshLogin))
$this->reLoginTalk(); // 重新取得登陸伺服器位址
else
$this->getLoginCode($this->sshLogin);
}
}
function reLink($server, $port) // 重設連線 {
$this->connect = null;
$this->server = $server;
$this->port = $port;
$this->trID = 1;
$this->startTalk();
}
function reLoginTalk() // 重新取得伺服器位址 {
$ch = curl_init($this->nexus);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$header =curl_exec($ch);
//print_r($header);
curl_close($ch);
preg_match('/DALogin=(.*?),/', $header, $out); // 捕捉伺服器登陸匹配
//print_r($out);
if (isset($out[1])) {
$this->getLoginCode($out[1]);
}
else {
//回傳 false;
exit("無法捕捉登陸伺服器的URL");
}
}
function getLoginCode($slogin) // 取得登陸程式碼 {
//echo($this->getCode);
if (!is_null($this->getCode)) {
$ch = curl_init("https://" . $slogin);
$loginInfo = array(
"授權:Passport1.4 rgVerb=GET,OrgURL=http://messenger.msn.com,sign-in=" . $this->使用者名稱 . ",pwd= " . $this->passWord . "," . $this->getCode,
"主機:login.passport.com"
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $loginInfo);
//print_r($loginInfo);
//$this->getCode = null;
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$header =curl_exec($ch);
//print_r($header);
preg_match("/from-PP='(.*?)'/", $header, $out);
//print_r($out);
if (isset($out[1])) {
$this->loginAction($out[1]);
} else {
//回傳 false;
exit("無法捕捉登陸程式碼的資訊");
}
} else {
回傳 false;
}
}
function loginAction($loginCode) // 登陸工作 {
$this->put("USR {$this->trID} TWN S {$loginCode} rn" ); // USR |trID| SSO S |
$data = $this->get();
//回顯$data;
//print_r($data); >//$this- >put("SYN {$this->trID} 0 rn");
//$this->put("CHG {$this->trID} NLN rn"); >//print_r($this- >get());
}
}
?>


以上就介紹了PHP模擬登陸MSN並獲得用戶訊息,包括了方面的內容,希望對PHP教程有興趣的朋友得到幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!