php读取msn上的用户信息类
程序员文章站
2022-10-06 08:53:49
<?php
$msn = new mymsn("h058@test.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("<div style='color:green;font-size:13px;'>>>>{$data}</div>");
}
}
function get()
{
if ($data = @fgets($this->connect, $this->maxmessage))
{
if ($this->debug)
print("<div style='color:red;font-size:13px;'><<<{$data}</div>");
return $data;
}
else
{
return false;
}
}
function isconnect()
{
if (!is_null($this->connect))
return true;
else
return false;
}
function 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");
$data = $this->get();
//echo $data;
if (false !== strripos($data, "cvr"))
$this->reqtalk();
}
function reqtalk() // 请求确认
{
$this->put("usr {$this->trid} twn i {$this->username} rn");
$data = $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
//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; // usr 3 twn s ct=1205292058,rver=5.0.3270.0,wp=fs_40sec_0_compact,lc=1033,id=507,ru=http:%2f%2fmessenger.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);
}
}
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
{
//return false;
exit("无法捕捉到登陆服务器的url");
}
}
function getlogincode($slogin) // 获取登陆代码
{
//echo($this->getcode);
if (!is_null($this->getcode))
{
$ch = curl_init("https://" . $slogin);
$logininfo = array(
"authorization: passport1.4 rgverb=get,orgurl=http%3a%2f%2fmessenger%2emsn%2ecom,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
{
//return false;
exit("无法捕捉到登陆代码的信息");
}
}
else
{
return false;
}
}
function loginaction($logincode) // 登陆工作
{
$this->put("usr {$this->trid} twn s {$logincode} rn"); // usr |trid| sso s |t=code|
$data = $this->get();
//echo $data;
//print_r($data);
//$this->put("syn {$this->trid} 0 rn");
//$this->put("chg {$this->trid} nln rn");
//print_r($this->get());
}
}
?>
$msn = new mymsn("h058@test.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("<div style='color:green;font-size:13px;'>>>>{$data}</div>");
}
}
function get()
{
if ($data = @fgets($this->connect, $this->maxmessage))
{
if ($this->debug)
print("<div style='color:red;font-size:13px;'><<<{$data}</div>");
return $data;
}
else
{
return false;
}
}
function isconnect()
{
if (!is_null($this->connect))
return true;
else
return false;
}
function 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");
$data = $this->get();
//echo $data;
if (false !== strripos($data, "cvr"))
$this->reqtalk();
}
function reqtalk() // 请求确认
{
$this->put("usr {$this->trid} twn i {$this->username} rn");
$data = $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
//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; // usr 3 twn s ct=1205292058,rver=5.0.3270.0,wp=fs_40sec_0_compact,lc=1033,id=507,ru=http:%2f%2fmessenger.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);
}
}
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
{
//return false;
exit("无法捕捉到登陆服务器的url");
}
}
function getlogincode($slogin) // 获取登陆代码
{
//echo($this->getcode);
if (!is_null($this->getcode))
{
$ch = curl_init("https://" . $slogin);
$logininfo = array(
"authorization: passport1.4 rgverb=get,orgurl=http%3a%2f%2fmessenger%2emsn%2ecom,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
{
//return false;
exit("无法捕捉到登陆代码的信息");
}
}
else
{
return false;
}
}
function loginaction($logincode) // 登陆工作
{
$this->put("usr {$this->trid} twn s {$logincode} rn"); // usr |trid| sso s |t=code|
$data = $this->get();
//echo $data;
//print_r($data);
//$this->put("syn {$this->trid} 0 rn");
//$this->put("chg {$this->trid} nln rn");
//print_r($this->get());
}
}
?>
上一篇: php 清除网页病毒的方法
下一篇: php获取网页内容方法总结
推荐阅读
-
php读取msn上的用户信息类
-
PHP读取配置文件的类 php读取ini、yaml、xml配置文件信息
-
php读取msn上的用户信息类_PHP
-
PHP读取MSN上的用户信息类
-
php读取msn上的用户信息类_PHP教程
-
microsoft kernel wave audio mi php读取msn上的用户信息类
-
php读取msn上的用户信息类_PHP教程
-
PHP读取配置文件的类 php读取ini、yaml、xml配置文件信息
-
ajax - 使用php从数据库中读取信息,在网页上创建表格,有哪些可用的库
-
microsoft kernel wave audio mi php读取msn上的用户信息类