Exemplo n.º 1
0
        static byte[] ByteStringToArray(string input)
        {
            List <byte> ret = new List <byte>();

            input = input.Replace(" ", "");
            input = input.Trim();
            if (input.Length % 2 == 1)
            {
                throw new Exception("Could not convert Byte String to Array. Size incorrect");
            }
            for (int i = 0; i < input.Length; i += 2)
            {
                ret.Add(byte.Parse(input.Substring(i, 2), System.Globalization.NumberStyles.HexNumber));
            }

            DLOG.Write("[FindAOB] IDA AOB: ");
            foreach (byte b in ret)
            {
                if (b == 0xAA)
                {
                    DLOG.Write("? ");
                }
                else
                {
                    DLOG.Write("{0:X2} ", b);
                }
            }
            DLOG.WriteLine();
            return(ret.ToArray());
        }
Exemplo n.º 2
0
        static void DebugBuffer(BinaryReader pBR, long pPos = 0)
        {
            var tmp = pBR.BaseStream.Position;

            if (pPos != 0)
            {
                pBR.BaseStream.Position = pPos;
            }
            DLOG.WriteLine("[FDEBUG] ---------------------------------------------------------");
            DLOG.WriteLine("[FDEBUG] Current Position {0:X8} ({1:X8})", pBR.BaseStream.Position, pBR.BaseStream.Position + FileOffset);
            DLOG.Write("[FDEBUG] - Data: ");
            var data = pBR.ReadBytes(50);

            foreach (byte b in data)
            {
                DLOG.Write("{0:X2} ", b);
            }
            pBR.BaseStream.Position = tmp;
            DLOG.WriteLine();
            DLOG.WriteLine("[FDEBUG] ---------------------------------------------------------");
        }
Exemplo n.º 3
0
        public static void Find(ProcessStream pStream, out byte[] pKey, out int pAmountOfStrings, out int pStringArrayListPosition)
        {
            DLOG.WriteLine("SEEKING DECODE FUNCTION");
            int _key_pos = 0, _key_size = 0, _key_size_pos = 0, _strings_amount_pos = 0;

            pAmountOfStrings = pStringArrayListPosition = 0;
            pKey             = new byte[0];

            DLOG.Write("[METHOD 1] ");
            long addr = Extension.FindAoB(pStream.pHandle, 0x00200000, _AoB_1);

            if (addr != 0)
            {
                DLOG.WriteLine("Found addr = {0:X8}", addr);
                pStream.Position = addr;

                pStream.Position += 2;

                pStringArrayListPosition = pStream.ReadInt();

                pStream.Position += 0x44 + 2;

                _key_size_pos = pStream.ReadInt();

                pStream.Position += 1;

                _key_pos            = pStream.ReadInt();
                _strings_amount_pos = _key_size_pos + 4;
                goto ParseData;
            }

            DLOG.Write("[METHOD 2] ");
            addr = Extension.FindAoB(pStream.pHandle, 0x00200000, _AoB_2);
            if (addr != 0)
            {
                DLOG.WriteLine("Found addr = {0:X8}", addr);
                pStream.Position = addr;

                pStream.Position += 5 + 2 + 2 + 3;

                pStringArrayListPosition = pStream.ReadInt();

                pStream.Position += 0x44 + 2;

                _key_size = pStream.ReadByte(); // Key Size O,o

                pStream.Position += 1;

                _key_pos            = pStream.ReadInt();
                _strings_amount_pos = _key_pos + _key_size + 4; // 4 = key size, once again

                pStream.Position = _key_pos;
                DLOG.WriteLine(pStream.ReadBytes(30));

                goto ParseData;
            }

            DLOG.Write("[METHOD 3] ");
            addr = Extension.FindAoB(pStream.pHandle, 0x00200000, _AoB_3);
            if (addr != 0)
            {
                DLOG.WriteLine("Found addr = {0:X8}", addr);
                pStream.Position = addr;

                pStream.Position += 8;

                _key_size = pStream.ReadByte(); // Key Size

                pStream.Position += 1;

                _key_pos            = pStream.ReadInt();
                _key_size_pos       = _key_pos + _key_size;
                _strings_amount_pos = _key_pos + _key_size + 4; // 4 = key size, once again

                pStringArrayListPosition = pStream.ReadInt();

                pStream.Position += 0x44 + 2;

                goto ParseData;
            }

ParseData:
            DLOG.Write("Gathering data needed...");
            if (_key_size_pos != 0)
            {
                // Read keysize!
                pStream.Position = _key_size_pos;
                _key_size        = pStream.ReadInt();
            }
            // Read key
            pStream.Position = _key_pos;
            pKey             = pStream.ReadBytes(_key_size);

            // Read amount of strings
            pStream.Position = _strings_amount_pos;
            pAmountOfStrings = pStream.ReadInt();
            DLOG.WriteLine("Done!");
        }