Esempio n. 1
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)
Esempio n. 2
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
Esempio 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)
Esempio n. 4
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)
Esempio n. 5
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)
Esempio n. 6
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
Esempio n. 7
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
Esempio n. 8
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
Esempio n. 9
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
Esempio n. 10
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())
Esempio n. 11
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
Esempio n. 12
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 '返回包为空'
Esempio n. 13
0
 def decodeTlv(self, cmd, data):
     if cmd == Coder.trim('01 6A'):
         pass
     elif cmd == Coder.trim('01 06'):
         pass
     elif cmd == Coder.trim('01 0C'):
         pass
     elif cmd == Coder.trim('01 0A'):
         self.token004c = data
     elif cmd == Coder.trim('01 0D'):
         pass
     elif cmd == Coder.trim('01 14'):
         pack = HexPacket(data)
         pack.shr(6)
         self.token0058 = pack.shr(Coder.hexstr2num(pack.shr(2)))
     elif cmd == Coder.trim('01 0E'):
         self.mst1Key = data
     elif cmd == Coder.trim('01 03'):
         self.stweb = data
     elif cmd == Coder.trim('01 1F'):
         pass
     elif cmd == Coder.trim('01 38'):
         pass
     elif cmd == Coder.trim('01 1A'):
         pack = HexPacket(data)
         pack.shr(2 + 1 + 1)
         self.nickname = Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(1))))
     elif cmd == Coder.trim('01 20'):
         self.skey = data
     elif cmd == Coder.trim('01 36'):
         self.vkey = data
     elif cmd == Coder.trim('01 1A'):
         pass
     elif cmd == Coder.trim('01 20'):
         pass
     elif cmd == Coder.trim('01 36'):
         pass
     elif cmd == Coder.trim('03 05'):
         self.sessionKey = data
     elif cmd == Coder.trim('01 43'):
         self.token002c = data
     elif cmd == Coder.trim('01 64'):
         self.sid = data
     elif cmd == Coder.trim('01 18'):
         pass
     elif cmd == Coder.trim('01 63'):
         pass
     elif cmd == Coder.trim('01 30'):
         pack = HexPacket(data)
         pack.shr(2)
         self.server_time = pack.shr(4)
         self.ip = Coder.hexstr2ip(pack.shr(4))
     elif cmd == Coder.trim('01 05'):
         pack = HexPacket(data)
         self.verifyToken1 = pack.shr(Coder.hexstr2num(pack.shr(2)))
         self.verifyPicHexstr = pack.shr(Coder.hexstr2num(pack.shr(2)))
     elif cmd == Coder.trim('01 04'):
         self.verifyToken2 = data
     elif cmd == Coder.trim('01 65'):
         pack = HexPacket(data)
         pack.shr(4)
         title = Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(1))))
         msg = Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(4))))
         self.verifyReason = title + ": " + msg
     elif cmd == Coder.trim('01 08'):
         self.ksid = data
     elif cmd == Coder.trim('01 6D'):
         self.superKey = data
     elif cmd == Coder.trim('01 6C'):
         self.psKey = data
     else:
         print 'unknown tlv: '
         print cmd, ': ', data
Esempio n. 14
0
 def decodeTlv(self, cmd, data):
     if cmd == Coder.trim('01 6A'):
         pass
     elif cmd == Coder.trim('01 06'):
         pass
     elif cmd == Coder.trim('01 0C'):
         pass
     elif cmd == Coder.trim('01 0A'):
         self.token004c = data
     elif cmd == Coder.trim('01 0D'):
         pass
     elif cmd == Coder.trim('01 14'):
         pack = HexPacket(data)
         pack.shr(6)
         self.token0058 = pack.shr(Coder.hexstr2num(pack.shr(2)))
     elif cmd == Coder.trim('01 0E'):
         self.mst1Key = data
     elif cmd == Coder.trim('01 03'):
         self.stweb = data
     elif cmd == Coder.trim('01 1F'):
         pass
     elif cmd == Coder.trim('01 38'):
         pass
     elif cmd == Coder.trim('01 1A'):
         pack = HexPacket(data)
         pack.shr(2 + 1 + 1)
         self.nickname = Coder.hexstr2str(
             pack.shr(Coder.hexstr2num(pack.shr(1))))
     elif cmd == Coder.trim('01 20'):
         self.skey = data
     elif cmd == Coder.trim('01 36'):
         self.vkey = data
     elif cmd == Coder.trim('01 1A'):
         pass
     elif cmd == Coder.trim('01 20'):
         pass
     elif cmd == Coder.trim('01 36'):
         pass
     elif cmd == Coder.trim('03 05'):
         self.sessionKey = data
     elif cmd == Coder.trim('01 43'):
         self.token002c = data
     elif cmd == Coder.trim('01 64'):
         self.sid = data
     elif cmd == Coder.trim('01 18'):
         pass
     elif cmd == Coder.trim('01 63'):
         pass
     elif cmd == Coder.trim('01 30'):
         pack = HexPacket(data)
         pack.shr(2)
         self.server_time = pack.shr(4)
         self.ip = Coder.hexstr2ip(pack.shr(4))
     elif cmd == Coder.trim('01 05'):
         pack = HexPacket(data)
         self.verifyToken1 = pack.shr(Coder.hexstr2num(pack.shr(2)))
         self.verifyPicHexstr = pack.shr(Coder.hexstr2num(pack.shr(2)))
     elif cmd == Coder.trim('01 04'):
         self.verifyToken2 = data
     elif cmd == Coder.trim('01 65'):
         pack = HexPacket(data)
         pack.shr(4)
         title = Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(1))))
         msg = Coder.hexstr2str(pack.shr(Coder.hexstr2num(pack.shr(4))))
         self.verifyReason = title + ": " + msg
     elif cmd == Coder.trim('01 08'):
         self.ksid = data
     elif cmd == Coder.trim('01 6D'):
         self.superKey = data
     elif cmd == Coder.trim('01 6C'):
         self.psKey = data
     else:
         print 'unknown tlv: '
         print cmd, ': ', data