MSN协议分析(1)— MSG消息分析

分析msn协议,我是用msn7.0,msn在登录完成后,与他人传送信息及控制命令全部是通过服务器中转。
我发送到服务器的命令格式为:
MSG 22 U 93                                 (我发送的控制命令)
MIME-Version: 1.0                          (版本)   
Content-Type: text/x-msmsgscontrol          (连接的类型)
TypingUser: wsgtrsys@hotmail.com             (我的地址)

我收到的数据包格式为:
MSG ldzhudandan@hotmail.com 书玉 96         (对方的地址)
MIME-Version: 1.0                            (版本)  
Content-Type: text/x-msmsgscontrol           (连接的类型)  
TypingUser: ldzhudandan@hotmail.com           (对方的地址)



连接的类型主要有:
   
conten-type:text/x-msmsgscontrol            消息传送控制
conten-type:symmetric-nat                   这个是用在视频连接
conent-type:text/x-msmsgsinvite             音频连接
conten-type:text/x-msnmsgrp2p                视频连接、游戏、及其它
Content-Type: text/plain                    文本连接


视频连接使用udp传送数据。


先使用udp stun穿越协议请求:
c -->  0001 0008
s -->  0101 0024


以上协商成功后,再向对方发送一个tcp包,告诉要建立的连接:
4d53 4720 31 38 31 20 44 20 31 33 34 38 0d 0a  (即:msg 181 d 1348)

udp:
我:  0660 ....... 3c 63 3a 70 3e.60 9a 12
对方:0660  ....... 3c 72 3a 70 3e
我反馈:  23 58 00 00 00 00 01 01 01 72 65 63 69 70 69 65 6e  (.x.......recipientid=...&sessionid=...)

再经tcp协协商后,
对方udp:
0e 58 00 00 00 00 00 02 01 01 63 6f 6e 6e 65 63 74 65 64 0d 0a 0d 0a 00  (.x.......connected....)
08 50 00 00 00 00 00 01 01 01 01 32 32
我反馈:
08 50 00 00 00 00 00 01 01 02 01
80 50 00 00 00 00 00 00 00 0a 00

现已经建立连接:
udp包好象有一个特征:
对方:f3 49 ... 04 d3 04 06 aa 95 9a 6a 7a
我    08 50 00 00 00 00 00 00 00 0a 01 00 00 36 c2 fd 04




msn game:
my-->server :4d 53 47 20 31 30 37 20 44 20 36 35 37 0d 0a (msg 107 d 657)
server-->my :4d 53 47 20 6a 61 63 6b 6c 79 32 30 30 38 40 68 6f 74 6d 61 69 (msg 对方的地址响应)
连接成功后,会在以下地址下载游戏程序:
get http://messenger.zone.msn.com/en-us/


综合以上。msn的特征在于:
MSG 22 U 93                                 msg是固定不变的
MIME-Version: 1.0                           版本不变。暂时   
Content-Type: text/x-msmsgscontrol          连接的类型只有以上五种类型
TypingUser: wsgtrsys@hotmail.com            地址可变

所以表达式为:
^msg.+/x0d/x0amime-version:1.0/x0d/x0acontent-type:(application/x-msnmsgrp2p|symmetric-nat|text/x-msmsgsinvite|text/x-msmsgscontrol)/x0d/x0a

udp video的表达式为:

^/x01?/x01[/x24/x08]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个使用Linux msg消息队列的简单例程,它演示了如何发送和接收消息: 发送消息的代码: ```c #include <stdio.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #define MSGKEY 9876 struct msgbuf { long mtype; // 消息类型,必须是正整数 char mtext[256]; // 消息正文,最大长度为256字节 }; int main() { int msgid; struct msgbuf msg; // 创建消息队列 msgid = msgget(MSGKEY, IPC_CREAT | 0666); if (msgid == -1) { perror("msgget error"); return -1; } // 填充消息数据 msg.mtype = 1; sprintf(msg.mtext, "Hello, message queue!"); // 发送消息 if (msgsnd(msgid, &msg, sizeof(msg.mtext), 0) == -1) { perror("msgsnd error"); return -1; } printf("Message sent successfully.\n"); return 0; } ``` 接收消息的代码: ```c #include <stdio.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #define MSGKEY 9876 struct msgbuf { long mtype; char mtext[256]; }; int main() { int msgid; struct msgbuf msg; // 打开消息队列 msgid = msgget(MSGKEY, 0666); if (msgid == -1) { perror("msgget error"); return -1; } // 接收消息 if (msgrcv(msgid, &msg, sizeof(msg.mtext), 0, 0) == -1) { perror("msgrcv error"); return -1; } printf("Received message: %s\n", msg.mtext); // 关闭消息队列 if (msgctl(msgid, IPC_RMID, NULL) == -1) { perror("msgctl error"); return -1; } return 0; } ``` 运行发送消息的程序后,再运行接收消息的程序,就可以看到从消息队列中接收到消息了。注意,在使用msg消息队列时,消息类型必须是正整数,并且发送和接收消息的长度必须相同。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值