本文需要3个前提
- 会使用https抓包工具
- 小程序wxapkg解密和解包工具 解密工具很多 解包推荐wxappUnpacker
- 一定编程基础,用自己编程语言实现
协议分析
1. 地图信息 https://cat-match.easygame2021.com/sheep/v1/game/map_info_ex?matchType=3
关于http头t字段 登录小程序得到的账号信息
{"err_code":0, "err_msg":"", "data":{"map_seed":[533201918,662591713,712900982,353412173], "map_seed_2":"1666869550", "map_md5":["046ef1bab26e5b9bfe2473ded237b572", "b5b742de1506849f1c1cf2fd2d10dfce"]}}
map_seed 游戏初始化随机数种子
map_md5 两关配置数据md5值
map_seed_2 游戏结束用到
2. 第二张地图配置 https://cat-match-static.easygame2021.com/maps/b5b742de1506849f1c1cf2fd2d10dfce.txt
{"widthNum":8,"heightNum":10,"levelKey":90024,"blockTypeData":{"1":4,"2":4,"3":4,"4":4,"5":5,"6":5,"7":4,"8":4,"9":4,"10":4,"11":4,"12":4,"13":4,"14":5,"16":5},"levelData":{"1":[{"id":"1-28-32","type":0,"rolNum":28,"rowNum":32,"layerNum":1,"moldType":1,"blockNode":null},}}
levelKey 关卡id
blockTypeData 方块类型:消除组数 *3 三个消除
"blockTypeData": {
"1": 4, //"1":4 表示小草 4组 4*3 12个块
"2": 4, //"2":4 表示胡萝卜 4组 4*3 12个块
"3": 4,
"4": 4,
"5": 5,
"6": 5,
"7": 4,
"8": 4,
"9": 4,
"10": 4,
"11": 4,
"12": 4,
"13": 4,
"14": 5,
"16": 5
}, levelData layerNum层 rolNum列 rowNum行 type类型 24号总192个消除块类型全部是随机 根据map_seed随机数种子初始化地图
"0": "随机",
"1": "小草",
"2": "胡萝卜",
"3": "玉米",
"4": "树桩",
"5": "叉子",
"6": "白菜",
"7": "饭团",
"8": "刷子",
"9": "剪刀",
"10": "牛奶",
"11": "脸盆",
"12": "手套",
"13": "铃铛",
"14": "火苗",
"15": "毛线",
"16": "草堆",
"17+": "白板"
3. 游戏结束发送请求 POST https://cat-match.easygame2021.com/sheep/v1/game/game_over_ex?
{"rank_score":1,"rank_state":1,"rank_time":233,"rank_role":2,"skin":1,"MatchPlayInfo":"...","MapSeed2":"...","Version":"0.0.1"}
rank_score: 1固定
rank_state: 1过关 2失败
rank_time: 游戏时间秒
rank_role: 1未使用道具 2使用过道具
skin: 1 换装皮肤id
MapSeed2: 第一个包中的map_seed_2
Version: 25号新增,固定
MatchPlayInfo: base64编码protobuf 即游戏点击记录 移出道具 多3个操作 撤销道具 多1个操作
proto数据定义
message MatchPlayInfo {
message MatchStepInfo {
required int32 chessIndex = 1;
required int32 timeTag = 2;
}
required int32 gameType = 1;
optional int32 mapId = 2;
optional int32 mapSeed = 3;
repeated MatchStepInfo stepInfoList = 4;
}
只用到2个字段 gameType 和 stepInfoList
gameType: 3每日挑战 0GAMEMAIN 1GAMETOMB 2过关挑战 4话题挑战
stepInfoList 列表 chessIndex 块id 从第1层0开始编号
timeTag 之前是操作间隔毫秒 24号改成type即方块初始化后的类型
MatchPlayInfo google protobuf to json数据如下
{
"gameType": 3,
"stepInfoList": [
{
"chessIndex": 176,
"timeTag": 2
},
......
]
}
思路通过blockTypeData和levelData 生成stepInfoList即操作记录 即先0开始编号chessIndex并按-layerNum,type,moldType字段升序排序 再把type=0类型按blockTypeData结构中的类型和数量顺序修改,最后结果发送到服务器即可过关
回复讨论协议更好的思路, 不要涉及工具使用 礼貌回帖 zsbd
protobuf python 实现 论坛jingtai123