<?php
/*
* msn.php
* Recherche de l'état des utilisateurs connectés à un compte MSN passport MSNP8
* Frédéric LOIRETTE - 2002-2005
*
* http://www.loirette.fr/frederic
* Merci à Daniel Winter (http://daniel.msnfanatic.com/contact.php)
*/
if (isset($Source))
{
//Copyright © 2003 Frédéric LOIRETTE, All Rights Reserved.
show_source("msn.php");
//Copyright © 2003 Frédéric LOIRETTE, All Rights Reserved.
//Copyright © 2002 - 2003 Daniel Winter, All Rights Reserved.
show_source("../../include/phplistgrab.php");
//Copyright © 2002 - 2003 Daniel Winter, All Rights Reserved.
show_source("../../include/msnpauth.php");
exit;
}
?>
<HTML>
<HEAD>
<style type="text/css">
<!--
body,pre,div,span,th,td,input,.s{font-family:arial,helvetica,sans-serif;font-size:12px}
-->
</style>
</HEAD>
<BODY bgcolor="#F5DEB3" text="000000">
Recherche de l'état des contacts référencés sur un compte MSN passport : <BR>
<form method="post" name="index" action="msn.php">
<table width="530" border="0" cellpadding="1" cellspacing="2" align="center">
<tr>
<td>Compte Passport :</td>
<td><input type="text" name="passport" value="<?echo $passport?>" size="50" /></td>
</tr>
<tr>
<td>Mot de passe :</td>
<td><input type="password" name="password" size="30" /></td>
</tr>
<tr>
<td><b></b></td>
<td><input type="submit" name="submit" value="Vérifier"/></td>
</tr>
</table>
</form>
<BR/>
<?php
ini_set("include_path", ".:../:./include:../include:../../include");
include "phplistgrab.php"; // Include the class file
$phplistgrab = new phpListGrab; // Create the object, the object (var) name is $phplistgrab
if (isset($passport) && isset($password))
{
echo "Connexion en cours...<BR/><BR/>\n";
$phplistgrab->passport = $passport; // Set the email address to sign in with
$phplistgrab->password = $password; // Set the password
}
else
{
exit;
}
$phplistgrab->Grab(); // Call the main function that connects and signs in
if ($phplistgrab->result == "OK") // If the lists were retrieved with no problems, the class returns OK
{
if ($phplistgrab->listonline<>"")
foreach($phplistgrab->listonline as $email => $etat)
echo "<LI>L'utilisateur <a href='mailto:$email'>$email</a> est ".$etat.".</LI>\n";
//include "results.php"; // Show the results, see below
}
else
echo "<font color='#FF0000'>Erreur : ".$phplistgrab->result."</font>";
echo "<BR/><BR/>Fin du listing... Déconnexion.\n";
echo "<BR/><BR/><I><a href='msn.php?Source=OK' target='_blank'>Code Source</a></I>\n";
?>
</BODY>
</HTML>
<?php
/* Recherche de l'état des utilisateurs connectés à un compte MSN passport MSNP8
* Copyright © 2002 - 2003 Frédéric LOIRETTE, All Rights Reserved.
*
* http://www.loirette.fr/frederic
* Merci à Daniel Winter (http://daniel.msnfanatic.com/contact.php)
*/
/**
* phpNickChange: implementation file
* phpListGrab : implementation file
*
* Copyright © 2002 - 2003 Daniel Winter, All Rights Reserved.
*
* http://daniel.msnfanatic.com/contact.php
* or
* mailto:danielwinter(@)paradise.(net).(nz)
* or
* msn:danny_dan28(@)hotmail.(com)
*
*
* This source file may be redistributed unmodified by any means at free
* will, but providing that this notice and the authors name and ALL COPYRIGHT
* notices remain intact. This source file is provided for educational
* purposes, and it may be used as a utility on web sites.
*
*
* If this source file is used on any web sites then the a statement along
* the lines of the following is required:
*
* "phpNickChange Copyright © 2002 - 2003 Daniel Winter" must be included in
* the page it is used on. Optionaly "About Page" or "Printed Documentation".
*
* This software is provided "as is" without express or implied warranty.
* Use it at your own risk! The author(s) accepts no liability for any
* damage/loss of business that this software may cause.
*
*/
// You can get this authentication class here: http://www.msnfanatic.com/re.php?a=191
require("msnpauth.php");
class phpListGrab
{
var $passport;
var $password;
var $time;
var $result;
var $list = Array("Allow" => NULL, "Block" => NULL, "Forward" => NULL, "Reverse" => NULL);
var $listCount = Array("Allow" => 0, "Block" => 0, "Forward" => 0, "Reverse" => 0);
var $_timer;
var $_socket;
var $_totalLsts;
var $_receivedLsts;
var $listonline;
var $listonlinestatus;
function phpListGrab()
{
$this->_startTimer(); // The clocks ticking (sort of)
}
function Grab($server = "messenger.hotmail.com")
{
$this->_socket = @fsockopen($server, 1863) or die("");
$this->_sendData("VER 0 MSNP8");
while (!feof($this->_socket)) {
$data = substr(fgets($this->_socket, 1024), 0, -2);
$this->_processData($data);
}
if($server != "messenger.hotmail.com" && $this->result == NULL) {
$this->result = "ERR_SERVER_UNAVAILABLE";
}
$this->_endTimer();
}
function _sendData($data)
{
fputs($this->_socket, $data."\r\n");
}
function _processData($data)
{
// echo $data."<BR/>\n";
$params = explode(" ", $data);
switch ($params[0]) {
case "VER":
$this->_sendData("CVR 1 0x0409 winnt 5.1 i386 MSNMSGR 7.0.0816 MSMSGS ".$this->passport);
break;
case "CVR":
$this->_sendData("USR 2 TWN I ".$this->passport);
break;
case "XFR":
$subparams = explode(":", $params[3]);
$this->Grab($subparams[0]);
break;
case "ILN":
$this->listonlinestatus[$params[3]] = $params[2];
switch ($params[2]) {
case "NLN":
$this->listonline[$params[3]]="en ligne";
break;
case "AWY":
$this->listonline[$params[3]]="absent";
break;
case "BSY":
$this->listonline[$params[3]]="occupé";
break;
case "BRB":
$this->listonline[$params[3]]="de retour dans 1 minute";
break;
case "PHN":
$this->listonline[$params[3]]="au téléphone";
break;
case "LUN":
$this->listonline[$params[3]]="en train de manger";
break;
case "HDN":
$this->listonline[$params[3]]="en mode invisible";
break;
case "IDL":
$this->listonline[$params[3]]="en mode veille";
break;
case "FLN":
$this->listonline[$params[3]]="déconnecté";
break;
}
break;
case "USR":
if ($params[2] == "TWN") {
$msnpauth = new MSNPAuth($this->passport, $this->password, $params[4]);
$hash = $msnpauth->getKey();
if (!$hash) {
$this->result = "Invalid passport or password";
$this->_sendData("OUT");
return false;
}
$this->_sendData("USR 3 TWN S ".$hash);
} elseif ($params[2] == "OK") {
$this->_sendData("SYN 4 0");
$this->_sendData("CHG 12 HDN");
sleep(5);
$this->_sendData("PNG");
}
break;
case "SYN":
$this->_totalLsts = $params[3];
break;
case "LST":
$this->_receivedLsts++;
if (($params[3] & 2) > 0) {
$this->listCount["Allow"]++;
$this->list["Allow"][$params[1]]["Email"] = $params[1];
$this->list["Allow"][$params[1]]["FriendlyName"] = $params[2];
}
if (($params[3] & 1) > 0) {
$this->listCount["Forward"]++;
$this->list["Forward"][$params[1]]["Email"] = $params[1];
$this->list["Forward"][$params[1]]["FriendlyName"] = $params[2];
}
if (($params[3] & 4) > 0) {
$this->listCount["Block"]++;
$this->list["Block"][$params[1]]["Email"] = $params[1];
$this->list["Block"][$params[1]]["FriendlyName"] = $params[2];
}
if (($params[3] & 8) > 0) {
$this->listCount["Reverse"]++;
$this->list["Reverse"][$params[1]]["Email"] = $params[1];
$this->list["Reverse"][$params[1]]["FriendlyName"] = $params[2];
}
if ($this->_totalLsts == $this->_receivedLsts) {
$this->_sendData("OUT");
$this->result = "OK";
}
break;
}
}
function _startTimer()
{
$mtime = microtime();
$mtime = explode (" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$this->_timer = $mtime;
}
function _endTimer()
{
$mtime = microtime();
$mtime = explode (" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = round(($endtime - $this->_timer), 5);
$this->time = $totaltime;
}
}
?>
<?php
class MSNPAuth
{
var $_cURL;
var $_key;
function MSNPAuth($passport, $password, $challenge)
{
$i = strpos($passport, "@");
switch (substr($passport, $i)) {
case "@hotmail.com":
$authURL = "https://loginnet.passport.com/login2.srf";
break;
case "@msn.com":
$authURL = "https://msnialogin.passport.com/login2.srf";
break;
default:
$authURL = "https://login.passport.com/login2.srf";
break;
}
$this->_cURL = curl_init();
curl_setopt ($this->_cURL, CURLOPT_URL, $authURL);
curl_setopt ($this->_cURL, CURLOPT_HEADERFUNCTION, "MSNPAuth_Read_Header");
curl_setopt ($this->_cURL, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt ($this->_cURL, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($this->_cURL, CURLOPT_HTTPHEADER, Array("Authorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom, sign-in=".str_replace("@", "%40", $passport).",pwd=".urlencode($password).",lc=1033,id=507,tw=40,fs=1, ru=http%3A%2F%2Fmessenger%2Emsn%2Ecom,ct=1061523064,kpp=1,kv=5, ver=2.1.0173.1,tpf=".$challenge));
curl_setopt ($this->_cURL, CURLOPT_HEADER, 0);
}
function getKey()
{
curl_exec($this->_cURL);
curl_close($this->_cURL);
$this->_key = $GLOBALS["MSNPAuth_Key"];
unset($GLOBALS["MSNPAuth_Key"]);
return $this->_key;
}
}
function MSNPAuth_Read_Header($cURL, $header)
{
$i = strpos($header, ":");
switch (substr($header, 0, $i)) {
case "WWW-Authenticate":
$GLOBALS["MSNPAuth_Key"] = false;
break;
case "Authentication-Info":
$value = substr($header, $i + 2);
$n = strpos($value, "'");
$GLOBALS["MSNPAuth_Key"] = substr($value, $n + 1, strrpos($value, "'") - $n - 1);
break;
}
return strlen($header);
}
?>