User Control Panel
Advertisements

HELP US, HELP YOU!

Sending a MSN msg with PHP.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Bot Depot Forum Index -> MSN Protocol
View unanswered posts
Author Message
Mazzie
Newbie
Newbie


Joined: 18 Nov 2005
Posts: 2

Reputation: 5.7Reputation: 5.7Reputation: 5.7Reputation: 5.7Reputation: 5.7

PostPosted: Fri Nov 18, 2005 4:59 pm    Post subject: Sending a MSN msg with PHP. Reply with quote

Hi dee Ho.

I am not sure if this is right place to ask.. But looks like you have lots of knowledge here, so I'll ask anyways ^_^

This is my first post to here, so before I start asking noobish questions, I will shortly introduce meself.

I am a student, studying physics. I also work in cupp-project, developing some equipments/software for our experiments, as well as taking care of our network. More about cupp here : http://cupp.oulu.fi

Now, the 1st. question.

I have been developing a php script, which should send one message to certain msn account, if some conditions are true. The developement has not really yet begun, I am just testing if I can send a message. Well, login to msn main server works fine, and I can also login to switchboard server, but when I try to invite someone to switchboard server, in order to send him/her a message, I will not get any reply from the server. So I'll paste the code in here, and if someone spots the error, please inform me

Logical structure of the code is not logical at all.. I'm sorry. But as I said, this is only something to test if the basic idea works. Anyways the CAL <trid> <user> command does not return anything, and I am puzzled...

Please ignore all junk there is, and also please forgive the bad coding standards.. I just try to get the idea working, and after that I'll do the real script...

Code:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  </head>
  <body>
<?php
class socket {
        var $_socket;
//      var $socket;
        var $_socket2;
        var $response;
        var $server;
        var $bla;
        var $ble;
        var $received;
        var $portti;
        var $loginacc="Secret@someserver.xx";
        var $pass="Top_Secret";


function PassportChallenge($challenge)
{
//Login to passport and get the response
        $passport_host='login.passport.com';
        $passport_url='login2.srf';
        $dastatus='failed';
        do {
                $fp=fsockopen("$passport_host",'80');
                if (!$fp){
                        echo "Error connecting to $location<br>\r\n";
                } else {
                        fwrite($fp,"GET /$passport_url HTTP/1.0\nAuthorization: Passport1.4 OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,sign-in=".$this->loginacc.", pwd=".$this->pass.",$challenge\r\n");
                        $html='';
                        while (!feof($fp)) {
                                $html .=fgets($fp,2048);
                        }

                        $tmpstart=(strpos($html,"da-status=")+10);
                        $tmpend=(strpos($html,",",$tmpstart)-$tmpstart);
                        $dastatus=trim(substr($html,$tmpstart,$tmpend));

                        switch ($dastatus) {
                            case 'redir':
                                $tmpstart=(strpos($html,"Location: '")+10);
                                $tmpend=(strpos($html,"\n",$tmpstart)-$tmpstart);
                                $location=trim(substr($html,$tmpstart,$tmpend));
                                $location=str_replace('https://','',$location);
                                list($passport_host,$passport_url)=explode('/',$location);

                            break;
                            case 'success':
                                $tmpstart=(strpos($html,"from-PP='")+9);
                                $tmpend=(strpos($html,"',",$tmpstart)-$tmpstart);
                                $response=trim(substr($html,$tmpstart,$tmpend));
                                                unset($html);
                                                unset($fp);
                                                unset($junk);
                                return $dastatus=$response;
                           break;
                           default:
                           $dastatus='redir';
                        }
                }
           } while ($dastatus=='redir');
                return $dastatus;
}



       function Send($strData='') {
                if (!feof($this->_socket)) {
                                echo "<font color=\"green\">SENT : ".$strData."</font><br>\r\n";
                                flush();
                        return fwrite($this->_socket, $strData);
                }
        }






        function Recv() {
                if (!feof($this->_socket)) {
                        $strData=@fgets($this->_socket, 1024);
                                echo "<font color=\"blue\">GOT : ".$strData."</font><br>\r\n";
                                flush();
                        return $strData;
                }
        }

       function Send2($strData='') {
                if (!feof($this->_socket2)) {
                                echo "<font color=\"yellow\">SENT : ".$strData."</font><br>\r\n";
                                flush();
                        return fwrite($this->_socket2, $strData);
                }
        echo 'at the terribly wrong place...';
        }

        function Recv2() {
                if (!feof($this->_socket2)) {
                        $strData=fgets($this->_socket2, 1024);
                                echo "<font color=\"red\">GOT : ".$strData."</font><br>\r\n";
                                flush();
                        return $strData;
                }
        echo 'at the wrong place...';
        }



function Login()
{
        $trid=0;
        $this->_socket=fsockopen($this->server,'1863',$this->bla,$this->ble,'60');
        if(!$this->_socket)
        {
                die("Dirty socks!");
        }
        $this->Send('VER '.$trid++." MSNP9 CVR0\r\n");
        $this->received=$this->Recv();
        $this->Send('CVR '.$trid++." 0x0409 win 4.10 i386 MSNMSGR 6.2 MSMSGS ".$this->loginacc."\r\n");
        $this->received=$this->Recv();
        $this->Send('USR '.$trid++." TWN I ".$this->loginacc."\r\n");
        $this->received=$this->Recv();
        if(eregi('^XFR ', $this->received))
        {
                list($junk, $junk, $junk, $this->server, $junk) = explode(' ', $this->received);
                list($this->server,$this->portti)=explode(':', $this->server);
                $this->Login();
        }
        else
        {
                list($junk, $junk, $junk, $junk, $challenge) = explode(' ', $this->received);
                $this->response=$this->PassportChallenge($challenge);
                $this->Send('USR '.$trid++.' TWN S '.$this->response."\r\n");
                $this->received=$this->Recv();
        $this->Send('SYN '.$trid++." 0\r\n");
        $this->Send('CHG '.$trid++." NLN 268435488\r\n");
        }
        return 0;
}



function PingPong() {
        $trid=0;
        $received=$this->Recv();
        if(substr($received,0,3)=="CHL")
        {
                $bits = explode (' ', trim($received));
                $return = md5($bits[2].'Q1P7W2E4J9R8U3S5');
                $this->Send("QRY ".$trid++." msmsgs@msnmsgr.com 32\r\n".$return);
                echo $this->Recv();
                $this->SwitchboardLogin();

        }
        flush();
        unset($received);

//        $this->Send("PNG\r\n");

}

function SwitchboardLogin()
        {
        $trid=0;
        $this->Send("XFR ".$trid++." SB\r\n");
        $received=$this->Recv();
        list($junk,$junk,$junk,$serv_n_port,$junk,$authstring)=explode(' ',$received);
        list($serv,$port)=explode(':',$serv_n_port);
        $this->_socket2=fsockopen($serv,$port,$gne,$gna,60);
        if(!$this->_socket2)
        {
                echo 'Switch socks!';
                echo $gne." and ".$gna;
        }
        $this->Send2("USR ".$trid++." ".$this->loginacc." ".$authstring."\r\n"); //This works
        $received=$this->Recv2(); //so does this
        if(substr($received,0,3)==911)
        {
                echo 'Wrong auth mate!';
        }
        while(!feof($this->_socket2))
{
        sleep(6);
        $this->Send2("CAL ".$trid++." someone@gmail.com\r\n"); //this probably works too, or at least the Send2() echoes the command
        $received=$this->Recv2(); //this returns nothing.
        list($junk,$junk,$ring,$junk)=explode(' ',$received);
        if($ring=="RINGING")
        {
                $meself=1;
        }
        $this->Send2("CAL ".$trid++." anotherone@suomi24.fi\r\n");
        $received=$this->Recv2();
        list($junk,$junk,$ring,$junk)=explode(' ',$received);
        if($ring=="RINGING")
        {
                $Janne=1;
        }

        $this->Send2("CAL ".$trid++." yet_anotherone@hotmail.com\n");
        $received=$this->Recv2();
        list($junk,$junk,$ring)=explode(' ',$received);
        if($ring=="RINGING")
        {
                $cupp=1;
        }
//      while($meself==1||$Janne==1||$cupp==1)
        {
//              $received=$this->Recv2();
//              if(substr($received,0,3)=="JOI")
                {
                                list($join,$who)=explode(' ',$received);
                                if($who=="someone@gmail.com")
                                {
                                        $meself=2;
                                }
                                if($who=="anotherone@suomi24.fi")
                                {
                                        $Janne=2;
                                }
                                if($who=="yet_anotherone@hotmail.com")
                                {
                                        $cupp=2;
                                }
                                sleep(6);
                                $this->Send2("MSG 4 N 133\r\nMIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\nX-MMS-IM-Format: FN=Arial; EF=I; CO=0; CS=0; PF=22\r\n\r\nSensor n is HOT!!!!");
                                echo $this->Recv2();
}
                        }
                }
        }
} //class ends

$gne=0;
ob_end_flush();
$socket=new socket;
$socket->server='messenger.hotmail.com';
$socket->Login();
while (!feof($socket->_socket))
{
        $socket->PingPong();
}
?>
</body>
</html>
Back to top
Frosty
Newbie
Newbie


Joined: 19 Nov 2005
Posts: 1
Location: California
Reputation: 5.6Reputation: 5.6Reputation: 5.6Reputation: 5.6Reputation: 5.6

PostPosted: Sat Nov 19, 2005 9:47 pm    Post subject: Reply with quote

Well, I've also been wanting to do what you are doing. I found some codes at http://www.phpclasses.com. I was unable to get them to work, but they almost did. Lol. Maybe you can find some there, and maybe study it a bit.
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Sat Nov 19, 2005 9:51 pm    Post subject: Reply with quote

Hi,

I don't know the protocol well enough to help you, however I can suggest looking at Blobsy's source for an example Smile.

_________________
~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Back to top
Mazzie
Newbie
Newbie


Joined: 18 Nov 2005
Posts: 2

Reputation: 5.7Reputation: 5.7Reputation: 5.7Reputation: 5.7Reputation: 5.7

PostPosted: Sat Nov 19, 2005 10:11 pm    Post subject: Reply with quote

Thx for help Smile

And to be honest, I have used blobsy as a base for that script. Didn't I mention it earlier???
Back to top
OpZChAoS
Newbie
Newbie


Joined: 17 Feb 2006
Posts: 11

Reputation: 5.1Reputation: 5.1Reputation: 5.1Reputation: 5.1Reputation: 5.1

PostPosted: Fri Feb 24, 2006 9:30 pm    Post subject: My Different Way Reply with quote

I have a working example of sendMsg (http://www.msnfanatic.com/) at http://www.dioxide.be/message/ but it requires the user to add webmessage@dioxide.be to receive the message...
Back to top
darkmonkey
The Merovingian
The Merovingian


Joined: 18 Apr 2004
Posts: 2557
Location: London, England
Reputation: 39.3Reputation: 39.3Reputation: 39.3Reputation: 39.3
votes: 7

PostPosted: Fri Feb 24, 2006 10:36 pm    Post subject: Reply with quote

That's amazing Wink. Sharing the code would be leet Surprised
_________________
~ Josh
[ Need bot hosting on a dedicated server? PM me. ]
Back to top
OpZChAoS
Newbie
Newbie


Joined: 17 Feb 2006
Posts: 11

Reputation: 5.1Reputation: 5.1Reputation: 5.1Reputation: 5.1Reputation: 5.1

PostPosted: Fri Feb 24, 2006 10:40 pm    Post subject: Code Reply with quote

Its on www.msnfanatic.com (http://www.msnfanatic.com/articles/send-a-message-using-php-375.html)
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Fri Feb 24, 2006 11:15 pm    Post subject: Reply with quote

I'm not sure what is so amazing about that. You have a bot running on a server that is fed messages to send out. Am I missing something?
Back to top
OpZChAoS
Newbie
Newbie


Joined: 17 Feb 2006
Posts: 11

Reputation: 5.1Reputation: 5.1Reputation: 5.1Reputation: 5.1Reputation: 5.1

PostPosted: Fri Feb 24, 2006 11:44 pm    Post subject: Reply with quote

Not quite, it creates a new connection via php to msn, signs in, the sends the message, then signs out, closes the connection and its done.
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Sat Feb 25, 2006 12:15 am    Post subject: Reply with quote

Alright, cool. But it seems a lot easier and more efficient for the bot to just keep the connection open.
Back to top
OpZChAoS
Newbie
Newbie


Joined: 17 Feb 2006
Posts: 11

Reputation: 5.1Reputation: 5.1Reputation: 5.1Reputation: 5.1Reputation: 5.1

PostPosted: Sat Feb 25, 2006 12:43 am    Post subject: Reply with quote

True, but this method doesn't actually sign in,

Plus with the original sendMsg thing, it allows people to use their own accounts (it doesn't knock them off msn)
Back to top
Mojave
Almost An Agent
Almost An Agent


Joined: 01 Nov 2003
Posts: 1434

Reputation: 66.4

PostPosted: Sat Feb 25, 2006 1:14 am    Post subject: Reply with quote

In the post before, you said it signs in and out each time it has to send a messge. Now you say it doesn't sign in or out. Can you make up your mind please? Wink

What do you mean it allows people to use their own accounts? Who is getting knocked off MSN? I'm talking about a bot running on the server accepting new messages via the web and sending them off to users, just like you're doing. I just don't see what's so special about this. Any MSN bot can do it.
Back to top
Daemon
Newbie
Newbie


Joined: 12 Mar 2006
Posts: 2

Reputation: 1.9

PostPosted: Sun Mar 12, 2006 1:39 am    Post subject: Reply with quote

when i try and use that, it gives this error:

PHP Fatal error: Call to undefined function: curl_init() in F:\Domains\thedaemon.co.uk\wwwroot\msn\msnpauth.php on line 26

does something need to be edited?

OpZChAoS, can you upload the scripts you used, as your is slightly edited anyway so that users dont have to sign in, which i prefer
Back to top
OpZChAoS
Newbie
Newbie


Joined: 17 Feb 2006
Posts: 11

Reputation: 5.1Reputation: 5.1Reputation: 5.1Reputation: 5.1Reputation: 5.1

PostPosted: Sun Mar 12, 2006 3:50 am    Post subject: Reply with quote

Daemon wrote:
when i try and use that, it gives this error:

PHP Fatal error: Call to undefined function: curl_init() in F:\Domains\thedaemon.co.uk\wwwroot\msn\msnpauth.php on line 26

does something need to be edited?


You need to have CURL installed, look on php.net for instructions...


Daemon wrote:

OpZChAoS, can you upload the scripts you used, as your is slightly edited anyway so that users dont have to sign in, which i prefer


I will remove my stuff (msn passwords, etc) and upload it as a zip file.

I will notify when it is available on my blog -> http://sean.dioxide.be/blog/
Back to top
Daemon
Newbie
Newbie


Joined: 12 Mar 2006
Posts: 2

Reputation: 1.9

PostPosted: Mon Mar 13, 2006 5:12 pm    Post subject: Reply with quote

ok, i got that installed...

it said "Undefined Variable: Msnpauth_key In Msnauth" i checked other forums, found this thread: http://forums.fanatic.net.nz/index.php?showtopic=11637&pid=96780&st=0&#entry96780

follow it to the end, there were no further replies... any help?

my site is http://thedaemon.co.uk/msm/
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Bot Depot Forum Index -> MSN Protocol All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 



Protected by phpBB Security phpBB-TweakS
phpBB Security Has Blocked 9 Exploit Attempts.
Antispam Captcha Mod by phpbb-security.com
Powered by phpBB © 2001, 2005 phpBB Group