Beispiel #1
0
            public override void Forward(NEncrypt.enc_args _enc_args, char key)
            {
                uint nSrcSize = _enc_args.nSrcSize;

                _enc_args.nSrcSize = _enc_args.uiSrcFileSize;
                _enc_args.nOutSize = _enc_args.nSrcSize + 24u;
                _enc_args.pOutBuf  = new byte[_enc_args.nOutSize];
                NEncrypt.Header header = new NEncrypt.Header();
                Random          random = new Random();
                int             num;

                if (key == ' ')
                {
                    num = random.Next() % 25;
                }
                else
                {
                    num = (int)key;
                }
                _enc_args.key = (byte)num + 65;
                header.Init(header, (long)((ulong)nSrcSize), key);
                byte[] pOutBuf = _enc_args.pOutBuf;
                byte[] array   = header.Init(header, (long)((ulong)nSrcSize), key);
                for (int i = 0; i < array.Length; i++)
                {
                    pOutBuf[i] = array[i];
                }
                if (_enc_args.pOutBuf[6] == 3)
                {
                    this.Type3_Forward(_enc_args.pSrcBuf, pOutBuf, nSrcSize, _enc_args.key);
                }
            }
Beispiel #2
0
        private static bool __isforwarded(Stream stream, NEncrypt.enc_type eType)
        {
            if (!stream.CanSeek)
            {
                return(false);
            }
            int num = (int)stream.Length;

            if (num == 0)
            {
                return(false);
            }
            if (num < 24)
            {
                return(false);
            }
            int num2 = num;

            byte[]       array        = new byte[num2];
            BinaryReader binaryReader = new BinaryReader(stream);

            array = binaryReader.ReadBytes(num);
            NEncrypt.Crypto crypto = NEncrypt.Crypto.Create(eType);
            bool            result = false;

            NEncrypt.enc_args enc_args = new NEncrypt.enc_args(eType, array, (uint)array.Length, null, false);
            if (crypto != null)
            {
                result = crypto.IsForwarded(enc_args);
            }
            return(result);
        }
Beispiel #3
0
        private static bool Encrypt(NEncrypt.enc_args _enc_args, char key = ' ')
        {
            bool result = false;

            NEncrypt.Crypto crypto = NEncrypt.Crypto.Create(_enc_args.type);
            if (!crypto.IsForwarded(_enc_args) && crypto.Verify_File_Format(_enc_args.pSrcBuf))
            {
                crypto.Forward(_enc_args, key);
                result = true;
            }
            return(result);
        }
Beispiel #4
0
        private static bool IsForwarded(byte[] pBuffer, uint nBufSize, NEncrypt.enc_type eType)
        {
            NEncrypt.Crypto   crypto   = NEncrypt.Crypto.Create(eType);
            NEncrypt.enc_args enc_args = new NEncrypt.enc_args(eType, pBuffer, nBufSize, null, false);
            if (eType == NEncrypt.enc_type.ENC_DEFAULT)
            {
                enc_args.uiSrcFileSize = nBufSize;
            }
            bool result = false;

            if (crypto != null)
            {
                result = crypto.IsForwarded(enc_args);
            }
            return(result);
        }
Beispiel #5
0
        public static bool Decrypt(NEncrypt.enc_args _enc_args, char key = ' ')
        {
            bool result = false;

            NEncrypt.Crypto crypto = NEncrypt.Crypto.Create(_enc_args.type);
            if (crypto == null)
            {
                return(false);
            }
            if (crypto.IsForwarded(_enc_args))
            {
                crypto.Backward(_enc_args, key);
                result = true;
            }
            return(result);
        }
Beispiel #6
0
            public override void Backward(NEncrypt.enc_args _enc_args, char key)
            {
                byte[] array = new byte[]
                {
                    71,
                    97,
                    109,
                    101,
                    98,
                    114,
                    121,
                    111,
                    32,
                    70,
                    105,
                    108,
                    101,
                    32,
                    70,
                    111,
                    114,
                    109,
                    97,
                    116
                };
                uint[] array2 = new uint[11];
                Buffer.BlockCopy(_enc_args.pSrcBuf, 21, array2, 0, 44);
                for (int i = 0; i < 20; i++)
                {
                    _enc_args.pSrcBuf[i] = array[i];
                }
                _enc_args.pOutBuf = _enc_args.pSrcBuf;
                int num = 0;

                for (int j = 20; j < 64; j++)
                {
                    if (_enc_args.pSrcBuf[j] == 10)
                    {
                        array2[num] -= 1600085855u;
                        num++;
                        break;
                    }
                }
                Buffer.BlockCopy(array2, 0, _enc_args.pOutBuf, 21, 44);
            }
Beispiel #7
0
            public override void Forward(NEncrypt.enc_args _enc_args, char key)
            {
                byte[] array = new byte[]
                {
                    78,
                    68,
                    83,
                    78,
                    73,
                    70,
                    46,
                    46,
                    46,
                    46,
                    64,
                    46,
                    46,
                    46,
                    46,
                    64,
                    46,
                    46,
                    46,
                    46
                };
                uint[] array2 = new uint[11];
                Buffer.BlockCopy(_enc_args.pSrcBuf, 21, array2, 0, 44);
                for (int i = 0; i < 20; i++)
                {
                    _enc_args.pSrcBuf[i] = array[i];
                }
                _enc_args.pOutBuf = _enc_args.pSrcBuf;
                int num = 0;

                for (int j = 20; j < 64; j++)
                {
                    if (_enc_args.pSrcBuf[j] == 10)
                    {
                        array2[num] += 1600085855u;
                        num++;
                        break;
                    }
                }
                Buffer.BlockCopy(array2, 0, _enc_args.pOutBuf, 21, 44);
            }
Beispiel #8
0
            public override void Backward(NEncrypt.enc_args _enc_args, char key)
            {
                byte[] pSrcBuf = _enc_args.pSrcBuf;
                uint   num     = 4279269124u + (uint)pSrcBuf[3];

                uint[] array = new uint[7];
                Buffer.BlockCopy(pSrcBuf, 4, array, 0, 28);
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] -= num;
                }
                pSrcBuf[0] = 68;
                pSrcBuf[1] = 68;
                pSrcBuf[2] = 83;
                pSrcBuf[3] = 32;
                Buffer.BlockCopy(array, 0, pSrcBuf, 4, 28);
                _enc_args.pOutBuf = pSrcBuf;
            }
Beispiel #9
0
            public virtual bool IsForwarded(NEncrypt.enc_args _enc_args)
            {
                byte[] pSrcBuf = _enc_args.pSrcBuf;
                bool   result  = true;
                int    type    = (int)_enc_args.type;

                char[] array = NEncrypt.const_enc_info[type].header_string.ToCharArray();
                uint   num   = (uint)array.Length;

                for (uint num2 = 0u; num2 < num; num2 += 1u)
                {
                    if ((char)pSrcBuf[(int)((UIntPtr)num2)] != array[(int)((UIntPtr)num2)])
                    {
                        result = false;
                        break;
                    }
                }
                return(result);
            }
Beispiel #10
0
            public override void Backward(NEncrypt.enc_args _enc_args, char key)
            {
                byte[] array = new byte[_enc_args.pSrcBuf.Length - 24];
                int    num   = 24;

                for (int i = 0; i < array.Length; i++)
                {
                    array[i] = _enc_args.pSrcBuf[num];
                    num++;
                }
                _enc_args.key        = _enc_args.pSrcBuf[12];
                _enc_args.nOutSize   = _enc_args.nSrcSize - 24u;
                _enc_args.pOutBuf    = _enc_args.pSrcBuf;
                _enc_args.bOutRefPtr = true;
                if (_enc_args.pSrcBuf[6] == 3)
                {
                    this.Type3_Backward(array, _enc_args.pOutBuf, _enc_args.nOutSize, _enc_args.key);
                    _enc_args.pOutBuf = array;
                }
            }
Beispiel #11
0
            public override void Forward(NEncrypt.enc_args _enc_args, char key)
            {
                Random random = new Random();
                byte   b      = (byte)(random.Next() % 256);

                b = 64;
                _enc_args.pSrcBuf[0] = 78;
                _enc_args.pSrcBuf[1] = 68;
                _enc_args.pSrcBuf[2] = 83;
                _enc_args.pSrcBuf[3] = b;
                uint num = 4279269124u + (uint)b;

                uint[] array = new uint[7];
                Buffer.BlockCopy(_enc_args.pSrcBuf, 4, array, 0, 28);
                for (int i = 0; i < array.Length; i++)
                {
                    array[i] += num;
                }
                _enc_args.pOutBuf = _enc_args.pSrcBuf;
                Buffer.BlockCopy(array, 0, _enc_args.pOutBuf, 4, 28);
            }
Beispiel #12
0
        private static bool Enc_Dec_File(string filename, NEncrypt.enc_type eType, NEncrypt.process_type _process_type, char key, string newfilename)
        {
            StreamReader streamReader = new StreamReader(new FileStream(filename, FileMode.Open));
            int          num          = (int)streamReader.BaseStream.Length;

            streamReader.Close();
            byte[]            array        = new byte[num];
            NEncrypt.enc_args enc_args     = new NEncrypt.enc_args(eType, array, (uint)array.Length, null, false);
            BinaryReader      binaryReader = new BinaryReader(new FileStream(filename, FileMode.Open));

            enc_args.pSrcBuf  = binaryReader.ReadBytes(num);
            enc_args.nSrcSize = (uint)num;
            binaryReader.Close();
            enc_args.uiSrcFileSize = (uint)num;
            bool flag = false;

            if (_process_type != NEncrypt.process_type.process_enc_type)
            {
                if (_process_type == NEncrypt.process_type.process_dec_type)
                {
                    flag = NEncrypt.Decrypt(enc_args, key);
                }
            }
            else
            {
                flag = NEncrypt.Encrypt(enc_args, key);
            }
            if (!flag)
            {
                return(false);
            }
            DateTime     lastWriteTime = File.GetLastWriteTime(filename);
            BinaryWriter binaryWriter  = new BinaryWriter(new FileStream(filename, FileMode.Create));

            binaryWriter.Write(enc_args.pOutBuf);
            binaryWriter.Close();
            File.SetLastWriteTime(filename, lastWriteTime);
            return(true);
        }
Beispiel #13
0
            public override void Backward(NEncrypt.enc_args _enc_args, char key)
            {
                byte[] pSrcBuf      = _enc_args.pSrcBuf;
                byte[] expr_0E_cp_0 = pSrcBuf;
                int    expr_0E_cp_1 = 2;

                expr_0E_cp_0[expr_0E_cp_1] -= 200;
                ushort[] array        = new ushort[7];
                byte[]   expr_27_cp_0 = pSrcBuf;
                int      expr_27_cp_1 = 17;

                expr_27_cp_0[expr_27_cp_1] -= pSrcBuf[7];
                Buffer.BlockCopy(pSrcBuf, 3, array, 0, 14);
                for (ushort num = 0; num < 7; num += 1)
                {
                    ushort[] expr_48_cp_0 = array;
                    ushort   expr_48_cp_1 = num;
                    expr_48_cp_0[(int)expr_48_cp_1] = expr_48_cp_0[(int)expr_48_cp_1] - 41269 * num;
                }
                Buffer.BlockCopy(array, 0, pSrcBuf, 3, 14);
                _enc_args.pOutBuf = pSrcBuf;
            }
Beispiel #14
0
            public override void Forward(NEncrypt.enc_args _enc_args, char key)
            {
                byte[] array = new byte[18];
                array = _enc_args.pSrcBuf;
                byte[] expr_16_cp_0 = array;
                int    expr_16_cp_1 = 2;

                expr_16_cp_0[expr_16_cp_1] += 200;
                ushort[] array2 = new ushort[7];
                Buffer.BlockCopy(array, 3, array2, 0, 14);
                for (ushort num = 0; num < 7; num += 1)
                {
                    ushort[] expr_40_cp_0 = array2;
                    ushort   expr_40_cp_1 = num;
                    expr_40_cp_0[(int)expr_40_cp_1] = expr_40_cp_0[(int)expr_40_cp_1] + 41269 * num;
                }
                Buffer.BlockCopy(array2, 0, array, 3, 14);
                byte[] expr_6C_cp_0 = array;
                int    expr_6C_cp_1 = 17;

                expr_6C_cp_0[expr_6C_cp_1] += array[7];
                _enc_args.pOutBuf           = array;
            }
Beispiel #15
0
 public override bool IsForwarded(NEncrypt.enc_args _enc_args)
 {
     return(_enc_args.pSrcBuf.Length >= 10 && _enc_args.pSrcBuf[0] == 78 && _enc_args.pSrcBuf[1] == 67 && _enc_args.pSrcBuf[2] == 82 && _enc_args.pSrcBuf[4] == 1 && (_enc_args.pSrcBuf[6] == 1 || _enc_args.pSrcBuf[6] == 2 || _enc_args.pSrcBuf[6] == 3) && (uint)_enc_args.pSrcBuf[8] <= _enc_args.uiSrcFileSize - 24u);
 }
Beispiel #16
0
 public override bool IsForwarded(NEncrypt.enc_args _enc_args)
 {
     byte[] array = new byte[18];
     array = _enc_args.pSrcBuf;
     return(200 <= array[2]);
 }
Beispiel #17
0
 public abstract void Backward(NEncrypt.enc_args _enc_args, char key = ' ');