├── EazDecodeLib
├── Resources
│ └── res.bin
├── EazDecodeLib.csproj
├── Crypto3Algorithms
│ ├── HashAlgoPadder.cs
│ ├── HashAlgoEncryption.cs
│ ├── HashAlgoFNV32.cs
│ ├── SymAlgoPadder.cs
│ ├── KeyedHashAlgo.cs
│ ├── SymAlgoSkipJack32.cs
│ ├── SymAlgoLengthOptimized.cs
│ └── SymAlgoBlowfish.cs
├── Extensions.cs
├── Crypto2.cs
├── Properties
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── SymbolDecompressor.cs
├── CryptoHelper.cs
└── Crypto3.cs
├── EazDecode
├── libs
│ └── Eazfuscator.NET.SDK.dll
├── app.config
├── Properties
│ ├── Settings.settings
│ ├── AssemblyInfo.cs
│ └── Settings.Designer.cs
├── Program.cs
├── Decoder.cs
├── app.manifest
├── Form1.cs
├── EazDecode.csproj
├── Form1.resx
└── Form1.Designer.cs
├── README.md
├── LICENSE
├── EazDecode.sln
└── .gitignore
/EazDecodeLib/Resources/res.bin:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/holly-hacker/EazDecode/HEAD/EazDecodeLib/Resources/res.bin
--------------------------------------------------------------------------------
/EazDecode/libs/Eazfuscator.NET.SDK.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/holly-hacker/EazDecode/HEAD/EazDecode/libs/Eazfuscator.NET.SDK.dll
--------------------------------------------------------------------------------
/EazDecode/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/EazDecode/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/EazDecode/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace EazDecode
5 | {
6 | internal static class Program
7 | {
8 | [STAThread]
9 | private static void Main()
10 | {
11 | Application.EnableVisualStyles();
12 | Application.SetCompatibleTextRenderingDefault(false);
13 | Application.Run(new Form1());
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/EazDecode/Decoder.cs:
--------------------------------------------------------------------------------
1 | using EazDecodeLib;
2 | using System;
3 | using System.Text.RegularExpressions;
4 |
5 | namespace EazDecode
6 | {
7 | internal class Decoder
8 | {
9 | private static readonly Regex RegexObfuscated = new Regex("#=[a-zA-Z0-9_$]+={0,2}");
10 |
11 | public static string DecodeAll(string input, CryptoHelper crypto) => RegexObfuscated.Replace(input, match => Evaluator(match, crypto));
12 | private static string Evaluator(Capture match, CryptoHelper crypto) => crypto.Decrypt(match.Value);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/EazDecode/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/EazDecodeLib/EazDecodeLib.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0
5 |
6 |
7 |
8 |
9 | True
10 | True
11 | Resources.resx
12 |
13 |
14 |
15 |
16 |
17 | ResXFileCodeGenerator
18 | Resources.Designer.cs
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # EazDecode
2 | A program for decoding EazFuscator stacktraces.
3 |
4 | ## Note
5 | This program does not allow you to decrypt symbols you don't have the password for. As such, it is only useful in a limited amount of cases (i.e. with past source leaks).
6 |
7 | All functionality in this progran is also present in the official EazFuscator SDK, however since the SDK will re-initialize its RNG every decryption cycle, it is very slow. This library does not have this limitation, allowing it to decrypt thousands of symbol names in under a second.
8 |
9 | ## Usage
10 | For examples on how to use the library, see the bundled EazDecode application or [osu-decoder](https://github.com/HoLLy-HaCKeR/osu-decoder), a tool which decrypts symbol names inside a binary and produces a runnable output.
11 |
--------------------------------------------------------------------------------
/EazDecode/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Reflection;
4 | using System.Runtime.CompilerServices;
5 | using System.Runtime.InteropServices;
6 | using System.Runtime.Versioning;
7 |
8 | [assembly: AssemblyVersion("1.0.0.0")]
9 | [assembly: CompilationRelaxations(8)]
10 | [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
11 | [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
12 | [assembly: AssemblyTitle("EazDecode")]
13 | [assembly: AssemblyDescription("")]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyCompany("")]
16 | [assembly: AssemblyProduct("EazDecode")]
17 | [assembly: AssemblyCopyright("Copyright © 2017")]
18 | [assembly: AssemblyTrademark("")]
19 | [assembly: ComVisible(false)]
20 | [assembly: Guid("c3f609b1-bfa3-44b9-ad43-845c2b51fe70")]
21 | [assembly: AssemblyFileVersion("1.0.0.0")]
22 |
--------------------------------------------------------------------------------
/EazDecode/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace EazDecode.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/EazDecodeLib/Crypto3Algorithms/HashAlgoPadder.cs:
--------------------------------------------------------------------------------
1 | using System.Security.Cryptography;
2 |
3 | namespace EazDecodeLib.Crypto3Algorithms
4 | {
5 | ///
6 | ///
7 | /// Hashes a 0 byte using a passed .
8 | ///
9 | internal sealed class HashAlgoPadder : HashAlgorithm
10 | {
11 | private readonly HashAlgorithm _hashAlgo;
12 |
13 | public override bool CanReuseTransform => _hashAlgo.CanReuseTransform;
14 | public override bool CanTransformMultipleBlocks => _hashAlgo.CanTransformMultipleBlocks;
15 |
16 | public HashAlgoPadder(HashAlgorithm hashAlgo)
17 | {
18 | HashSizeValue = 8;
19 | _hashAlgo = hashAlgo;
20 | }
21 |
22 | public override void Initialize() => _hashAlgo.Initialize();
23 |
24 | protected override void HashCore(byte[] array, int ibStart, int cbSize)
25 | {
26 | _hashAlgo.TransformBlock(array, ibStart, cbSize, array, ibStart);
27 | }
28 |
29 | protected override byte[] HashFinal()
30 | {
31 | _hashAlgo.TransformFinalBlock(new byte[0], 0, 0);
32 |
33 | return new[] { _hashAlgo.Hash[0] };
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/EazDecodeLib/Extensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Text;
4 |
5 | namespace EazDecodeLib
6 | {
7 | internal static class Extensions
8 | {
9 | public static Guid ReadGuid(this BinaryReader br)
10 | {
11 | byte[] array = br.ReadBytes(16);
12 | return new Guid(array[0] | array[1] << 8 | array[2] << 16 | array[3] << 24,
13 | (short)(array[4] | array[5] << 8),
14 | (short)(array[6] | array[7] << 8),
15 | array[8], array[9], array[10], array[11], array[12], array[13], array[14], array[15]);
16 | }
17 |
18 | public static string ReadStringNullTerminated(this BinaryReader br)
19 | {
20 | var sb = new StringBuilder();
21 | for (;;) {
22 | byte b = br.ReadByte();
23 | if (b == 0) break;
24 | sb.Append((char) b);
25 | }
26 | return sb.ToString();
27 | }
28 |
29 | public static int ReadByteCrypted(this BinaryReader br, byte unk3)
30 | {
31 | byte b = br.ReadByte();
32 | if (b <= unk3) return b;
33 |
34 | b -= (byte)(unk3 + 1);
35 |
36 | byte b2 = br.ReadByte();
37 | return (b << 8 | b2) + unk3 - b;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/EazDecodeLib/Crypto3Algorithms/HashAlgoEncryption.cs:
--------------------------------------------------------------------------------
1 | using System.Security.Cryptography;
2 |
3 | namespace EazDecodeLib.Crypto3Algorithms
4 | {
5 | ///
6 | ///
7 | /// Uses a to return an encrypted hash of an empty buffer.
8 | ///
9 | internal sealed class HashAlgoEncryption : HashAlgorithm
10 | {
11 | private readonly HashAlgorithm _hashAlgo;
12 | private readonly SymmetricAlgorithm _symAlgo;
13 |
14 | public HashAlgoEncryption(HashAlgorithm h, SymmetricAlgorithm s)
15 | {
16 | HashSizeValue = h.HashSize;
17 | _hashAlgo = h;
18 | _symAlgo = s;
19 | }
20 |
21 | public override bool CanReuseTransform => _hashAlgo.CanReuseTransform;
22 | public override bool CanTransformMultipleBlocks => _hashAlgo.CanTransformMultipleBlocks;
23 |
24 | public override void Initialize() => _hashAlgo.Initialize();
25 |
26 | protected override void HashCore(byte[] array, int ibStart, int cbSize)
27 | {
28 | _hashAlgo.TransformBlock(array, ibStart, cbSize, array, ibStart);
29 | }
30 |
31 | protected override byte[] HashFinal()
32 | {
33 | //hash empty byte array
34 | _hashAlgo.TransformFinalBlock(new byte[0], 0, 0);
35 |
36 | //return encrypted hash
37 | using (ICryptoTransform trans = _symAlgo.CreateEncryptor())
38 | return trans.TransformFinalBlock(_hashAlgo.Hash, 0, _hashAlgo.Hash.Length);
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | BSD 3-Clause License
2 |
3 | Copyright (c) 2019, HoLLy
4 | All rights reserved.
5 |
6 | Redistribution and use in source and binary forms, with or without
7 | modification, are permitted provided that the following conditions are met:
8 |
9 | * Redistributions of source code must retain the above copyright notice, this
10 | list of conditions and the following disclaimer.
11 |
12 | * Redistributions in binary form must reproduce the above copyright notice,
13 | this list of conditions and the following disclaimer in the documentation
14 | and/or other materials provided with the distribution.
15 |
16 | * Neither the name of the copyright holder nor the names of its
17 | contributors may be used to endorse or promote products derived from
18 | this software without specific prior written permission.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 |
--------------------------------------------------------------------------------
/EazDecodeLib/Crypto3Algorithms/HashAlgoFNV32.cs:
--------------------------------------------------------------------------------
1 | using System.Security.Cryptography;
2 |
3 | namespace EazDecodeLib.Crypto3Algorithms
4 | {
5 | ///
6 | ///
7 | /// An implementation of the Fowler–Noll–Vo 1a hashing algorithm.
8 | ///
9 | internal sealed class HashAlgoFNV32 : HashAlgorithm
10 | {
11 | private const uint Basis = 0x811C9DC5;
12 | private const uint Prime = 0x01000193;
13 | private uint _hash;
14 |
15 | public HashAlgoFNV32()
16 | {
17 | HashSizeValue = 32;
18 | InitSeed();
19 | }
20 |
21 | public override void Initialize() => InitSeed();
22 | private void InitSeed() => _hash = Basis;
23 |
24 | protected override void HashCore(byte[] array, int ibStart, int cbSize)
25 | {
26 | _hash = DoHash(_hash, array, ibStart, cbSize);
27 | }
28 |
29 | protected override byte[] HashFinal()
30 | {
31 | return new[] {
32 | (byte) (_hash >> 24),
33 | (byte) (_hash >> 16),
34 | (byte) (_hash >> 8),
35 | (byte) (_hash >> 0)
36 | };
37 | }
38 |
39 | public static int DoHash(byte[] array) => (int)DoHash(Basis, array, 0, array.Length);
40 |
41 | private static uint DoHash(uint hash, byte[] array, int ibStart, int cbSize)
42 | {
43 | for (int i = ibStart; i < ibStart + cbSize; i++) {
44 | hash ^= array[i];
45 | hash *= Prime;
46 | }
47 |
48 | return hash;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/EazDecode.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.26730.16
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EazDecode", "EazDecode\EazDecode.csproj", "{11F2E02A-DA1E-4C2D-A398-4D1ED8AC2CE6}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EazDecodeLib", "EazDecodeLib\EazDecodeLib.csproj", "{1570C9EA-1AAB-4D65-B0AC-511984CFC3F4}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {11F2E02A-DA1E-4C2D-A398-4D1ED8AC2CE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {11F2E02A-DA1E-4C2D-A398-4D1ED8AC2CE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {11F2E02A-DA1E-4C2D-A398-4D1ED8AC2CE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {11F2E02A-DA1E-4C2D-A398-4D1ED8AC2CE6}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {1570C9EA-1AAB-4D65-B0AC-511984CFC3F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {1570C9EA-1AAB-4D65-B0AC-511984CFC3F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {1570C9EA-1AAB-4D65-B0AC-511984CFC3F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {1570C9EA-1AAB-4D65-B0AC-511984CFC3F4}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {FC5E658A-6C9F-4855-83E0-064880174698}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/EazDecodeLib/Crypto2.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Security.Cryptography;
3 | using System.Text;
4 |
5 | namespace EazDecodeLib
6 | {
7 | ///
8 | /// Cryptographic algorithm used by Eazfuscator before 5.8. Consists of a
9 | /// round of AES and an xor.
10 | ///
11 | internal class Crypto2
12 | {
13 | private readonly SymmetricAlgorithm _symmetricAlgorithm;
14 |
15 | public Crypto2(string password)
16 | {
17 | _symmetricAlgorithm = new RijndaelManaged
18 | {
19 | KeySize = 256,
20 | BlockSize = 128,
21 | IV = new Rfc2898DeriveBytes(password, new byte[]
22 | {
23 | 0x1C, 0x88, 0x1B, 0xD8, 0x53, 0x93, 0x8C, 0xCF,
24 | 0x3C, 0x99, 0x29, 0x6B, 0x75, 0xA4, 0x25, 0x9D,
25 | 0x5E, 0xE9, 0x33, 0x30, 0x92, 0x6C, 0x7F, 0xBF,
26 | 0x1E, 0xE2, 0xFA, 0x58, 0x6D, 0x07, 0x84, 0x0F
27 | }).GetBytes(16),
28 | Key = new Rfc2898DeriveBytes(password, new byte[]
29 | {
30 | 0xA7, 0x7E, 0x70, 0x10, 0x04, 0xF4, 0x0F, 0x78,
31 | 0x87, 0x74, 0x7B, 0xD4, 0x9D, 0x30, 0x05, 0xC2,
32 | 0x0C, 0xB3, 0x99, 0xC9, 0xCC, 0xF9, 0xF8, 0xD4,
33 | 0x56, 0x14, 0xD7, 0x37, 0x69, 0x9D, 0x6F, 0x0B
34 | }).GetBytes(32)
35 | };
36 | }
37 |
38 | internal string Decrypt(byte[] toDecrypt)
39 | {
40 | //decrypt with AES
41 | using (var ms = new MemoryStream()) {
42 | using (CryptoStream cs = new CryptoStream(ms, _symmetricAlgorithm.CreateDecryptor(), CryptoStreamMode.Write))
43 | cs.Write(toDecrypt, 0, toDecrypt.Length);
44 |
45 | //decrypt xor
46 | toDecrypt = CryptoHelper.XorArray(ms.ToArray());
47 | return Encoding.UTF8.GetString(toDecrypt);
48 | }
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/EazDecode/Form1.cs:
--------------------------------------------------------------------------------
1 | using EazDecodeLib;
2 | using System;
3 | using System.IO;
4 | using System.Security.Cryptography;
5 | using System.Windows.Forms;
6 |
7 | namespace EazDecode
8 | {
9 | public partial class Form1
10 | {
11 | private CryptoHelper _crypto;
12 |
13 | public Form1()
14 | {
15 | InitializeComponent();
16 |
17 | if (File.Exists("password.txt"))
18 | txtbPassword.Text = File.ReadAllText("password.txt");
19 | }
20 |
21 | private void txtbIn_TextChanged(object sender, EventArgs e)
22 | {
23 | if (cbAuto.Checked)
24 | btnDecode_Click(sender, e);
25 | }
26 |
27 | private void cbAuto_CheckedChanged(object sender, EventArgs e) => txtbIn_TextChanged(sender, e);
28 |
29 | private void txtbPassword_TextChanged(object sender, EventArgs e)
30 | {
31 | _crypto = new CryptoHelper(txtbPassword.Text);
32 | File.WriteAllText("password.txt", txtbPassword.Text);
33 | txtbIn_TextChanged(sender, e);
34 | }
35 |
36 | private void btnDecode_Click(object sender, EventArgs e)
37 | {
38 | try
39 | {
40 | txtbOut.Text = Decoder.DecodeAll(txtbIn.Text, _crypto);
41 | }
42 | catch (Exception ex)
43 | {
44 | txtbOut.Text = $"An error occured while decoding ourself: {ex.Message}\r\n";
45 | if (ex is CryptographicException)
46 | {
47 | txtbOut.Text += "Please check if the password is correct.\r\n";
48 | }
49 |
50 | txtbOut.Text += "\r\n" + new string('-', 20) + "\r\n\r\n";
51 |
52 | try
53 | {
54 | string str = Eazfuscator.NET.SDK.StackTraceDecoding.StackTraceDecoder.Run(txtbIn.Text, _crypto.Password) + "\n";
55 | txtbOut.Text += str;
56 | }
57 | catch (Exception ex2)
58 | {
59 | txtbOut.Text += "Official SDK could also not decrypt this: " + ex2.Message + "\n";
60 | throw;
61 | }
62 | }
63 | }
64 |
65 | private void btnFlip_Click(object sender, EventArgs e)
66 | {
67 | scMain.Orientation = (Orientation)Math.Abs(scMain.Orientation - Orientation.Vertical);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/EazDecodeLib/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace EazDecodeLib.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("EazDecodeLib.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Byte[].
65 | ///
66 | internal static byte[] res {
67 | get {
68 | object obj = ResourceManager.GetObject("res", resourceCulture);
69 | return ((byte[])(obj));
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/EazDecodeLib/SymbolDecompressor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.IO;
5 | using System.Text;
6 | using EazDecodeLib.Properties;
7 |
8 | namespace EazDecodeLib
9 | {
10 | ///
11 | /// Used by
12 | ///
13 | internal class SymbolDecompressor
14 | {
15 | private const string ValidChars = @"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_.<>`";
16 |
17 | private Dictionary _wordsDic;
18 | private List> _wordsList;
19 |
20 | private readonly byte[] _toReal = new byte[256];
21 | private readonly byte[] _fromReal = new byte[256]; //unused
22 | private readonly int _commonWordsStart;
23 | private readonly byte _cryptoKey;
24 |
25 | public SymbolDecompressor()
26 | {
27 | Read(Resources.res);
28 |
29 | long num = ((_wordsList.Count + 256L) * 256L / 255L >> 8) + 1L;
30 | int index = 1;
31 | foreach (char c in ValidChars)
32 | {
33 | byte b = (byte) c;
34 | _fromReal[b] = (byte)index;
35 | _toReal[index] = b;
36 | index++;
37 | }
38 | _commonWordsStart = index - 1;
39 | _cryptoKey = checked((byte) (256L - num));
40 | }
41 |
42 | public string Decompress(byte[] buffer)
43 | {
44 | using (var memoryStream = new MemoryStream(buffer, false))
45 | using (var binaryReader = new BinaryReader(memoryStream)) {
46 | var stringBuilder = new StringBuilder();
47 |
48 | while (memoryStream.Position < memoryStream.Length) {
49 | //read encrypted index
50 | int index = binaryReader.ReadByteCrypted(_cryptoKey);
51 |
52 | //if the index is for a common word
53 | if (index > _commonWordsStart) {
54 | index -= _commonWordsStart;
55 | stringBuilder.Append(_wordsList[index - 1].Value);
56 | }
57 | //else, it is a character
58 | else {
59 | char value = (char) _toReal[index];
60 | stringBuilder.Append(value);
61 | }
62 | }
63 | return stringBuilder.ToString();
64 | }
65 | }
66 |
67 | private void Read(byte[] src)
68 | {
69 | using (var ms = new MemoryStream(src, false))
70 | using (var br = new BinaryReader(ms))
71 | {
72 | Guid guid = br.ReadGuid();
73 | byte b = br.ReadByte();
74 | Debug.Assert(guid == new Guid("{397590B3-8E32-442F-B114-9C4C9754E169}"));
75 | Debug.Assert(b == 1);
76 |
77 | _wordsDic = new Dictionary();
78 | _wordsList = new List>();
79 | while (ms.Position < ms.Length)
80 | {
81 | string word = br.ReadStringNullTerminated();
82 | int id = br.ReadInt32();
83 |
84 | _wordsDic[word] = _wordsDic.Count;
85 | _wordsList.Add(new KeyValuePair(id, word));
86 | }
87 | }
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/EazDecode/EazDecode.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {11F2E02A-DA1E-4C2D-A398-4D1ED8AC2CE6}
8 | WinExe
9 | EazDecode
10 | EazDecode
11 | v4.6.1
12 | 512
13 | app.manifest
14 | EazDecode.Program
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 | False
39 | libs\Eazfuscator.NET.SDK.dll
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | Form
52 |
53 |
54 | Form1.cs
55 |
56 |
57 |
58 |
59 | Settings.settings
60 | True
61 | True
62 |
63 |
64 |
65 |
66 | Form1.cs
67 |
68 |
69 |
70 |
71 |
72 |
73 | SettingsSingleFileGenerator
74 | Settings.Designer.cs
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | {1570c9ea-1aab-4d65-b0ac-511984cfc3f4}
83 | EazDecodeLib
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/EazDecodeLib/CryptoHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 |
4 | namespace EazDecodeLib
5 | {
6 | public class CryptoHelper
7 | {
8 | public string Password { get; }
9 |
10 | private readonly Crypto2 _c2;
11 | private readonly Crypto3 _c3;
12 |
13 | public CryptoHelper(string password)
14 | {
15 | Password = password;
16 |
17 | _c2 = new Crypto2(password);
18 | _c3 = new Crypto3(password);
19 | }
20 |
21 | ///
22 | /// Attempt to decrypt the input by finding the correct algorithm and
23 | /// applying it.
24 | ///
25 | ///
26 | ///
27 | public string Decrypt(string input)
28 | {
29 | if (!input.StartsWith("#="))
30 | {
31 | throw new NotImplementedException("I don't support this encryption type");
32 | }
33 | char c = input[2];
34 | string b64 = input.Substring(3);
35 | b64 = b64.Replace('_', '+').Replace('$', '/'); //TODO: not always!
36 | byte[] bytes = Convert.FromBase64String(b64);
37 |
38 | switch (c) {
39 | case 'q':
40 | return _c2.Decrypt(bytes);
41 | case 'z':
42 | return _c3.Decrypt(bytes);
43 | }
44 | throw new NotImplementedException("I don't support this encryption type (yet), poke me about it");
45 | }
46 |
47 | ///
48 | /// Take the last byte of input and xor it with
49 | /// the rest of the array.
50 | ///
51 | /// Array including xor byte
52 | /// Xored array w/o last byte
53 | internal static byte[] XorArray(byte[] data)
54 | {
55 | //don't do anything to empty arrays
56 | if (data.Length == 0) return data;
57 |
58 | //last byte of the array is the xor key
59 | byte xorKey = data[data.Length - 1];
60 |
61 | //resize the original array to trim off the xor byte
62 | Array.Resize(ref data, data.Length - 1);
63 |
64 | //xor the entire array with this byte
65 | for (int i = 0; i < data.Length; i++)
66 | data[i] ^= xorKey;
67 |
68 | return data;
69 | }
70 |
71 | ///
72 | /// Xor an array at offset
73 | /// with another array
74 | /// at offset for
75 | /// bytes.
76 | ///
77 | ///
78 | ///
79 | ///
80 | ///
81 | ///
82 | internal static void XorArray(byte[] arr, int arrOffset, byte[] xor, int xorOffset, int size)
83 | {
84 | for (int i = 0; i < size; i++)
85 | {
86 | arr[arrOffset + i] ^= xor[xorOffset + i];
87 | }
88 | }
89 |
90 | ///
91 | /// Remove all null-bytes at the end of the array.
92 | ///
93 | ///
94 | /// without null bytes at the end
95 | internal static byte[] RemoveTrailingNullBytes(byte[] input)
96 | {
97 | int lastNonZero = input.Length;
98 | while (input[lastNonZero - 1] == 0)
99 | {
100 | lastNonZero--;
101 | Debug.Assert(lastNonZero != 0);
102 | }
103 |
104 | byte[] ret = new byte[lastNonZero];
105 | Buffer.BlockCopy(input, 0, ret, 0, lastNonZero);
106 | return ret;
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | build/
21 | bld/
22 | [Bb]in/
23 | [Oo]bj/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opensdf
80 | *.sdf
81 | *.cachefile
82 |
83 | # Visual Studio profiler
84 | *.psess
85 | *.vsp
86 | *.vspx
87 | *.sap
88 |
89 | # TFS 2012 Local Workspace
90 | $tf/
91 |
92 | # Guidance Automation Toolkit
93 | *.gpState
94 |
95 | # ReSharper is a .NET coding add-in
96 | _ReSharper*/
97 | *.[Rr]e[Ss]harper
98 | *.DotSettings.user
99 |
100 | # JustCode is a .NET coding add-in
101 | .JustCode
102 |
103 | # TeamCity is a build add-in
104 | _TeamCity*
105 |
106 | # DotCover is a Code Coverage Tool
107 | *.dotCover
108 |
109 | # NCrunch
110 | _NCrunch_*
111 | .*crunch*.local.xml
112 | nCrunchTemp_*
113 |
114 | # MightyMoose
115 | *.mm.*
116 | AutoTest.Net/
117 |
118 | # Web workbench (sass)
119 | .sass-cache/
120 |
121 | # Installshield output folder
122 | [Ee]xpress/
123 |
124 | # DocProject is a documentation generator add-in
125 | DocProject/buildhelp/
126 | DocProject/Help/*.HxT
127 | DocProject/Help/*.HxC
128 | DocProject/Help/*.hhc
129 | DocProject/Help/*.hhk
130 | DocProject/Help/*.hhp
131 | DocProject/Help/Html2
132 | DocProject/Help/html
133 |
134 | # Click-Once directory
135 | publish/
136 |
137 | # Publish Web Output
138 | *.[Pp]ublish.xml
139 | *.azurePubxml
140 | # TODO: Comment the next line if you want to checkin your web deploy settings
141 | # but database connection strings (with potential passwords) will be unencrypted
142 | *.pubxml
143 | *.publishproj
144 |
145 | # NuGet Packages
146 | *.nupkg
147 | # The packages folder can be ignored because of Package Restore
148 | **/packages/*
149 | # except build/, which is used as an MSBuild target.
150 | !**/packages/build/
151 | # Uncomment if necessary however generally it will be regenerated when needed
152 | #!**/packages/repositories.config
153 |
154 | # Windows Azure Build Output
155 | csx/
156 | *.build.csdef
157 |
158 | # Windows Store app package directory
159 | AppPackages/
160 |
161 | # Visual Studio cache files
162 | # files ending in .cache can be ignored
163 | *.[Cc]ache
164 | # but keep track of directories ending in .cache
165 | !*.[Cc]ache/
166 |
167 | # Others
168 | ClientBin/
169 | [Ss]tyle[Cc]op.*
170 | ~$*
171 | *~
172 | *.dbmdl
173 | *.dbproj.schemaview
174 | *.pfx
175 | *.publishsettings
176 | node_modules/
177 | orleans.codegen.cs
178 |
179 | # RIA/Silverlight projects
180 | Generated_Code/
181 |
182 | # Backup & report files from converting an old project file
183 | # to a newer Visual Studio version. Backup files are not needed,
184 | # because we have git ;-)
185 | _UpgradeReport_Files/
186 | Backup*/
187 | UpgradeLog*.XML
188 | UpgradeLog*.htm
189 |
190 | # SQL Server files
191 | *.mdf
192 | *.ldf
193 |
194 | # Business Intelligence projects
195 | *.rdl.data
196 | *.bim.layout
197 | *.bim_*.settings
198 |
199 | # Microsoft Fakes
200 | FakesAssemblies/
201 |
202 | # Node.js Tools for Visual Studio
203 | .ntvs_analysis.dat
204 |
205 | # Visual Studio 6 build log
206 | *.plg
207 |
208 | # Visual Studio 6 workspace options file
209 | *.opt
210 |
211 | # Visual Studio LightSwitch build output
212 | **/*.HTMLClient/GeneratedArtifacts
213 | **/*.DesktopClient/GeneratedArtifacts
214 | **/*.DesktopClient/ModelManifest.xml
215 | **/*.Server/GeneratedArtifacts
216 | **/*.Server/ModelManifest.xml
217 | _Pvt_Extensions
218 |
219 | \.idea/
220 |
--------------------------------------------------------------------------------
/EazDecodeLib/Crypto3Algorithms/SymAlgoPadder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Security.Cryptography;
4 |
5 | namespace EazDecodeLib.Crypto3Algorithms
6 | {
7 | ///
8 | ///
9 | /// Encrypts an incrementing number one byte at the time. Since the
10 | /// BlockSize is 8 bits, it can be used for padding.
11 | ///
12 | internal sealed class SymAlgoPadder : SymmetricAlgorithm
13 | {
14 | private readonly SymmetricAlgorithm _algo;
15 |
16 | public SymAlgoPadder(SymmetricAlgorithm algo)
17 | {
18 | LegalBlockSizesValue = new[] { new KeySizes(8, 8, 0) };
19 | LegalKeySizesValue = algo.LegalKeySizes;
20 | BlockSizeValue = 8; //1 byte
21 | Mode = CipherMode.ECB;
22 | Padding = PaddingMode.None;
23 | algo.Mode = CipherMode.ECB;
24 | algo.Padding = PaddingMode.None;
25 | _algo = algo;
26 | }
27 |
28 | public override ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) => new Transform(_algo, key);
29 | public override ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) => new Transform(_algo, key);
30 |
31 | public override void GenerateKey() => KeyValue = _algo.Key;
32 | public override void GenerateIV() => IVValue = new byte[0];
33 |
34 | private sealed class Transform : ICryptoTransform, IDisposable
35 | {
36 | private readonly byte[] _block;
37 | private readonly ICryptoTransform _encryptor;
38 | private readonly Queue _queue = new Queue();
39 |
40 | public int InputBlockSize => 1;
41 | public int OutputBlockSize => 1;
42 | public bool CanTransformMultipleBlocks => true;
43 | public bool CanReuseTransform => false;
44 |
45 | public Transform(SymmetricAlgorithm algo, byte[] key)
46 | {
47 | _block = new byte[algo.BlockSize / 8];
48 | _encryptor = algo.CreateEncryptor(key, new byte[algo.BlockSize / 8]);
49 | }
50 |
51 | public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
52 | {
53 | byte[] array = new byte[inputCount];
54 | TransformBlock(inputBuffer, inputOffset, inputCount, array, 0);
55 | return array;
56 | }
57 |
58 | public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
59 | {
60 | //xor every input byte with the encrypted one
61 | for (int i = 0; i < inputCount; i++)
62 | outputBuffer[i + outputOffset] = (byte)(inputBuffer[i + inputOffset] ^ Dequeue());
63 |
64 | return inputCount;
65 | }
66 |
67 | ///
68 | /// Dequeue a byte, enqueueing new ones if needed.
69 | ///
70 | ///
71 | private byte Dequeue()
72 | {
73 | //if the queue is empty, fill it again
74 | if (_queue.Count == 0)
75 | EnqueueBytes();
76 |
77 | //dequeue a byte and return it
78 | return _queue.Dequeue();
79 | }
80 |
81 | ///
82 | /// Create a new block and enqueue its bytes for use in the crypto.
83 | ///
84 | private void EnqueueBytes()
85 | {
86 | //encrypt the block
87 | byte[] encrypted = new byte[_block.Length];
88 | _encryptor.TransformBlock(_block, 0, _block.Length, encrypted, 0);
89 |
90 | //increment the block by 1
91 | IncrementBlock();
92 |
93 | //enqueue all encrypted bytes
94 | foreach (byte item in encrypted)
95 | _queue.Enqueue(item);
96 | }
97 |
98 | ///
99 | /// Treat as an integer and increase it by 1.
100 | ///
101 | private void IncrementBlock()
102 | {
103 | for (int i = _block.Length - 1; i >= 0; i--)
104 | {
105 | //increment buffer[i]
106 | _block[i]++;
107 |
108 | //if it is not not zero, break
109 | if (_block[i] != 0) break;
110 | }
111 | }
112 |
113 | public void Dispose() { }
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/EazDecodeLib/Crypto3Algorithms/KeyedHashAlgo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Security.Cryptography;
3 |
4 | namespace EazDecodeLib.Crypto3Algorithms
5 | {
6 | ///
7 | ///
8 | /// Chain a hashing algorithm and call it a keyed one.
9 | ///
10 | internal sealed class KeyedHashAlgo : KeyedHashAlgorithm
11 | {
12 | private readonly HashAlgorithm _hashAlgo1;
13 | private readonly HashAlgorithm _hashAlgo2;
14 |
15 | private byte[] _buffer1;
16 | private byte[] _buffer2;
17 |
18 | private bool _seeded; //could also mean "in use"
19 |
20 | private int _hashSize = 64; //default value never used
21 |
22 | public KeyedHashAlgo(HashAlgorithm hashAlgo, byte[] key)
23 | {
24 | SetMyHashSize(hashAlgo.HashSize / 8);
25 | _hashAlgo1 = hashAlgo;
26 | _hashAlgo2 = hashAlgo;
27 | SetKey(key);
28 | }
29 |
30 | protected override void Dispose(bool disposing)
31 | {
32 | if (disposing) {
33 | ((IDisposable)_hashAlgo1)?.Dispose();
34 | ((IDisposable)_hashAlgo2)?.Dispose();
35 |
36 | if (_buffer1 != null) Array.Clear(_buffer1, 0, _buffer1.Length);
37 | if (_buffer2 != null) Array.Clear(_buffer2, 0, _buffer2.Length);
38 | }
39 | base.Dispose(disposing);
40 | }
41 |
42 | protected override void HashCore(byte[] array, int ibStart, int cbSize)
43 | {
44 | if (!_seeded) {
45 | _hashAlgo1.TransformBlock(_buffer1, 0, _buffer1.Length, _buffer1, 0);
46 | _seeded = true;
47 | }
48 | _hashAlgo1.TransformBlock(array, ibStart, cbSize, array, ibStart);
49 | }
50 |
51 | protected override byte[] HashFinal()
52 | {
53 | //hash buffer1 contents if not done yet
54 | if (!_seeded) {
55 | _hashAlgo1.TransformBlock(_buffer1, 0, _buffer1.Length, _buffer1, 0);
56 | _seeded = true;
57 | }
58 |
59 | //get hash from _hashAlgo1
60 | byte[] zeroBuffer = new byte[0];
61 | _hashAlgo1.TransformFinalBlock(zeroBuffer, 0, 0);
62 | byte[] hash = _hashAlgo1.Hash;
63 |
64 | //make sure we start fresh
65 | if (_hashAlgo2 == _hashAlgo1)
66 | _hashAlgo1.Initialize();
67 |
68 | //hash _buffer2, hash hash, then run the original zero buffer (which is the same as hash?) through
69 | _hashAlgo2.TransformBlock(_buffer2, 0, _buffer2.Length, _buffer2, 0);
70 | _hashAlgo2.TransformBlock(hash, 0, hash.Length, hash, 0);
71 | _hashAlgo2.TransformFinalBlock(zeroBuffer, 0, 0);
72 |
73 | //reset seeded var
74 | _seeded = false;
75 |
76 | return _hashAlgo2.Hash;
77 | }
78 |
79 | public override void Initialize()
80 | {
81 | _hashAlgo1.Initialize();
82 | _hashAlgo2.Initialize();
83 | _seeded = false;
84 | }
85 |
86 | private void SetKey(byte[] key)
87 | {
88 | //reset buffers
89 | _buffer1 = null;
90 | _buffer2 = null;
91 |
92 | //hash key if it is too small, else use it as is
93 | KeyValue = key.Length > GetMyHashSize()
94 | ? _hashAlgo1.ComputeHash(key)
95 | : (byte[])key.Clone();
96 |
97 | //init buffers
98 | InitBuffers();
99 | }
100 |
101 | private void InitBuffers()
102 | {
103 | int hashSize = GetMyHashSize();
104 |
105 | //init buffers
106 | if (_buffer1 == null) _buffer1 = new byte[hashSize];
107 | if (_buffer2 == null) _buffer2 = new byte[hashSize];
108 |
109 | //fill buffers with constants
110 | for (int i = 0; i < hashSize; i++)
111 | {
112 | _buffer1[i] = 54;
113 | _buffer2[i] = 92;
114 | }
115 |
116 | //xor buffers with key, can maybe be merged with above for loop
117 | for (int i = 0; i < KeyValue.Length; i++)
118 | {
119 | _buffer1[i] ^= KeyValue[i];
120 | _buffer2[i] ^= KeyValue[i];
121 | }
122 | }
123 |
124 | private int GetMyHashSize() => _hashSize;
125 | private void SetMyHashSize(int val) => _hashSize = val;
126 |
127 | public override byte[] Key
128 | {
129 | get => (byte[])KeyValue.Clone();
130 | set => SetKey(value);
131 | }
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/EazDecodeLib/Crypto3.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Security.Cryptography;
5 | using EazDecodeLib.Crypto3Algorithms;
6 |
7 | namespace EazDecodeLib
8 | {
9 | ///
10 | /// Encryption used in Eazfuscator 5.8+. Designed to produce compact
11 | /// output.
12 | ///
13 | internal class Crypto3
14 | {
15 | private const string base64Salt = "dZ58E5Xa0RKqscx+HA3eLBcOcAExpKXCkF9MODmm1wVk8NynKuzorgv8y50USvuaLvlpLbwJWb9hQQSGoZx9kw==";
16 | private static byte[] salt = Convert.FromBase64String(base64Salt);
17 |
18 | private SymAlgoLengthOptimized[] _algos = new SymAlgoLengthOptimized[5];
19 | private SymmetricAlgorithm _padder;
20 | private KeyedHashAlgorithm _kha;
21 | private HashAlgorithm _homebrewHasher;
22 |
23 | private readonly SymbolDecompressor _sc;
24 |
25 | public Crypto3(string password)
26 | {
27 | //create SymbolDecompressor
28 | _sc = new SymbolDecompressor();
29 |
30 | //get a random provider
31 | var deriveBytes = new Rfc2898DeriveBytes(password, salt, 3000);
32 |
33 | //fill our list of algorithms
34 | for (int i = 0; i < _algos.Length; i++)
35 | {
36 | var algo = new SymAlgoLengthOptimized(new SymmetricAlgorithm[]
37 | {
38 | new RijndaelManaged(), //blocksize prob 128 or 256
39 | new SymAlgoBlowfish(), //blocksize 64 (8b)
40 | new SymAlgoSkipJack32(), //blocksize 32 (4b)
41 | });
42 |
43 | algo.Key = deriveBytes.GetBytes(algo.KeySize / 8);
44 | algo.IV = deriveBytes.GetBytes(algo.IVSize / 8);
45 | _algos[i] = algo;
46 | }
47 |
48 | //create padder algorithm
49 | _padder = new SymAlgoPadder(new RijndaelManaged()) {Key = deriveBytes.GetBytes(32)};
50 |
51 | //create kha
52 | _kha = new KeyedHashAlgo(new HashAlgoPadder(new HashAlgoEncryption(new HashAlgoFNV32(), new SymAlgoSkipJack32(new byte[] {
53 | 0xA3, 0x73, 0xF3, 0x68,
54 | 0xA0, 0x4A, 0x89, 0xE9,
55 | 0x92, 0xEC
56 | }))), deriveBytes.GetBytes(2));
57 |
58 | //create another hasher
59 | //this is not used?
60 | _homebrewHasher = new HashAlgoEncryption(new HashAlgoFNV32(), new SymAlgoSkipJack32(new byte[]
61 | {
62 | 0xEA, 0x5F, 0x88, 0xF2,
63 | 0xA2, 0x9C, 0x0F, 0xA9,
64 | 0x70, 0x9E
65 | }));
66 | }
67 |
68 | public string Decrypt(byte[] enc)
69 | {
70 | enc = TrimChecksumByte(enc);
71 | enc = RunThroughAlgoArray(enc, false);
72 | enc = Depad(enc);
73 | enc = CryptoHelper.RemoveTrailingNullBytes(enc);
74 | enc = CryptoHelper.XorArray(enc);
75 | return _sc.Decompress(enc);
76 | }
77 |
78 | ///
79 | /// Mostly used for verification. Trims the last byte and uses it as a
80 | /// checksum.
81 | ///
82 | /// Input byte[], including the checksum byte at
83 | /// the end
84 | /// Input without checksum byte
85 | private byte[] TrimChecksumByte(byte[] input)
86 | {
87 | if (input.Length == 0) return input;
88 |
89 | int newLen = input.Length - 1;
90 | lock (_kha) {
91 | byte hashFirstChar = _kha.ComputeHash(input, 0, newLen)[0];
92 | byte encLastChar = input[input.Length - 1];
93 | Debug.Assert(hashFirstChar == encLastChar);
94 | }
95 |
96 | byte[] ret = new byte[newLen];
97 | Buffer.BlockCopy(input, 0, ret, 0, newLen);
98 | return ret;
99 | }
100 |
101 | ///
102 | /// Uses the array to encrypt and decrypt a
103 | /// bunch of times.
104 | ///
105 | /// Bytes to process
106 | /// Whether to encrypt or decrypt
107 | /// Encrypted or decrypted bytes, depending on
108 | private byte[] RunThroughAlgoArray(byte[] buffer, bool encrypt)
109 | {
110 | if (encrypt) {
111 | for (int i = 0; i < _algos.Length; i++)
112 | {
113 | using (ICryptoTransform t = encrypt ? _algos[i].CreateEncryptor() : _algos[i].CreateDecryptor())
114 | buffer = t.TransformFinalBlock(buffer, 0, buffer.Length);
115 |
116 | encrypt = !encrypt;
117 | }
118 | } else {
119 | for (int i = _algos.Length - 1; i >= 0; i--)
120 | {
121 | using (ICryptoTransform t = encrypt ? _algos[i].CreateEncryptor() : _algos[i].CreateDecryptor())
122 | buffer = t.TransformFinalBlock(buffer, 0, buffer.Length);
123 |
124 | encrypt = !encrypt;
125 | }
126 | }
127 |
128 | return buffer;
129 | }
130 |
131 | ///
132 | /// Uses the 's decryptor to decrypt the
133 | /// padding bytes.
134 | ///
135 | /// Bytes to decrypt
136 | /// The decrypted bytes
137 | private byte[] Depad(byte[] enc)
138 | {
139 | using (var memoryStream = new MemoryStream()) {
140 | using (var cryptoStream = new CryptoStream(memoryStream, _padder.CreateDecryptor(), CryptoStreamMode.Write)) {
141 | cryptoStream.Write(enc, 0, enc.Length);
142 | }
143 | return memoryStream.ToArray();
144 | }
145 | }
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/EazDecode/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/EazDecodeLib/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\res.bin;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
123 |
124 |
--------------------------------------------------------------------------------
/EazDecodeLib/Crypto3Algorithms/SymAlgoSkipJack32.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Security.Cryptography;
3 |
4 | namespace EazDecodeLib.Crypto3Algorithms
5 | {
6 | ///
7 | ///
8 | /// An implementation of the SkipJack cipher
9 | ///
10 | internal sealed class SymAlgoSkipJack32 : SymmetricAlgorithm
11 | {
12 | private static readonly byte[] F = {
13 | 0xA3, 0xD7, 0x09, 0x83, 0xF8, 0x48, 0xF6, 0xF4,
14 | 0xB3, 0x21, 0x15, 0x78, 0x99, 0xB1, 0xAF, 0xF9,
15 | 0xE7, 0x2D, 0x4D, 0x8A, 0xCE, 0x4C, 0xCA, 0x2E,
16 | 0x52, 0x95, 0xD9, 0x1E, 0x4E, 0x38, 0x44, 0x28,
17 | 0x0A, 0xDF, 0x02, 0xA0, 0x17, 0xF1, 0x60, 0x68,
18 | 0x12, 0xB7, 0x7A, 0xC3, 0xE9, 0xFA, 0x3D, 0x53,
19 | 0x96, 0x84, 0x6B, 0xBA, 0xF2, 0x63, 0x9A, 0x19,
20 | 0x7C, 0xAE, 0xE5, 0xF5, 0xF7, 0x16, 0x6A, 0xA2,
21 | 0x39, 0xB6, 0x7B, 0x0F, 0xC1, 0x93, 0x81, 0x1B,
22 | 0xEE, 0xB4, 0x1A, 0xEA, 0xD0, 0x91, 0x2F, 0xB8,
23 | 0x55, 0xB9, 0xDA, 0x85, 0x3F, 0x41, 0xBF, 0xE0,
24 | 0x5A, 0x58, 0x80, 0x5F, 0x66, 0x0B, 0xD8, 0x90,
25 | 0x35, 0xD5, 0xC0, 0xA7, 0x33, 0x06, 0x65, 0x69,
26 | 0x45, 0x00, 0x94, 0x56, 0x6D, 0x98, 0x9B, 0x76,
27 | 0x97, 0xFC, 0xB2, 0xC2, 0xB0, 0xFE, 0xDB, 0x20,
28 | 0xE1, 0xEB, 0xD6, 0xE4, 0xDD, 0x47, 0x4A, 0x1D,
29 | 0x42, 0xED, 0x9E, 0x6E, 0x49, 0x3C, 0xCD, 0x43,
30 | 0x27, 0xD2, 0x07, 0xD4, 0xDE, 0xC7, 0x67, 0x18,
31 | 0x89, 0xCB, 0x30, 0x1F, 0x8D, 0xC6, 0x8F, 0xAA,
32 | 0xC8, 0x74, 0xDC, 0xC9, 0x5D, 0x5C, 0x31, 0xA4,
33 | 0x70, 0x88, 0x61, 0x2C, 0x9F, 0x0D, 0x2B, 0x87,
34 | 0x50, 0x82, 0x54, 0x64, 0x26, 0x7D, 0x03, 0x40,
35 | 0x34, 0x4B, 0x1C, 0x73, 0xD1, 0xC4, 0xFD, 0x3B,
36 | 0xCC, 0xFB, 0x7F, 0xAB, 0xE6, 0x3E, 0x5B, 0xA5,
37 | 0xAD, 0x04, 0x23, 0x9C, 0x14, 0x51, 0x22, 0xF0,
38 | 0x29, 0x79, 0x71, 0x7E, 0xFF, 0x8C, 0x0E, 0xE2,
39 | 0x0C, 0xEF, 0xBC, 0x72, 0x75, 0x6F, 0x37, 0xA1,
40 | 0xEC, 0xD3, 0x8E, 0x62, 0x8B, 0x86, 0x10, 0xE8,
41 | 0x08, 0x77, 0x11, 0xBE, 0x92, 0x4F, 0x24, 0xC5,
42 | 0x32, 0x36, 0x9D, 0xCF, 0xF3, 0xA6, 0xBB, 0xAC,
43 | 0x5E, 0x6C, 0xA9, 0x13, 0x57, 0x25, 0xB5, 0xE3,
44 | 0xBD, 0xA8, 0x3A, 0x01, 0x05, 0x59, 0x2A, 0x46
45 | };
46 |
47 | public SymAlgoSkipJack32()
48 | {
49 | LegalBlockSizesValue = new[] { new KeySizes(32, 32, 0) };
50 | LegalKeySizesValue = new[] { new KeySizes(80, 80, 0) };
51 | BlockSizeValue = 32;
52 | KeySizeValue = 80;
53 | ModeValue = CipherMode.ECB;
54 | PaddingValue = PaddingMode.None;
55 | }
56 |
57 | public SymAlgoSkipJack32(byte[] key) : this()
58 | {
59 | Key = key;
60 | }
61 |
62 | public override ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) => GetTransform(key, iv, false);
63 | public override ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) => GetTransform(key, iv, true);
64 |
65 | private ICryptoTransform GetTransform(byte[] key, byte[] iv, bool encrypt) => new CryptTrans(key, encrypt);
66 |
67 | public override void GenerateIV() => IV = new byte[BlockSize / 8];
68 | public override void GenerateKey() => Key = new byte[0];
69 |
70 | public byte[] Encrypt(byte[] bytes) => DoCrypto(bytes, true);
71 | public byte[] Decrypt(byte[] bytes) => DoCrypto(bytes, false);
72 |
73 | public uint Encrypt(uint val) => GetUInt(Encrypt(GetBytes(val)));
74 | public uint Decrypt(uint val) => GetUInt(Decrypt(GetBytes(val)));
75 |
76 | public int Encrypt(int val) => GetInt(Encrypt(GetBytes(val)));
77 | public int Decrypt(int val) => GetInt(Decrypt(GetBytes(val)));
78 |
79 | private static byte[] GetBytes(uint val) => new[] { (byte)(val >> 24), (byte)(val >> 16), (byte)(val >> 8), (byte)val };
80 | private static byte[] GetBytes(int val) => new[] { (byte)(val >> 24), (byte)(val >> 16), (byte)(val >> 8), (byte)val };
81 |
82 | private static uint GetUInt(byte[] val) => (uint)(val[0] << 24 | val[1] << 16 | val[2] << 8 | val[3]);
83 | private static int GetInt(byte[] val) => val[0] << 24 | val[1] << 16 | val[2] << 8 | val[3];
84 |
85 | private static ushort G(byte[] key, int step, ushort w)
86 | {
87 | byte g1 = (byte)(w >> 8 & 255);
88 | byte g2 = (byte)(w & 255);
89 |
90 | byte g3 = (byte)(F[g2 ^ key[(step * 4 + 0) % 10]] ^ g1);
91 | byte g4 = (byte)(F[g3 ^ key[(step * 4 + 1) % 10]] ^ g2);
92 | byte g5 = (byte)(F[g4 ^ key[(step * 4 + 2) % 10]] ^ g3);
93 | byte g6 = (byte)(F[g5 ^ key[(step * 4 + 3) % 10]] ^ g4);
94 |
95 | return (ushort)((g5 << 8) + g6);
96 | }
97 |
98 | private byte[] DoCrypto(byte[] buffer, bool encrypt)
99 | {
100 | byte[] array = new byte[buffer.Length];
101 | for (int i = 0; i < buffer.Length; i += 4)
102 | {
103 | TransformBlock(Key, buffer, i, array, i, encrypt);
104 | }
105 | return array;
106 | }
107 |
108 | private static void TransformBlock(byte[] key, byte[] inputBuffer, int inputOffset, byte[] outputBuffer, int outputOffset, bool encrypt)
109 | {
110 | int kstep = encrypt ? 1 : -1;
111 | int k = encrypt ? 0 : 23;
112 |
113 | ushort wl = (ushort)((inputBuffer[inputOffset + 0] << 8) + inputBuffer[inputOffset + 1]);
114 | ushort wr = (ushort)((inputBuffer[inputOffset + 2] << 8) + inputBuffer[inputOffset + 3]);
115 |
116 | for (int i = 0; i < 12; i++)
117 | {
118 | wr ^= (ushort)(G(key, k, wl) ^ k);
119 | k += kstep;
120 | wl ^= (ushort)(G(key, k, wr) ^ k);
121 | k += kstep;
122 | }
123 |
124 | outputBuffer[outputOffset + 0] = (byte)(wr >> 8);
125 | outputBuffer[outputOffset + 1] = (byte)(wr & 255);
126 | outputBuffer[outputOffset + 2] = (byte)(wl >> 8);
127 | outputBuffer[outputOffset + 3] = (byte)(wl & 255);
128 | }
129 |
130 | private sealed class CryptTrans : ICryptoTransform, IDisposable
131 | {
132 | private readonly byte[] _key;
133 | private readonly bool _encrypt;
134 |
135 | public int InputBlockSize => 4;
136 | public int OutputBlockSize => 4;
137 | public bool CanTransformMultipleBlocks => true;
138 | public bool CanReuseTransform => true;
139 |
140 | public CryptTrans(byte[] key, bool encrypt)
141 | {
142 | _key = key;
143 | _encrypt = encrypt;
144 | }
145 |
146 | public void Dispose() { }
147 |
148 | public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
149 | {
150 | for (int i = 0; i < inputCount; i += 4)
151 | SymAlgoSkipJack32.TransformBlock(_key, inputBuffer, inputOffset + i, outputBuffer, outputOffset + i, _encrypt);
152 |
153 | return inputCount;
154 | }
155 |
156 | public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
157 | {
158 | byte[] array = new byte[inputCount];
159 | TransformBlock(inputBuffer, inputOffset, inputCount, array, 0);
160 | return array;
161 | }
162 | }
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/EazDecode/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace EazDecode
2 | {
3 | // Token: 0x02000004 RID: 4
4 | public partial class Form1 : global::System.Windows.Forms.Form
5 | {
6 | // Token: 0x0600000E RID: 14 RVA: 0x00002363 File Offset: 0x00000563
7 | protected override void Dispose(bool disposing)
8 | {
9 | if (disposing && this.components != null)
10 | {
11 | this.components.Dispose();
12 | }
13 | base.Dispose(disposing);
14 | }
15 |
16 | // Token: 0x0600000F RID: 15 RVA: 0x00002384 File Offset: 0x00000584
17 | private void InitializeComponent()
18 | {
19 | this.tableLayoutPanel1 = new global::System.Windows.Forms.TableLayoutPanel();
20 | this.scMain = new global::System.Windows.Forms.SplitContainer();
21 | this.txtbIn = new global::System.Windows.Forms.TextBox();
22 | this.txtbOut = new global::System.Windows.Forms.TextBox();
23 | this.panel1 = new global::System.Windows.Forms.Panel();
24 | this.cbAuto = new global::System.Windows.Forms.CheckBox();
25 | this.btnDecode = new global::System.Windows.Forms.Button();
26 | this.btnFlip = new global::System.Windows.Forms.Button();
27 | this.label1 = new global::System.Windows.Forms.Label();
28 | this.txtbPassword = new global::System.Windows.Forms.TextBox();
29 | this.tableLayoutPanel1.SuspendLayout();
30 | ((global::System.ComponentModel.ISupportInitialize)this.scMain).BeginInit();
31 | this.scMain.Panel1.SuspendLayout();
32 | this.scMain.Panel2.SuspendLayout();
33 | this.scMain.SuspendLayout();
34 | this.panel1.SuspendLayout();
35 | base.SuspendLayout();
36 | this.tableLayoutPanel1.ColumnCount = 1;
37 | this.tableLayoutPanel1.ColumnStyles.Add(new global::System.Windows.Forms.ColumnStyle(global::System.Windows.Forms.SizeType.Percent, 100f));
38 | this.tableLayoutPanel1.Controls.Add(this.scMain, 0, 1);
39 | this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 0);
40 | this.tableLayoutPanel1.Dock = global::System.Windows.Forms.DockStyle.Fill;
41 | this.tableLayoutPanel1.Location = new global::System.Drawing.Point(0, 0);
42 | this.tableLayoutPanel1.Name = "tableLayoutPanel1";
43 | this.tableLayoutPanel1.RowCount = 2;
44 | this.tableLayoutPanel1.RowStyles.Add(new global::System.Windows.Forms.RowStyle(global::System.Windows.Forms.SizeType.Absolute, 50f));
45 | this.tableLayoutPanel1.RowStyles.Add(new global::System.Windows.Forms.RowStyle());
46 | this.tableLayoutPanel1.Size = new global::System.Drawing.Size(514, 358);
47 | this.tableLayoutPanel1.TabIndex = 0;
48 | this.scMain.Dock = global::System.Windows.Forms.DockStyle.Fill;
49 | this.scMain.Location = new global::System.Drawing.Point(3, 53);
50 | this.scMain.Name = "scMain";
51 | this.scMain.Panel1.Controls.Add(this.txtbIn);
52 | this.scMain.Panel2.Controls.Add(this.txtbOut);
53 | this.scMain.Size = new global::System.Drawing.Size(508, 302);
54 | this.scMain.SplitterDistance = 169;
55 | this.scMain.TabIndex = 1;
56 | this.txtbIn.Dock = global::System.Windows.Forms.DockStyle.Fill;
57 | this.txtbIn.Location = new global::System.Drawing.Point(0, 0);
58 | this.txtbIn.Multiline = true;
59 | this.txtbIn.Name = "txtbIn";
60 | this.txtbIn.Size = new global::System.Drawing.Size(169, 302);
61 | this.txtbIn.TabIndex = 0;
62 | this.txtbIn.TextChanged += new global::System.EventHandler(this.txtbIn_TextChanged);
63 | this.txtbOut.Dock = global::System.Windows.Forms.DockStyle.Fill;
64 | this.txtbOut.Location = new global::System.Drawing.Point(0, 0);
65 | this.txtbOut.Multiline = true;
66 | this.txtbOut.Name = "txtbOut";
67 | this.txtbOut.Size = new global::System.Drawing.Size(335, 302);
68 | this.txtbOut.TabIndex = 0;
69 | this.panel1.Controls.Add(this.cbAuto);
70 | this.panel1.Controls.Add(this.btnDecode);
71 | this.panel1.Controls.Add(this.btnFlip);
72 | this.panel1.Controls.Add(this.label1);
73 | this.panel1.Controls.Add(this.txtbPassword);
74 | this.panel1.Dock = global::System.Windows.Forms.DockStyle.Fill;
75 | this.panel1.Location = new global::System.Drawing.Point(3, 3);
76 | this.panel1.Name = "panel1";
77 | this.panel1.Size = new global::System.Drawing.Size(508, 44);
78 | this.panel1.TabIndex = 2;
79 | this.cbAuto.AutoSize = true;
80 | this.cbAuto.Checked = true;
81 | this.cbAuto.CheckState = global::System.Windows.Forms.CheckState.Checked;
82 | this.cbAuto.Location = new global::System.Drawing.Point(6, 23);
83 | this.cbAuto.Name = "cbAuto";
84 | this.cbAuto.Size = new global::System.Drawing.Size(87, 17);
85 | this.cbAuto.TabIndex = 6;
86 | this.cbAuto.Text = "Auto-decode";
87 | this.cbAuto.UseVisualStyleBackColor = true;
88 | this.cbAuto.CheckedChanged += new global::System.EventHandler(this.cbAuto_CheckedChanged);
89 | this.btnDecode.Anchor = (global::System.Windows.Forms.AnchorStyles.Top | global::System.Windows.Forms.AnchorStyles.Right);
90 | this.btnDecode.FlatStyle = global::System.Windows.Forms.FlatStyle.Flat;
91 | this.btnDecode.Location = new global::System.Drawing.Point(399, 0);
92 | this.btnDecode.Name = "btnDecode";
93 | this.btnDecode.Size = new global::System.Drawing.Size(66, 44);
94 | this.btnDecode.TabIndex = 5;
95 | this.btnDecode.Text = "Decode";
96 | this.btnDecode.UseVisualStyleBackColor = true;
97 | this.btnDecode.Click += new global::System.EventHandler(this.btnDecode_Click);
98 | this.btnFlip.Anchor = (global::System.Windows.Forms.AnchorStyles.Top | global::System.Windows.Forms.AnchorStyles.Right);
99 | this.btnFlip.FlatStyle = global::System.Windows.Forms.FlatStyle.Flat;
100 | this.btnFlip.Location = new global::System.Drawing.Point(464, 0);
101 | this.btnFlip.Name = "btnFlip";
102 | this.btnFlip.Size = new global::System.Drawing.Size(44, 44);
103 | this.btnFlip.TabIndex = 5;
104 | this.btnFlip.Text = "Flip";
105 | this.btnFlip.UseVisualStyleBackColor = true;
106 | this.btnFlip.Click += new global::System.EventHandler(this.btnFlip_Click);
107 | this.label1.AutoSize = true;
108 | this.label1.Location = new global::System.Drawing.Point(3, 6);
109 | this.label1.Name = "label1";
110 | this.label1.Size = new global::System.Drawing.Size(56, 13);
111 | this.label1.TabIndex = 4;
112 | this.label1.Text = "Password:";
113 | this.txtbPassword.Location = new global::System.Drawing.Point(59, 3);
114 | this.txtbPassword.Name = "txtbPassword";
115 | this.txtbPassword.PasswordChar = '•';
116 | this.txtbPassword.Size = new global::System.Drawing.Size(150, 20);
117 | this.txtbPassword.TabIndex = 3;
118 | this.txtbPassword.TextChanged += new global::System.EventHandler(this.txtbPassword_TextChanged);
119 | base.AutoScaleDimensions = new global::System.Drawing.SizeF(6f, 13f);
120 | base.AutoScaleMode = global::System.Windows.Forms.AutoScaleMode.Font;
121 | this.BackColor = global::System.Drawing.Color.MediumSeaGreen;
122 | base.ClientSize = new global::System.Drawing.Size(514, 358);
123 | base.Controls.Add(this.tableLayoutPanel1);
124 | base.Name = "Form1";
125 | base.ShowIcon = false;
126 | this.Text = "EazDecode";
127 | this.tableLayoutPanel1.ResumeLayout(false);
128 | this.scMain.Panel1.ResumeLayout(false);
129 | this.scMain.Panel1.PerformLayout();
130 | this.scMain.Panel2.ResumeLayout(false);
131 | this.scMain.Panel2.PerformLayout();
132 | ((global::System.ComponentModel.ISupportInitialize)this.scMain).EndInit();
133 | this.scMain.ResumeLayout(false);
134 | this.panel1.ResumeLayout(false);
135 | this.panel1.PerformLayout();
136 | base.ResumeLayout(false);
137 | }
138 |
139 | // Token: 0x04000004 RID: 4
140 | private global::System.ComponentModel.IContainer components;
141 |
142 | // Token: 0x04000005 RID: 5
143 | private global::System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
144 |
145 | // Token: 0x04000006 RID: 6
146 | private global::System.Windows.Forms.SplitContainer scMain;
147 |
148 | // Token: 0x04000007 RID: 7
149 | private global::System.Windows.Forms.TextBox txtbIn;
150 |
151 | // Token: 0x04000008 RID: 8
152 | private global::System.Windows.Forms.TextBox txtbOut;
153 |
154 | // Token: 0x04000009 RID: 9
155 | private global::System.Windows.Forms.Panel panel1;
156 |
157 | // Token: 0x0400000A RID: 10
158 | private global::System.Windows.Forms.Label label1;
159 |
160 | // Token: 0x0400000B RID: 11
161 | private global::System.Windows.Forms.TextBox txtbPassword;
162 |
163 | // Token: 0x0400000C RID: 12
164 | private global::System.Windows.Forms.Button btnFlip;
165 |
166 | // Token: 0x0400000D RID: 13
167 | private global::System.Windows.Forms.Button btnDecode;
168 |
169 | // Token: 0x0400000E RID: 14
170 | private global::System.Windows.Forms.CheckBox cbAuto;
171 | }
172 | }
173 |
--------------------------------------------------------------------------------
/EazDecodeLib/Crypto3Algorithms/SymAlgoLengthOptimized.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Security.Cryptography;
6 |
7 | namespace EazDecodeLib.Crypto3Algorithms
8 | {
9 | ///
10 | ///
11 | /// Chain various algorithms in order of descending blocksizes, to prevent
12 | /// padding as much as possible.
13 | ///
14 | internal sealed class SymAlgoLengthOptimized : SymmetricAlgorithm
15 | {
16 | public int IVSize;
17 |
18 | private readonly SymmetricAlgorithm[] _algos;
19 |
20 | public SymAlgoLengthOptimized(IEnumerable algos)
21 | {
22 | //sort input by blocksize
23 | var l = algos.ToList();
24 | l.Sort((x, y) => y.BlockSize.CompareTo(x.BlockSize));
25 | _algos = l.ToArray();
26 |
27 | //set all algos to ECB and get total key size
28 | int totalKeySize = 0;
29 | int lastBlockSize = -1;
30 | foreach (var alg in _algos)
31 | {
32 | Debug.Assert(lastBlockSize != alg.BlockSize, $"BlockSize being equal to {nameof(lastBlockSize)} would throw an exception");
33 | lastBlockSize = alg.BlockSize;
34 | totalKeySize += alg.KeySize;
35 | alg.Mode = CipherMode.ECB;
36 | alg.Padding = PaddingMode.None;
37 | }
38 |
39 | //set algo settings
40 | BlockSizeValue = _algos[_algos.Length - 1].BlockSize; //TODO: also last blocksize?
41 | LegalBlockSizesValue = new[] { new KeySizes(BlockSizeValue, BlockSizeValue, 0) };
42 | KeySizeValue = totalKeySize;
43 | LegalKeySizesValue = new[] { new KeySizes(totalKeySize, totalKeySize, 0) };
44 | IVSize = _algos[0].BlockSize;
45 | Mode = CipherMode.ECB;
46 | Padding = PaddingMode.None;
47 | }
48 |
49 | public override byte[] IV
50 | {
51 | get => base.IV;
52 | set => IVValue = (byte[])value.Clone();
53 | }
54 |
55 | public override ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) => GetCryptoTransform(key, iv, true);
56 | public override ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) => GetCryptoTransform(key, iv, false);
57 | private ICryptoTransform GetCryptoTransform(byte[] key, byte[] iv, bool encrypt) => new CryptTrans(_algos, key, iv, encrypt);
58 |
59 | public override void GenerateKey() => throw new NotSupportedException();
60 | public override void GenerateIV() => throw new NotSupportedException();
61 |
62 | private sealed class CryptTrans : ICryptoTransform, IDisposable
63 | {
64 | private readonly SymmetricAlgorithm[] _algos;
65 | private readonly int _blockSize;
66 | private readonly bool _encrypt;
67 | private readonly byte[] _iv;
68 | private readonly byte[] _key;
69 | private ICryptoTransform[] _transforms;
70 |
71 | public int InputBlockSize => _blockSize;
72 | public int OutputBlockSize => _blockSize;
73 | public bool CanTransformMultipleBlocks => true;
74 | public bool CanReuseTransform => true;
75 |
76 | public CryptTrans(SymmetricAlgorithm[] algos, byte[] key, byte[] iv, bool encrypt)
77 | {
78 | _algos = algos;
79 | _key = key;
80 | _encrypt = encrypt;
81 | _iv = iv;
82 | _blockSize = algos[algos.Length - 1].BlockSize / 8;
83 | }
84 |
85 | public void Dispose()
86 | {
87 | if (_transforms == null) return;
88 | foreach (ICryptoTransform t in _transforms) t?.Dispose();
89 | _transforms = null;
90 | }
91 |
92 | public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
93 | {
94 | //copy input to output
95 | Buffer.BlockCopy(inputBuffer, inputOffset, outputBuffer, outputOffset, inputCount);
96 |
97 | //create ICryptoTransforms
98 | PopulateTransforms();
99 |
100 | //encrypt or decrypt
101 | if (_encrypt)
102 | Encrypt(outputBuffer, outputOffset, inputCount);
103 | else
104 | Decrypt(outputBuffer, outputOffset, inputCount);
105 |
106 | //kind of useless in this case, but return input size
107 | return inputCount;
108 | }
109 |
110 | private void PopulateTransforms()
111 | {
112 | //don't do this if we already did before
113 | if (_transforms != null) return;
114 |
115 | _transforms = new ICryptoTransform[_algos.Length];
116 |
117 | int keyOffset = 0;
118 | for (int i = 0; i < _algos.Length; i++)
119 | {
120 | SymmetricAlgorithm algo = _algos[i];
121 |
122 | //get array with key and iv
123 | int keySizeBytes = algo.KeySize / 8;
124 | byte[] key = new byte[keySizeBytes];
125 | Buffer.BlockCopy(_key, keyOffset, key, 0, keySizeBytes);
126 | byte[] iv = new byte[algo.BlockSize / 8];
127 |
128 | //increment key offset
129 | keyOffset += keySizeBytes;
130 |
131 | //get actual transform
132 | ICryptoTransform cryptoTransform = _encrypt
133 | ? algo.CreateEncryptor(key, iv)
134 | : algo.CreateDecryptor(key, iv);
135 |
136 | //some checks
137 | Debug.Assert(cryptoTransform.CanReuseTransform);
138 | Debug.Assert(algo.BlockSize == cryptoTransform.InputBlockSize * 8);
139 | Debug.Assert(cryptoTransform.InputBlockSize == cryptoTransform.OutputBlockSize);
140 |
141 | //store in array
142 | _transforms[i] = cryptoTransform;
143 | }
144 | }
145 |
146 | private void Encrypt(byte[] buffer, int offset, int count)
147 | {
148 | //store iv in block
149 | byte[] block = new byte[_iv.Length];
150 | Buffer.BlockCopy(_iv, 0, block, 0, block.Length);
151 |
152 | int lastOffset = 0;
153 | foreach (ICryptoTransform transform in _transforms)
154 | {
155 | //calculate size of current "chunk"
156 | int blockSize = transform.InputBlockSize;
157 | int currentCount = count - lastOffset & ~(blockSize - 1); //count - rounded lastOffset, eg: count - lastOffset & 0b11111111_11000000
158 | int nextOffset = lastOffset + currentCount;
159 |
160 | for (int i = lastOffset; i < nextOffset; i += blockSize)
161 | {
162 | //xor buffer with block
163 | int bufferOffset = i + offset;
164 | CryptoHelper.XorArray(buffer, bufferOffset, block, 0, blockSize);
165 |
166 | //decrypt buffer to buffer
167 | if (transform.TransformBlock(buffer, bufferOffset, blockSize, buffer, bufferOffset) != blockSize) throw new Exception();
168 |
169 | //copy buffer to block
170 | Buffer.BlockCopy(buffer, bufferOffset, block, 0, blockSize);
171 | }
172 |
173 | //update lastOffset
174 | lastOffset = nextOffset;
175 |
176 | //if we're at the end, stop
177 | if (nextOffset == count)
178 | break;
179 | }
180 | }
181 |
182 | private void Decrypt(byte[] buffer, int offset, int count)
183 | {
184 | //allocate buffers
185 | byte[] block = new byte[_iv.Length];
186 | Buffer.BlockCopy(_iv, 0, block, 0, block.Length);
187 | byte[] tempBuffer = new byte[block.Length];
188 |
189 | int lastOffset = 0;
190 | foreach (ICryptoTransform transform in _transforms)
191 | {
192 | //calculate size of current "chunk"
193 | int blockSize = transform.InputBlockSize;
194 | int currentCount = count - lastOffset & ~(blockSize - 1); //how much we're doing now
195 | int nextOffset = lastOffset + currentCount;
196 |
197 | for (int i = lastOffset; i < nextOffset; i += blockSize)
198 | {
199 | //copy buffer to tempBuffer
200 | int bufferOffset = i + offset;
201 | Buffer.BlockCopy(buffer, bufferOffset, tempBuffer, 0, blockSize);
202 |
203 | //decrypt buffer into buffer
204 | if (transform.TransformBlock(buffer, bufferOffset, blockSize, buffer, bufferOffset) != blockSize) throw new Exception();
205 |
206 | //xor buffer with block
207 | CryptoHelper.XorArray(buffer, bufferOffset, block, 0, blockSize);
208 |
209 | //copy tempBuffer to block to xor the next time
210 | Buffer.BlockCopy(tempBuffer, 0, block, 0, blockSize);
211 | }
212 |
213 | //update lastOffset
214 | lastOffset = nextOffset;
215 |
216 | //if we're at the end, stop
217 | if (nextOffset == count)
218 | break;
219 | }
220 | }
221 |
222 | public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
223 | {
224 | byte[] array = new byte[inputCount];
225 | TransformBlock(inputBuffer, inputOffset, inputCount, array, 0);
226 | return array;
227 | }
228 | }
229 | }
230 | }
231 |
--------------------------------------------------------------------------------
/EazDecodeLib/Crypto3Algorithms/SymAlgoBlowfish.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Security.Cryptography;
4 |
5 | namespace EazDecodeLib.Crypto3Algorithms
6 | {
7 | ///
8 | ///
9 | /// Implementation of the Blowfish cipher
10 | ///
11 | internal sealed class SymAlgoBlowfish : SymmetricAlgorithm
12 | {
13 | private readonly object _lock = new object();
14 | private byte[] _key;
15 | private BlowfishKey _blowfishKey;
16 |
17 | public SymAlgoBlowfish()
18 | {
19 | LegalBlockSizesValue = new[] { new KeySizes(64, 64, 0) };
20 | LegalKeySizesValue = new[] { new KeySizes(32, 448, 32) };
21 | BlockSizeValue = 64;
22 | KeySizeValue = 256;
23 | }
24 |
25 | public override ICryptoTransform CreateEncryptor(byte[] key, byte[] iv) => GetCryptoTransform(key, iv, true);
26 | public override ICryptoTransform CreateDecryptor(byte[] key, byte[] iv) => GetCryptoTransform(key, iv, false);
27 |
28 | private ICryptoTransform GetCryptoTransform(byte[] key, byte[] iv, bool encrypt) => new CryptTrans(GetKey(key), encrypt);
29 |
30 | public override void GenerateKey() => throw new NotImplementedException();
31 | public override void GenerateIV() => throw new NotImplementedException();
32 |
33 | ///
34 | /// Get a for the passed key.
35 | ///
36 | ///
37 | ///
38 | private BlowfishKey GetKey(byte[] key)
39 | {
40 | lock (_lock) {
41 | //if key bytes match, return previous key
42 | if (_key != null && key.Length == _key.Length && !key.Where((t, i) => t != _key[i]).Any())
43 | return _blowfishKey;
44 | }
45 |
46 | //otherwise, make a new one
47 | var blowfishKey = new BlowfishKey(key);
48 | lock (_lock)
49 | {
50 | _key = key;
51 | _blowfishKey = blowfishKey;
52 | }
53 | return blowfishKey;
54 | }
55 |
56 | private sealed class CryptTrans : ICryptoTransform, IDisposable
57 | {
58 | private readonly BlowfishKey _blowfishKey;
59 | private readonly bool _encrypt;
60 |
61 | public CryptTrans(BlowfishKey key, bool encrypt)
62 | {
63 | _blowfishKey = key;
64 | _encrypt = encrypt;
65 | }
66 |
67 | public int InputBlockSize => 8;
68 | public int OutputBlockSize => 8;
69 | public bool CanTransformMultipleBlocks => true;
70 | public bool CanReuseTransform => true;
71 |
72 | public void Dispose() { }
73 |
74 | public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
75 | {
76 | //loop through all bytes and encrypt/decrypt them
77 | for (int i = 0; i < inputCount; i += 8) {
78 | if (_encrypt)
79 | _blowfishKey.Encrypt(inputBuffer, inputOffset + i, outputBuffer, outputOffset + i);
80 | else
81 | _blowfishKey.Decrypt(inputBuffer, inputOffset + i, outputBuffer, outputOffset + i);
82 | }
83 | return inputCount;
84 | }
85 |
86 | public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
87 | {
88 | byte[] array = new byte[inputCount];
89 | TransformBlock(inputBuffer, inputOffset, inputCount, array, 0);
90 | return array;
91 | }
92 | }
93 |
94 | private sealed class BlowfishKey
95 | {
96 | #region keys
97 | private static readonly uint[] P = {
98 | 0x243F6A88u, 0x85A308D3u, 0x13198A2Eu, 0x03707344u,
99 | 0xA4093822u, 0x299F31D0u, 0x082EFA98u, 0xEC4E6C89u,
100 | 0x452821E6u, 0x38D01377u, 0xBE5466CFu, 0x34E90C6Cu,
101 | 0xC0AC29B7u, 0xC97C50DDu, 0x3F84D5B5u, 0xB5470917u,
102 | 0x9216D5D9u, 0x8979FB1Bu
103 | };
104 |
105 | private static readonly uint[,] S = {
106 | {
107 | 0xD1310BA6u, 0x98DFB5ACu, 0x2FFD72DBu, 0xD01ADFB7u, 0xB8E1AFEDu, 0x6A267E96u, 0xBA7C9045u, 0xF12C7F99u, 0x24A19947u, 0xB3916CF7u, 0x0801F2E2u, 0x858EFC16u, 0x636920D8u, 0x71574E69u, 0xA458FEA3u, 0xF4933D7Eu,
108 | 0x0D95748Fu, 0x728EB658u, 0x718BCD58u, 0x82154AEEu, 0x7B54A41Du, 0xC25A59B5u, 0x9C30D539u, 0x2AF26013u, 0xC5D1B023u, 0x286085F0u, 0xCA417918u, 0xB8DB38EFu, 0x8E79DCB0u, 0x603A180Eu, 0x6C9E0E8Bu, 0xB01E8A3Eu,
109 | 0xD71577C1u, 0xBD314B27u, 0x78AF2FDAu, 0x55605C60u, 0xE65525F3u, 0xAA55AB94u, 0x57489862u, 0x63E81440u, 0x55CA396Au, 0x2AAB10B6u, 0xB4CC5C34u, 0x1141E8CEu, 0xA15486AFu, 0x7C72E993u, 0xB3EE1411u, 0x636FBC2Au,
110 | 0x2BA9C55Du, 0x741831F6u, 0xCE5C3E16u, 0x9B87931Eu, 0xAFD6BA33u, 0x6C24CF5Cu, 0x7A325381u, 0x28958677u, 0x3B8F4898u, 0x6B4BB9AFu, 0xC4BFE81Bu, 0x66282193u, 0x61D809CCu, 0xFB21A991u, 0x487CAC60u, 0x5DEC8032u,
111 | 0xEF845D5Du, 0xE98575B1u, 0xDC262302u, 0xEB651B88u, 0x23893E81u, 0xD396ACC5u, 0x0F6D6FF3u, 0x83F44239u, 0x2E0B4482u, 0xA4842004u, 0x69C8F04Au, 0x9E1F9B5Eu, 0x21C66842u, 0xF6E96C9Au, 0x670C9C61u, 0xABD388F0u,
112 | 0x6A51A0D2u, 0xD8542F68u, 0x960FA728u, 0xAB5133A3u, 0x6EEF0B6Cu, 0x137A3BE4u, 0xBA3BF050u, 0x7EFB2A98u, 0xA1F1651Du, 0x39AF0176u, 0x66CA593Eu, 0x82430E88u, 0x8CEE8619u, 0x456F9FB4u, 0x7D84A5C3u, 0x3B8B5EBEu,
113 | 0xE06F75D8u, 0x85C12073u, 0x401A449Fu, 0x56C16AA6u, 0x4ED3AA62u, 0x363F7706u, 0x1BFEDF72u, 0x429B023Du, 0x37D0D724u, 0xD00A1248u, 0xDB0FEAD3u, 0x49F1C09Bu, 0x075372C9u, 0x80991B7Bu, 0x25D479D8u, 0xF6E8DEF7u,
114 | 0xE3FE501Au, 0xB6794C3Bu, 0x976CE0BDu, 0x04C006BAu, 0xC1A94FB6u, 0x409F60C4u, 0x5E5C9EC2u, 0x196A2463u, 0x68FB6FAFu, 0x3E6C53B5u, 0x1339B2EBu, 0x3B52EC6Fu, 0x6DFC511Fu, 0x9B30952Cu, 0xCC814544u, 0xAF5EBD09u,
115 | 0xBEE3D004u, 0xDE334AFDu, 0x660F2807u, 0x192E4BB3u, 0xC0CBA857u, 0x45C8740Fu, 0xD20B5F39u, 0xB9D3FBDBu, 0x5579C0BDu, 0x1A60320Au, 0xD6A100C6u, 0x402C7279u, 0x679F25FEu, 0xFB1FA3CCu, 0x8EA5E9F8u, 0xDB3222F8u,
116 | 0x3C7516DFu, 0xFD616B15u, 0x2F501EC8u, 0xAD0552ABu, 0x323DB5FAu, 0xFD238760u, 0x53317B48u, 0x3E00DF82u, 0x9E5C57BBu, 0xCA6F8CA0u, 0x1A87562Eu, 0xDF1769DBu, 0xD542A8F6u, 0x287EFFC3u, 0xAC6732C6u, 0x8C4F5573u,
117 | 0x695B27B0u, 0xBBCA58C8u, 0xE1FFA35Du, 0xB8F011A0u, 0x10FA3D98u, 0xFD2183B8u, 0x4AFCB56Cu, 0x2DD1D35Bu, 0x9A53E479u, 0xB6F84565u, 0xD28E49BCu, 0x4BFB9790u, 0xE1DDF2DAu, 0xA4CB7E33u, 0x62FB1341u, 0xCEE4C6E8u,
118 | 0xEF20CADAu, 0x36774C01u, 0xD07E9EFEu, 0x2BF11FB4u, 0x95DBDA4Du, 0xAE909198u, 0xEAAD8E71u, 0x6B93D5A0u, 0xD08ED1D0u, 0xAFC725E0u, 0x8E3C5B2Fu, 0x8E7594B7u, 0x8FF6E2FBu, 0xF2122B64u, 0x8888B812u, 0x900DF01Cu,
119 | 0x4FAD5EA0u, 0x688FC31Cu, 0xD1CFF191u, 0xB3A8C1ADu, 0x2F2F2218u, 0xBE0E1777u, 0xEA752DFEu, 0x8B021FA1u, 0xE5A0CC0Fu, 0xB56F74E8u, 0x18ACF3D6u, 0xCE89E299u, 0xB4A84FE0u, 0xFD13E0B7u, 0x7CC43B81u, 0xD2ADA8D9u,
120 | 0x165FA266u, 0x80957705u, 0x93CC7314u, 0x211A1477u, 0xE6AD2065u, 0x77B5FA86u, 0xC75442F5u, 0xFB9D35CFu, 0xEBCDAF0Cu, 0x7B3E89A0u, 0xD6411BD3u, 0xAE1E7E49u, 0x00250E2Du, 0x2071B35Eu, 0x226800BBu, 0x57B8E0AFu,
121 | 0x2464369Bu, 0xF009B91Eu, 0x5563911Du, 0x59DFA6AAu, 0x78C14389u, 0xD95A537Fu, 0x207D5BA2u, 0x02E5B9C5u, 0x83260376u, 0x6295CFA9u, 0x11C81968u, 0x4E734A41u, 0xB3472DCAu, 0x7B14A94Au, 0x1B510052u, 0x9A532915u,
122 | 0xD60F573Fu, 0xBC9BC6E4u, 0x2B60A476u, 0x81E67400u, 0x08BA6FB5u, 0x571BE91Fu, 0xF296EC6Bu, 0x2A0DD915u, 0xB6636521u, 0xE7B9F9B6u, 0xFF34052Eu, 0xC5855664u, 0x53B02D5Du, 0xA99F8FA1u, 0x08BA4799u, 0x6E85076Au
123 | }, {
124 | 0x4B7A70E9u, 0xB5B32944u, 0xDB75092Eu, 0xC4192623u, 0xAD6EA6B0u, 0x49A7DF7Du, 0x9CEE60B8u, 0x8FEDB266u, 0xECAA8C71u, 0x699A17FFu, 0x5664526Cu, 0xC2B19EE1u, 0x193602A5u, 0x75094C29u, 0xA0591340u, 0xE4183A3Eu,
125 | 0x3F54989Au, 0x5B429D65u, 0x6B8FE4D6u, 0x99F73FD6u, 0xA1D29C07u, 0xEFE830F5u, 0x4D2D38E6u, 0xF0255DC1u, 0x4CDD2086u, 0x8470EB26u, 0x6382E9C6u, 0x021ECC5Eu, 0x09686B3Fu, 0x3EBAEFC9u, 0x3C971814u, 0x6B6A70A1u,
126 | 0x687F3584u, 0x52A0E286u, 0xB79C5305u, 0xAA500737u, 0x3E07841Cu, 0x7FDEAE5Cu, 0x8E7D44ECu, 0x5716F2B8u, 0xB03ADA37u, 0xF0500C0Du, 0xF01C1F04u, 0x0200B3FFu, 0xAE0CF51Au, 0x3CB574B2u, 0x25837A58u, 0xDC0921BDu,
127 | 0xD19113F9u, 0x7CA92FF6u, 0x94324773u, 0x22F54701u, 0x3AE5E581u, 0x37C2DADCu, 0xC8B57634u, 0x9AF3DDA7u, 0xA9446146u, 0x0FD0030Eu, 0xECC8C73Eu, 0xA4751E41u, 0xE238CD99u, 0x3BEA0E2Fu, 0x3280BBA1u, 0x183EB331u,
128 | 0x4E548B38u, 0x4F6DB908u, 0x6F420D03u, 0xF60A04BFu, 0x2CB81290u, 0x24977C79u, 0x5679B072u, 0xBCAF89AFu, 0xDE9A771Fu, 0xD9930810u, 0xB38BAE12u, 0xDCCF3F2Eu, 0x5512721Fu, 0x2E6B7124u, 0x501ADDE6u, 0x9F84CD87u,
129 | 0x7A584718u, 0x7408DA17u, 0xBC9F9ABCu, 0xE94B7D8Cu, 0xEC7AEC3Au, 0xDB851DFAu, 0x63094366u, 0xC464C3D2u, 0xEF1C1847u, 0x3215D908u, 0xDD433B37u, 0x24C2BA16u, 0x12A14D43u, 0x2A65C451u, 0x50940002u, 0x133AE4DDu,
130 | 0x71DFF89Eu, 0x10314E55u, 0x81AC77D6u, 0x5F11199Bu, 0x043556F1u, 0xD7A3C76Bu, 0x3C11183Bu, 0x5924A509u, 0xF28FE6EDu, 0x97F1FBFAu, 0x9EBABF2Cu, 0x1E153C6Eu, 0x86E34570u, 0xEAE96FB1u, 0x860E5E0Au, 0x5A3E2AB3u,
131 | 0x771FE71Cu, 0x4E3D06FAu, 0x2965DCB9u, 0x99E71D0Fu, 0x803E89D6u, 0x5266C825u, 0x2E4CC978u, 0x9C10B36Au, 0xC6150EBAu, 0x94E2EA78u, 0xA5FC3C53u, 0x1E0A2DF4u, 0xF2F74EA7u, 0x361D2B3Du, 0x1939260Fu, 0x19C27960u,
132 | 0x5223A708u, 0xF71312B6u, 0xEBADFE6Eu, 0xEAC31F66u, 0xE3BC4595u, 0xA67BC883u, 0xB17F37D1u, 0x018CFF28u, 0xC332DDEFu, 0xBE6C5AA5u, 0x65582185u, 0x68AB9802u, 0xEECEA50Fu, 0xDB2F953Bu, 0x2AEF7DADu, 0x5B6E2F84u,
133 | 0x1521B628u, 0x29076170u, 0xECDD4775u, 0x619F1510u, 0x13CCA830u, 0xEB61BD96u, 0x0334FE1Eu, 0xAA0363CFu, 0xB5735C90u, 0x4C70A239u, 0xD59E9E0Bu, 0xCBAADE14u, 0xEECC86BCu, 0x60622CA7u, 0x9CAB5CABu, 0xB2F3846Eu,
134 | 0x648B1EAFu, 0x19BDF0CAu, 0xA02369B9u, 0x655ABB50u, 0x40685A32u, 0x3C2AB4B3u, 0x319EE9D5u, 0xC021B8F7u, 0x9B540B19u, 0x875FA099u, 0x95F7997Eu, 0x623D7DA8u, 0xF837889Au, 0x97E32D77u, 0x11ED935Fu, 0x16681281u,
135 | 0x0E358829u, 0xC7E61FD6u, 0x96DEDFA1u, 0x7858BA99u, 0x57F584A5u, 0x1B227263u, 0x9B83C3FFu, 0x1AC24696u, 0xCDB30AEBu, 0x532E3054u, 0x8FD948E4u, 0x6DBC3128u, 0x58EBF2EFu, 0x34C6FFEAu, 0xFE28ED61u, 0xEE7C3C73u,
136 | 0x5D4A14D9u, 0xE864B7E3u, 0x42105D14u, 0x203E13E0u, 0x45EEE2B6u, 0xA3AAABEAu, 0xDB6C4F15u, 0xFACB4FD0u, 0xC742F442u, 0xEF6ABBB5u, 0x654F3B1Du, 0x41CD2105u, 0xD81E799Eu, 0x86854DC7u, 0xE44B476Au, 0x3D816250u,
137 | 0xCF62A1F2u, 0x5B8D2646u, 0xFC8883A0u, 0xC1C7B6A3u, 0x7F1524C3u, 0x69CB7492u, 0x47848A0Bu, 0x5692B285u, 0x095BBF00u, 0xAD19489Du, 0x1462B174u, 0x23820E00u, 0x58428D2Au, 0x0C55F5EAu, 0x1DADF43Eu, 0x233F7061u,
138 | 0x3372F092u, 0x8D937E41u, 0xD65FECF1u, 0x6C223BDBu, 0x7CDE3759u, 0xCBEE7460u, 0x4085F2A7u, 0xCE77326Eu, 0xA6078084u, 0x19F8509Eu, 0xE8EFD855u, 0x61D99735u, 0xA969A7AAu, 0xC50C06C2u, 0x5A04ABFCu, 0x800BCADCu,
139 | 0x9E447A2Eu, 0xC3453484u, 0xFDD56705u, 0x0E1E9EC9u, 0xDB73DBD3u, 0x105588CDu, 0x675FDA79u, 0xE3674340u, 0xC5C43465u, 0x713E38D8u, 0x3D28F89Eu, 0xF16DFF20u, 0x153E21E7u, 0x8FB03D4Au, 0xE6E39F2Bu, 0xDB83ADF7u
140 | }, {
141 | 0xE93D5A68u, 0x948140F7u, 0xF64C261Cu, 0x94692934u, 0x411520F7u, 0x7602D4F7u, 0xBCF46B2Eu, 0xD4A20068u, 0xD4082471u, 0x3320F46Au, 0x43B7D4B7u, 0x500061AFu, 0x1E39F62Eu, 0x97244546u, 0x14214F74u, 0xBF8B8840u,
142 | 0x4D95FC1Du, 0x96B591AFu, 0x70F4DDD3u, 0x66A02F45u, 0xBFBC09ECu, 0x03BD9785u, 0x7FAC6DD0u, 0x31CB8504u, 0x96EB27B3u, 0x55FD3941u, 0xDA2547E6u, 0xABCA0A9Au, 0x28507825u, 0x530429F4u, 0x0A2C86DAu, 0xE9B66DFBu,
143 | 0x68DC1462u, 0xD7486900u, 0x680EC0A4u, 0x27A18DEEu, 0x4F3FFEA2u, 0xE887AD8Cu, 0xB58CE006u, 0x7AF4D6B6u, 0xAACE1E7Cu, 0xD3375FECu, 0xCE78A399u, 0x406B2A42u, 0x20FE9E35u, 0xD9F385B9u, 0xEE39D7ABu, 0x3B124E8Bu,
144 | 0x1DC9FAF7u, 0x4B6D1856u, 0x26A36631u, 0xEAE397B2u, 0x3A6EFA74u, 0xDD5B4332u, 0x6841E7F7u, 0xCA7820FBu, 0xFB0AF54Eu, 0xD8FEB397u, 0x454056ACu, 0xBA489527u, 0x55533A3Au, 0x20838D87u, 0xFE6BA9B7u, 0xD096954Bu,
145 | 0x55A867BCu, 0xA1159A58u, 0xCCA92963u, 0x99E1DB33u, 0xA62A4A56u, 0x3F3125F9u, 0x5EF47E1Cu, 0x9029317Cu, 0xFDF8E802u, 0x04272F70u, 0x80BB155Cu, 0x05282CE3u, 0x95C11548u, 0xE4C66D22u, 0x48C1133Fu, 0xC70F86DCu,
146 | 0x07F9C9EEu, 0x41041F0Fu, 0x404779A4u, 0x5D886E17u, 0x325F51EBu, 0xD59BC0D1u, 0xF2BCC18Fu, 0x41113564u, 0x257B7834u, 0x602A9C60u, 0xDFF8E8A3u, 0x1F636C1Bu, 0x0E12B4C2u, 0x02E1329Eu, 0xAF664FD1u, 0xCAD18115u,
147 | 0x6B2395E0u, 0x333E92E1u, 0x3B240B62u, 0xEEBEB922u, 0x85B2A20Eu, 0xE6BA0D99u, 0xDE720C8Cu, 0x2DA2F728u, 0xD0127845u, 0x95B794FDu, 0x647D0862u, 0xE7CCF5F0u, 0x5449A36Fu, 0x877D48FAu, 0xC39DFD27u, 0xF33E8D1Eu,
148 | 0x0A476341u, 0x992EFF74u, 0x3A6F6EABu, 0xF4F8FD37u, 0xA812DC60u, 0xA1EBDDF8u, 0x991BE14Cu, 0xDB6E6B0Du, 0xC67B5510u, 0x6D672C37u, 0x2765D43Bu, 0xDCD0E804u, 0xF1290DC7u, 0xCC00FFA3u, 0xB5390F92u, 0x690FED0Bu,
149 | 0x667B9FFBu, 0xCEDB7D9Cu, 0xA091CF0Bu, 0xD9155EA3u, 0xBB132F88u, 0x515BAD24u, 0x7B9479BFu, 0x763BD6EBu, 0x37392EB3u, 0xCC115979u, 0x8026E297u, 0xF42E312Du, 0x6842ADA7u, 0xC66A2B3Bu, 0x12754CCCu, 0x782EF11Cu,
150 | 0x6A124237u, 0xB79251E7u, 0x06A1BBE6u, 0x4BFB6350u, 0x1A6B1018u, 0x11CAEDFAu, 0x3D25BDD8u, 0xE2E1C3C9u, 0x44421659u, 0x0A121386u, 0xD90CEC6Eu, 0xD5ABEA2Au, 0x64AF674Eu, 0xDA86A85Fu, 0xBEBFE988u, 0x64E4C3FEu,
151 | 0x9DBC8057u, 0xF0F7C086u, 0x60787BF8u, 0x6003604Du, 0xD1FD8346u, 0xF6381FB0u, 0x7745AE04u, 0xD736FCCCu, 0x83426B33u, 0xF01EAB71u, 0xB0804187u, 0x3C005E5Fu, 0x77A057BEu, 0xBDE8AE24u, 0x55464299u, 0xBF582E61u,
152 | 0x4E58F48Fu, 0xF2DDFDA2u, 0xF474EF38u, 0x8789BDC2u, 0x5366F9C3u, 0xC8B38E74u, 0xB475F255u, 0x46FCD9B9u, 0x7AEB2661u, 0x8B1DDF84u, 0x846A0E79u, 0x915F95E2u, 0x466E598Eu, 0x20B45770u, 0x8CD55591u, 0xC902DE4Cu,
153 | 0xB90BACE1u, 0xBB8205D0u, 0x11A86248u, 0x7574A99Eu, 0xB77F19B6u, 0xE0A9DC09u, 0x662D09A1u, 0xC4324633u, 0xE85A1F02u, 0x09F0BE8Cu, 0x4A99A025u, 0x1D6EFE10u, 0x1AB93D1Du, 0x0BA5A4DFu, 0xA186F20Fu, 0x2868F169u,
154 | 0xDCB7DA83u, 0x573906FEu, 0xA1E2CE9Bu, 0x4FCD7F52u, 0x50115E01u, 0xA70683FAu, 0xA002B5C4u, 0x0DE6D027u, 0x9AF88C27u, 0x773F8641u, 0xC3604C06u, 0x61A806B5u, 0xF0177A28u, 0xC0F586E0u, 0x006058AAu, 0x30DC7D62u,
155 | 0x11E69ED7u, 0x2338EA63u, 0x53C2DD94u, 0xC2C21634u, 0xBBCBEE56u, 0x90BCB6DEu, 0xEBFC7DA1u, 0xCE591D76u, 0x6F05E409u, 0x4B7C0188u, 0x39720A3Du, 0x7C927C24u, 0x86E3725Fu, 0x724D9DB9u, 0x1AC15BB4u, 0xD39EB8FCu,
156 | 0xED545578u, 0x08FCA5B5u, 0xD83D7CD3u, 0x4DAD0FC4u, 0x1E50EF5Eu, 0xB161E6F8u, 0xA28514D9u, 0x6C51133Cu, 0x6FD5C7E7u, 0x56E14EC4u, 0x362ABFCEu, 0xDDC6C837u, 0xD79A3234u, 0x92638212u, 0x670EFA8Eu, 0x406000E0u
157 | }, {
158 | 0x3A39CE37u, 0xD3FAF5CFu, 0xABC27737u, 0x5AC52D1Bu, 0x5CB0679Eu, 0x4FA33742u, 0xD3822740u, 0x99BC9BBEu, 0xD5118E9Du, 0xBF0F7315u, 0xD62D1C7Eu, 0xC700C47Bu, 0xB78C1B6Bu, 0x21A19045u, 0xB26EB1BEu, 0x6A366EB4u,
159 | 0x5748AB2Fu, 0xBC946E79u, 0xC6A376D2u, 0x6549C2C8u, 0x530FF8EEu, 0x468DDE7Du, 0xD5730A1Du, 0x4CD04DC6u, 0x2939BBDBu, 0xA9BA4650u, 0xAC9526E8u, 0xBE5EE304u, 0xA1FAD5F0u, 0x6A2D519Au, 0x63EF8CE2u, 0x9A86EE22u,
160 | 0xC089C2B8u, 0x43242EF6u, 0xA51E03AAu, 0x9CF2D0A4u, 0x83C061BAu, 0x9BE96A4Du, 0x8FE51550u, 0xBA645BD6u, 0x2826A2F9u, 0xA73A3AE1u, 0x4BA99586u, 0xEF5562E9u, 0xC72FEFD3u, 0xF752F7DAu, 0x3F046F69u, 0x77FA0A59u,
161 | 0x80E4A915u, 0x87B08601u, 0x9B09E6ADu, 0x3B3EE593u, 0xE990FD5Au, 0x9E34D797u, 0x2CF0B7D9u, 0x022B8B51u, 0x96D5AC3Au, 0x017DA67Du, 0xD1CF3ED6u, 0x7C7D2D28u, 0x1F9F25CFu, 0xADF2B89Bu, 0x5AD6B472u, 0x5A88F54Cu,
162 | 0xE029AC71u, 0xE019A5E6u, 0x47B0ACFDu, 0xED93FA9Bu, 0xE8D3C48Du, 0x283B57CCu, 0xF8D56629u, 0x79132E28u, 0x785F0191u, 0xED756055u, 0xF7960E44u, 0xE3D35E8Cu, 0x15056DD4u, 0x88F46DBAu, 0x03A16125u, 0x0564F0BDu,
163 | 0xC3EB9E15u, 0x3C9057A2u, 0x97271AECu, 0xA93A072Au, 0x1B3F6D9Bu, 0x1E6321F5u, 0xF59C66FBu, 0x26DCF319u, 0x7533D928u, 0xB155FDF5u, 0x03563482u, 0x8ABA3CBBu, 0x28517711u, 0xC20AD9F8u, 0xABCC5167u, 0xCCAD925Fu,
164 | 0x4DE81751u, 0x3830DC8Eu, 0x379D5862u, 0x9320F991u, 0xEA7A90C2u, 0xFB3E7BCEu, 0x5121CE64u, 0x774FBE32u, 0xA8B6E37Eu, 0xC3293D46u, 0x48DE5369u, 0x6413E680u, 0xA2AE0810u, 0xDD6DB224u, 0x69852DFDu, 0x09072166u,
165 | 0xB39A460Au, 0x6445C0DDu, 0x586CDECFu, 0x1C20C8AEu, 0x5BBEF7DDu, 0x1B588D40u, 0xCCD2017Fu, 0x6BB4E3BBu, 0xDDA26A7Eu, 0x3A59FF45u, 0x3E350A44u, 0xBCB4CDD5u, 0x72EACEA8u, 0xFA6484BBu, 0x8D6612AEu, 0xBF3C6F47u,
166 | 0xD29BE463u, 0x542F5D9Eu, 0xAEC2771Bu, 0xF64E6370u, 0x740E0D8Du, 0xE75B1357u, 0xF8721671u, 0xAF537D5Du, 0x4040CB08u, 0x4EB4E2CCu, 0x34D2466Au, 0x0115AF84u, 0xE1B00428u, 0x95983A1Du, 0x06B89FB4u, 0xCE6EA048u,
167 | 0x6F3F3B82u, 0x3520AB82u, 0x011A1D4Bu, 0x277227F8u, 0x611560B1u, 0xE7933FDCu, 0xBB3A792Bu, 0x344525BDu, 0xA08839E1u, 0x51CE794Bu, 0x2F32C9B7u, 0xA01FBAC9u, 0xE01CC87Eu, 0xBCC7D1F6u, 0xCF0111C3u, 0xA1E8AAC7u,
168 | 0x1A908749u, 0xD44FBD9Au, 0xD0DADECBu, 0xD50ADA38u, 0x0339C32Au, 0xC6913667u, 0x8DF9317Cu, 0xE0B12B4Fu, 0xF79E59B7u, 0x43F5BB3Au, 0xF2D519FFu, 0x27D9459Cu, 0xBF97222Cu, 0x15E6FC2Au, 0x0F91FC71u, 0x9B941525u,
169 | 0xFAE59361u, 0xCEB69CEBu, 0xC2A86459u, 0x12BAA8D1u, 0xB6C1075Eu, 0xE3056A0Cu, 0x10D25065u, 0xCB03A442u, 0xE0EC6E0Eu, 0x1698DB3Bu, 0x4C98A0BEu, 0x3278E964u, 0x9F1F9532u, 0xE0D392DFu, 0xD3A0342Bu, 0x8971F21Eu,
170 | 0x1B0A7441u, 0x4BA3348Cu, 0xC5BE7120u, 0xC37632D8u, 0xDF359F8Du, 0x9B992F2Eu, 0xE60B6F47u, 0x0FE3F11Du, 0xE54CDA54u, 0x1EDAD891u, 0xCE6279CFu, 0xCD3E7E6Fu, 0x1618B166u, 0xFD2C1D05u, 0x848FD2C5u, 0xF6FB2299u,
171 | 0xF523F357u, 0xA6327623u, 0x93A83531u, 0x56CCCD02u, 0xACF08162u, 0x5A75EBB5u, 0x6E163697u, 0x88D273CCu, 0xDE966292u, 0x81B949D0u, 0x4C50901Bu, 0x71C65614u, 0xE6C6C7BDu, 0x327A140Au, 0x45E1D006u, 0xC3F27B9Au,
172 | 0xC9AA53FDu, 0x62A80F00u, 0xBB25BFE2u, 0x35BDD2F6u, 0x71126905u, 0xB2040222u, 0xB6CBCF7Cu, 0xCD769C2Bu, 0x53113EC0u, 0x1640E3D3u, 0x38ABBD60u, 0x2547ADF0u, 0xBA38209Cu, 0xF746CE76u, 0x77AFA1C5u, 0x20756060u,
173 | 0x85CBFE4Eu, 0x8AE88DD8u, 0x7AAAF9B0u, 0x4CF9AA7Eu, 0x1948C25Cu, 0x02FB8A8Cu, 0x01C36AE4u, 0xD6EBE1F9u, 0x90D4F869u, 0xA65CDEA0u, 0x3F09252Du, 0xC208E69Fu, 0xB74E6132u, 0xCE77E25Bu, 0x578FDFE3u, 0x3AC372E6u
174 | }
175 | };
176 | #endregion
177 |
178 | private readonly uint[] _p;
179 | private readonly uint[,] _s;
180 |
181 | public BlowfishKey(byte[] key)
182 | {
183 | _p = (uint[])P.Clone();
184 | _s = (uint[,])S.Clone();
185 |
186 | short i = 0;
187 | for (short j = 0; j < 18; j += 1)
188 | {
189 | uint data = 0u;
190 | for (short k = 0; k < 4; k += 1)
191 | {
192 | data = data << 8 | key[i];
193 |
194 | i++;
195 | if (i >= key.Length)
196 | i = 0;
197 | }
198 | _p[j] ^= data;
199 | }
200 |
201 | uint a = 0u;
202 | uint b = 0u;
203 | for (short j = 0; j < 18; j += 2)
204 | {
205 | ProcessTableE(ref a, ref b);
206 | _p[j + 0] = a;
207 | _p[j + 1] = b;
208 | }
209 |
210 | for (short j = 0; j < 4; j += 1)
211 | {
212 | for (i = 0; i < 256; i += 2)
213 | {
214 | ProcessTableE(ref a, ref b);
215 | _s[j, i + 0] = a;
216 | _s[j, i + 1] = b;
217 | }
218 | }
219 | }
220 |
221 | private uint F(uint val)
222 | {
223 | ushort num1 = (ushort)(val & 0xFF);
224 | val >>= 8;
225 | ushort num2 = (ushort)(val & 0xFF);
226 | val >>= 8;
227 | ushort num3 = (ushort)(val & 0xFF);
228 | val >>= 8;
229 | ushort num4 = (ushort)(val & 0xFF);
230 | return (_s[0, num4] + _s[1, num3] ^ _s[2, num2]) + _s[3, num1];
231 | }
232 |
233 | public void Encrypt(byte[] inputBuffer, int inputOffset, byte[] outputBuffer, int outputOffset)
234 | {
235 | uint num = (uint)(inputBuffer[inputOffset] << 24
236 | | inputBuffer[inputOffset + 1] << 16
237 | | inputBuffer[inputOffset + 2] << 8
238 | | inputBuffer[inputOffset + 3]);
239 | uint num2 = (uint)(inputBuffer[inputOffset + 4] << 24
240 | | inputBuffer[inputOffset + 5] << 16
241 | | inputBuffer[inputOffset + 6] << 8
242 | | inputBuffer[inputOffset + 7]);
243 |
244 | ProcessTableE(ref num, ref num2);
245 |
246 | outputBuffer[outputOffset + 0] = (byte)(num >> 24);
247 | outputBuffer[outputOffset + 1] = (byte)(num >> 16);
248 | outputBuffer[outputOffset + 2] = (byte)(num >> 8);
249 | outputBuffer[outputOffset + 3] = (byte)num;
250 | outputBuffer[outputOffset + 4] = (byte)(num2 >> 24);
251 | outputBuffer[outputOffset + 5] = (byte)(num2 >> 16);
252 | outputBuffer[outputOffset + 6] = (byte)(num2 >> 8);
253 | outputBuffer[outputOffset + 7] = (byte)num2;
254 | }
255 |
256 | private void ProcessTableE(ref uint a, ref uint b)
257 | {
258 | for (short i = 0; i < 16; i++)
259 | {
260 | a ^= _p[i];
261 | b = F(a) ^ b;
262 |
263 | //swap
264 | uint temp = a;
265 | a = b;
266 | b = temp;
267 | }
268 |
269 | //swap
270 | uint temp2 = a;
271 | a = b;
272 | b = temp2;
273 |
274 | a ^= _p[17];
275 | b ^= _p[16];
276 | }
277 |
278 | public void Decrypt(byte[] inputBuffer, int inputOffset, byte[] outputBuffer, int outputOffset)
279 | {
280 | uint num = (uint)(inputBuffer[inputOffset] << 24
281 | | inputBuffer[inputOffset + 1] << 16
282 | | inputBuffer[inputOffset + 2] << 8
283 | | inputBuffer[inputOffset + 3]);
284 |
285 | uint num2 = (uint)(inputBuffer[inputOffset + 4] << 24
286 | | inputBuffer[inputOffset + 5] << 16
287 | | inputBuffer[inputOffset + 6] << 8
288 | | inputBuffer[inputOffset + 7]);
289 |
290 | ProcessTableD(ref num, ref num2);
291 |
292 | outputBuffer[outputOffset + 0] = (byte)(num >> 24);
293 | outputBuffer[outputOffset + 1] = (byte)(num >> 16);
294 | outputBuffer[outputOffset + 2] = (byte)(num >> 8);
295 | outputBuffer[outputOffset + 3] = (byte)num;
296 | outputBuffer[outputOffset + 4] = (byte)(num2 >> 24);
297 | outputBuffer[outputOffset + 5] = (byte)(num2 >> 16);
298 | outputBuffer[outputOffset + 6] = (byte)(num2 >> 8);
299 | outputBuffer[outputOffset + 7] = (byte)num2;
300 | }
301 |
302 | private void ProcessTableD(ref uint a, ref uint b)
303 | {
304 | for (short i = 17; i > 1; i--)
305 | {
306 | a ^= _p[i];
307 | b = F(a) ^ b;
308 |
309 | //swap
310 | uint temp = a;
311 | a = b;
312 | b = temp;
313 | }
314 |
315 | //swap
316 | uint temp2 = a;
317 | a = b;
318 | b = temp2;
319 |
320 | a ^= _p[0];
321 | b ^= _p[1];
322 | }
323 | }
324 | }
325 | }
326 |
--------------------------------------------------------------------------------