Exemplo n.º 1
0
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
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
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
Exemplo n.º 9
0
 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
Exemplo n.º 10
0
 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
Exemplo n.º 11
0
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())
Exemplo n.º 12
0
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
Exemplo n.º 13
0
    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 '返回包为空'
Exemplo n.º 14
0
def decode(data,qqkey):


    value = TEA.detea_hexstr(data,qqkey)
    print value
    return value.decode('hex')