zl程序教程

您现在的位置是:首页 >  后端

当前栏目

PHP模拟登陆MSN并获得用户信息

PHP模拟 用户 信息 获得 登陆 MSN
2023-06-13 09:14:09 时间
复制代码代码如下:

<?php
/*
*PHP100中文网,整体提供,测试通过
*/
$msn=newmyMSN(php100@php100.com,"123");
//MSNv9
classmyMSN{
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;
functionmyMSN($userName="",$passWord=""){
if(!empty($userName)&&!empty($passWord)){
$this->userName=$userName;
//$this->passWord=urlencode($passWord);
$this->passWord=$passWord;
$this->startTalk();
}
}
functionput($data){
if($this->isConnect()){
fputs($this->connect,$data);
$this->trID;
if($this->debug)
print("<divstyle="color:green;font-size:13px;">>>>{$data}</div>");
}
}
functionget(){
if($data=@fgets($this->connect,$this->maxMessage)){
if($this->debug)
print("<divstyle="color:red;font-size:13px;"><<<{$data}</div>");
return$data;
}else{
returnfalse;
}
}
functionisConnect(){
if(!is_null($this->connect))
returntrue;
else
returnfalse;
}
functionclose(){
@fclose($this->connect);
}
functionstartTalk(){
if($this->connect=fsockopen($this->server,$this->port,$errno,$errstr,2))
$this->verTalk();
}
functionverTalk()//MSN协议协商{
$this->put("VER{$this->trID}MSNP9CVR0rn");
$data=$this->get();
//echo$data;
if(false!==strripos($data,"VER"))
$this->envTalk();
}
functionenvTalk()//环境协商{
$this->put("CVR{$this->trID}0x0409winnt5.0i386MSNMSGR7.0.0816MSMSGS{$this->userName}rn");
$data=$this->get();
//echo$data;
if(false!==strripos($data,"CVR"))
$this->reqTalk();
}
functionreqTalk()//请求确认{
$this->put("USR{$this->trID}TWNI{$this->userName}rn");
$data=$this->get();//XFR3NS207.46.107.41:1863065.54.239.210:1863XFR3NS207.46.107.25:1863UD
//echo$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;//USR3TWNSct=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)=explode("",trim($data));
//echo$data;
if(empty($this->sshLogin))
$this->reLoginTalk();//重新获取登陆服务器地址
else
$this->getLoginCode($this->sshLogin);
}
}
functionreLink($server,$port)//重置连接{
$this->connect=null;
$this->server=$server;
$this->port=$port;
$this->trID=1;
$this->startTalk();
}
functionreLoginTalk()//重新获取服务器地址{
$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{
//returnfalse;
exit("无法捕捉到登陆服务器的URL");
}
}
functiongetLoginCode($slogin)//获取登陆代码{
//echo($this->getCode);
if(!is_null($this->getCode)){
$ch=curl_init("https://".$slogin);
$loginInfo=array(
"Authorization:Passport1.4rgVerb=GET,OrgURL=http://messenger.msn.com,sign-in=".$this->userName.",pwd=".$this->passWord.",".$this->getCode,
"Host: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{
//returnfalse;
exit("无法捕捉到登陆代码的信息");
}
}else{
returnfalse;
}
}
functionloginAction($loginCode)//登陆工作{
$this->put("USR{$this->trID}TWNS{$loginCode}rn");//USR|trID|SSOS|t=code|
$data=$this->get();
//echo$data;
//print_r($data);
//$this->put("SYN{$this->trID}0rn");
//$this->put("CHG{$this->trID}NLNrn");
//print_r($this->get());
}
}
?>