コード例 #1
0
        public override void OnReceived(Packet thePacket)
        {
            Logger.DEBUG(string.Empty);
            try
            {
                int    num   = thePacket.theContent.Length - this.detectedHeaderLength;
                byte[] array = new byte[num];
                Array.Copy(thePacket.theContent, this.detectedHeaderLength, array, 0, num);
                string @string = Encoding.get_UTF8().GetString(array);
                Dictionary <string, object> dictionary = Json.Deserialize(@string) as Dictionary <string, object>;
                string text             = dictionary.get_Item("data") as string;
                byte[] encodedDataBytes = Convert.FromBase64String(text);
                string text2            = MsdkTea.Decode(encodedDataBytes);
                if (text2.get_Length() > 0)
                {
                    Logger.DEBUG_LOGCAT(text2);
                    Dictionary <string, object> content = Json.Deserialize(text2) as Dictionary <string, object>;
                    Message message = new Message();
                    message.status  = 0;
                    message.action  = this.theAction;
                    message.content = content;
                    Pandora.Instance.GetNetLogic().EnqueueResult(message);
                    this.theAction = null;
                }
            }
            catch (Exception ex)
            {
                Logger.ERROR(ex.get_StackTrace());
            }
            long uniqueSocketId = base.GetUniqueSocketId();

            Pandora.Instance.GetNetLogic().Close(uniqueSocketId);
        }
コード例 #2
0
        public static string Encode(string rawData)
        {
            byte[] bytes  = Encoding.UTF8.GetBytes(rawData);
            byte[] bytes2 = Encoding.UTF8.GetBytes("msdkmsdkmsdkmsdk");
            int    length = 0;

            byte[] array = new byte[bytes.Length + 18];
            MsdkTea.oi_symmetry_encrypt2(bytes, bytes.Length, bytes2, array, ref length);
            return(Convert.ToBase64String(array, 0, length));
        }
コード例 #3
0
        public static string Decode(byte[] encodedDataBytes)
        {
            byte[] bytes = Encoding.UTF8.GetBytes("msdkmsdkmsdkmsdk");
            int    num   = encodedDataBytes.Length;

            byte[] array = new byte[num + 1];
            int    num2  = MsdkTea.oi_symmetry_decrypt2(encodedDataBytes, encodedDataBytes.Length, bytes, array, ref num);

            if (num2 != 0)
            {
                return(string.Empty);
            }
            return(Encoding.UTF8.GetString(array, 0, num));
        }
コード例 #4
0
        public override void OnConnected()
        {
            Logger.DEBUG(string.Empty);
            long uniqueSocketId = base.GetUniqueSocketId();
            Action <int, Dictionary <string, object> > action = delegate(int status, Dictionary <string, object> content)
            {
                try
                {
                    UserData userData = Pandora.Instance.GetUserData();
                    string   text     = string.Concat(new string[]
                    {
                        "openid=",
                        userData.sOpenId,
                        "&partition=",
                        userData.sPartition,
                        "&gameappversion=",
                        userData.sGameVer,
                        "&areaid=",
                        userData.sArea,
                        "&appid=",
                        userData.sAppId,
                        "&acctype=",
                        userData.sAcountType,
                        "&platid=",
                        userData.sPlatID,
                        "&sdkversion=",
                        Pandora.Instance.GetSDKVersion(),
                        "&_pdr_time=",
                        Utils.NowSeconds().ToString()
                    });
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    dictionary.set_Item("openid", userData.sOpenId);
                    dictionary.set_Item("partition", userData.sPartition);
                    dictionary.set_Item("gameappversion", userData.sGameVer);
                    dictionary.set_Item("areaid", userData.sArea);
                    dictionary.set_Item("acctype", userData.sAcountType);
                    dictionary.set_Item("platid", userData.sPlatID);
                    dictionary.set_Item("appid", userData.sAppId);
                    dictionary.set_Item("sdkversion", Pandora.Instance.GetSDKVersion());
                    string rawData = Json.Serialize(dictionary);
                    string text2   = MsdkTea.Encode(rawData);
                    string text3   = "{\"data\":\"" + text2 + "\",\"encrypt\" : \"true\"}";
                    Uri    uri     = new Uri(this.configUrl);
                    string text4   = string.Concat(new string[]
                    {
                        "POST ",
                        uri.get_AbsolutePath(),
                        "?",
                        text,
                        " HTTP/1.1\r\nHost:",
                        uri.get_Host(),
                        "\r\nAccept:*/*\r\nUser-Agent:Pandora(",
                        Pandora.Instance.GetSDKVersion(),
                        ")\r\nContent-Length:",
                        text3.get_Length().ToString(),
                        "\r\nConnection: keep-alive\r\n\r\n",
                        text3
                    });
                    Logger.DEBUG_LOGCAT(text4);
                    byte[] bytes = Encoding.get_UTF8().GetBytes(text4);
                    Pandora.Instance.GetNetLogic().SendPacket(uniqueSocketId, bytes);
                }
                catch (Exception ex)
                {
                    Logger.ERROR(ex.get_Message());
                    Pandora.Instance.GetNetLogic().Close(uniqueSocketId);
                }
            };
            Message message = new Message();

            message.status = 0;
            message.action = action;
            Pandora.Instance.GetNetLogic().EnqueueResult(message);
        }
コード例 #5
0
        public static void oi_symmetry_encrypt2(byte[] inBuf, int inBufLen, byte[] key, byte[] outBuf, ref int outBufLen)
        {
            int num  = 0;
            int num2 = 0;

            byte[] array  = new byte[8];
            byte[] array2 = new byte[8];
            byte[] array3 = new byte[8];
            int    num3   = inBufLen + 1 + MsdkTea.kSaltLen + MsdkTea.kZeroLen;
            int    num4;

            if ((num4 = num3 % 8) != 0)
            {
                num4 = 8 - num4;
            }
            Random random = new Random();

            array[0] = (byte)((random.Next(256) & 248) | num4);
            int num5 = 1;

            while (num4-- != 0)
            {
                array[num5++] = (byte)random.Next(256);
            }
            int i;

            for (i = 0; i < 8; i++)
            {
                array2[i] = 0;
            }
            outBufLen = 0;
            i         = 1;
            while (i <= MsdkTea.kSaltLen)
            {
                if (num5 < 8)
                {
                    array[num5++] = (byte)random.Next(256);
                    i++;
                }
                if (num5 == 8)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        byte[] expr_E9_cp_0 = array;
                        int    expr_E9_cp_1 = j;
                        expr_E9_cp_0[expr_E9_cp_1] ^= array3[j];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int j = 0; j < 8; j++)
                    {
                        int expr_11D_cp_1 = num2 + j;
                        outBuf[expr_11D_cp_1] ^= array2[j];
                    }
                    for (int j = 0; j < 8; j++)
                    {
                        array2[j] = array[j];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
            while (inBufLen != 0)
            {
                if (num5 < 8)
                {
                    array[num5++] = inBuf[num++];
                    inBufLen--;
                }
                if (num5 == 8)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        byte[] expr_1B7_cp_0 = array;
                        int    expr_1B7_cp_1 = j;
                        expr_1B7_cp_0[expr_1B7_cp_1] ^= array3[j];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int j = 0; j < 8; j++)
                    {
                        int expr_1EB_cp_1 = num2 + j;
                        outBuf[expr_1EB_cp_1] ^= array2[j];
                    }
                    for (int j = 0; j < 8; j++)
                    {
                        array2[j] = array[j];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
            i = 1;
            while (i <= MsdkTea.kZeroLen)
            {
                if (num5 < 8)
                {
                    array[num5++] = 0;
                    i++;
                }
                if (num5 == 8)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        byte[] expr_27D_cp_0 = array;
                        int    expr_27D_cp_1 = j;
                        expr_27D_cp_0[expr_27D_cp_1] ^= array3[j];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int j = 0; j < 8; j++)
                    {
                        int expr_2B1_cp_1 = num2 + j;
                        outBuf[expr_2B1_cp_1] ^= array2[j];
                    }
                    for (int j = 0; j < 8; j++)
                    {
                        array2[j] = array[j];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
        }
コード例 #6
0
        public static int oi_symmetry_decrypt2(byte[] inBuf, int inBufLen, byte[] key, byte[] outBuf, ref int outBufLen)
        {
            int num  = 0;
            int num2 = 0;

            byte[] array  = new byte[8];
            byte[] array2 = new byte[8];
            byte[] array3 = new byte[8];
            byte[] array4 = new byte[8];
            int    num3   = 0;

            if (inBufLen % 8 != 0 || inBufLen < 16)
            {
                return(-1);
            }
            MsdkTea.TeaDecryptECB(inBuf, key, array);
            int num4 = (int)(array[0] & 7);
            int i    = inBufLen - 1 - num4 - MsdkTea.kSaltLen - MsdkTea.kZeroLen;

            if (outBufLen < i || i < 0)
            {
                return(-1);
            }
            outBufLen = i;
            for (i = 0; i < 8; i++)
            {
                array2[i] = 0;
            }
            Array.Copy(inBuf, 0, array4, 0, 8);
            num  += 8;
            num3 += 8;
            int num5 = 1;

            num5 += num4;
            i     = 1;
            while (i <= MsdkTea.kSaltLen)
            {
                if (num5 < 8)
                {
                    num5++;
                    i++;
                }
                else if (num5 == 8)
                {
                    Array.Copy(array4, 0, array3, 0, 8);
                    Array.Copy(inBuf, num, array4, 0, 8);
                    for (int j = 0; j < 8; j++)
                    {
                        if (num3 + j >= inBufLen)
                        {
                            return(-1);
                        }
                        byte[] expr_10D_cp_0 = array;
                        int    expr_10D_cp_1 = j;
                        expr_10D_cp_0[expr_10D_cp_1] ^= inBuf[num + j];
                    }
                    MsdkTea.TeaDecryptECB(array, key, array);
                    num  += 8;
                    num3 += 8;
                    num5  = 0;
                }
            }
            int num6 = outBufLen;

            while (num6 != 0)
            {
                if (num5 < 8)
                {
                    outBuf[num2++] = (array[num5] ^ array3[num5]);
                    num5++;
                    num6--;
                }
                else if (num5 == 8)
                {
                    Array.Copy(array4, 0, array3, 0, 8);
                    Array.Copy(inBuf, num, array4, 0, 8);
                    for (int j = 0; j < 8; j++)
                    {
                        if (num3 + j >= inBufLen)
                        {
                            return(-1);
                        }
                        byte[] expr_1B9_cp_0 = array;
                        int    expr_1B9_cp_1 = j;
                        expr_1B9_cp_0[expr_1B9_cp_1] ^= inBuf[num + j];
                    }
                    MsdkTea.TeaDecryptECB(array, key, array);
                    num  += 8;
                    num3 += 8;
                    num5  = 0;
                }
            }
            i = 1;
            while (i <= MsdkTea.kZeroLen)
            {
                if (num5 < 8)
                {
                    if ((array[num5] ^ array3[num5]) != 0)
                    {
                        return(-1);
                    }
                    num5++;
                    i++;
                }
                else if (num5 == 8)
                {
                    Array.Copy(array4, 0, array3, 0, 8);
                    Array.Copy(inBuf, num, array4, 0, 8);
                    for (int j = 0; j < 8; j++)
                    {
                        if (num3 + j >= inBufLen)
                        {
                            return(-1);
                        }
                        byte[] expr_25F_cp_0 = array;
                        int    expr_25F_cp_1 = j;
                        expr_25F_cp_0[expr_25F_cp_1] ^= inBuf[num + j];
                    }
                    MsdkTea.TeaDecryptECB(array, key, array);
                    num  += 8;
                    num3 += 8;
                    num5  = 0;
                }
            }
            return(0);
        }
コード例 #7
0
        public static void oi_symmetry_encrypt2(byte[] inBuf, int inBufLen, byte[] key, byte[] outBuf, ref int outBufLen)
        {
            int num  = 0;
            int num2 = 0;

            byte[] array  = new byte[8];
            byte[] array2 = new byte[8];
            byte[] array3 = new byte[8];
            int    num3   = inBufLen + 1 + MsdkTea.kSaltLen + MsdkTea.kZeroLen;
            int    num4;

            if ((num4 = num3 % 8) != 0)
            {
                num4 = 8 - num4;
            }
            Random random = new Random();

            array[0] = (byte)((random.Next(256) & 248) | num4);
            int num5 = 1;

            while (num4-- != 0)
            {
                array[num5++] = (byte)random.Next(256);
            }
            int i;

            for (i = 0; i < 8; i++)
            {
                array2[i] = 0;
            }
            outBufLen = 0;
            i         = 1;
            while (i <= MsdkTea.kSaltLen)
            {
                if (num5 < 8)
                {
                    array[num5++] = (byte)random.Next(256);
                    i++;
                }
                if (num5 == 8)
                {
                    for (int j = 0; j < 8; j++)
                    {
                        byte[] array4       = array;
                        int    num6         = j;
                        byte[] expr_F2_cp_0 = array4;
                        int    expr_F2_cp_1 = num6;
                        expr_F2_cp_0[expr_F2_cp_1] ^= array3[j];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int k = 0; k < 8; k++)
                    {
                        int num7          = num2 + k;
                        int expr_129_cp_1 = num7;
                        outBuf[expr_129_cp_1] ^= array2[k];
                    }
                    for (int l = 0; l < 8; l++)
                    {
                        array2[l] = array[l];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
            while (inBufLen != 0)
            {
                if (num5 < 8)
                {
                    array[num5++] = inBuf[num++];
                    inBufLen--;
                }
                if (num5 == 8)
                {
                    for (int m = 0; m < 8; m++)
                    {
                        byte[] array5        = array;
                        int    num8          = m;
                        byte[] expr_1C6_cp_0 = array5;
                        int    expr_1C6_cp_1 = num8;
                        expr_1C6_cp_0[expr_1C6_cp_1] ^= array3[m];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int n = 0; n < 8; n++)
                    {
                        int num9          = num2 + n;
                        int expr_1FD_cp_1 = num9;
                        outBuf[expr_1FD_cp_1] ^= array2[n];
                    }
                    for (int num10 = 0; num10 < 8; num10++)
                    {
                        array2[num10] = array[num10];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
            i = 1;
            while (i <= MsdkTea.kZeroLen)
            {
                if (num5 < 8)
                {
                    array[num5++] = 0;
                    i++;
                }
                if (num5 == 8)
                {
                    for (int num11 = 0; num11 < 8; num11++)
                    {
                        byte[] array6        = array;
                        int    num12         = num11;
                        byte[] expr_292_cp_0 = array6;
                        int    expr_292_cp_1 = num12;
                        expr_292_cp_0[expr_292_cp_1] ^= array3[num11];
                    }
                    MsdkTea.TeaEncryptECB(array, key, outBuf, num2);
                    for (int num13 = 0; num13 < 8; num13++)
                    {
                        int num14         = num2 + num13;
                        int expr_2C9_cp_1 = num14;
                        outBuf[expr_2C9_cp_1] ^= array2[num13];
                    }
                    for (int num15 = 0; num15 < 8; num15++)
                    {
                        array2[num15] = array[num15];
                    }
                    num5 = 0;
                    Array.Copy(outBuf, num2, array3, 0, 8);
                    outBufLen += 8;
                    num2      += 8;
                }
            }
        }