public void MergeDecryptionCode(AssemblyDef target) { // Merge decryption code string code = Resources.DesValueDecrypterCode(); var decrypter = AssemblyDef.Compile(code); target.Merge(decrypter); // Add rule to avoid recursive calls to decryption code // and method dead core removal ObfuscationRule rule = new ObfuscationRule("des_values"); rule.Exclude(Features.ValueEncryption, Features.DeadCode) .Targeting(Targets.Methods) .Matching(new Regex("DesValueDecrypter.*")); rule.ApplyTo(target); // Get merged methods _decryptArray = target.Find <MethodDef>("DesEncrypt.Code.DesValueDecrypter::DecryptArray.*", true); _decryptInt32 = target.Find <MethodDef>("DesEncrypt.Code.DesValueDecrypter::DecryptInt32.*", true); // Store to encrypted data _encryptedData = target.Find <FieldDef>("DesEncrypt.Code.DesValueDecrypter::encrypted.*", true); }
private void MergeDecompress(AssemblyDef target) { string lzma = Resources.LZMADecoderCode(); string code = Resources.ResUnpakerCode(); var unpacker = AssemblyDef.Compile(lzma, code); target.Merge(unpacker); _unpackStream = target.Find <MethodDef>("ResPacker.Code.ResUnpaker::UnpackResourceStream.*", true); }
private void MergeAntiDebug(AssemblyDef target) { string code = Resources.AntiDebugNetCode(); Compiler compiler = new Compiler(); compiler.ReferencedAssemblies.Add("System.dll"); var antiDebug = AssemblyDef.Compile(compiler, code); target.Merge(antiDebug); var method = target.Find <MethodDef>("AntiDebug.Code.AntiDebug::Start.*", true); // Call AntiDebug::Start at module initializer target.CallAtModuleInitializer(method); }
private void MergeLicensingCode(AssemblyDef target) { // Merge decryption code string code = Resources.LicenseFileCheckWinFormCode(); Compiler compiler = new Compiler(); compiler.ReferencedAssemblies.Add("System.dll"); compiler.ReferencedAssemblies.Add("System.Windows.Forms.dll"); compiler.ReferencedAssemblies.Add(@".\Babel.Licensing.dll"); var licensing = AssemblyDef.Compile(compiler, code); target.Merge(licensing, true); var method = target.Find <MethodDef>(".*::ValidateLicense.*", true); // Call license validation at module initializer target.CallAtModuleInitializer(method); }