PHP get MSN Buddy List code (2009-05-14 test passed) _php instance

Source: Internet
Author: User
Tags auth explode rtrim urlencode
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
&LT;TITLE&GT;MSN Test </title>
<meta name= "generator" content= "Bluefish 1.0.6"/>
<meta name= "keywords" content= "MSN"/>
<meta name= "description" content= "MSN test"/>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<style type= "Text/css" >
<!--
div {
Font-family:arial, Helvetica, Sans-serif;
font-size:13px;
margin:10px;
padding:2px 10px 1px;
Background-color: #C60;
Color: #FFFFFF;
border-top:1px solid #C90;
border-left:1px solid #C90;
border-bottom:1px solid #333;
border-right:1px solid #333;
}
a:link {
Color: #00FFBE;
}
--></style>
<body>
<div>

<?php
# filename:fm.php
# purpose:get MSN Contact List
# Author:http://qartis.com/?qmsn Modified by Druggo

$username = $_post[' username '];
$password = $_post[' password '];
$debug = 0;
$trid = 0;
$proto = "MSNP10";

# Start Here
echo "Communication protocol $proto <br/>";
echo "Start login <br/>";
# login Now
$sbconn = Fsockopen ("messenger.hotmail.com", 1863) or Die ("Can ' t connect to MSN Server");
Flush ();
Data_out ("VER $trid $proto CVR0");
Data_in ();
Data_out ("CVR $trid 0x0409 winnt 5.1 i386 MSNMSGR 8.0.0812 $username");
Data_in ();
Data_out ("USR $trid TWN I $username");

$temp = data_in ();

if (!stristr ($temp, ":")) {
if (substr ($temp, 0, 3) ==601) {
#echo "Error:the MSN servers are currently unavailable.";
echo "Unfortunately, the MSN server has hung >.<<br/>";
Die ();
} else {
echo "Connection failed!<br/>";
Fclose ($sbconn);
Die ();
}
}

@fclose ($sbconn);
$temp _array = Explode ("", $temp);
$temp _array = Explode (":", $temp _array[3]);
Flush ();
$sbconn = Fsockopen ($temp _array[0], $temp _array[1]) or Die ("Error-_-#");
Data_out ("VER $trid $proto CVR0");
Data_in ();
Flush ();
Data_out ("CVR $trid 0x0409 winnt 5.1 i386 MSNMSGR 8.0.0812 $username");
Data_in ();
Data_out ("USR $trid TWN I $username");
$temp = data_in ();
$temp _array = Explode ("", $temp);
Flush ();
$TOKENSTRING = Trim (end ($temp _array));
#echo "Authenticating";
echo "......<br/> in Authentication";
Flush ();

$nexus _socket = Fsockopen ("ssl://nexus.passport.com", 443);
Fputs ($nexus _socket, "get/rdr/pprdr.asp http/1.0\r\n\r\n");

while ($temp!= "\ r \ n") {
$temp = fgets ($nexus _socket,1024);
if (substr ($temp, 0,12) = = "Passporturls") {
$urls = substr ($temp, 14);
}
}

$temp _array = Explode (",", $urls);
$temp = $temp _array[1];
$temp = substr ($temp, 8);

$temp _array = Explode ("/", $temp);
@fclose ($nexus _socket);

$ssl _conn = Fsockopen ("ssl://". $temp _array[0],443);
Fputs ($ssl _conn, "Get/{$temp _array[1]} http/1.1\r\n");
Fputs ($ssl _conn, "authorization:passport1.4 orgverb=get,orgurl=http%3a%2f%2fmessenger%2emsn%2ecom,sign-in=". UrlEncode ($username). ", pwd= $password, $TOKENSTRING \ r \ n");
Fputs ($ssl _conn, "user-agent:msmsgs\r\n");
Fputs ($ssl _conn, "Host: {$temp _array[0]}\r\n");
Fputs ($ssl _conn, "connection:keep-alive\r\n");
Fputs ($ssl _conn, "cache-control:no-cache\r\n\r\n");
$temp = fgets ($ssl _conn,512);

if (RTrim ($temp) = = "http/1.1 302 Found") {
#echo "redirection";
echo "Start redirect <br/>";
Flush ();
while ($temp!= "\ r \ n") {
$temp = fgets ($ssl _conn,256);
if (substr ($temp, 0,9) = = "Location:") {
$temp _array = Explode (":", $temp);
$temp _array = Explode ("/", Trim (end ($temp _array));
Break
}
}
@fclose ($ssl _conn);
$ssl _conn = Fsockopen ("ssl://". $temp _array[2],443);
Fputs ($ssl _conn, "Get/{$temp _array[3]} http/1.1\r\n");
Fputs ($ssl _conn, "authorization:passport1.4 orgverb=get,orgurl=http%3a%2f%2fmessenger%2emsn%2ecom,sign-in=". UrlEncode ($username). ", pwd= $password, $TOKENSTRING \ r \ n");
Fputs ($ssl _conn, "user-agent:msmsgs\r\n");
Fputs ($ssl _conn, "Host: {$temp _array[2]}\r\n");
Fputs ($ssl _conn, "connection:keep-alive\r\n");
Fputs ($ssl _conn, "cache-control:no-cache\r\n\r\n");
} elseif (RTrim ($temp) = = "http/1.1 401 Unauthorized") {
#echo "Invalidcreds";
echo "Validation failed! <br/> ";
@fclose ($ssl _conn);
Die ();
} else {
if (RTrim ($temp)!= "http/1.1 OK") {
#echo "Unknown HTTP status code: $temp <br>";
echo "Unknown status code $temp <br/>";
Flush ();
Die ();
} else {
#echo "Set_bar_len30";
}
}

while ($temp!= "\ r \ n") {
$temp = fgets ($ssl _conn,1024);
if (substr ($temp, 0,19) = = "Authentication-info") {
$auth _info = $temp;
$temp = fgets ($ssl _conn,1024);
if (substr ($temp, 0,14)!= "Content-length") {
$auth _info.= fgets ($ssl _conn,1024);
}
Break
}
}
@fclose ($ssl _conn);

$temp _array = Explode ("'", $auth _info);
Flush ();

Data_out ("USR $trid TWN S {$temp _array[1]}");
Flush ();

$temp =data_in ();

Flush ();
$time _since_initmsg = time ();
while (!strstr ($temp, "abchmigrated") && is_string (Trim ($temp))) {
if (substr ($temp, 0,3) = = "Sid") {
$sid = Trim (substr ($temp, 5));
}
if (substr ($temp, 0,2) = = "KV") {
$KV = Trim (substr ($temp, 4));
}
if (substr ($temp, 0,7) = = "MSPAuth") {
$mspauth = Trim (substr ($temp, 9));
Flush ();
}
$temp = data_in ();
}
$temp = data_in ();
#echo "Authenticated<br/>";
echo "Verify through! <br/> ";
Flush ();

#data_out ("LST 9 RL");
#data_in ();

Data_out ("SYN $trid 0 0");
#echo "Retreiving_contact_list<br/>";
echo "is getting buddy list ......<br/><br/>";
Flush ();
Stream_set_timeout ($sbconn, 0,125000);

* A lazy man doing this:D * *
For ($i =0 $i <160; $i + +) # Some say Max is 150
{
$temp = data_in ();
Switch (substr ($temp, 0, 3))
{
Case "LST":
$temp _array = Explode ("", $temp);
$un = substr ($temp _array[1], 2);
$nn = substr ($temp _array[2], 2);
$nn 1 = substr ($temp _array[2], 0, 1);
if ($nn 1 = "F")
{
echo "<a href=\" mailto: $un \ "> $nn </a><br/>";
}
Else
{
echo "Once friends: $un <br/>";
}
#echo $temp. " <br/> ";
Break
Default
# no Nothing
Break
}
}
echo "List End";
@fclose ($sbconn);

# Here's the end

# functions

function Data_out ($data) {
Global $sbconn, $debug, $trid;
Fputs ($sbconn, $data. " \ r \ n ");
$trid + +;
if ($debug &&!empty ($data)) {echo ">". $data. " <br>\r\n ";}
}

function data_in () {
Global $sbconn, $debug;
$temp = fgets ($sbconn, 256);
if ($debug &&!empty ($temp)) {echo "<". $temp. " <br>\r\n ";}
return $temp;
}
?>

</div>
</body>

A friend in Need can refer to it for a few seconds.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.