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

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

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

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐