class test(): if __name__ == '__main__': print 111 code = '3c8c40ab23bc0024d7f0ae9408004500039b40e840008006c623c0a86407716c5a35cbce1f90d7280432bea3a13c5018409962ed000000000373000000080200000004000000000d3633343534353339397a990a6f0da475adcf8c1ed97a7bd860baeaf32322c29186adf521109e60560b579d739d4f891b2e257bea15b0b67d907d388deae0e6b90492456eff361d13b7678cc800352238077f9e1f7124a7b05c252f33cc866da276441b5b2c12a6e487d910e5a51511c9df7008ccc6a51746dc1e7ab36b2deea4f8f007fe42831cb4929192d98e53dec70d03807096bb3bfd16a758465c8bfacfca72ffb2613471718a9e9bcfc1559e51d431a74eefc36f424e143d065e36ca5692f7b85674482a44832aa835703c8999a4a8b97e7b564d0e43274a4ec223ce42eaf38e5fcc68bdf2d054877e2ab27c0f78c3d23bcde79f13fe5c4cad1e6b16ab4352c106ea384e06e9cb185bdeeec36f1ad271cd6e9e65a4c30a424f22ab892430d89c7ff9c461f7e5e721d0391ed1796a2a047eca9e895b50de787e3e1173a98977a4b7581015e21b71d98ec9fbf69157965473150a50222b6d21bff57e2269eaff9eb336563629f99c906dcd1f23aef8ada277bee00c979209e43d6c3404ab9ba41c7c769e37c435441c3adff0359e17d966782adc4105424712d7f03c7906deb73b9e71fb960105c5faf233647291dcaf00f97562b7f300fe77cdac08d81b8137c817491306a95430045488f064b7a219a60c768bf83e3fdc5f26d8f8c8e997f22c166026fec63707706c9a111e5317f138fa22eb3d8dcba6731f0fac3e0ef73a63d9481752feefe3db2c72f57d048804e70f40f9b93108d7a233d81d1de5d175f2392566e18a0263fd20e1f05e31c21b67678afd6f2c9ff0953c83020fe3feb2213f2e496ad17b3d24485ae6abadead85e31704dc9c1ce6aefbd7b2ed1d5e17b786fd8cd37e164eacea9ec60c6f6fa1c5965ffefe8f69148e60c27ce772551157fba9d46c87df59d87fb8f4d383184f52aaa911eed8fd8750e87e221aa18642fd5856376aeb5adbd45b1bf589ef143f44ca5781b82ec5d7ddd3aaae2b1d5c962ec2835bb6599ba1f3d16271ccc262cf0d20e65b1a8741f7fbdca64317759b232ba3a8fc820d3449be7e008609e7dee817df72604c7f20139a2e762f2799fce00bf81f3832de40415ec4c0f90e4af0df5cda6a456b15bee7ce3689688abaf427568fa9551a19eb542ad1e01ba4bed153809bc59c869438f7c09bf124f2aa9b06610bf5f4319bcd05eefe3079c1a1eb38bed8e096e1bea6ee8a1075c6ca3c2f9' #print Coder.hexstr2str(code); # print code.encode('hex'); print 8 << 4 print Coder.num2hexstr(len(Coder.str2hexstr('634545399')) / 2 + 4, 4) print Coder.str2hexstr('634545399') qq = AndroidQQ('634545399', 'xiaomin0322####') packet = qq.packSendLoginMessage() print Coder.num2hexstr(len(packet) / 2 + 4, 4) print len(packet) # ss = '7a215d1c28d0681072f3370142669487fee6b5a222b18751a1a4ce6da0b952253994e847c9e1399a945be54facbd25d5f0d25b8325114dbfc40c2c5c48db42e9fb02e8c566529f7705d7fdf8958b2de7944f5fcfab050838d4809c83b5ab657cf4a4c2042129169059f8053e6f0cd5f0b5ed75dee694a70b236b6d040055bc336ebf678a520911be00e057435ac6c0b21f40718338e696133bc7df52d51632053484b5e53a8a82fde7b148fe5f91bc546d92b1a24f48db2863f7741df7881085a78f75f9b7912c57ccff62bddaa821e4e41dd08ca6c995a5c766b5763c8afcfc96feb80944017eb95e87b0e2f1b156aeb86c0c38d2521a8e9a7cac7ab4184c5d1f89b43dc16e9d24aed14a9f798a974a9ad6555f41ee65d1f5094a8b845140ecfbe01774d0a6ac2a3af893b7a60bdae2d92285bddd0b2162501bc726fbb169abc3c0388e49584f2839225cd5748a8cea428cb89d9f8b36fbacbfdfbbcf2c331d6e548a21c3490a29a20b904f6bf3766042ce90c45376830ce23ca65b261ed79d08722b02aa9d0f3589671efa5860db35fa7e352c765747cfad6ee9ee908dc3b49b9995120c6fe70667250ee615d64004dd20951a274fa7a635262b509db37e1e1115d269c2b90af5da75530e5bba7573798355f6e2839a1fb71c3adf4bf361df606180b71d81bc6faa1132478c0da88475ed835cdda5626142163fb3cf1009730cf18a560fc6c072f84f1e860ed2fed6d58a5befdee5f1579bd978057cdaa59b83940256b9b109984fe16b624338869ed8d01d7e969054abe7f8ae6efc2ba8cf88be35158380f2638bc1c1d86b33f73850d1a3631f5c74aedba7908ac8989729619f192a67809734a21c274c3469384ba209baa1fb60a7e48bc823383ee7a667532e59799b807bb862935e0e72900be302b8f14ada32e30dcb06773db42ea695ae0fdba8440b40c63963452733a9a4fb745df6d29e8a1f7a0c806b2e64f53bac94b7bb6791a36006126f28d1cb975c8253e8148069e4d460cbf3d018b75baebbc9b8ff052cb62c2e39b30d6111f0aca0cb56a852797d1eeefe243168bc87f5b5b574109198c626c64cde9a59d5be65c2f87708de9118b5e272176ec6f7b9bcb030aea0e3a498648aad32d7ddf16e74d9145ee9afab1e29a67012984eb144ae2fa5743bd2b6b209ccef89975d51d122794bd7700df174c5bd' #print TEA.detea_hexstr(ss,'00'*16) ss = '886c8763f92b24c6b7b430906a5466ecdf06d5a9278827279819457bdf1138b901a449f185c23806b0f66a3bb58e4d7b40324bde661bb3e0f31b9d314c21c36de6a6dcd2fa922e5bf53bf27cbac4479aff1295a084d6a9dce8e36fddccbb605267d4fd775fd09a96ab338bba38df5baf51e74266e9ae797c7a6f9c19aea63d551a5639aceb17dc8dbd262b3451f39f3e3b23cf5a964ab52128e31a0b9a88b4fae0ff3b276fc7f450031768de11b57f4773b7bc18218cc5e8261cf2df3a880ef351c195e026596ef5518ffa9765f7a8e458656f1ca72878e8b99f4219ed48ed1b9216c163642aeeffdfa430fcfc02cb58ff0696a313b23de17c77c7ee210155277394060d735ba5210b021a76794578331871275cb26b71880da0843a7bc603e3039fa3094845b6fa21e45a37f795d3103245898a965605d2be285de3a5f135af5478702d2561dbf7b7d1e9b7db8b3297a9a09d86cf812bbf57d7f125ec72c1b05473048cf33297f6f43a9f5c7765e879b77ee7dc73ea372663fda6142bd2686346344557d9c51d6257ea62f7433823e2fe5658543e3874ff33da458ff8e8aedacde7ccb88c6f5bfd6d838ea1a12beedd17a3e8f857b7edd5fcb58ba163ac140a644ce6b86d03c455449f7f25d07991804d97ba6a7c8e014556ac38cb205b28ea0806fdde2eef3b8f70f91dab155efcb1dab319ef8933c6ce00c5a021ab9d8a4f7a37f1f3c66ce3ae165cd9163788385ea77dc06bb15f9476f178e5f2e5f0603948682dabc76cf36a833694d126dde1cc2c730974d1c820f8ee8e9d350f80f63ab5661f92b912cbbdf31543718fd036587c33c303d1665078c39b9c4709d539ba39ab60c345e9731b9276854d25b6e0f3d4d93ddcd425ce5d28ae39cccd90f2086881f38384a9fa847e5e762eb2cde2719a75b1bd4316426e4259efc851826808683b6bd68b7e769b9eaeefb7bcec8bd81c4f66ebfda3fe7fa937a436c459c54f7dd34cfde5a2957704f10d0e46455df476a39256ecbfaa993282100fcdfa8c0d0cd231354748126d31fb95e8083bba7b82a8030a3bf9b0409cb290f8add92e59069994adfb082555b6c0ea2bc5fa51f8b31c608904c12a12987f2de6973cee52fec49a3072949f863334a4142155e846d8ead69cfc6b744b6ec166495d549c0af06a110bbb76d0149f3f83ad3162b4a00ae50dfec4ef8468' packSendLoginMessage = TEA.detea_hexstr(ss, '00' * 16) print packSendLoginMessage packSendLoginTlv = packSendLoginMessage[382:1678] testShareKey = '579C2169A0A34E1162C6E6DB66C2D45D' packSendLoginTlv = TEA.detea_hexstr(packSendLoginTlv, testShareKey) print packSendLoginTlv[108:340] tvl106 = packSendLoginTlv[108:340] print 'tvl106 val ' + tvl106 tvl106 = tvl106[8:len(tvl106)] print 'tvl106 endocer ' + tvl106 pwdKey = '919260a4e19d44a59b5932b8790fc37d' tvl106 = TEA.detea_hexstr(tvl106, pwdKey) tgtKeys = tvl106[102:134] print 'tgtkeys ' + tgtKeys
def unpackRecvLoginSucceedMessage(self, data): data = TEA.detea_hexstr(data, self.shareKey) pack = HexPacket(data) pack.shr(2 + 1 + 4) data = pack.shr(Coder.hexstr2num(pack.shr(2))) #TLV解包 data = TEA.detea_hexstr(data, self.tgtKey) pack = HexPacket(data) tlv_num = Coder.hexstr2num(pack.shr(2)) for i in xrange(tlv_num): tlv_cmd = pack.shr(2) tlv_data = pack.shr(Coder.hexstr2num(pack.shr(2))) self.decodeTlv(tlv_cmd, tlv_data)
def unpackRecvLoginSucceedMessage(self, data): data = TEA.detea_hexstr(data, self.shareKey) pack = HexPacket(data) pack.shr(2 + 1 + 4) data = pack.shr(Coder.hexstr2num(pack.shr(2))) #TLV解包 data = TEA.detea_hexstr(data, self.tgtKey) pack = HexPacket(data) tlv_num = Coder.hexstr2num(pack.shr(2)) for i in xrange(tlv_num): tlv_cmd = pack.shr(2) tlv_data = pack.shr(Coder.hexstr2num(pack.shr(2))) self.decodeTlv(tlv_cmd, tlv_data)
def unpackRecvLoginSucceedMessage(data): data = TEA.detea_hexstr(data,'9A1BDA11D3BEA2DEDC58C487B3D174BA') #shareKey pack = HexPacket(data) pack.shr(2 + 1 + 4) data = pack.shr(Coder.hexstr2num(pack.shr(2))) #TLV解包 data = TEA.detea_hexstr(data,'9d2a2efab0653d0aecdb8a3e97c4dd22')#tgtKey pack = HexPacket(data) tlv_num = Coder.hexstr2num(pack.shr(2)) for i in xrange(tlv_num): tlv_cmd = pack.shr(2) tlv_data = pack.shr(Coder.hexstr2num(pack.shr(2))) decodeTlv(tlv_cmd, tlv_data)
def packSendLoginTlv(self, verifyCode=None): if verifyCode == None: tlv = '' tlv += Coder.trim('00 09') tlv += Coder.trim('00 14') #tlv包个数 #tlv组包 tlv += Tlv.tlv18(self.uin) tlv += Tlv.tlv1(self.uin, self.server_time) print 'packSendLoginTlv tlv106 start ' + bytes(len(tlv)) tvl106 = Tlv.tlv106(self.uin, self.server_time, self.pwdMd5, self.tgtKey, self.imei, self.appId, self.pwdKey) tlv +=tvl106 print 'packSendLoginTlv tlv106 end ' + bytes(len(tlv)) tlv += Tlv.tlv116() tlv += Tlv.tlv100() tlv += Tlv.tlv107() tlv += Tlv.tlv144(self.tgtKey, self.imei, self.os_type, self.os_version, self.network_type, self.sim_operator_name, self.apn, self.device, self.device_product) tlv += Tlv.tlv142(self.package_name) tlv += Tlv.tlv145(self.imei) tlv += Tlv.tlv154(self.seq) tlv += Tlv.tlv141(self.sim_operator_name, self.network_type, self.apn) tlv += Tlv.tlv8() tlv += Tlv.tlv16b() tlv += Tlv.tlv147() tlv += Tlv.tlv177() tlv += Tlv.tlv187() tlv += Tlv.tlv188() tlv += Tlv.tlv191() tlv += Tlv.tlv194() tlv += Tlv.tlv202(self.wifi_name) print 'tvl106 index :' + bytes(tlv.find(tvl106)) + '----' + bytes(tlv.find(tvl106)+len(tvl106)) print 'packSendLoginTlv tlv :'+tlv tlv = TEA.entea_hexstr(tlv, self.shareKey) return tlv else: tlv = '' tlv += Coder.trim('00 02') tlv += Coder.trim('00 04') #tlv组包 tlv += Tlv.tlv2(verifyCode, self.verifyToken1) tlv += Tlv.tlv8() tlv += Tlv.tlv104(self.verifyToken2) tlv += Tlv.tlv116() tlv = TEA.entea_hexstr(tlv, self.shareKey) return tlv
def Pack_FriendListServiceServantObj_GetTroopMemberListReq(self, GroupNumber): msg = '' msg += Coder.trim( '00 00 00 2D 00 00 00 21 66 72 69 65 6E 64 6C 69 73 74 2E 67 65 74 54 72 6F 6F 70 4D 65 6D 62 65 72 4C 69 73 74 00 00 00 08 31 61 D2 53 00 00 00 7D' ) msg += Coder.trim( '10 03 2C 3C 42 2F 42 20 DF 56 29 6D 71 71 2E 49 4D 53 65 72 76 69 63 65 2E 46 72 69 65 6E 64 4C 69 73 74 53 65 72 76 69 63 65 53 65 72 76 61 6E 74 4F 62 6A 66 15 47 65 74 54 72 6F 6F 70 4D 65 6D 62 65 72 4C 69 73 74 52 65 71 7D 00 00 25 08 00 01 06 04 47 54 4D 4C 1D 00 00 18 0A 02' ) msg += Coder.qqnum2hexstr(self.qqnum) msg += Coder.trim('12') msg += Coder.qqnum2hexstr(GroupNumber) msg += Coder.trim('2C 33 00 00 00 00 9D 3F C2 21 40 02 0B 8C 98 0C A8 0C') data = TEA.entea_hexstr(msg, self.qqkey) data = TEA.entea_hexstr(msg, self.qqkey) return Pack(self, data, 2)
def tlv106(uin, server_time, pwdMd5, tgtKey, imei, appId, pwdKey): tlv = '' tlv += Coder.trim('00 03') tlv += Coder.genBytesHexstr(4) tlv += Coder.trim('00 00 00 05 00 00 00 10 00 00 00 00 00 00 00 00') tlv += uin tlv += server_time tlv += Coder.trim('00 00 00 00 01') tlv += pwdMd5 print 'tlv106 start len '+ bytes(len(tlv)) print 'tgtKey val:' +tgtKey tlv += tgtKey print 'tlv106 end len '+ bytes(len(tlv)) tlv += Coder.trim('00 00 00 00 01') tlv += imei tlv += appId tlv += Coder.trim('00 00 00 01') tlv += Coder.trim('00 00') print 'tlv106 val:'+tlv tlv = TEA.entea_hexstr(tlv, pwdKey) tlvlen = len(tlv) tlv = Coder.num2hexstr(len(tlv)/2, 2) + tlv tlv = Coder.trim('01 06') + tlv print 'tlv title :'+Coder.trim('01 06') + Coder.num2hexstr(len(tlv)/2, 2) print 'tlv entea index :' + bytes(len(tlv) - tlvlen) +" end "+bytes(tlvlen) return tlv
def packSendLoginMessage(self, verifyCode=None): #MessageHead msgHeader = '' msgHeader += Coder.num2hexstr(self.seq+1, 4) msgHeader += self.appId msgHeader += self.appId msgHeader += Coder.trim('01 00 00 00 00 00 00 00 00 00 00 00') msgHeader += Coder.num2hexstr(len(self.extBin)/2+4, 4) + self.extBin msgHeader += Coder.num2hexstr(len(self.loginCmd)/2+4, 4) + self.loginCmd msgHeader += Coder.num2hexstr(len(self.msgCookies)/2+4, 4) + self.msgCookies msgHeader += Coder.num2hexstr(len(self.imei)/2+4, 4) + self.imei msgHeader += Coder.num2hexstr(len(self.ksid)/2+4, 4) + self.ksid msgHeader += Coder.num2hexstr(len(self.ver)/2+2, 2) + self.ver msgHeader = Coder.num2hexstr(len(msgHeader)/2+4, 4) + msgHeader #Message msg = '' msg += Coder.trim('1F 41') msg += Coder.trim('08 10 00 01') msg += self.uin msg += Coder.trim('03 07 00 00 00 00 02 00 00 00 00 00 00 00 00 01 01') msg += self.randomKey msg += Coder.trim('01 02') msg += Coder.num2hexstr(len(self.pubKey)/2, 2) + self.pubKey #TEA加密的TLV msg += self.packSendLoginTlv(verifyCode) msg += Coder.trim('03') msg = Coder.num2hexstr(len(msg)/2+2+1, 2) + msg msg = Coder.trim('02') + msg msg = Coder.num2hexstr(len(msg)/2+4, 4) + msg packet = msgHeader + msg packet = TEA.entea_hexstr(packet, self.defaultKey) return packet
def Pack_EncounterSvc_ReqGetEncounter(self, long, lat): """ 获取附近的人 """ # 0000002c00000020456e636f756e7465725376632e526571476574456e636f756e74657200000008844cd92b000001ff msg = '' msg += Coder.trim( '00 00 00 2C 00 00 00 20 45 6E 63 6F 75 6E 74 65 72 53 76 63 2E 52 65 71 47 65 74 45 6E 63 6F 75 6E 74 65 72 00 00 00 08 D7 1C 77 15 00 00 01 88' ) msg += Coder.trim('10 03 2C 3C 42') self.qq00001 = random.randint(10000000, 99999999) msg += str(self.qq00001) msg += Coder.trim( ' 56 0C 45 6E 63 6F 75 6E 74 65 72 4F 62 6A 66 13 43 4D 44 5F 47 45 54 5F 45 4E 43 4F 55 4E 54 45 52 56 32 7D 00 01 01 4E 08 00 02 06 09 52 65 71 48 65 61 64 65 72 1D 00 00 13 0A 00 02 12' ) msg += Coder.trim(Coder.qqnum2hexstr(self.qqnum)) msg += Coder.trim('22 20 02 9A A9 3C 40 02 5C 6C 0B 06 11') msg += Coder.trim( '52 65 71 47 65 74 45 6E 63 6F 75 6E 74 65 72 56 32 1D 00 01 01 11 0A 0A 0A 02' ) msg += Coder.num2hexstr(lat, 4) msg += Coder.trim('12') msg += Coder.num2hexstr(long, 4) msg += Coder.trim( '2C 30 01 0B 19 0C 29 0C 36 16 42 31 5F 51 51 5F 4E 65 69 67 68 62 6F 72 5F 61 6E 64 72 6F 69 64 46 08 4E 7A 56 4B 5F 71 47 45 5C 6C 0B 1A 0C 12 35 A4 E9 00 22 35 A4 E9 00 3C 4C 56 00 0B 20 00 30 FF 5D 00 00 01 00 6C 71 07 D0 80 FF 9C BD 00 00 72 00 00 00 72' ) msg += Coder.trim( '10 03 2C 3C 40 01 56 1C 50 75 62 41 63 63 6F 75 6E 74 53 76 63 2E 6E 65 61 72 62 79 5F 70 75 62 61 63 63 74 66 0E 6E 65 61 72 62 79 5F 70 75 62 61 63 63 74 7D 00 00 31 08 00 01 06 0E 6E 65 61 72 62 79 5F 70 75 62 61 63 63 74 1D 00 00 1A 0A 00 02 1D 00 0C 20 02 3A 0A 02 01 78 40 64 12 06 1D 64 AD 2C 30 01 0B 0B 0B 8C 98 0C A8 0C CC D0 00 EC FC 0F FC 10 F1 11 01 E0 FC 12 FC 13 FC 14 F0 15 00 FC 16 FA 17 0A 02 01 78 40 64 12 06 1D 64 AD 2C 30 01 0B 19 0C 29 0C 36 00 46 00 50 01 6C 0B F0 18 0F FD 19 00 0C FC 1A FC 1B 0B 8C 98 0C A8 0C' ) print msg data = TEA.entea_hexstr(msg, self.qqkey) return Pack(self, data, 2)
def Pack_SummaryCardServantObj_ReqCondSearch_again(self, message, n): alllong = Coder.num2hexstr(151 + len(message)) msglong = Coder.num2hexstr(len(message)) mainlong = Coder.num2hexstr(91 + len(message)) erlong = Coder.num2hexstr(52 + len(message)) COUNT = Coder.num2hexstr(n) msg = '' msg += Coder.trim( '00 00 00 29 00 00 00 1D 53 75 6D 6D 61 72 79 43 61 72 64 2E 52 65 71 43 6F 6E 64 53 65 61 72 63 68 00 00 00 08 E4 A7 76 B4 00 00 00' ) msg += alllong msg += Coder.trim( '10 03 2C 3C 42 7A 15 57 8D 56 15 53 75 6D 6D 61 72 79 43 61 72 64 53 65 72 76 61 6E 74 4F 62 6A 66 0D 52 65 71 43 6F 6E 64 53 65 61 72 63 68 7D 00 00' ) msg += mainlong msg += Coder.trim( '08 00 02 06 07 52 65 71 48 65 61 64 1D 00 00 04 0A 00 02 0B 06 0D 52 65 71 43 6F 6E 64 53 65 61 72 63 68 1D 00 00' ) msg += erlong msg += Coder.trim('0A 00') msg += COUNT msg += Coder.trim('10 01') msg += Coder.trim('20 01 36') msg += msglong msg += Coder.str2hexstr(message) msg += Coder.trim( '4C 5D 00 00 10 00 00 00 31 00 00 00 00 00 00 00 00 00 00 00 00 6C 7D 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 8C 98 0C A8 0C' ) data = TEA.entea_hexstr(msg, self.qqkey) return Pack(self, data, 2)
def Pack_QzoneNewService_getApplist(self, targetQQ): """ 获取指定qq号说说列表(完成) """ msg = '' msg += Coder.trim( '00 00 00 25 00 00 00 19 53 51 51 7A 6F 6E 65 53 76 63 2E 67 65 74 41 70 70 6C 69 73 74 00 00 00 08 71 72 5A A3 00 00 01 BE 02 00 00 C4 27 12 00 0F 42 5B 22' ) msg += Coder.qqnum2hexstr(self.qqnum) msg += Coder.trim( '36 19 56 31 5F 41 4E 44 5F 53 51 5F 35 2E 38 2E 30 5F 32 36 34 5F 59 59 42 5F 44 46 1A 51 7A 6F 6E 65 4E 65 77 53 65 72 76 69 63 65 2E 67 65 74 41 70 70 6C 69 73 74 56 75 69 3D 38 36 30 38 34 31 30 32 33 36 37 36 34 36 39 26 6D 61 63 3D 30 30 3A 31 36 3A 36 64 3A 66 30 3A 32 39 3A 63 36 26 6D 3D 38 31 39 30 51 26 6F 3D 34 2E 31 2E 32 26 61 3D 31 36 26 73 63 3D 31 26 73 64 3D 30 26 70 3D 35 34 30 2A 39 36 30 26 66 3D 59 75 4C 6F 6E 67 26 6E 3D 77 69 66 69 26 6C 6F 6E 67 69 74 75 64 65 3D 26 6C 61 74 69 74 75 64 65 3D 6A 00 40 1D 00 0C 28 00 01 00 01 1D 00 00 01 00 0B 7A 0C 1C 2C 3D 00 00 06 00 00 00 00 00 00 0B 8D 00 01 00 88' ) p1 = Coder.trim( '08 00 03 06 05 72 65 66 65 72 18 00 01 06 06 73 74 72 69 6E 67 1D 00 00 0D 06 0B 67 65 74 4D 61 69 6E 50 61 67 65 06 0A 67 65 74 41 70 70 6C 69 73 74 18 00 01 06 22 4E 53 5F 4D 4F 42 49 4C 45 5F 46 45 45 44 53 2E 6D 6F 62 69 6C 65 5F 61 70 70 6C 69 73 74 5F 72 65 71 1D 00 00 12 0A 02' ) p2 = Coder.qqnum2hexstr(targetQQ) p3 = Coder.trim( '11 01 37 20 0A 36 00 4C 50 01 6C 0B 06 07 68 6F 73 74 75 69 6E 18 00 01 06 05 69 6E 74 36 34 1D 00 00 05 02' ) p4 = Coder.qqnum2hexstr(self.qqnum) msg += Coder.str2hexstr(zlib.compress(Coder.hexstr2str(p1 + p2 + p3 + p4))) msg += Coder.trim( '9D 00 00 3D 08 00 01 06 0B 62 75 73 69 43 6F 6D 70 43 74 6C 18 00 01 06 1B 51 4D 46 5F 50 52 4F 54 4F 43 41 4C 2E 51 6D 66 42 75 73 69 43 6F 6E 74 72 6F 6C 1D 00 00 09 0A 00 01 11 00 8B 20 01 0B AC BC CA 0C 1C 23 00 00' ) msg += '0' + Coder.qqnum2hexstr(int(time.time() * 1000)) + '0b' data1 = TEA.entea_hexstr(msg, self.qqkey) return Pack(self, data1, 2)
def Pack_QzoneNewService_getWidget(self): """ 未完成 :param self: :return: """ print Coder.qqnum2hexstr(self.qqnum) msg = '' msg += Coder.trim( '00 00 00 2C 00 00 00 20 53 51 51 7A 6F 6E 65 53 76 63 2E 67 65 74 4E 65 77 41 63 74 69 76 65 46 65 65 64 73 00 00 00 08 31 61 D2 53 00 00 01 CF 01 37 5D 12 00 0F 42 5B 22' ) msg += Coder.qqnum2hexstr(self.qqnum) msg += Coder.trim( '36 19 56 31 5F 41 4E 44 5F 53 51 5F 35 2E 37 2E 31 5F 32 35 38 5F 59 59 42 5F 44 46 21 51 7A 6F 6E 65 4E 65 77 53 65 72 76 69 63 65 2E 67 65 74 4E 65 77 41 63 74 69 76 65 46 65 65 64 73 56 75 69 3D 38 36 30 38 34 31 30 32 33 36 37 36 34 36 39 26 6D 61 63 3D 30 30 3A 31 36 3A 36 64 3A 66 30 3A 32 39 3A 63 36 26 6D 3D 38 31 39 30 51 26 6F 3D 34 2E 31 2E 32 26 61 3D 31 36 26 73 63 3D 31 26 73 64 3D 30 26 70 3D 35 34 30 2A 39 36 30 26 66 3D 59 75 4C 6F 6E 67 26 6E 3D 77 69 66 69 26 6C 6F 6E 67 69 74 75 64 65 3D 26 6C 61 74 69 74 75 64 65 3D 6A 00 40 1D 00 0C 28 00 01 00 01 1D 00 00 01 00 0B 7A 0C 1C 2C 3D 00 00 06 00 00 00 00 00 00 0B 8D 00 00 5A' ) p1 = Coder.trim( '08 00 02 06 09 67 65 74 57 69 64 67 65 74 18 00 01 06 1D 4E 53 5F 4D 4F 42 49 4C 45 5F 57 49 44 47 45 54 2E 47 65 74 57 69 64 67 65 74 52 65 71 1D 00 00 0D 0A 00 FF 12' ) p2 = '' p3 = Coder.trim( '20 08 36 00 0B 06 07 68 6F 73 74 75 69 6E 18 00 01 06 05 69 6E 74 36 34 1D 00 00 05 02' ) p4 = Coder.qqnum2hexstr(self.qqnum) msg += Coder.str2hexstr(zlib.compress(Coder.hexstr2str(p1 + p2 + p3 + p4))) msg += Coder.trim( '9D 00 00 3C 08 00 01 06 0B 62 75 73 69 43 6F 6D 70 43 74 6C 18 00 01 06 1B 51 4D 46 5F 50 52 4F 54 4F 43 41 4C 2E 51 6D 66 42 75 73 69 43 6F 6E 74 72 6F 6C 1D 00 00 08 0A 00 01 10 5D 20 01 0B AC BC CA 0C 1C 23 00 00' ) msg += '0' + Coder.qqnum2hexstr(int(time.time() * 1000)) + '0b' print msg return Pack(self, TEA.entea_hexstr(msg, self.qqkey), 2)
def unpackRecvLoginVerifyMessage(self, data): data = TEA.detea_hexstr(data, self.shareKey) pack = HexPacket(data) pack.shr(3) tlv_num = Coder.hexstr2num(pack.shr(2)) for i in xrange(tlv_num): tlv_cmd = pack.shr(2) tlv_data = pack.shr(Coder.hexstr2num(pack.shr(2))) self.decodeTlv(tlv_cmd, tlv_data)
def unpackRecvLoginVerifyMessage(self, data): data = TEA.detea_hexstr(data, self.shareKey) pack = HexPacket(data) pack.shr(3) tlv_num = Coder.hexstr2num(pack.shr(2)) for i in xrange(tlv_num): tlv_cmd = pack.shr(2) tlv_data = pack.shr(Coder.hexstr2num(pack.shr(2))) self.decodeTlv(tlv_cmd, tlv_data) pass
def tlv144(tgtKey, imei, os_type, os_version, network_type, sim_operator_name, apn, device, device_product): tlv = '' tlv += Coder.trim('00 04') tlv += Tlv.tlv109(imei) tlv += Tlv.tlv124(os_type, os_version, network_type, sim_operator_name, apn) tlv += Tlv.tlv128(device, imei, device_product) tlv += Tlv.tlv16e(device) tlv = TEA.entea_hexstr(tlv, tgtKey) tlv = Coder.num2hexstr(len(tlv)/2, 2) + tlv tlv = Coder.trim('01 44') + tlv return tlv
def tlv144(tgtKey, imei, os_type, os_version, network_type, sim_operator_name, apn, device, device_product): tlv = '' tlv += Coder.trim('00 04') tlv += Tlv.tlv109(imei) tlv += Tlv.tlv124(os_type, os_version, network_type, sim_operator_name, apn) tlv += Tlv.tlv128(device, imei, device_product) tlv += Tlv.tlv16e(device) tlv = TEA.entea_hexstr(tlv, tgtKey) tlv = Coder.num2hexstr(len(tlv)/2, 2) + tlv tlv = Coder.trim('01 44') + tlv return tlv
def unpackRecvLoginMessage(self, data): data = TEA.detea_hexstr(data, self.defaultKey) print 'undata:', data pack = HexPacket(data) head = pack.shr(Coder.hexstr2num(pack.shr(4)) - 4) body = pack.remain(1) #head pack = HexPacket(head) Coder.hexstr2num(pack.shr(4)) #seq pack.shr(4) pack.shr(Coder.hexstr2num(pack.shr(4)) - 4) Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(4)) - 4)) #cmd pack.shr(Coder.hexstr2num(pack.shr(4)) - 4) #body pack = HexPacket(body) pack.shr(4 + 1 + 2 + 10 + 2) retCode = Coder.hexstr2num(pack.shr(1)) if retCode == 0: #登录成功 self.unpackRecvLoginSucceedMessage(pack.remain()) print u'登录成功: ', self.nickname print 'qqkey', self.qqkey self.alive = True self.verify = False elif retCode == 2: #需要验证码 self.unpackRecvLoginVerifyMessage(pack.remain()) print self.verifyReason self.alive = False self.verify = True print self.verifyPicHexstr code = self.window.SetVerification(self.verifyPicHexstr) print code self.login(Coder.str2hexstr(code)) else: #登录失败 pack = HexPacket(TEA.detea_hexstr(pack.remain(), self.shareKey)) pack.shr(2 + 1 + 4 + 2) pack.shr(4) #type title = Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(2)))) msg = Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(2)))) print title, ': ', msg self.alive = False self.verify = False
def Make_sendSsoMsg(self, cmd, bin): serviceCmd = Coder.str2hexstr(cmd) msg = '' msg += Coder.num2hexstr(len(serviceCmd) / 2 + 4, 4) + serviceCmd msg += Coder.num2hexstr(len(self.msgCookies2) / 2 + 4, 4) + self.msgCookies2 data = '' data += Coder.num2hexstr(len(msg) / 2 + 4, 4) + msg data += bin value = TEA.entea_hexstr(data, self.qqkey) return value
def decode(data): packet = TEA.detea_hexstr(data, '00' * 16) value1 = re.findall('0307000000000200000000000000000101(.*)', packet)[0] value2 = value1[:32] print 'randomKey', value2 value1 = value1[36:] print value1 lenstr = Coder.hexstr2num(value1[:4]) * 2 print 'pubKey 长度', lenstr pubKey = value1[4:][:lenstr] print 'pubKey ', pubKey if pubKey in Keys.pubKeys: print '有' else: print '没有' tlvstr = value1[4 + lenstr:][:-2] print 'tlv加密前', tlvstr lll = TEA.detea_hexstr(tlvstr, '08C1A214C4E76086152128B59784D1AA') print 'tlv', lll return lll
def unpackRecvLoginMessage(self, data): data = TEA.detea_hexstr(data, self.defaultKey) pack = HexPacket(data) head = pack.shr(Coder.hexstr2num(pack.shr(4)) - 4) body = pack.remain(1) #head pack = HexPacket(head) Coder.hexstr2num(pack.shr(4)) #seq pack.shr(4) pack.shr(Coder.hexstr2num(pack.shr(4)) - 4) Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(4)) - 4)) #cmd pack.shr(Coder.hexstr2num(pack.shr(4)) - 4) #body pack = HexPacket(body) pack.shr(4 + 1 + 2 + 10 + 2) retCode = Coder.hexstr2num(pack.shr(1)) if retCode == 0: #登录成功 self.unpackRecvLoginSucceedMessage(pack.remain()) print u'登录成功: ', self.nickname self.alive = True self.verify = False elif retCode == 2: #需要验证码 self.unpackRecvLoginVerifyMessage(pack.remain()) print self.verifyReason self.alive = False self.verify = True threading.Thread(target=Img.showFromHexstr, args=(self.verifyPicHexstr, )).start() code = raw_input(u'请输入验证码:') self.login(Coder.str2hexstr(code)) else: #登录失败 pack = HexPacket(TEA.detea_hexstr(pack.remain(), self.shareKey)) pack.shr(2 + 1 + 4 + 2) pack.shr(4) #type title = Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(2)))) msg = Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(2)))) print title, ': ', msg self.alive = False self.verify = False
def packSendLoginTlv(self, verifyCode=None): if verifyCode == None: tlv = '' tlv += Coder.trim('00 09') tlv += Coder.trim('00 14') #tlv包个数 #tlv组包 tlv += Tlv.tlv18(self.uin) tlv += Tlv.tlv1(self.uin, self.server_time) tlv += Tlv.tlv106(self.uin, self.server_time, self.pwdMd5, self.tgtKey, self.imei, self.appId, self.pwdKey) tlv += Tlv.tlv116() tlv += Tlv.tlv100() tlv += Tlv.tlv107() tlv += Tlv.tlv144(self.tgtKey, self.imei, self.os_type, self.os_version, self.network_type, self.sim_operator_name, self.apn, self.device, self.device_product) tlv += Tlv.tlv142(self.package_name) tlv += Tlv.tlv145(self.imei) tlv += Tlv.tlv154(self.seq) tlv += Tlv.tlv141(self.sim_operator_name, self.network_type, self.apn) tlv += Tlv.tlv8() tlv += Tlv.tlv16b() tlv += Tlv.tlv147() tlv += Tlv.tlv177() tlv += Tlv.tlv187() tlv += Tlv.tlv188() tlv += Tlv.tlv191() tlv += Tlv.tlv194() tlv += Tlv.tlv202(self.wifi_name) tlv = TEA.entea_hexstr(tlv, self.shareKey) return tlv else: tlv = '' tlv += Coder.trim('00 02') tlv += Coder.trim('00 04') #tlv组包 tlv += Tlv.tlv2(verifyCode, self.verifyToken1) tlv += Tlv.tlv8() tlv += Tlv.tlv104(self.verifyToken2) tlv += Tlv.tlv116() tlv = TEA.entea_hexstr(tlv, self.shareKey) return tlv
def unpackRecvLoginMessage(self, data): data = TEA.detea_hexstr(data, self.defaultKey) pack = HexPacket(data) head = pack.shr(Coder.hexstr2num(pack.shr(4))-4) body = pack.remain(1) #head pack = HexPacket(head) Coder.hexstr2num(pack.shr(4)) #seq pack.shr(4) pack.shr(Coder.hexstr2num(pack.shr(4))-4) Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(4))-4)) #cmd pack.shr(Coder.hexstr2num(pack.shr(4))-4) #body pack = HexPacket(body) pack.shr(4 + 1 + 2 + 10 + 2) retCode = Coder.hexstr2num(pack.shr(1)) if retCode == 0: #登录成功 self.unpackRecvLoginSucceedMessage(pack.remain()) print u'登录成功: ', self.nickname self.alive = True self.verify = False elif retCode == 2: #需要验证码 self.unpackRecvLoginVerifyMessage(pack.remain()) print self.verifyReason self.alive = False self.verify = True threading.Thread(target=Img.showFromHexstr, args=(self.verifyPicHexstr, )).start() code = raw_input(u'请输入验证码:') self.login(Coder.str2hexstr(code)) else: #登录失败 pack = HexPacket(TEA.detea_hexstr(pack.remain(), self.shareKey)) pack.shr(2 + 1 + 4 + 2) pack.shr(4) #type title = Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(2)))) msg = Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(2)))) print title, ': ', msg self.alive = False self.verify = False
def packSendLoginMessage(self, verifyCode=None): #MessageHead msgHeader = '' msgHeader += Coder.num2hexstr(self.seq, 4) msgHeader += self.appId msgHeader += self.appId msgHeader += Coder.trim('01 00 00 00 00 00 00 00 00 00 00 00') msgHeader += Coder.num2hexstr(len(self.extBin) / 2 + 4, 4) + self.extBin msgHeader += Coder.num2hexstr(len(self.loginCmd) / 2 + 4, 4) + self.loginCmd msgHeader += Coder.num2hexstr(len(self.msgCookies) / 2 + 4, 4) + self.msgCookies msgHeader += Coder.num2hexstr(len(self.imei) / 2 + 4, 4) + self.imei msgHeader += Coder.num2hexstr(len(self.ksid) / 2 + 4, 4) + self.ksid msgHeader += Coder.num2hexstr(len(self.ver) / 2 + 2, 2) + self.ver msgHeader = Coder.num2hexstr(len(msgHeader) / 2 + 4, 4) + msgHeader #Message msg = '' msg += Coder.trim('1F 41') msg += Coder.trim('08 10 00 01') msg += self.uin msg += Coder.trim('03 07 00 00 00 00 02 00 00 00 00 00 00 00 00') if self.pubKey: ext_bin_null = False msg += Coder.trim('01 01') else: msg += Coder.trim('01 02') ext_bin_null = True msg += self.randomKey msg += Coder.trim('01 02') msg += Coder.num2hexstr(len(self.pubKey) / 2, 2) if ext_bin_null: msg += Coder.trim('00 00') else: msg += self.pubKey #TEA加密的TLV msg += self.packSendLoginTlv(verifyCode) msg += Coder.trim('03') msg = Coder.num2hexstr(len(msg) / 2 + 2 + 1, 2) + msg msg = Coder.trim('02') + msg msg = Coder.num2hexstr(len(msg) / 2 + 4, 4) + msg packet = msgHeader + msg packet = TEA.entea_hexstr(packet, self.defaultKey) return packet
def packSendLoginMessage(self, verifyCode=None): #MessageHead msgHeader = '' msgHeader += Coder.num2hexstr(self.seq+1, 4) msgHeader += self.appId msgHeader += self.appId msgHeader += Coder.trim('01 00 00 00 00 00 00 00 00 00 00 00') msgHeader += Coder.num2hexstr(len(self.extBin)/2+4, 4) + self.extBin msgHeader += Coder.num2hexstr(len(self.loginCmd)/2+4, 4) + self.loginCmd msgHeader += Coder.num2hexstr(len(self.msgCookies)/2+4, 4) + self.msgCookies msgHeader += Coder.num2hexstr(len(self.imei)/2+4, 4) + self.imei msgHeader += Coder.num2hexstr(len(self.ksid)/2+4, 4) + self.ksid msgHeader += Coder.num2hexstr(len(self.ver)/2+2, 2) + self.ver msgHeader = Coder.num2hexstr(len(msgHeader)/2+4, 4) + msgHeader print 'msgHeader len :'+bytes(len(msgHeader)) #Message msg = '' msg += Coder.trim('1F 41') msg += Coder.trim('08 10 00 01') msg += self.uin msg += Coder.trim('03 07 00 00 00 00 02 00 00 00 00 00 00 00 00 01 01') msg += self.randomKey msg += Coder.trim('01 02') msg += Coder.num2hexstr(len(self.pubKey)/2, 2) + self.pubKey print 'packSendLoginTlv start len : ' + bytes(len(msg)) packSendLoginTlv = self.packSendLoginTlv(verifyCode) #TEA加密的TLV msg += packSendLoginTlv print ' packSendLoginTlv end len : ' +bytes(len(msg)) msg += Coder.trim('03') msg = Coder.num2hexstr(len(msg)/2+2+1, 2) + msg msg = Coder.trim('02') + msg msg = Coder.num2hexstr(len(msg)/2+4, 4) + msg packet = msgHeader + msg print 'packSendLoginTlv index :' + bytes(packet.find(packSendLoginTlv)) + '----' + bytes(packet.find(packSendLoginTlv)+len(packSendLoginTlv)) packet = TEA.entea_hexstr(packet, self.defaultKey) print 'packet entea_hexstr content :' +packet return packet
def Make_sendSsoMsg(self, cmd, bin): """ SsoMsg二次组包使用 qqkey 加密 (完整) || **--> Pack_sendSsoMsg_simple -> this || """ serviceCmd = Coder.str2hexstr(cmd) msg = '' msg += Coder.num2hexstr(len(serviceCmd) / 2 + 4, 4) + serviceCmd msg += Coder.num2hexstr(len(config.msgCookies) / 2 + 4, 4) + config.msgCookies data = '' data += Coder.num2hexstr(len(msg) / 2 + 4, 4) + msg data += bin value = TEA.entea_hexstr(data, self.qqkey) return value
def unpackRecvLoginMessage(data): data = TEA.detea_hexstr(data, '00'*16) pack = HexPacket(data) head = pack.shr(Coder.hexstr2num(pack.shr(4))-4) body = pack.remain(1) #head pack = HexPacket(head) Coder.hexstr2num(pack.shr(4)) #seq pack.shr(4) pack.shr(Coder.hexstr2num(pack.shr(4))-4) Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(4))-4)) #cmd pack.shr(Coder.hexstr2num(pack.shr(4))-4) #body pack = HexPacket(body) pack.shr(4 + 1 + 2 + 10 + 2) retCode = Coder.hexstr2num(pack.shr(1)) if retCode == 0: #登录成功 unpackRecvLoginSucceedMessage(pack.remain())
def tlvdecode(value): data = value[8:] #去掉头 #TLV18 data = data[8:] data = data[28:] qqnum = data[:8] print qqnum data = data[8:] data = data[8:] #TLV1 value = data[4:] value = value[16:] qqnum = value[:8] value = value[8:] print qqnum value = value[8:] #时间 value = value[12:] print value #TLV106 value1 = value[4:] #01 06 lenstr1 = Coder.hexstr2num(value1[:4]) * 2 str = value1[4:][:lenstr1] print '106加密前', str pwdKey = Coder.hash_qqpwd_hexstr('188075889', 'qw6012827') print 'pwdKey', pwdKey string = TEA.detea_hexstr(str, pwdKey) print '106解密后', string value = string[4:] value = value[8:] value = value[32:] value = value[16:] value = value[10:] pwdmd5 = MD5.md5_hex('qw6012827') print pwdmd5 value = value[32:] tgtKey = value[:32] print 'tgtKey', tgtKey
def tlv106(uin, server_time, pwdMd5, tgtKey, imei, appId, pwdKey): tlv = '' tlv += Coder.trim('00 03') tlv += Coder.genBytesHexstr(4) tlv += Coder.trim('00 00 00 05 00 00 00 10 00 00 00 00 00 00 00 00') tlv += uin tlv += server_time tlv += Coder.trim('00 00 00 00 01') tlv += pwdMd5 tlv += tgtKey tlv += Coder.trim('00 00 00 00 01') tlv += imei tlv += appId tlv += Coder.trim('00 00 00 01') tlv += Coder.trim('00 00') tlv = TEA.entea_hexstr(tlv, pwdKey) tlv = Coder.num2hexstr(len(tlv)/2, 2) + tlv tlv = Coder.trim('01 06') + tlv return tlv
def tlv106(uin, server_time, pwdMd5, tgtKey, imei, appId, pwdKey): tlv = '' tlv += Coder.trim('00 03') tlv += Coder.genBytesHexstr(4) tlv += Coder.trim('00 00 00 05 00 00 00 10 00 00 00 00 00 00 00 00') tlv += uin tlv += server_time tlv += Coder.trim('00 00 00 00 01') tlv += pwdMd5 tlv += tgtKey tlv += Coder.trim('00 00 00 00 01') tlv += imei tlv += appId tlv += Coder.trim('00 00 00 01') tlv += Coder.trim('00 00') tlv = TEA.entea_hexstr(tlv, pwdKey) tlv = Coder.num2hexstr(len(tlv) / 2, 2) + tlv tlv = Coder.trim('01 06') + tlv return tlv
def Make_login_sendSsoMsg(self, cmd, bin): #MessageHead cmd = Coder.str2hexstr(cmd) msgHeader = '' msgHeader += Coder.num2hexstr(self.seq, 4) msgHeader += self.appId msgHeader += self.appId msgHeader += Coder.trim('01 00 00 00 00 00 00 00 00 00 00 00') msgHeader += Coder.num2hexstr(len(self.token004c) / 2 + 4, 4) + self.token004c msgHeader += Coder.num2hexstr(len(cmd) / 2 + 4, 4) + cmd msgHeader += Coder.num2hexstr(len(self.msgCookies2) / 2 + 4, 4) + self.msgCookies2 msgHeader += Coder.num2hexstr(len(self.imei) / 2 + 4, 4) + self.imei msgHeader += Coder.num2hexstr(len(self.ksid) / 2 + 4, 4) + self.ksid msgHeader += Coder.num2hexstr(len(self.ver) / 2 + 2, 2) + self.ver Header = Coder.num2hexstr(len(msgHeader) / 2 + 4, 4) + msgHeader body = Header + Coder.num2hexstr(len(bin) / 2 + 4, 4) + bin data = TEA.entea_hexstr(body, self.qqkey) return data
def Pack_EncounterSvc_ReqGetEncounter2(self): msg = '' msg += '10032c3c42' msg += str(self.qq00001 + 1) msg += '560c456e636f756e7465724f626a6613434d445f4745545f454e434f554e54455256327d0001' body = '08000206095265714865616465721d0000130a000312' body += Coder.qqnum2hexstr(self.qqnum) body += '2220029f533c40025c6c0b0611526571476574456e636f756e74657256321d0001' body_1 = '0a0a0a0c1c20ff3c0b361642315f51515f4e65696768626f725f616e64726f696446084e7a564b5f7147455c600289' body_1 += '00100a030000c6850826a74b10e00b0a03000014e6e4bf7c2e10e00b0a030000586d8f6806bd10cb0b0a030000b8ee65d56cda10c40b0a0300003c8c4048eb5010cc0b0a0300003c8c4048fdd010c60b0a0300003c8c4049069010c50b0a0300003c8c40490f6010b30b0a0300003c8c4048f7d010b80b0a0300003c8c404902e010b40b0a0300003c8c4048ed7010b00b0a030000246968a5359c10b50b0a0300003c8c404910e010af0b0a0300003c8c4049033010ab0b0a0300003c8c404907c010a90b0a0300003c8c4049085010af0b' body_1 += '9900010a0101cc100121361f31179240ff0b0b1a02' body_1 += Coder.num2hexstr(int(time.time()), 4) body_1 += '12' body_1 += Coder.num2hexstr(self.lat, 4) body_1 += '22' body_1 += Coder.num2hexstr(self.long, 4) body_1 += '3c43' body_1 += '01c9d64000b778c0' body_1 += '56' city = Coder.str2hexstr('浙江省杭州市') body_1 += Coder.num2hexstr(len(city) / 2) + city body_1 += '6d0000130d000c1c2301c9c38000b785403c4c50ff6c7c0b200130ff5d000001006c7107d080ff9cccd001ecfc0ffc10f11101e0fc12fc13fc14f01501fc16f0180ffd1900000e1800200028003000380040004a00fc1afc1bfc1cf61d' j = '{"dtype":1,"muid":"8DF9E26F89DDC39EEA9F32691174D17C","carrier":2,"conn":1,"posw":216,"posh":150,"lat":' + str( self.lat) + ',"lng":' + str( self.long) + ',"c_os":"android","c_osver":"5.1.1"}' jsondata = Coder.str2hexstr(j) body_1 += Coder.num2hexstr(len(jsondata) / 2) + jsondata body_1 += 'f01e3ffc1ff020030b' body += Coder.num2hexstr(len(body_1) / 2, 2) + body_1 msg += Coder.num2hexstr(len(body) / 2, 2) + body msg += '8c980ca80c' print msg d1 = '0000002c00000020456e636f756e7465725376632e526571476574456e636f756e746572' d1 += Coder.trim('00 00 00 08 D7 1C 77 15') d2 = d1 + Coder.num2hexstr(len(msg) / 2 + 4, 4) + msg data = TEA.entea_hexstr(d2, self.qqkey) return Pack(self, data, 2)
def Fun_recv(self): list = [] ret = self.socket.recv() if ret: if ret == '0': return try: retdata = Coder.str2hexstr(ret) while retdata: n = retdata[:8] long = Coder.hexstr2num(n) * 2 list.append(retdata[:long]) retdata = retdata[long:] for item in list: qq = self.qqHexstr + '(.*)' data1 = re.findall(qq, item)[0] data = TEA.detea_hexstr(data1, self.qqkey) pack = HexPacket(data) head = pack.shr(Coder.hexstr2num(pack.shr(4)) - 4) body = pack.remain(1) #head pack = HexPacket(head) Coder.hexstr2num(pack.shr(4)) #seq pack.shr(4) pack.shr(Coder.hexstr2num(pack.shr(4)) - 4) cmd = Coder.hexstr2str( pack.shr(Coder.hexstr2num(pack.shr(4)) - 4)) #cmd print '##################', cmd, '#####################' pack.shr(Coder.hexstr2num(pack.shr(4)) - 4) self.unpack(cmd, body) except: traceback.print_exc() else: print '返回包为空'
def decode(data,qqkey): value = TEA.detea_hexstr(data,qqkey) print value return value.decode('hex')
def getmessage(self): k = '00000023000000174d6573736167655376632e50624765744d73670000000854e96b10' pb = k + PB.getmsg() + '01' body = TEA.entea_hexstr(pb, self.qqkey) value = self.pack(body, 2) self.FunSend(Coder.hexstr2str(value))