中国移动飞信WAP登陆分析及脚本

中国移动飞信WAP网页版 http://f.10086.cn/im5/

用WAP飞信登录并向好友发送信息,同时用wireshark抓包。

1.过滤POST表单提交数据包(wireshark规则: http.request.method == POST),查找分析登陆数据

从上图可知:

登陆URL:http://f.10086.cn/im5/login/loginHtml5.action?t=1393041438687

POST数据:m=手机号&pass=密码&captchaCode=&checkCodeKey=null

Referer:http://f.10086.cn/im5/login/login.action?mnative=0&t=1393041438687

Cookie:UUID=...; JSESSIONID=...; infoversion=2[部分省略]

2.根据这个数据包向前寻找Cookie等参数的来源

(wireshark规则: http and ip.addr = 221.130.45.197

从上图可知:

登陆数据包前,有2个前置页面,可获取Cookie等参数

红色框中的参数根据其数值变化情况,可推测出是距1970年1月1日之间的毫秒数


3.根据以上信息即可成功登陆WAP飞信,下面寻找向好友发送消息的数据包

从上图可知:

登陆URL:http://f.10086.cn/im5/chat/sendNewMsg.action

POST数据:touserid=用户ID&msg=消息内容

Referer:http://f.10086.cn/im5/login/login.action?mnative=0&t=1393041417548

Cookie:UUID=...; JSESSIONID=...; infoversion=2; cell_cookie=...; loginstatusCookie=400; MarkTips=2014-02-22[部分省略]

发送消息POST数据包含用户ID及消息内容

红色框请求可查询用户ID

 

4.请求查询用户ID页面

从上图可知:

登陆URL:http://f.10086.cn/im5/index/searchFriendsByQueryKey.action

POST数据:queryKey=消息接受者手机号

Referer:http://f.10086.cn/im5/login/login.action?mnative=0&t=1393041417548

Cookie:UUID=...; JSESSIONID=...; infoversion=2; cell_cookie=...; loginstatusCookie=400; MarkTips=2014-02-22[部分省略]

通过手机号可以查询用户ID

实现流程

1.通过前置页面获取Cookie等参数

2.提交账号、密码表单登陆

3.查询消息接受者用户ID

4.发送消息

各个页面携带Referer、Cookie等参数(必须时需要user_agent参数)


Shell脚本如下:

 1 #!/bin/bash
 2 
 3 if [ $# -eq 0 ]; then
 4     echo "Usage: fetion [-u name|tel] -m Message"
 5     exit 1
 6 fi
 7 
 8 while [ $# -gt 0 ]
 9 do
10     case $1 in
11     -u)    destination=$2
12     shift
13         ;;
14     -m) message=$2
15     shift
16         ;;
17     -*) echo "Usage: fetion [-u name|tel] -m Message"
18         exit 1
19         ;;
20     *)    break
21         ;;
22     esac
23     shift
24 done
25 
26 user_id="用户ID"
27 password="密码"
28 
29 ##############################################################
30 #get cookie
31 curl -c cookie.txt http://f.10086.cn/im5/ &> /dev/null
32 
33 #login
34 post_data="m=$user_id&pass=$password&captchaCode=&checkCodeKey=null"
35 timestamp=$((`date +%s`+3600))
36 url="http://f.10086.cn/im5/login/loginHtml5.action?t=$timestamp"
37 curl -b cookie.txt -c cookie.txt -d $post_data $url &> /dev/null
38 
39 ###################################################################
40 #name->userid tel->userid
41 
42 url="http://f.10086.cn/im5/index/searchFriendsByQueryKey.action"
43 post_data="queryKey=$destination"
44 head_referer="Referer: http://f.10086.cn/im5/login/login.action?mnative=0&t=$timestamp"
45 result=`curl -s -b cookie.txt -H $head_referer -d $post_data  $url`
46 #echo $result > temp
47 result=`echo $result | grep -o -E 'idContact":[0-9]+' | sed 's/.*://g'`
48 if [ -n "$result" ]; then
49     userid=$result
50     echo "Id: $userid"
51 else
52     userid="用户ID" #自己的ID,可通过添加上面注释行在temp中找到
53     echo "User ID does not exist!"
54     echo "\_[This message will be sent to your moblie phone]"
55 fi
56 #######################################################################
57 #seny message to myself
58 
59 message=${message// /%20}   #replace spaces
60 echo "Message: $message"
61 msg_post_data="msg=$message&touserid=$userid"
62 send_url="http://f.10086.cn/im5/chat/sendNewGroupShortMsg.action"
63 head_referer="Referer: http://f.10086.cn/im5/login/login.action?mnative=0&t=$timestamp"
64 result=`curl -s -b cookie.txt -c cookie.txt -H $head_referer -d $msg_post_data $send_url`
65 
66 result=`echo $result | grep -o -E 'sendCode":"[0-9]{1,3}' | sed 's/.*"//g'`
67 
68 if [ $result -eq 200 ]; then
69     echo "send message success![$result]"
70 else
71     echo "send message failure![$result]"
72 fi
原文地址:https://www.cnblogs.com/rainmote/p/4160544.html