PHP get the MSN Friends List code (2009-05-14 test pass) _php tutorial

Source: Internet
Author: User
Copy CodeThe code is as follows:



<title>MSN Test</title>









# 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
";
echo "Start login
";
# 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 msmsgs $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 is currently unavailable.";
echo "Unfortunately, the MSN server is hung up >.<
";
Die ();
} else {
echo "Connection failed!
";
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 msmsgs $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 "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 redirection
";
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 "Verification failed!
";
@fclose ($ssl _conn);
Die ();
} else {
if (RTrim ($temp)! = "http/1.1 ok") {
#echo "Unknown HTTP status code: $temp
";
echo "Unknown status code $temp
";
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
";
echo "Verification passed!
";
Flush ();

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

Data_out ("SYN $trid 0 0");
#echo "Retreiving_contact_list
";
echo "Getting friends list ...

";
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 "$nn
";
}
Else
{
echo "Friend of the past: $un
";
}
#echo $temp. "
";
Break
Default
# no Nothing
Break
}
}
echo "End of List";
@fclose ($sbconn);

# End Here

# functions

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

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





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

http://www.bkjia.com/PHPjc/320502.html www.bkjia.com true http://www.bkjia.com/PHPjc/320502.html techarticle Copy the code code as follows:! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "HTML xmlns=" http://www.w3.org/199 ...

  • 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.