public virtual MarkerSetting MarkAssemblies(Confuser cr, Logger logger) { this.cr = cr; this.proj = cr.param.Project; MarkerSetting ret = new MarkerSetting(); ret.Assemblies = new AssemblySetting[proj.Count]; InitRules(); Marking setting = new Marking(); using (setting.Level()) { for (int i = 0; i < proj.Count; i++) { using (setting.Level()) ret.Assemblies[i] = _MarkAssembly(proj[i], setting); logger._Progress(i + 1, proj.Count); } if (proj.Packer != null) { ret.Packer = Packers[proj.Packer.Id]; ret.PackerParameters = Clone(proj.Packer); } } return(ret); }
private void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { Confuser.Obfuscate(textBox1.Text); button1.Enabled = true; textBox1.Enabled = true; button2.Enabled = true; }
public virtual MarkerSetting MarkAssemblies(IList <AssemblyDefinition> asms, Preset preset, Confuser cr, EventHandler <LogEventArgs> err) { this.cr = cr; MarkerSetting ret = new MarkerSetting(); ret.Assemblies = new AssemblySetting[asms.Count]; for (int i = 0; i < asms.Count; i++) { Marking setting = new Marking(); FillPreset(preset, setting.CurrentConfusions); ret.Assemblies[i] = MarkAssembly(asms[i], setting); if (i == 0) { NameValueCollection param; Packer packer; ProcessPackers(asms[i], out param, out packer); ret.Packer = packer; ret.PackerParameters = param; } } return(ret); }
internal ObfuscationHelper(Confuser cr, int seed) { this.cr = cr; this.seed = seed; }
internal void MarkHelperAssembly(AssemblyDefinition asm, Confuser cr) { cr.settings.Add(MarkAssembly(asm, new Marking())); }
internal void MarkHelperAssembly(AssemblyDefinition asm, ObfuscationSettings settings, Confuser cr) { AssemblySetting ret = new AssemblySetting(asm); ret.GlobalParameters = new ObfuscationSettings(settings); ret.Modules = asm.Modules.Select(_ => new ModuleSetting(_) { Parameters = new ObfuscationSettings() }).ToArray(); foreach (var mod in asm.Modules) { if (mod.GetType("<Module>").GetStaticConstructor() == null) { MethodDefinition cctor = new MethodDefinition(".cctor", MethodAttributes.Private | MethodAttributes.HideBySig | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName | MethodAttributes.Static, mod.TypeSystem.Void); cctor.Body = new MethodBody(cctor); cctor.Body.GetILProcessor().Emit(OpCodes.Ret); mod.GetType("<Module>").Methods.Add(cctor); } } cr.settings.Add(ret); }
protected string[] ProtectStub(AssemblyDefinition asm) { string tmp = Path.GetTempPath() + "\\" + Path.GetRandomFileName() + "\\"; Directory.CreateDirectory(tmp); ModuleDefinition modDef = this.cr.settings.Single(_ => _.IsMain).Assembly.MainModule; asm.MainModule.TimeStamp = modDef.TimeStamp; byte[] mvid = new byte[0x10]; Random.NextBytes(mvid); asm.MainModule.Mvid = new Guid(mvid); MetadataProcessor psr = new MetadataProcessor(); Section oldRsrc = null; foreach (Section s in modDef.GetSections()) { if (s.Name == ".rsrc") { oldRsrc = s; break; } } if (oldRsrc != null) { psr.ProcessImage += accessor => { Section sect = null; foreach (Section s in accessor.Sections) { if (s.Name == ".rsrc") { sect = s; break; } } if (sect == null) { sect = new Section() { Name = ".rsrc", Characteristics = 0x40000040 }; foreach (Section s in accessor.Sections) { if (s.Name == ".text") { accessor.Sections.Insert(accessor.Sections.IndexOf(s) + 1, sect); break; } } } sect.VirtualSize = oldRsrc.VirtualSize; sect.SizeOfRawData = oldRsrc.SizeOfRawData; int idx = accessor.Sections.IndexOf(sect); sect.VirtualAddress = accessor.Sections[idx - 1].VirtualAddress + ((accessor.Sections[idx - 1].VirtualSize + 0x2000U - 1) & ~(0x2000U - 1)); sect.PointerToRawData = accessor.Sections[idx - 1].PointerToRawData + accessor.Sections[idx - 1].SizeOfRawData; for (int i = idx + 1; i < accessor.Sections.Count; i++) { accessor.Sections[i].VirtualAddress = accessor.Sections[i - 1].VirtualAddress + ((accessor.Sections[i - 1].VirtualSize + 0x2000U - 1) & ~(0x2000U - 1)); accessor.Sections[i].PointerToRawData = accessor.Sections[i - 1].PointerToRawData + accessor.Sections[i - 1].SizeOfRawData; } ByteBuffer buff = new ByteBuffer(oldRsrc.Data); PatchResourceDirectoryTable(buff, oldRsrc, sect); sect.Data = buff.GetBuffer(); }; } psr.Process(asm.MainModule, tmp + Path.GetFileName(modDef.FullyQualifiedName), new WriterParameters() { StrongNameKeyPair = this.cr.sn, WriteSymbols = this.cr.param.Project.Debug }); Confuser cr = new Confuser(); ConfuserProject proj = new ConfuserProject(); proj.Seed = Random.Next().ToString(); proj.Debug = this.cr.param.Project.Debug; foreach (var i in this.cr.param.Project.Rules) { proj.Rules.Add(i); } proj.Add(new ProjectAssembly() { Path = tmp + Path.GetFileName(modDef.FullyQualifiedName) }); proj.OutputPath = tmp; foreach (var i in this.cr.param.Project.Plugins) { proj.Plugins.Add(i); } proj.SNKeyPath = this.cr.param.Project.SNKeyPath; ConfuserParameter par = new ConfuserParameter(); par.Project = proj; par.ProcessMetadata = PostProcessMetadata; par.ProcessImage = PostProcessImage; cr.Confuse(par); return(Directory.GetFiles(tmp)); }
private void CompileCheat() { if (BuildInProgress) { txtLog.Log("Build already in progress.", Color.Yellow); return; } BuildInProgress = true; string sourceMemory = Properties.Resources.Memory; string sourceOffsets = Properties.Resources.Offsets; string sourceProgram = Properties.Resources.Program; string sourceAimbotMath = Properties.Resources.AimbotMath; // Temporarily getting cheat source from local files, replace before release. /* * string sourceMemory = File.ReadAllText(@"C:\Users\Justin\Documents\Programming\Programs\Applications\Dynago\Dynago Stub\Dynago Stub\Memory.cs"); * string sourceOffsets = File.ReadAllText(@"C:\Users\Justin\Documents\Programming\Programs\Applications\Dynago\Dynago Stub\Dynago Stub\Offsets.cs"); * string sourceProgram = File.ReadAllText(@"C:\Users\Justin\Documents\Programming\Programs\Applications\Dynago\Dynago Stub\Dynago Stub\Program.cs"); * string sourceAimbotMath = File.ReadAllText(@"C:\Users\Justin\Documents\Programming\Programs\Applications\Dynago\Dynago Stub\Dynago Stub\AimbotMath.cs"); */ string sourceFinal = sourceMemory + sourceOffsets + sourceProgram; txtLog.Log("Initialized original cheat source."); #region settings // Note: use.ToString(format) when converting floats/decimals. #region aimbot settings bool aimbot_required = cb_aimbot_enabled.Checked || general_settings.trigger_magnetic || pistol_settings.trigger_magnetic || sniper_settings.trigger_magnetic; if (aimbot_required) { sourceFinal += sourceAimbotMath; } for (int i = 0; i < cmb_aimbot_type.Items.Count; i++) { string typeName = cmb_aimbot_type.Items[i].ToString(); WeaponSettings type = null; switch (typeName) { case "general": type = general_settings; break; case "pistols": type = pistol_settings; break; case "snipers": type = sniper_settings; break; } if (type.aimbot_on_key) { sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_key", KeyManagement.KeyFromText(type.aimbot_key_txt).ToString()); } else { sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_key", "-1"); } sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_bone", BoneList.GetBone((cmb_aimbot_bone.Items[type.aimbot_bone_index]).ToString()).ToString()); sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_fov", type.aimbot_fov.ToString(format) + "f"); sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_smooth", type.aimbot_smooth.ToString(format) + "f"); sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_rcs", type.aimbot_control_recoil.ToString().ToLower()); sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_enemy", type.aimbot_shoot_enemies.ToString().ToLower()); sourceFinal = sourceFinal.ReplaceComment($"setting_aimbot_{typeName}_team", type.aimbot_shoot_teammates.ToString().ToLower()); } sourceFinal = sourceFinal.ReplaceComment("setting_aimbot_thread_delay", Convert.ToInt32(nud_aimbot_thread_delay.Value).ToString()); if (!cb_aimbot_enabled.Checked) { sourceFinal = sourceFinal.EraseComment("feature_aimbot"); } if (!aimbot_required) { sourceFinal = sourceFinal.EraseComment("feature_aimbot/magnet"); } #endregion #region trigger settings for (int i = 0; i < cmb_triggerbot_type.Items.Count; i++) { string typeName = cmb_triggerbot_type.Items[i].ToString(); WeaponSettings type = null; switch (typeName) { case "general": type = general_settings; break; case "pistols": type = pistol_settings; break; case "snipers": type = sniper_settings; break; } if (type.trigger_on_key) { sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_key", KeyManagement.KeyFromText(type.trigger_key_txt).ToString()); } else { sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_key", "-1"); } sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_magnetbone", BoneList.GetBone((cmb_trigger_magnet_bone.Items[type.trigger_magnet_bone_index]).ToString()).ToString()); sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_magnetfov", type.trigger_magnet_fov.ToString(format) + "f"); sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_magnetsmooth", type.trigger_magnet_smooth.ToString(format) + "f"); sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_magnetic", type.trigger_magnetic.ToString().ToLower()); sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_enemy", type.trigger_shoot_enemies.ToString().ToLower()); sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_team", type.trigger_shoot_teammates.ToString().ToLower()); sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_delay", type.trigger_delay.ToString()); sourceFinal = sourceFinal.ReplaceComment($"setting_triggerbot_{typeName}_overshoot", type.trigger_overshoot.ToString()); } if (nud_trigger_thread_delay.Value > 0) { sourceFinal = sourceFinal.ReplaceComment("setting_trigger_thread_delay", Convert.ToInt32(nud_trigger_thread_delay.Value).ToString()); } if (!cb_trigger_enabled.Checked) { sourceFinal = sourceFinal.EraseComment("feature_triggerbot"); } #endregion #region visual settings // Teammate settings sourceFinal = sourceFinal.ReplaceComment("setting_visuals_teammate_color_r", lbl_visuals_teammates_color.BackColor.R.ToString()); sourceFinal = sourceFinal.ReplaceComment("setting_visuals_teammate_color_g", lbl_visuals_teammates_color.BackColor.G.ToString()); sourceFinal = sourceFinal.ReplaceComment("setting_visuals_teammate_color_b", lbl_visuals_teammates_color.BackColor.B.ToString()); sourceFinal = sourceFinal.ReplaceComment("setting_visuals_teammate_alpha", Convert.ToInt32(nud_visuals_teammates_glowalpha.Value).ToString()); if (!cb_visuals_teammates_visibleonly.Checked) { sourceFinal = sourceFinal.EraseComment("feature_visuals_teammate_chams_enabled"); } else { sourceFinal = sourceFinal.EraseComment("feature_visuals_teammate_chams_disabled"); } if (!cb_visuals_teammates_healthbased.Checked) { sourceFinal = sourceFinal.EraseComment("feature_teammate_healthbased"); } if (!cb_visuals_teammates_enabled.Checked) { sourceFinal = sourceFinal.EraseComment("feature_visuals_teammate"); } // Enemy settings sourceFinal = sourceFinal.ReplaceComment("setting_visuals_enemy_color_r", lbl_visuals_enemies_color.BackColor.R.ToString()); sourceFinal = sourceFinal.ReplaceComment("setting_visuals_enemy_color_g", lbl_visuals_enemies_color.BackColor.G.ToString()); sourceFinal = sourceFinal.ReplaceComment("setting_visuals_enemy_color_b", lbl_visuals_enemies_color.BackColor.B.ToString()); sourceFinal = sourceFinal.ReplaceComment("setting_visuals_enemy_alpha", Convert.ToInt32(nud_visuals_enemies_glowalpha.Value).ToString()); if (!cb_visuals_enemies_visibleonly.Checked) { sourceFinal = sourceFinal.EraseComment("feature_visuals_enemy_chams_enabled"); } else { sourceFinal = sourceFinal.EraseComment("feature_visuals_enemy_chams_disabled"); } if (!cb_visuals_enemies_healthbased.Checked) { sourceFinal = sourceFinal.EraseComment("feature_enemy_healthbased"); } if (!cb_visuals_enemies_enabled.Checked) { sourceFinal = sourceFinal.EraseComment("feature_visuals_enemy"); } // Settings that apply to both if (!cb_visuals_teammates_healthbased.Checked && !cb_visuals_enemies_healthbased.Checked) { sourceFinal = sourceFinal.EraseComment("feature_healthbased"); } if (nud_visuals_thread_delay.Value > 0) { sourceFinal = sourceFinal.ReplaceComment("setting_visuals_thread_delay", Convert.ToInt32(nud_visuals_thread_delay.Value).ToString()); } else { sourceFinal = sourceFinal.EraseComment("feature_visuals_thread_delay"); } if (!cb_visuals_enabled.Checked) { sourceFinal = sourceFinal.EraseComment("feature_visuals"); } #endregion #region misc settings // Bunny hop sourceFinal = sourceFinal.ReplaceComment("setting_bhop_key", KeyManagement.KeyFromText(txt_bhop_key.Text).ToString()); if (!cb_bhop_enabled.Checked) { sourceFinal = sourceFinal.EraseComment("feature_bhop"); } // No flash sourceFinal = sourceFinal.ReplaceComment("setting_noflash_percent", nud_noflash_percent.Value.ToString()); if (!cb_noflash_enabled.Checked) { sourceFinal = sourceFinal.EraseComment("feature_noflash"); } // Recoil control sourceFinal = sourceFinal.ReplaceComment("setting_rcs_scale_x", ((float)nud_rcs_x_percent.Value * 0.02f).ToString(format) + "f"); sourceFinal = sourceFinal.ReplaceComment("setting_rcs_scale_y", ((float)nud_rcs_y_percent.Value * 0.02f).ToString(format) + "f"); if (!cb_rcs_enabled.Checked) { sourceFinal = sourceFinal.EraseComment("feature_rcs"); } // Radar if (!cb_radar_enabled.Checked) { sourceFinal = sourceFinal.EraseComment("feature_radar"); } // FOV Changer sourceFinal = sourceFinal.ReplaceComment("setting_custom_fov", nud_fov_changer.Value.ToString()); if (!cb_fov_changer.Checked) { sourceFinal = sourceFinal.EraseComment("feature_fov_changer"); } // Skin Changer sourceFinal = sourceFinal.ReplaceComment("setting_skinchanger_bat", Randomize.String() + ".bat"); if (!cb_skinchanger_enabled.Checked) { sourceFinal = sourceFinal.EraseComment("feature_skinchanger"); } #endregion #region removals if (!cb_aimbot_enabled.Checked && !cb_trigger_enabled.Checked) { sourceFinal = sourceFinal.EraseComment("weapon_type_lists"); } #endregion #endregion txtLog.Log("Implemented selected settings."); sourceFinal = Randomize.RandomizeOrders(sourceFinal); txtLog.Log("Randomized order of code."); sourceFinal = Randomize.Code("rnd", sourceFinal); txtLog.Log("Randomized class names."); txtLog.Log("Randomized variable names."); txtLog.Log("Randomized namespace names."); txtLog.Log("Randomized method names."); txtLog.Log("Randomized goto labels."); sourceFinal = OffsetList.ReplaceOffsets(sourceFinal); txtLog.Log("Replaced offset variables."); sourceFinal = Randomize.ReplaceNumbers(sourceFinal); //txtLog.Log("Replaced numbers with new sigs."); // Does nothing so excluding from logs for now. sourceFinal = sourceFinal.Junkify(); txtLog.Log("Distributed randomized junk code."); sourceFinal = sourceFinal.ReplaceComment("setting_window_title", Randomize.String(16, 32)); sourceFinal = sourceFinal.ReplaceComment("dynago_version", Program.currentVersion); sourceFinal = sourceFinal.ReplaceComment("dynago_user", Program.currentUser); txtLog.Log("Replaced dynamic build strings."); // ENABLE WHEN TESTING Clipboard.SetText(sourceFinal); new Thread(() => { List <string> errors = Compiler.Compile(sourceFinal, txt_build_path.Text); bool success = errors.Count == 0; if (success) { txtLog.Log("Compiled cheat to " + Path.GetFileName(txt_build_path.Text)); // Credits to ConfuserEx (https://yck1509.github.io/ConfuserEx/) // Works by using the Confuser CLI obfuscate an assembly with settings from a .crproj file. if (cb_obfuscation_enabled.Checked) { txtLog.Log("Beginning obfuscation process..."); txtLog.Log("Installing obfuscation dependencies..."); string obf = Program.directory + "\\" + Randomize.String(); Confuser.Install(obf); string confuserPreset = cmb_obfuscation_preset.SelectedItem.ToString(); txtLog.Log("Running obfuscation file..."); string confuserOutput = Confuser.Obfuscate(obf, txt_build_path.Text, confuserPreset); Regex completionCheck = new Regex("Finished at.* elapsed."); Match completionMatch = completionCheck.Match(confuserOutput); if (completionMatch.Success) { txtLog.Log("Build obfuscated successfully."); } else { txtLog.Log("Build obfuscation failed & skipped.", Color.Yellow); } } DialogResult result = MessageBox.Show("Cheat compiled successfully.\nWould you like to run it now?", "Dynago", MessageBoxButtons.YesNo, MessageBoxIcon.Information); try { if (result == DialogResult.Yes) { ProcessStartInfo info = new ProcessStartInfo(txt_build_path.Text); info.UseShellExecute = true; info.Verb = "runas"; Process.Start(info); } } catch (Exception) { MessageBox.Show("Failed to run the cheat.\nPlease launch Dynago manually.", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { txtLog.Log("Oh no! There were " + errors.Count + " errors.", Color.Yellow); foreach (string err in errors) { txtLog.Log(err, Color.Red); } // upload sourcefinal + error log to server??? string result = string.Empty; if (string.IsNullOrEmpty(result)) { result = "Shit is scuffed."; } txtLog.Log("Error log ID: " + result, Color.Yellow); txtLog.Log("[Please give that to Me-re-ly]", Color.Green); MessageBox.Show("Build failed!\nWe found some errors :(", "Dynago", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }).Start(); BuildInProgress = false; }
protected string[] ProtectStub(AssemblyDefinition asm) { string tmp = Path.GetTempPath() + "\\" + Path.GetRandomFileName() + "\\"; Directory.CreateDirectory(tmp); ModuleDefinition modDef = this.cr.settings.Single(_ => _.IsMain).Assembly.MainModule; asm.MainModule.TimeStamp = modDef.TimeStamp; byte[] mvid = new byte[0x10]; Random.NextBytes(mvid); asm.MainModule.Mvid = new Guid(mvid); MetadataProcessor psr = new MetadataProcessor(); Section oldRsrc = null; foreach (Section s in modDef.GetSections()) if (s.Name == ".rsrc") { oldRsrc = s; break; } if (oldRsrc != null) { psr.ProcessImage += accessor => { Section sect = null; foreach (Section s in accessor.Sections) if (s.Name == ".rsrc") { sect = s; break; } if (sect == null) { sect = new Section() { Name = ".rsrc", Characteristics = 0x40000040 }; foreach (Section s in accessor.Sections) if (s.Name == ".text") { accessor.Sections.Insert(accessor.Sections.IndexOf(s) + 1, sect); break; } } sect.VirtualSize = oldRsrc.VirtualSize; sect.SizeOfRawData = oldRsrc.SizeOfRawData; int idx = accessor.Sections.IndexOf(sect); sect.VirtualAddress = accessor.Sections[idx - 1].VirtualAddress + ((accessor.Sections[idx - 1].VirtualSize + 0x2000U - 1) & ~(0x2000U - 1)); sect.PointerToRawData = accessor.Sections[idx - 1].PointerToRawData + accessor.Sections[idx - 1].SizeOfRawData; for (int i = idx + 1; i < accessor.Sections.Count; i++) { accessor.Sections[i].VirtualAddress = accessor.Sections[i - 1].VirtualAddress + ((accessor.Sections[i - 1].VirtualSize + 0x2000U - 1) & ~(0x2000U - 1)); accessor.Sections[i].PointerToRawData = accessor.Sections[i - 1].PointerToRawData + accessor.Sections[i - 1].SizeOfRawData; } ByteBuffer buff = new ByteBuffer(oldRsrc.Data); PatchResourceDirectoryTable(buff, oldRsrc, sect); sect.Data = buff.GetBuffer(); }; } psr.Process(asm.MainModule, tmp + Path.GetFileName(modDef.FullyQualifiedName), new WriterParameters() { StrongNameKeyPair = this.cr.sn, WriteSymbols = this.cr.param.Project.Debug }); Confuser cr = new Confuser(); ConfuserProject proj = new ConfuserProject(); proj.Seed = Random.Next().ToString(); proj.Debug = this.cr.param.Project.Debug; foreach (var i in this.cr.param.Project.Rules) proj.Rules.Add(i); proj.Add(new ProjectAssembly() { Path = tmp + Path.GetFileName(modDef.FullyQualifiedName) }); proj.OutputPath = tmp; foreach (var i in this.cr.param.Project.Plugins) proj.Plugins.Add(i); proj.SNKeyPath = this.cr.param.Project.SNKeyPath; ConfuserParameter par = new ConfuserParameter(); par.Project = proj; par.ProcessMetadata = PostProcessMetadata; par.ProcessImage = PostProcessImage; cr.Confuse(par); return Directory.GetFiles(tmp); }
internal void SetConfuser(Confuser cr) { this.Confuser = cr; this.Logger = cr.param.Logger; }