https://blog.csdn.net/mengfanzhong/article/details/53190083html
https://yq.aliyun.com/articles/59972git
https://github.com/xuyisheng/AccessibilityUtilgithub
https://www.jianshu.com/p/8fb9b04305ef算法
https://www.52pojie.cn/thread-641432-1-1.htmlcookie
https://blog.csdn.net/coderinfo/article/details/60604416網絡
https://www.jianshu.com/p/bb65b76c1b4bsession
def qrcode_login(): qrcode_request = mmtest_pb2.QRcodeRequest( device=mmtest_pb2.QRcodeRequest.Device( unknown1="", len=0, clientSeqID_sign="I\275\241\375\251\023\250N\212\312(\213]a\007\267".encode(encoding="utf-8"), clientSeqID=369493792, deviceModel="iPad iPhone OS9.3.5", unknown2=0 ), aes=mmtest_pb2.QRcodeRequest.AesKey( len=16, key="\231\324|C\277\373t\306\253\013\336\250\020Z\330\233".encode(encoding="utf-8") ), unknown3=0 ) send_data = pack(qrcode_request.SerializeToString(), 701) # 發包 ret_bytes = Util.mmPost('/cgi-bin/micromsg-bin/newsync', send_data) print(str(ret_bytes)) # 組包(壓縮加密+封包),參數:protobuf序列化後數據,cgi類型,是否使用壓縮算法 def pack(src, cgi_type, use_compress=0): # 必要參數合法性斷定 if not Util.cookie or not Util.uin or not Util.sessionKey: return b'' # 壓縮加密 len_proto_compressed = len(src) if use_compress: (body, len_proto_compressed) = Util.compress_and_aes(src, Util.sessionKey) else: body = Util.aes(src, Util.sessionKey) logger.debug("cgi:{},protobuf數據:{}\n加密後數據:{}".format(cgi_type, Util.b2hex(src), Util.b2hex(body))) # 封包包頭 header = bytearray(0) header += b'\xbf' # 標誌位(可忽略該字節) header += bytes([0]) # 最後2bit:02--包體不使用壓縮算法;前6bit:包頭長度,最後計算 header += bytes([((0x5 << 4) + 0xf)]) # 05:AES加密算法 0xf:cookie長度(默認使用15字節長的cookie) header += struct.pack(">I", define.__CLIENT_VERSION__) # 客戶端版本號 網絡字節序 header += struct.pack(">i", Util.uin) # uin header += Util.cookie # cookie header += encoder._VarintBytes(cgi_type) # cgi type header += encoder._VarintBytes(len(src)) # body proto壓縮前長度 header += encoder._VarintBytes(len_proto_compressed) # body proto壓縮後長度 header += bytes([0]*15) # 3個未知變長整數參數,共15字節 header[1] = (len(header) << 2) + (1 if use_compress else 2) # 包頭長度 logger.debug("包頭數據:{}".format(Util.b2hex(header))) # 組包 senddata = header + body return senddata
syntax = "proto2"; //登錄二維碼請求 message QRcodeRequest { message Device { required string unknown1 = 1; required int32 len = 2; required string clientSeqID_sign = 3; required int32 clientSeqID = 4; required string deviceModel = 5; required int32 unknown2 = 6; } required Device device=1; message AesKey { required int32 len = 1; required bytes key = 2; } required AesKey aes = 2; required int32 unknown3 = 3; }