Exemplo n.º 1
0
    def Pack_Head(self, pkt, mtype):
        pack = Pack()
        if mtype == 1:
            pack.write_hex('00 00 00 0A 02 00 00 00 04')
        elif mtype == 2:
            pack.write_hex('00 00 00 0A 01')
            pack.write_int(len(self.token0143) + 4)
            pack.write_bytes(self.token0143)
        elif mtype == 3:
            pack.write_hex('00 00 00 0B 01')
            pack.write_int(self.requestId)
        else:
            pack.write_hex('00 00 00 0B 02')
            pack.write_int(self.requestId)
        pack.write_hex('00 00 00')
        pack.write_short(len(self.qq) + 4)
        pack.write_str(self.qq)
        pack.write_bytes(pkt)

        pkt = pack.get_all()

        pack.set_empty()
        pack.write_int(len(pkt) + 4)
        pack.write_bytes(pkt)

        pkt = pack.get_all()
        return pkt
Exemplo n.º 2
0
    def Pack_FunHead(self, cmd, pkt: bytes):
        pack = Pack()
        pack.write_int(len(cmd) + 4)
        pack.write_str(cmd)
        pack.write_int(8)
        pack.write_bytes(self.msgCookies)
        pack.write_int(4)
        data = pack.get_all()

        pack.set_empty()
        pack.write_int(len(data) + 4)
        pack.write_bytes(data)
        pack.write_int(len(pkt) + 4)
        pack.write_bytes(pkt)
        return pack.get_all()
Exemplo n.º 3
0
    def Pack_LoginHead(self, cmd, pkt, cmd2):
        pack = Pack()
        pack.write_int(self.requestId)
        pack.write_int(self.appid)
        pack.write_int(self.appid2)
        pack.write_hex('01 00 00 00 00 00 00 00 00 00 01 00 00 00 00 04')
        pack.write_int(len(cmd) + 4)
        pack.write_str(cmd)
        pack.write_hex('00 00 00 08')
        pack.write_bytes(getRandomBin(4))  #msgCookie
        pack.write_int(len(self.deviceimie) + 4)
        pack.write_str(self.deviceimie)
        pack.write_hex('00 00 00 04')
        pack.write_short(len(self.ver) + 2)
        pack.write_str(self.ver)
        pack.write_hex('00 00 00 04')

        headpkt = pack.get_all()
        pack.set_empty()
        pack.write_int(len(headpkt) + 4)
        pack.write_bytes(headpkt)
        headpkt = pack.get_all()

        pack.set_empty()
        pack.write_hex('1F 41 08 ' + cmd2 + ' 00 01')
        pack.write_int(int(self.qq))
        pack.write_hex('03 87 00 00 00 00 02 00 00 00 00 00 00 00 00 02 01')
        pack.write_bytes(getRandomBin(16))
        pack.write_hex('01 31 00 01')
        pack.write_short(len(self.publickey))
        pack.write_bytes(self.publickey)
        pack.write_bytes(pkt)

        pkt = pack.get_all()

        pack.set_empty()
        pack.write_hex('02')
        pack.write_short(len(pkt) + 4)
        pack.write_bytes(pkt)
        pack.write_hex('03')

        pkt = pack.get_all()

        pack.set_empty()
        pack.write_bytes(headpkt)
        pack.write_int(len(pkt) + 4)
        pack.write_bytes(pkt)

        pkt = teaEncrypt(pack.get_all(), bytes(16))
        return pkt
Exemplo n.º 4
0
    def Pack_Online(self, mtype):
        pack = Pack()
        pack.write_int(self.requestId)
        pack.write_int(self.appid)
        pack.write_int(self.appid2)
        pack.write_hex('01 00 00 00 00 00 00 00 00 00 01 00')
        pack.write_hex('00 00 00 4C')
        pack.write_bytes(self.token010A)
        pack.write_int(len('StatSvc.register') + 4)
        pack.write_str('StatSvc.register')
        pack.write_hex('00 00 00 08')
        pack.write_bytes(self.msgCookies)
        pack.write_int(len(self.deviceimie) + 4)
        pack.write_str(self.deviceimie)
        if mtype == 0:
            pack.write_hex('00 00 00 04')
        else:
            pack.set_long_token(getRandomBin(16))
        pack.write_short(len(self.ver) + 2)
        pack.write_str(self.ver)
        pack.write_hex('00 00 00 04')
        headdata = pack.get_all()

        pack.set_empty()
        pack.write_hex(
            '10 03 2C 3C 4C 56 0B 50 75 73 68 53 65 72 76 69 63 65 66 0E 53 76 63 52 65 71 52 65 67 69 73 74 65 72 7D'
        )
        if mtype == 0:
            pack.write_hex('00 01 00 E6 08 00')
        elif mtype == 1:
            pack.write_hex('00 01 00 EA 08 00')
        elif mtype == 2:
            pack.write_hex('00 01 00 BD 08 00')
        pack.write_hex('01 06 0E 53 76 63 52 65 71 52 65 67 69 73 74 65 72')
        if mtype == 0:
            pack.write_hex('1D 00 01 00 CE 0A 03 00 00 00 00')
        elif mtype == 1:
            pack.write_hex('1D 00 01 00 D2 0A 03 00 00 00 00')
        elif mtype == 2:
            pack.write_hex('1D 00 01 00 A5 0A 03 00 00 00 00')
        pack.write_int(self.intqq)
        if mtype == 2:
            pack.write_hex('1C')
        else:
            pack.write_hex('10 07')
        pack.write_hex('2C 36 00')
        if mtype == 2:
            pack.write_hex('40 15')
        else:
            pack.write_hex('40 0B')
        pack.write_hex(
            '5C 6C 7C 8C 9C A0 75 B0 16 C0 01 D6 00 EC FD 10 00 00 10')
        pack.write_hex(self.deviceguid)
        pack.write_hex('F1 11 08 04 FC 12 F6 13')
        pack.write_bytes(int2bytes(len(self.devicename), 1))
        pack.write_str(self.devicename)
        pack.write_hex('F6 14')
        pack.write_bytes(int2bytes(len(self.devicename), 1))
        pack.write_str(self.devicename)
        pack.write_hex('F6 15 05')
        pack.write_hex('35 2E 31 2E 31')  #5.1.1
        pack.write_hex('F0 16 01')
        if mtype == 2:
            pack.write_hex('F1 17')
        else:
            pack.write_hex('F1 17 00 D7')
        pack.write_hex('FC 18')
        if mtype == 0:
            pack.write_hex('F3 1A 00 00 00 00 A6 3C 5E 7D F2 1B 5F 0D 60 71')
        elif mtype == 1:
            pack.write_hex(
                'F3 1A 00 00 00 00 D9 0C 60 71 F3 1B 00 00 00 00 A6 3C 5E 7D')
        elif mtype == 2:
            pack.write_hex('FC 1A FC 1B')
        pack.write_hex('F6 1C 00 FC 1D')
        if mtype == 2:
            pack.write_hex('F6 1E 00 F6 1F 00')
        else:
            pack.write_hex(
                'F6 1E 07 5B 75 5D 6F 70 70 6F F6 1F 14 3F 4C 59 5A 32 38 4E 3B 61 6E 64 72 6F 69 64 5F 78 38 36 2D'
            )
        pack.write_hex(
            'F6 20 00 FD 21 00 00 11 0A 08 08 2E 10 9A EF 9C FB 05 0A 05 08 9B 02 10 00 FC 22 FC 24'
        )
        if mtype == 2:
            pack.write_hex('F0 26 FF')
        else:
            pack.write_hex('FC 26')
        pack.write_hex('FC 27 FA 2A 00 01 0B 0B 8C 98 0C A8 0C')
        data = pack.get_all()

        pack.set_empty()
        pack.write_int(len(headdata) + 4)
        pack.write_bytes(headdata)
        pack.write_int(len(data) + 4)
        pack.write_bytes(data)
        data = pack.get_all()

        data = teaEncrypt(data, self.sessionKey)
        data = self.Pack_Head(data, 2)

        return data