Ejemplo n.º 1
0
        public int GetGuide()
        {
            int      count;
            DateTime time       = new DateTime(0x7b2, 1, 1, 0, 0, 0, 0);
            string   requestUri = string.Format("http://{0}/http_replay_guide-get_snapshot?guide_file_name=0&serial_no=RTV4080K0000000000", this.theDevice.ip, (long)(((ulong)(DateTime.UtcNow.Ticks - time.Ticks)) / 0x989680));

            try
            {
                byte[] haystack = HTTPClient.Get(requestUri);
                int    offset   = ReplayHelper.FindInByteArray(haystack, this.encoding.GetBytes("#####ATTACHED_FILE_START#####")) + 0x1d;
                count = ReplayHelper.FindInByteArray(haystack, this.encoding.GetBytes("#####ATTACHED_FILE_END#####")) - offset;
                try
                {
                    if (count > 0)
                    {
                        FileStream stream = File.Create(this.guideFile);
                        stream.Write(haystack, offset, count);
                        stream.Close();
                    }
                }
                catch (Exception)
                {
                    ReplayLogger.DebugLog(string.Concat(new object[] { "Unable to create guide file: ", this.guideFile, " of ", count, " bytes." }));
                }
            }
            catch (Exception)
            {
                ReplayLogger.DebugLog(string.Format("Unable to contact ReplayTV {0} at {1}", this.theDevice.friendlyName, this.theDevice.ip));
                throw new ApplicationException(string.Format("Unable to contact ReplayTV {0} at {1}", this.theDevice.friendlyName, this.theDevice.ip));
            }
            return(count);
        }
Ejemplo n.º 2
0
        public ReplayGuide(ReplayDevice rd)
        {
            this.theDevice    = rd;
            this.guideFile    = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".guide");
            this.guideXMLFile = ReplayHelper.MakePathAndFile(this.theDevice.serialNumber + ".xml");
            OperatingSystem oSVersion = Environment.OSVersion;

            if (((oSVersion.Platform == PlatformID.Win32NT) || (oSVersion.Platform == PlatformID.Win32S)) || (oSVersion.Platform == PlatformID.Win32Windows))
            {
                ReplayLogger.DebugLog("Using Default Encoding for Windows - " + oSVersion.Platform);
                this.encoding = Encoding.Default;
            }
            else
            {
                ReplayLogger.DebugLog("Request iso-8859-1 Encoding for " + oSVersion.Platform);
                this.encoding = Encoding.GetEncoding("iso-8859-1");
            }
        }
Ejemplo n.º 3
0
        private static byte[] RTVDecrypt(byte[] cryptoText, byte[] extraData)
        {
            MD5 md = new MD5CryptoServiceProvider();

            byte[] destinationArray = new byte[0x10];
            byte[] buffer2          = new byte[4];
            uint   key = 0;

            byte[] buffer3 = new byte[4];
            byte[] buffer4 = new byte[4];
            byte[] buffer5 = new byte[(cryptoText.Length - 0x18) + extraData.Length];
            byte[] buffer6 = new byte[4];
            Array.Copy(cryptoText, 8, destinationArray, 0, 0x10);
            if (BitConverter.IsLittleEndian)
            {
                buffer2[0] = cryptoText[7];
                buffer2[1] = cryptoText[1];
                buffer2[2] = cryptoText[4];
                buffer2[3] = cryptoText[2];
            }
            else
            {
                buffer2[0] = cryptoText[2];
                buffer2[1] = cryptoText[4];
                buffer2[2] = cryptoText[1];
                buffer2[3] = cryptoText[7];
            }
            key        = BitConverter.ToUInt32(buffer2, 0) ^ 0xcb0baf47;
            buffer4[0] = cryptoText[6];
            buffer4[1] = cryptoText[5];
            buffer4[2] = cryptoText[3];
            buffer4[3] = cryptoText[0];
            Array.Copy(cryptoText, 0x18, buffer5, 0, cryptoText.Length - 0x18);
            Array.Copy(extraData, 0, buffer5, cryptoText.Length - 0x18, extraData.Length);
            byte[] byteArray = md.ComputeHash(buffer5);
            if (!ReplayHelper.ByteArrayToHexString(byteArray).Equals(ReplayHelper.ByteArrayToHexString(destinationArray)))
            {
                object[] args = new object[] { ReplayHelper.ByteArrayToHexString(byteArray), ReplayHelper.ByteArrayToHexString(destinationArray) };
                ReplayLogger.DebugLog("Bad checksum (Computed: {0}) (Expected: {1})", args);
                return(null);
            }
            ReplayCryptBlock(ref cryptoText, key, cryptoText.Length - 0x18, 0x18);
            Array.Copy(cryptoText, 0x18, buffer3, 0, 4);
            uint num2 = !BitConverter.IsLittleEndian ? 0x42ffdfa9 : 0xa9dfff42;

            if (BitConverter.ToUInt32(buffer3, 0) != num2)
            {
                object[] objArray2 = new object[] { ReplayHelper.ByteArrayToHexString(buffer3), BitConverter.ToInt32(buffer3, 0), 0x42ffdfa9 };
                ReplayLogger.DebugLog("Bad sanity number in decrypted data ({1} != {2}) {0}", objArray2);
                return(null);
            }
            Array.Copy(cryptoText, 0x1c, buffer6, 0, 4);
            if (BitConverter.IsLittleEndian)
            {
                Array.Reverse(buffer6);
            }
            int num3 = (int)(((ulong)(DateTime.UtcNow.Ticks - UTCBase.Ticks)) / 0x989680);

            timeOffset = ((int)BitConverter.ToUInt32(buffer6, 0)) - num3;
            byte[] buffer8 = new byte[cryptoText.Length - 0x20];
            Array.Copy(cryptoText, 0x20, buffer8, 0, cryptoText.Length - 0x20);
            return(buffer8);
        }