美团websocket 分析

声明

本文章中所有内容仅供学习交流使用,不用于其他任何目的,抓包内容、敏感网址、数据接口等均已做脱敏处理,严禁用于商业用途和非法用途,否则由

此产生的一切后果均与作者无关!

部分python代码

复制代码
hex_data = '' hex # 填入 Node 输出的完整 hex
print(hex_data)
import array

def on_open(ws):
    print("连接已建立")

    # 1. 将 hex 直接转为 bytes(不加任何额外数据)
    binary_message = bytes.fromhex(hex_data)

    # 2. 验证长度
    print(f"hex_data 长度: {len(hex_data) // 2} 字节")
    print(f"转换后长度: {len(binary_message)} 字节")

    # 3. 解析前4字节看看(应该就是长度字段)
    if len(binary_message) >= 4:
        existing_length = int.from_bytes(binary_message[:4], byteorder='little')
        print(f"消息中前4字节表示的长度: {existing_length}")
        print(f"与实际长度匹配: {'✅' if existing_length == len(binary_message) else '❌'}")

    # 4. 直接发送(不要加额外头)
    ws.send(binary_message, opcode=websocket.ABNF.OPCODE_BINARY)
    print(f"已发送 {len(binary_message)} 字节,应与浏览器 1163 字节一致")


def on_message(ws, message):
    # 美团回传的通常也是二进制,可能需要打印 hex 查看
    if isinstance(message, bytes):
        print(f"收到二进制响应 (hex): {len(message)}")
    else:
        print(f"收到文本响应: {message}")


def on_error(ws, error):
    print(f"错误: {error}")


def on_close(ws, code, msg):
    print(f"连接关闭: {code} - {msg}")


if __name__ == "__main__":
    ws_url = "meituan.com"
    ws = websocket.WebSocketApp(
        ws_url,
        on_open=on_open,
        on_message=on_message,
        on_error=on_error,
        on_close=on_close
    )
    # run_forever 增加 SSL 忽略配置
    ws.run_forever(sslopt={"cert_reqs": ssl.CERT_NONE})

结果

总结

1.出于安全考虑,本章未提供完整流程,调试环节省略较多,只提供大致思路,具体细节要你自己还原,相信你也能调试出来。

相关推荐
extrao19 小时前
🚀 Kea DHCP4 自动分配系统完整搭建
网络协议
CSharp精选营1 天前
WebSocket 快速入门教程(附示例源码)
websocket·教程·csharp·实时通信·asp.net-core
不做菜鸟的网工3 天前
BGP特性
网络协议
Flynt4 天前
npm v12 来了:allowScripts 默认关闭,我的项目差点跑不起来
安全·npm·node.js
明月_清风5 天前
开发者网络概念全扫盲:一篇搞定
后端·网络协议
刘马想放假5 天前
Modbus 全栈技术解析:TCP、RTU、ASCII、RTU over TCP
数据结构·网络协议
王二端茶倒水6 天前
一套可落地的无线运营方案,不能只管 AP,还要管用户、计费和运维
网络协议
162723816086 天前
EtherCAT 分布式时钟(DC)原理与配置实战:把多轴真正"对齐到同一时刻"
网络协议
JuliusDeng6 天前
一文搞懂 `.npmrc`:npm 源、SSL 与 `_authToken` 配置避坑
npm·前端工程化
王二端茶倒水7 天前
宽带无线项目,怎么从一次性交付变成长期运营收入?
网络协议