MSNP protocol communication process [en]

xiaoxiao2021-03-06  177

You have been using MSN for quite some time wondering how it works. Well You need not look any further. This article will not just tell you how MSN works but will also tell you how to make your own version of MSN messenger. You can download A Sample Application from Here Msn Clone .let's Get Ready to Rumble !!!!

We can split up the working of msn messenger Into 2 Phases

Authentication Phase Instant Messaging Phase

The Authentication Phasenger Server and Also (Friends) List Retrieval in this case.

.

The MSN messenger protocol is an ASCII based protocol. In other words the commands are in pure English !!!. The first phase involves connecting to an MSN messenger server .In this case we shall connect to the server 64.4.13.58 on port 1863 ( MSN Messenger Works THROUGH Port 1863).

Once the connection is done we need to start the log in process. The first stage in this phase is the versioning stage. In this stage the client (in this case your app) lists / sends the versions that it can support to the server and Waits for the Server to respond.

Ver 0 MSNP7 MSNP6 MSNP5 MSNP4 CVRO

In The MSN Messenger Protocol A "Trial ID" is Sent Along with Every Command. The Trial ID Starts from 0 and is incremented Every Time The Server Responds SuccessFully To The Client's Commands.

The Server Responds Like this

VER 0 MSNP7 MSNP6 MSNP5 MSNP4

The Client and The Server Have Agreed on a Version in Which They Will Communicate.

NEXT The Client Sends a Request to The Server Asking It for The Name of The Security Package It Supports for Authentication.

INF 1

Unlike Yahoo, Rediff and a few other Messengers MSN does not actually send the password as it is.It encrypts the password while sending it ensuring that your password will not be leaked out easily if somebody monitors your port.The server responds with this

INF 1 MD5

Here Md5 is The name of the security package..

Next The Client Sends the Userid to The Server

USR 2 MD5 I venky_dude@hotmail.com

Here The Server Does a Check WHETHER IT Contains All The Relevant Details About The User for Authentication .if It Does Not1 Sends The Following Reply

XFR 2 NS 64.4.13.55:1863 0

What the server says is that the client should connect to the Notification Server (NS) on 64.4.13.55 on port 1863. We close the current connection and repeat the steps while being connected to the new server i.e 64.4.13.55

(Client) VER 3 MSNP7 MSNP6 MSNP5 MSNP4 CVRO (Server) Ver 3 MSNP7 MSNP6 MSNP5 MSNP4 (Client) INF 4 (Server) INF 4 MD5 (Client) USR 5 MD5 I Venky_Dude@hotmail.com

Now the Server to which we are connect to Has The Relevant Information About The User Trying to log in. The Server Replies this Way

USR 5 MD5 S 989048851.1851137130

The string which is sent by the server is the "MD5 Hash". It is a hash generated by the server and is used in the authentication process. The client then has to send the password which is encrypted using the MD5 algorithm.In effect the client has to send the unique MD5 equivalent of the MD5 hash ie 989048851.1851137130 in this case and the password combined .ie MD5 equivalent of (hash pass). in this case it turns out to be 3b7926d277068ec49576a0c40598ff21.

USR 6 MD5 S 3B7926D277068EC49576A0C40598FF21

If The Password Is Right The Server Replies with thisusr 6 OK VENKY_DUDE@hotmail.com Venkat

Here the last word is the nickname / name by Which the user is known.

In The New Version of The Protocol (MSNP7) The Server Sends Additional Data Like Some General Information About The User and a Authentication Code Something Similar To a cookie Which Can Be Used for Various Other functions.

MSG Hotmai Hotmail 362MIME-Version: 1.0Content-Type: text / x-msmsgspro file; charset = UTLoginTime: 1011252477EmailEnabled: 1MemberIdHigh: 84736MemberIdLow: - 1434729391lang _preference: 103preferredEmai l: venky_dude@hotmail.comcountry: INPostalCode: Gender: MKid: 0Age: 22Sid: 517kv: 2mspauth: 2AAAAAAAADU0P4UXXXJTDJOZJSLUTS0I7YPWNC9PUHRV56YKXXXCTWMG $$

Now We are Logged Into the Server But Our Status Is Still Offline. We need to change our status to online in order of send and receive messages. The client does this in the folload

CHG 7 NLN

The Server Replies with friends Who is online and in various stats.

CHG 7 NLniln 7 nln btxxxe@hotmail.com Nickiln 7 awy wmpyxxx@msn.com mikeiln 7 bsy tehpxxpxx@hotmail.com Yeaxxx

Msg Hotmail Hotmail 223mime-version: 1.0content-type: text / x-msmsgsinitialeMailNotification; Charset = UTF-8

Inbox-Unread: 293Folders-Unread: 0inBox-Url: / cgi-bin / HotmailFolders-URL: / CGI-BIN / FoldersPost-URL: http://www.hotmail.com

The next command to be sent to the server pertains to the version of the client currently being used.The client send to the server it's version number and also information about the machine like the OS and the build.

CVR 8 0x0409 Win 4.10 i386 MSMSGS 4.5.0127 MSMSGS

Here 0x409 win 4.10 i386 specifies that the client is running win98 on a intel microprocessor, and MSMSGS 4.5.0127 MSMSGS here specifies the version and build no of msmsgs.exe (basically the version no of MSN messenger) .The server responds with the url To Download The Latest Version and Some Other Info

CVR 8 4.5.0127 4.5.0127 1.0.0863 http://download/msnmessenger/install/4.5/win98me/en-us/mmssetup.exe http://Messenger.microsoft.com

IT IS Not Nessarry To Send The CVR Command, The Messenger Protocol Will Function Properly Regardless of this Command Being Sent

TO GET A List of People Who Are IN Our Friends List WE May Send this Command

LST 9 RL

On sending this command the server will reply by sending the reverse list .The reverse list is basically a list of users who can see you when you are online and send you a message.You could alternatively also request for the forward list by sending LST 9 Fl .the forward list Contains a list of all Users whom the user has added to his / her list.

The Server Responds this Way

LST 9 RL 69 1 19 Venky_Dude@hotmail.com Venkatlst 9 rl 69 2 19 puxxxxx@hotmail.com Pujalst 9 rl 69 3 19 Vancxxxx@hotmail.com Ramachandrast 9 RL 69 4 19 Moxxxxx@hotmail.com Chandramoulill 9 rl 69 5 19 v_n_xxxxx@hotmail.com NarayanaswamyLST 9 RL 69 6 19 dexxxxx@hotmail.com VenkateshLST 9 RL 69 7 19 lousydxxxxx@hotmail.com deepika% 20kalyani% 20Vairam LST 9 RL 69 8 19 hexxxxxr@hotmail.com Hetchar% 20RamachandranLST 9 RL 69 9 19 AMBXXXX@hotmail.com Aiyerlst 9 RL 69 10 19 Suxx@hotmail.com Ganeshlst 9 rl 69 11 19 DeExxxxx@hotmail.com Deepaklst 9 rl 69 12 19 Anillst 9 RL 69 13 19 DIXXXX@hotmail.com LST 9 RL 69 14 19 NVxxxx@hotmail.com Girilst 9 RL 69 15 19 Shxxx@hotmail.com Harilst 9 RL 69 16 8 Radhikashuxxxxx@hotmail.com Radhikalst 9 RL 69 17 19 eskaxxxx@hotmail.com kannanlst 9 rl 69 18 19 Shaxxxx@hotmail.com Shankarlst 9 RL 69 19 19 Puneetagarxxxx@hotmail.com Puneet * Every Time A Friend Comes Online Time ERVER (NS) SENDS US THE FOLLOWING COMMAND

NLN 10nln Deaxxxx@hotmail.com Venkatesh

And when the friend goes offline the server sends US this

FLN 10 fln deaxxx@hotmail.com

......................................... ...CRIPLILE, TELEGEMENT OF. 1.

CHL 0 20881396011366812350

The client has to send the md5 equivalent of this string which is formed by appending this hash with the string "Q1P7W2E4J9R8U3S5" .So the final string which will be sent to the server will be the md5 equivalent of 20881396011366812350Q1P7W2E4J9R8U3S5i.e MD5string (20881396011366812350Q1P7W2E4J9R8U3S5)

So The Client Response Would Be Something Like this

Qry 18 msmsgs@msnmsgr.com 320212EAAD0876AFB8505859CA75D21A78

Here 18 Is The Trial ID. Repece It by The Appropriate Trial ID in your program.

The Server Will Respond in The Following Way If The Authentication IS RIGHT

QRY 18

We have successfully logged into the msn messenger server. The instant message.

Instant Messaging In Msn Messenger is session based on the conference is going to take place. We cannot dession mode. We can start a chat session with a user.

There Are Basically Two Methods in Which a User Can Be in a chat session

User Sends a chat session request to another user user receives a chat session request from another user

User Sends a chat session requestion Request

The Client (user) Sends a Command To The Server Asking It for the Address of the Switchboard (SB) Server. All Instant Messaging Conversation Take Place Via The Switchboard Server.

XFR 9 SB

The server (SB) replies back with the ip address of the switchboard server (SB), the port on which to connect and a CKI hash. CKI is a security package and the client has to use the hash to connect to the switchboard server.

XFR 9 SB 64.4.13.88:1863 CKI 989487642.2070896604

Now we have to make another new connection this time to the switchboard server. Our previous connection to the MSN messenger server must be kept as it is. If we lose connection with that server we would log out.After we have connected to the switchboard server (SB) We send the folloading command to the switchboard server.

USR 1 venky_dude@hotmail.com 989487642.2070896604

If the cki hash slow by us is right the server (sb) responds back with this

USR 1 OK VENKY_DUDE@hotmail.com Venkat

After this has been done the user has to "call" The other user to the chat session. This is done by sending the following command.

Cal 2 deadXX@hotmail.com

The Server Replies Back with The a session ID Which it will pass on to the Other user

Cal 2 ringing 11717653

WHEN THE OTHER USER REPLIES AND IS Ready for a chat the server (sb) sends US THIS Command

Joi deadlee@hotmail.com Venkatesh

..............

User Receives A Chat Session Request

.

RNG 11742066 64.4.13.74:1863 CKI 989495494.750408580 Deaxxxx@hotmail.com Venkatesh

Here The Server (NS) SENDS USS U.

Now We since Time to the Switchboard Server. Our Previous Connection To The MSN Messenger Server Must Be Kept As It Server We Would Log Out.

WE Connect to the Switchboard Server And Send The Following Command

Ans 1 venky_dude@hotmail.com 989495494.750408580 11742066Here We send Our login name, the cki hash That Was Sent to us and the session id thing WAS SENT TO US

The Server Responds Back with

Iro 1 1 1 Deaxxxx@hotmail.com Venkatesh

and

ANS 1 ok

WE Are Now Ready to Send and Receive Messages.

Before sending / recaising message let us see how the message is constructed.

WHEN We are sending a message we build the header information in the folowing way

Mime-version: 1.0content-type: text / plain; charset = UTF-8X-MMS-IM-FORMAT: FN = Microsoft% 20Sans% 20serif; EF =; CO = 0; CS = 0; PF = 22

While Sending a Message We send it this Way

MSG 2 N 137 MIME-VERSITION: 1.0Content-Type: Text / Plain; Charset = UTF-8X-MMS-IM-Format: Fn = Microsoft% 20SAns% 20serif; EF =; CO = 0; CS = 0; PF = 22Hello

Here 2 is the trial id which has to incremented each time we send a message. 137 is the total length of the message i.e length of the header and length of the actual message that we are sending in this case it is 'hello'.

While Receiving The Message It Is More Or Less Similar

Here is an example of a message received

Msg Deaxxxx@hotmail.com Venkatesh 137mime-version: 1.0content-type: text / plain; charSet = UTF-8X-MMS-IM-FORMAT: FN = Microsoft% 20Sans% 20serif; EF =; CO = 0; CS = 0 Pf = 22hello

When the Other User is Typing a Message We Receive The Foll Message

Msg Deaxxx@hotmail.com Venkatesh 100mime-version: 1.0content-type: text / x-msmsgscontrolTypingUser: deaxxxx@hotmail.com

I guess now u guys are well on your way to make your own version of MSN messenger.Post your doubts / comments / message in the Forumn .Do visit my projects page for some cool vb & c codesI'll keep adding to the protocol, Will Try to Put in Addition Functions Like Add / Remove Users, Rename User ID, File Transfer and Voice Chat, So Keep Checking Back

References:

You Could Take a Look at these Sites for more information

This is The Original Protocol Published by Microsoft.

http://www.tlsecurity.net/textware/misc/draft-movva-msn-mesenger-protocol-00.txt

This is the md5 homepage where u can Find Programs / Codes for doing the md5 encryption

http://userpages.umbc.edu/~mabzug1/cs/md5/md5.html

转载请注明原文地址:https://www.9cbs.com/read-128220.html

New Post(0)