Exemple #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
Exemple #2
0
    def getQRCode(self):
        pack = Pack()
        pack.write_short(0)
        pack.write_int(16)
        pack.write_bytes(bytes(8))
        pack.write_hex('08')
        pack.write_short(0)
        pack.write_short(6)
        pack.write_bytes(
            Tlv.tlv016(16, self.appid, self.deviceguid, self.apkid,
                       self.deviceVersion, self.apk_sig))
        pack.write_bytes(Tlv.tlv01B())
        pack.write_bytes(Tlv.tlv01D(self.miscBitmap))
        pack.write_bytes(Tlv.tlv01F(self.deviceVersion))
        pack.write_bytes(Tlv.tlv033(self.deviceguid))
        pack.write_bytes(Tlv.tlv035())
        data = pack.get_all()
        data = self.BuildCode2DRequestPacket('00 31', 0, data)

        pack.set_empty()
        pack.write_hex('00 01 11 00 00 00 10 00 00 00 72 00 00 00')
        pack.write_int(int(time.time()))
        pack.write_bytes(data)
        data = pack.get_all()
        data = teaEncrypt(data, self.sharekey)
        data = self.Pack_LoginHead('wtlogin.trans_emp', data, '12')
        data = self.Pack_QRHead(data)
        return data
Exemple #3
0
 def Pack_Login_204(self):
     pack = Pack()
     pack.write_short(20)
     pack.write_short(4)
     pack.write_bytes(Tlv.tlv008())
     pack.write_bytes(Tlv.tlv104(self.token0104))
     pack.write_bytes(Tlv.tlv116())
     pack.write_bytes(Tlv.tlv401())
     data = pack.get_all()
     data = teaEncrypt(data, self.sharekey)
     data = self.Pack_LoginHead('wtlogin.login', data, '10')
     data = self.Pack_Head(data, 1)
     return data
Exemple #4
0
 def BuildCode2DRequestPacket(self, cmd, seq, data):
     pack = Pack()
     pack.write_hex('02')
     pack.write_short(43 + len(data) + 1)
     pack.write_hex(cmd)
     pack.write_hex(
         '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 32'
     )
     pack.write_int(seq)
     pack.write_bytes(bytes(8))
     pack.write_bytes(data)
     pack.write_hex('03')
     return pack.get_all()
Exemple #5
0
    def Pack_QRHead(self, pkt):
        pack = Pack()
        pack.write_hex('00 00 00 0A 02 00 00 00 04')
        pack.write_hex('00 00 00')
        pack.write_short(5)
        pack.write_hex('30')
        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
Exemple #6
0
    def getQRStatus(self):
        pack = Pack()
        pack.write_hex('00 05 01 00 00 00 08 00 00 00 10')
        pack.write_short(len(self.verifysig))
        pack.write_bytes(self.verifysig)
        pack.write_hex('00 00 00 00 00 00 00 00 08 00 00 00 00')
        data = pack.get_all()
        data = self.BuildCode2DRequestPacket('00 12', 1, data)

        pack.set_empty()
        pack.write_hex('00 00 62 00 00 00 10 00 00 00 72 00 00 00')
        pack.write_int(int(time.time()))
        pack.write_bytes(data)
        data = pack.get_all()

        data = teaEncrypt(data, self.sharekey)
        data = self.Pack_LoginHead('wtlogin.trans_emp', data, '12')
        data = self.Pack_QRHead(data)
        return data
Exemple #7
0
    def Pack_Login(self):
        pack = Pack()
        pack.write_short(9)
        pack.write_short(24)  #24个tlv
        pack.write_bytes(Tlv.tlv018(self.qq))
        pack.write_bytes(Tlv.tlv001(self.qq, self.starttime))
        pack.write_bytes(Tlv.tlv_pack("01 06", self.tmpPwd))
        pack.write_bytes(Tlv.tlv116())
        pack.write_bytes(Tlv.tlv100(self.appid, self.main_signmap))
        pack.write_bytes(Tlv.tlv107())
        pack.write_bytes(Tlv.tlv142(self.apkid))
        pack.write_bytes(
            Tlv.tlv144(
                self.tgtkey, Tlv.tlv109(self.AndroidId),
                Tlv.tlv124(self.deviceVersion),
                Tlv.tlv128(self.devicename, self.devicebrand, self.deviceguid),
                Tlv.tlv16E(self.devicename)))
        pack.write_bytes(Tlv.tlv145(self.deviceguid))
        pack.write_bytes(Tlv.tlv147(self.apk_v, self.apk_sig))
        pack.write_bytes(Tlv.tlv_pack("01 6A", self.tmpNoPicSig))
        pack.write_bytes(Tlv.tlv154(self.requestId))
        pack.write_bytes(Tlv.tlv141())
        pack.write_bytes(Tlv.tlv008())
        pack.write_bytes(Tlv.tlv511())
        pack.write_bytes(Tlv.tlv187(self.deviceMac))
        pack.write_bytes(Tlv.tlv188(self.deviceMac))
        pack.write_bytes(Tlv.tlv194(self.deviceImsi))
        pack.write_bytes(Tlv.tlv191("00"))
        pack.write_bytes(Tlv.tlv202(self.bssid, self.ssid))
        pack.write_bytes(Tlv.tlv177(self.starttime, self.sdkversion))
        pack.write_bytes(Tlv.tlv516())
        pack.write_bytes(Tlv.tlv521())
        pack.write_bytes(Tlv.tlv_pack("03 18", self.tgtQR))

        pkt = teaEncrypt(pack.get_all(), self.sharekey)
        pkt = self.Pack_LoginHead('wtlogin.login', pkt, '10')
        pkt = self.Pack_Head(pkt, 1)
        return pkt
Exemple #8
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
Exemple #9
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