diff --git a/.gitignore b/.gitignore index 2fa12e83..a59d299c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ *.suo /Debug/ /Release/ +/deobfuscator.*/ +!/deobfuscator.Template/ diff --git a/de4dot.code/AssemblyClient/AssemblyClient.cs b/de4dot.code/AssemblyClient/AssemblyClient.cs index 83e7a3c5..f5e85861 100644 --- a/de4dot.code/AssemblyClient/AssemblyClient.cs +++ b/de4dot.code/AssemblyClient/AssemblyClient.cs @@ -24,7 +24,7 @@ using System.Threading; using AssemblyData; namespace de4dot.code.AssemblyClient { - sealed class AssemblyClient : IAssemblyClient { + public sealed class AssemblyClient : IAssemblyClient { const int WAIT_TIME_BEFORE_CONNECTING = 1000; const int MAX_CONNECT_WAIT_TIME_MS = 2000; IAssemblyServerLoader loader; diff --git a/de4dot.code/AssemblyClient/AssemblyClientFactory.cs b/de4dot.code/AssemblyClient/AssemblyClientFactory.cs index fcc4b60c..e6c38602 100644 --- a/de4dot.code/AssemblyClient/AssemblyClientFactory.cs +++ b/de4dot.code/AssemblyClient/AssemblyClientFactory.cs @@ -44,7 +44,7 @@ namespace de4dot.code.AssemblyClient { this.serverVersion = ServerClrVersion.CLR_ANY_ANYCPU; } - internal NewProcessAssemblyClientFactory(ServerClrVersion serverVersion) { + public NewProcessAssemblyClientFactory(ServerClrVersion serverVersion) { this.serverVersion = serverVersion; } @@ -56,7 +56,7 @@ namespace de4dot.code.AssemblyClient { return new AssemblyClient(new NewProcessAssemblyServerLoader(serviceType, serverVersion)); } - internal static ServerClrVersion GetServerClrVersion(ModuleDef module) { + public static ServerClrVersion GetServerClrVersion(ModuleDef module) { switch (module.GetPointerSize()) { default: case 4: diff --git a/de4dot.code/AssemblyClient/IAssemblyServerLoader.cs b/de4dot.code/AssemblyClient/IAssemblyServerLoader.cs index 72dff479..5f50fbf5 100644 --- a/de4dot.code/AssemblyClient/IAssemblyServerLoader.cs +++ b/de4dot.code/AssemblyClient/IAssemblyServerLoader.cs @@ -21,7 +21,7 @@ using System; using AssemblyData; namespace de4dot.code.AssemblyClient { - interface IAssemblyServerLoader : IDisposable { + public interface IAssemblyServerLoader : IDisposable { void LoadServer(); IAssemblyService CreateService(); } diff --git a/de4dot.code/AssemblyClient/IpcAssemblyServerLoader.cs b/de4dot.code/AssemblyClient/IpcAssemblyServerLoader.cs index d1388330..62bd9022 100644 --- a/de4dot.code/AssemblyClient/IpcAssemblyServerLoader.cs +++ b/de4dot.code/AssemblyClient/IpcAssemblyServerLoader.cs @@ -21,7 +21,7 @@ using System; using AssemblyData; namespace de4dot.code.AssemblyClient { - enum ServerClrVersion { + public enum ServerClrVersion { CLR_ANY_ANYCPU, CLR_ANY_x86, CLR_ANY_x64, @@ -31,7 +31,7 @@ namespace de4dot.code.AssemblyClient { CLR_v40_x64, } - abstract class IpcAssemblyServerLoader : IAssemblyServerLoader { + public abstract class IpcAssemblyServerLoader : IAssemblyServerLoader { readonly string assemblyServerFilename; protected string ipcName; protected string ipcUri; diff --git a/de4dot.code/AssemblyClient/NewAppDomainAssemblyServerLoader.cs b/de4dot.code/AssemblyClient/NewAppDomainAssemblyServerLoader.cs index ffdbff3b..21215e19 100644 --- a/de4dot.code/AssemblyClient/NewAppDomainAssemblyServerLoader.cs +++ b/de4dot.code/AssemblyClient/NewAppDomainAssemblyServerLoader.cs @@ -23,7 +23,7 @@ using AssemblyData; namespace de4dot.code.AssemblyClient { // Starts the server in a new app domain. - sealed class NewAppDomainAssemblyServerLoader : IpcAssemblyServerLoader { + public sealed class NewAppDomainAssemblyServerLoader : IpcAssemblyServerLoader { AppDomain appDomain; Thread thread; diff --git a/de4dot.code/AssemblyClient/NewProcessAssemblyServerLoader.cs b/de4dot.code/AssemblyClient/NewProcessAssemblyServerLoader.cs index 9cc22b03..42352018 100644 --- a/de4dot.code/AssemblyClient/NewProcessAssemblyServerLoader.cs +++ b/de4dot.code/AssemblyClient/NewProcessAssemblyServerLoader.cs @@ -23,7 +23,7 @@ using AssemblyData; namespace de4dot.code.AssemblyClient { // Starts the server in a new process - class NewProcessAssemblyServerLoader : IpcAssemblyServerLoader { + public class NewProcessAssemblyServerLoader : IpcAssemblyServerLoader { Process process; public NewProcessAssemblyServerLoader(AssemblyServiceType serviceType) diff --git a/de4dot.code/AssemblyClient/SameAppDomainAssemblyServerLoader.cs b/de4dot.code/AssemblyClient/SameAppDomainAssemblyServerLoader.cs index f999309c..f2844477 100644 --- a/de4dot.code/AssemblyClient/SameAppDomainAssemblyServerLoader.cs +++ b/de4dot.code/AssemblyClient/SameAppDomainAssemblyServerLoader.cs @@ -22,7 +22,7 @@ using AssemblyData; namespace de4dot.code.AssemblyClient { // Starts the server in the current app domain. - class SameAppDomainAssemblyServerLoader : IAssemblyServerLoader { + public class SameAppDomainAssemblyServerLoader : IAssemblyServerLoader { IAssemblyService service; AssemblyServiceType serviceType; diff --git a/de4dot.code/AssemblyModule.cs b/de4dot.code/AssemblyModule.cs index 62c4f2a7..5d060e4e 100644 --- a/de4dot.code/AssemblyModule.cs +++ b/de4dot.code/AssemblyModule.cs @@ -25,7 +25,7 @@ using dnlib.DotNet.Writer; using de4dot.blocks; namespace de4dot.code { - class AssemblyModule { + public class AssemblyModule { string filename; ModuleDefMD module; ModuleContext moduleContext; diff --git a/de4dot.code/DumpedMethodsRestorer.cs b/de4dot.code/DumpedMethodsRestorer.cs index b7e8224c..573afe51 100644 --- a/de4dot.code/DumpedMethodsRestorer.cs +++ b/de4dot.code/DumpedMethodsRestorer.cs @@ -25,7 +25,7 @@ using dnlib.DotNet; using de4dot.blocks; namespace de4dot.code { - class DumpedMethodsRestorer : IRowReader, IColumnReader, IMethodDecrypter { + public class DumpedMethodsRestorer : IRowReader, IColumnReader, IMethodDecrypter { ModuleDefMD module; DumpedMethods dumpedMethods; diff --git a/de4dot.code/HandleProcessCorruptedStateExceptionsAttribute.cs b/de4dot.code/HandleProcessCorruptedStateExceptionsAttribute.cs index 08f278be..3f2bb530 100644 --- a/de4dot.code/HandleProcessCorruptedStateExceptionsAttribute.cs +++ b/de4dot.code/HandleProcessCorruptedStateExceptionsAttribute.cs @@ -19,6 +19,6 @@ namespace System.Runtime.ExceptionServices { [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)] - class HandleProcessCorruptedStateExceptionsAttribute : Attribute { + public class HandleProcessCorruptedStateExceptionsAttribute : Attribute { } } diff --git a/de4dot.code/MethodPrinter.cs b/de4dot.code/MethodPrinter.cs index 5fb7a41d..72560e4c 100644 --- a/de4dot.code/MethodPrinter.cs +++ b/de4dot.code/MethodPrinter.cs @@ -24,7 +24,7 @@ using dnlib.DotNet.Emit; using de4dot.blocks; namespace de4dot.code { - class MethodPrinter { + public class MethodPrinter { LoggerEvent loggerEvent; IList allInstructions; IList allExceptionHandlers; diff --git a/de4dot.code/MethodReturnValueInliner.cs b/de4dot.code/MethodReturnValueInliner.cs index e955fa26..640d8c89 100644 --- a/de4dot.code/MethodReturnValueInliner.cs +++ b/de4dot.code/MethodReturnValueInliner.cs @@ -25,7 +25,7 @@ using de4dot.blocks; namespace de4dot.code { // A simple class that statically detects the values of some local variables - class VariableValues { + public class VariableValues { IList allBlocks; IList locals; Dictionary variableToValue = new Dictionary(); @@ -140,7 +140,7 @@ namespace de4dot.code { } } - abstract class MethodReturnValueInliner { + public abstract class MethodReturnValueInliner { protected List callResults; List allBlocks; MethodDef theMethod; diff --git a/de4dot.code/PrintNewTokens.cs b/de4dot.code/PrintNewTokens.cs index 060901c7..fc90315e 100644 --- a/de4dot.code/PrintNewTokens.cs +++ b/de4dot.code/PrintNewTokens.cs @@ -22,7 +22,7 @@ using dnlib.DotNet.MD; using dnlib.DotNet.Writer; namespace de4dot.code { - class PrintNewTokens : IModuleWriterListener { + public class PrintNewTokens : IModuleWriterListener { readonly ModuleDef module; readonly IModuleWriterListener otherListener; diff --git a/de4dot.code/StringInliner.cs b/de4dot.code/StringInliner.cs index d280203f..09933c55 100644 --- a/de4dot.code/StringInliner.cs +++ b/de4dot.code/StringInliner.cs @@ -25,7 +25,7 @@ using de4dot.code.AssemblyClient; using de4dot.blocks; namespace de4dot.code { - abstract class StringInlinerBase : MethodReturnValueInliner { + public abstract class StringInlinerBase : MethodReturnValueInliner { protected override void InlineReturnValues(IList callResults) { foreach (var callResult in callResults) { var block = callResult.block; @@ -62,7 +62,7 @@ namespace de4dot.code { } } - class DynamicStringInliner : StringInlinerBase { + public class DynamicStringInliner : StringInlinerBase { IAssemblyClient assemblyClient; Dictionary methodTokenToId = new Dictionary(); @@ -127,7 +127,7 @@ namespace de4dot.code { } } - class StaticStringInliner : StringInlinerBase { + public class StaticStringInliner : StringInlinerBase { MethodDefAndDeclaringTypeDict> stringDecrypters = new MethodDefAndDeclaringTypeDict>(); public override bool HasHandlers { diff --git a/de4dot.code/Utils.cs b/de4dot.code/Utils.cs index b7b65400..b9bef453 100644 --- a/de4dot.code/Utils.cs +++ b/de4dot.code/Utils.cs @@ -35,7 +35,7 @@ namespace de4dot.code { public delegate void Action(T1 arg1, T2 arg2); public delegate void Action(T1 arg1, T2 arg2, T3 arg3); - class Tuple { + public class Tuple { public T1 Item1 { get; set; } public T2 Item2 { get; set; } public override bool Equals(object obj) { diff --git a/de4dot.code/Win32Path.cs b/de4dot.code/Win32Path.cs index e0bc30b0..010a7532 100644 --- a/de4dot.code/Win32Path.cs +++ b/de4dot.code/Win32Path.cs @@ -18,7 +18,7 @@ */ namespace de4dot.code { - static class Win32Path { + public static class Win32Path { public static string GetFileName(string path) { if (path == null) return null; diff --git a/de4dot.code/deobfuscators/ArrayFinder.cs b/de4dot.code/deobfuscators/ArrayFinder.cs index f23f631b..0aa20607 100644 --- a/de4dot.code/deobfuscators/ArrayFinder.cs +++ b/de4dot.code/deobfuscators/ArrayFinder.cs @@ -24,7 +24,7 @@ using de4dot.blocks; using de4dot.blocks.cflow; namespace de4dot.code.deobfuscators { - static class ArrayFinder { + public static class ArrayFinder { public static List GetArrays(MethodDef method) { return GetArrays(method, null); } diff --git a/de4dot.code/deobfuscators/Blowfish.cs b/de4dot.code/deobfuscators/Blowfish.cs index 55d35715..4ac9f3d4 100644 --- a/de4dot.code/deobfuscators/Blowfish.cs +++ b/de4dot.code/deobfuscators/Blowfish.cs @@ -20,7 +20,7 @@ using System; namespace de4dot.code.deobfuscators { - class Blowfish { + public class Blowfish { static readonly uint[] Pboxes = new uint[18] { 0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89, diff --git a/de4dot.code/deobfuscators/CRC32.cs b/de4dot.code/deobfuscators/CRC32.cs index c3f094a1..15489ee0 100644 --- a/de4dot.code/deobfuscators/CRC32.cs +++ b/de4dot.code/deobfuscators/CRC32.cs @@ -18,7 +18,7 @@ */ namespace de4dot.code.deobfuscators { - struct CRC32 { + public struct CRC32 { static readonly uint[] table = new uint[256] { 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, diff --git a/de4dot.code/deobfuscators/ConstantsReader.cs b/de4dot.code/deobfuscators/ConstantsReader.cs index ed4f1ef2..8f5a6304 100644 --- a/de4dot.code/deobfuscators/ConstantsReader.cs +++ b/de4dot.code/deobfuscators/ConstantsReader.cs @@ -23,7 +23,7 @@ using dnlib.DotNet.Emit; using de4dot.blocks; namespace de4dot.code.deobfuscators { - class ConstantsReader { + public class ConstantsReader { protected IInstructions instructions; protected IList locals; protected Dictionary localsValuesInt32 = new Dictionary(); diff --git a/de4dot.code/deobfuscators/DeobUtils.cs b/de4dot.code/deobfuscators/DeobUtils.cs index 63ce733e..96e63c11 100644 --- a/de4dot.code/deobfuscators/DeobUtils.cs +++ b/de4dot.code/deobfuscators/DeobUtils.cs @@ -28,7 +28,7 @@ using ICSharpCode.SharpZipLib.Zip.Compression; using de4dot.blocks; namespace de4dot.code.deobfuscators { - static class DeobUtils { + public static class DeobUtils { public static void DecryptAndAddResources(ModuleDef module, string encryptedName, Func decryptResource) { Logger.v("Decrypting resources, name: {0}", Utils.ToCsharpString(encryptedName)); var decryptedResourceData = decryptResource(); diff --git a/de4dot.code/deobfuscators/DeobfuscatorBase.cs b/de4dot.code/deobfuscators/DeobfuscatorBase.cs index e3541f89..35e3504c 100644 --- a/de4dot.code/deobfuscators/DeobfuscatorBase.cs +++ b/de4dot.code/deobfuscators/DeobfuscatorBase.cs @@ -27,7 +27,7 @@ using de4dot.blocks; using de4dot.blocks.cflow; namespace de4dot.code.deobfuscators { - abstract class DeobfuscatorBase : IDeobfuscator, IModuleWriterListener { + public abstract class DeobfuscatorBase : IDeobfuscator, IModuleWriterListener { public const string DEFAULT_VALID_NAME_REGEX = @"^[a-zA-Z_<{$][a-zA-Z_0-9<>{}$.`-]*$"; public const string DEFAULT_ASIAN_VALID_NAME_REGEX = @"^[\u2E80-\u9FFFa-zA-Z_<{$][\u2E80-\u9FFFa-zA-Z_0-9<>{}$.`-]*$"; @@ -61,7 +61,7 @@ namespace de4dot.code.deobfuscators { set { moduleBytes = value; } } - internal class OptionsBase : IDeobfuscatorOptions { + public class OptionsBase : IDeobfuscatorOptions { public bool RenameResourcesInCode { get; set; } public NameRegexes ValidNameRegex { get; set; } public bool DecryptStrings { get; set; } diff --git a/de4dot.code/deobfuscators/ExceptionLoggerRemover.cs b/de4dot.code/deobfuscators/ExceptionLoggerRemover.cs index 24f64335..946ddd21 100644 --- a/de4dot.code/deobfuscators/ExceptionLoggerRemover.cs +++ b/de4dot.code/deobfuscators/ExceptionLoggerRemover.cs @@ -23,7 +23,7 @@ using dnlib.DotNet.Emit; using de4dot.blocks; namespace de4dot.code.deobfuscators { - class ExceptionLoggerRemover { + public class ExceptionLoggerRemover { MethodDefAndDeclaringTypeDict exceptionLoggerMethods = new MethodDefAndDeclaringTypeDict(); public int NumRemovedExceptionLoggers { get; set; } diff --git a/de4dot.code/deobfuscators/InitializedDataCreator.cs b/de4dot.code/deobfuscators/InitializedDataCreator.cs index bf5dc9b3..9c3bc645 100644 --- a/de4dot.code/deobfuscators/InitializedDataCreator.cs +++ b/de4dot.code/deobfuscators/InitializedDataCreator.cs @@ -26,7 +26,7 @@ using dnlib.DotNet.Emit; using de4dot.blocks; namespace de4dot.code.deobfuscators { - class InitializedDataCreator { + public class InitializedDataCreator { ModuleDef module; Dictionary sizeToArrayType = new Dictionary(); TypeDef ourType; diff --git a/de4dot.code/deobfuscators/InlinedMethodsFinder.cs b/de4dot.code/deobfuscators/InlinedMethodsFinder.cs index b4cb39fc..f4ab7acc 100644 --- a/de4dot.code/deobfuscators/InlinedMethodsFinder.cs +++ b/de4dot.code/deobfuscators/InlinedMethodsFinder.cs @@ -23,7 +23,7 @@ using dnlib.DotNet.Emit; using de4dot.blocks; namespace de4dot.code.deobfuscators { - static class InlinedMethodsFinder { + public static class InlinedMethodsFinder { public static List Find(ModuleDef module) { // Not all garbage methods are inlined, possibly because we remove some code that calls // the garbage method before the methods inliner has a chance to inline it. Try to find diff --git a/de4dot.code/deobfuscators/MemberReferenceBuilder.cs b/de4dot.code/deobfuscators/MemberReferenceBuilder.cs index a76f61c9..e5dcf62a 100644 --- a/de4dot.code/deobfuscators/MemberReferenceBuilder.cs +++ b/de4dot.code/deobfuscators/MemberReferenceBuilder.cs @@ -23,7 +23,7 @@ using dnlib.DotNet; using de4dot.blocks; namespace de4dot.code.deobfuscators { - class MemberRefBuilder { + public class MemberRefBuilder { ModuleDefMD module; Dictionary createdTypes = new Dictionary(TypeEqualityComparer.Instance); diff --git a/de4dot.code/deobfuscators/MethodBodyParser.cs b/de4dot.code/deobfuscators/MethodBodyParser.cs index 49101dd3..dde747df 100644 --- a/de4dot.code/deobfuscators/MethodBodyParser.cs +++ b/de4dot.code/deobfuscators/MethodBodyParser.cs @@ -23,7 +23,7 @@ using dnlib.IO; namespace de4dot.code.deobfuscators { [Serializable] - class InvalidMethodBody : Exception { + public class InvalidMethodBody : Exception { public InvalidMethodBody() { } @@ -32,14 +32,14 @@ namespace de4dot.code.deobfuscators { } } - class MethodBodyHeader { + public class MethodBodyHeader { public ushort flags; public ushort maxStack; public uint codeSize; public uint localVarSigTok; } - static class MethodBodyParser { + public static class MethodBodyParser { public static MethodBodyHeader ParseMethodBody(IBinaryReader reader, out byte[] code, out byte[] extraSections) { try { return ParseMethodBody2(reader, out code, out extraSections); diff --git a/de4dot.code/deobfuscators/MethodCallRestorerBase.cs b/de4dot.code/deobfuscators/MethodCallRestorerBase.cs index 6dadfd02..db195671 100644 --- a/de4dot.code/deobfuscators/MethodCallRestorerBase.cs +++ b/de4dot.code/deobfuscators/MethodCallRestorerBase.cs @@ -23,7 +23,7 @@ using dnlib.DotNet.Emit; using de4dot.blocks; namespace de4dot.code.deobfuscators { - class MethodCallRestorerBase { + public class MethodCallRestorerBase { protected MemberRefBuilder builder; protected ModuleDefMD module; MethodDefAndDeclaringTypeDict oldToNewMethod = new MethodDefAndDeclaringTypeDict(); diff --git a/de4dot.code/deobfuscators/MethodCollection.cs b/de4dot.code/deobfuscators/MethodCollection.cs index b31cc10e..6eac10e1 100644 --- a/de4dot.code/deobfuscators/MethodCollection.cs +++ b/de4dot.code/deobfuscators/MethodCollection.cs @@ -22,7 +22,7 @@ using dnlib.DotNet; using de4dot.blocks; namespace de4dot.code.deobfuscators { - class MethodCollection { + public class MethodCollection { TypeDefDict types = new TypeDefDict(); MethodDefAndDeclaringTypeDict methods = new MethodDefAndDeclaringTypeDict(); diff --git a/de4dot.code/deobfuscators/MethodStack.cs b/de4dot.code/deobfuscators/MethodStack.cs index 093a8bd9..e19bcc9e 100644 --- a/de4dot.code/deobfuscators/MethodStack.cs +++ b/de4dot.code/deobfuscators/MethodStack.cs @@ -23,7 +23,7 @@ using dnlib.DotNet.Emit; using de4dot.blocks; namespace de4dot.code.deobfuscators { - class PushedArgs { + public class PushedArgs { List args; int nextIndex; @@ -74,7 +74,7 @@ namespace de4dot.code.deobfuscators { } } - static class MethodStack { + public static class MethodStack { // May not return all args. The args are returned in reverse order. public static PushedArgs GetPushedArgInstructions(IList instructions, int index) { try { diff --git a/de4dot.code/deobfuscators/MethodsDecrypter.cs b/de4dot.code/deobfuscators/MethodsDecrypter.cs index 8db05e0e..f09442f8 100644 --- a/de4dot.code/deobfuscators/MethodsDecrypter.cs +++ b/de4dot.code/deobfuscators/MethodsDecrypter.cs @@ -26,7 +26,7 @@ using de4dot.blocks; using de4dot.mdecrypt; namespace de4dot.code.deobfuscators { - static class MethodsDecrypter { + public static class MethodsDecrypter { public static DumpedMethods Decrypt(ModuleDef module, byte[] moduleCctorBytes) { return Decrypt(NewProcessAssemblyClientFactory.GetServerClrVersion(module), module.Location, moduleCctorBytes); } diff --git a/de4dot.code/deobfuscators/MyPEImage.cs b/de4dot.code/deobfuscators/MyPEImage.cs index a7b909b6..f7c38993 100644 --- a/de4dot.code/deobfuscators/MyPEImage.cs +++ b/de4dot.code/deobfuscators/MyPEImage.cs @@ -6,7 +6,7 @@ using dnlib.DotNet.MD; using de4dot.blocks; namespace de4dot.code.deobfuscators { - sealed class MyPEImage : IDisposable { + public sealed class MyPEImage : IDisposable { IPEImage peImage; byte[] peImageData; IImageStream peStream; diff --git a/de4dot.code/deobfuscators/NullStream.cs b/de4dot.code/deobfuscators/NullStream.cs index 9b5c0021..f91f1428 100644 --- a/de4dot.code/deobfuscators/NullStream.cs +++ b/de4dot.code/deobfuscators/NullStream.cs @@ -21,7 +21,7 @@ using System; using System.IO; namespace de4dot.code.deobfuscators { - class NullStream : Stream { + public class NullStream : Stream { long offset = 0; long length = 0; diff --git a/de4dot.code/deobfuscators/Operations.cs b/de4dot.code/deobfuscators/Operations.cs index e1dc7f7f..e57e72c3 100644 --- a/de4dot.code/deobfuscators/Operations.cs +++ b/de4dot.code/deobfuscators/Operations.cs @@ -34,7 +34,7 @@ namespace de4dot.code.deobfuscators { OpDecryptString DecryptStrings { get; } } - class Operations : IOperations { + public class Operations : IOperations { public bool KeepObfuscatorTypes { get; set; } public MetaDataFlags MetaDataFlags { get; set; } public RenamerFlags RenamerFlags { get; set; } diff --git a/de4dot.code/deobfuscators/ProxyCallFixerBase.cs b/de4dot.code/deobfuscators/ProxyCallFixerBase.cs index 238e91c8..9f240b08 100644 --- a/de4dot.code/deobfuscators/ProxyCallFixerBase.cs +++ b/de4dot.code/deobfuscators/ProxyCallFixerBase.cs @@ -24,7 +24,7 @@ using dnlib.DotNet.Emit; using de4dot.blocks; namespace de4dot.code.deobfuscators { - abstract class ProxyCallFixerBase { + public abstract class ProxyCallFixerBase { protected ModuleDefMD module; protected List delegateCreatorMethods = new List(); protected Dictionary delegateTypesDict = new Dictionary(); @@ -187,7 +187,7 @@ namespace de4dot.code.deobfuscators { // ldsfld delegate_instance // ...push args... // call Invoke - abstract class ProxyCallFixer1 : ProxyCallFixerBase { + public abstract class ProxyCallFixer1 : ProxyCallFixerBase { FieldDefAndDeclaringTypeDict fieldToDelegateInfo = new FieldDefAndDeclaringTypeDict(); protected ProxyCallFixer1(ModuleDefMD module) @@ -375,7 +375,7 @@ namespace de4dot.code.deobfuscators { // Invoke() on a delegate instance, eg.: // ...push args... // call static method - abstract class ProxyCallFixer2 : ProxyCallFixerBase { + public abstract class ProxyCallFixer2 : ProxyCallFixerBase { MethodDefAndDeclaringTypeDict proxyMethodToDelegateInfo = new MethodDefAndDeclaringTypeDict(); protected ProxyCallFixer2(ModuleDefMD module) @@ -497,7 +497,7 @@ namespace de4dot.code.deobfuscators { // ...push args... // ldsfld delegate instance // call static method - abstract class ProxyCallFixer3 : ProxyCallFixer1 { + public abstract class ProxyCallFixer3 : ProxyCallFixer1 { protected ProxyCallFixer3(ModuleDefMD module) : base(module) { } diff --git a/de4dot.code/deobfuscators/QuickLZ.cs b/de4dot.code/deobfuscators/QuickLZ.cs index d370b789..23783c7d 100644 --- a/de4dot.code/deobfuscators/QuickLZ.cs +++ b/de4dot.code/deobfuscators/QuickLZ.cs @@ -12,7 +12,7 @@ using System; namespace de4dot.code.deobfuscators { - class QuickLZBase { + public class QuickLZBase { protected static uint Read32(byte[] data, int index) { return BitConverter.ToUInt32(data, index); } @@ -113,7 +113,7 @@ namespace de4dot.code.deobfuscators { } } - class QuickLZ : QuickLZBase { + public class QuickLZ : QuickLZBase { static int DEFAULT_QCLZ_SIG = 0x5A4C4351; // "QCLZ" public static bool IsCompressed(byte[] data) { diff --git a/de4dot.code/deobfuscators/RandomNameChecker.cs b/de4dot.code/deobfuscators/RandomNameChecker.cs index 139ec9fb..2b62c5c5 100644 --- a/de4dot.code/deobfuscators/RandomNameChecker.cs +++ b/de4dot.code/deobfuscators/RandomNameChecker.cs @@ -22,7 +22,7 @@ using System.Text; using System.Text.RegularExpressions; namespace de4dot.code.deobfuscators { - static class RandomNameChecker { + public static class RandomNameChecker { static Regex noUpper = new Regex(@"^[^A-Z]+$"); static Regex allUpper = new Regex(@"^[A-Z]+$"); diff --git a/de4dot.code/deobfuscators/StringCounts.cs b/de4dot.code/deobfuscators/StringCounts.cs index bed73163..0c5ba5b7 100644 --- a/de4dot.code/deobfuscators/StringCounts.cs +++ b/de4dot.code/deobfuscators/StringCounts.cs @@ -23,7 +23,7 @@ using dnlib.DotNet; using dnlib.DotNet.Emit; namespace de4dot.code.deobfuscators { - class StringCounts { + public class StringCounts { Dictionary strings = new Dictionary(StringComparer.Ordinal); public IEnumerable Strings { @@ -65,7 +65,7 @@ namespace de4dot.code.deobfuscators { } } - class FieldTypes : StringCounts { + public class FieldTypes : StringCounts { public FieldTypes(TypeDef type) { Initialize(type.Fields); } @@ -85,7 +85,7 @@ namespace de4dot.code.deobfuscators { } } - class LocalTypes : StringCounts { + public class LocalTypes : StringCounts { public LocalTypes(MethodDef method) { if (method != null && method.Body != null) Initialize(method.Body.Variables); diff --git a/de4dot.code/deobfuscators/TypesRestorer.cs b/de4dot.code/deobfuscators/TypesRestorer.cs index 131ccf04..02a22575 100644 --- a/de4dot.code/deobfuscators/TypesRestorer.cs +++ b/de4dot.code/deobfuscators/TypesRestorer.cs @@ -27,7 +27,7 @@ namespace de4dot.code.deobfuscators { // Restore the type of all fields / parameters that have had their type turned into object. // This thing requires a lot more code than I have time to do now (similar to symbol renaming) // so it will be a basic implementation only. - abstract class TypesRestorerBase { + public abstract class TypesRestorerBase { ModuleDef module; List allMethods; Dictionary> argInfos = new Dictionary>(); @@ -639,7 +639,7 @@ namespace de4dot.code.deobfuscators { } } - class TypesRestorer : TypesRestorerBase { + public class TypesRestorer : TypesRestorerBase { public TypesRestorer(ModuleDef module) : base(module) { } diff --git a/de4dot.code/deobfuscators/UnpackedFile.cs b/de4dot.code/deobfuscators/UnpackedFile.cs index 8d3a154e..b94b28c2 100644 --- a/de4dot.code/deobfuscators/UnpackedFile.cs +++ b/de4dot.code/deobfuscators/UnpackedFile.cs @@ -18,7 +18,7 @@ */ namespace de4dot.code.deobfuscators { - class UnpackedFile { + public class UnpackedFile { public string filename; public byte[] data; diff --git a/de4dot.code/deobfuscators/UnusedMethodsFinder.cs b/de4dot.code/deobfuscators/UnusedMethodsFinder.cs index c9157e83..fab05d7b 100644 --- a/de4dot.code/deobfuscators/UnusedMethodsFinder.cs +++ b/de4dot.code/deobfuscators/UnusedMethodsFinder.cs @@ -23,7 +23,7 @@ using dnlib.DotNet.Emit; using de4dot.blocks; namespace de4dot.code.deobfuscators { - class UnusedMethodsFinder { + public class UnusedMethodsFinder { ModuleDef module; MethodCollection removedMethods; Dictionary possiblyUnusedMethods = new Dictionary(); diff --git a/de4dot.code/deobfuscators/ValueInlinerBase.cs b/de4dot.code/deobfuscators/ValueInlinerBase.cs index 36b0aabe..7cdc1469 100644 --- a/de4dot.code/deobfuscators/ValueInlinerBase.cs +++ b/de4dot.code/deobfuscators/ValueInlinerBase.cs @@ -24,7 +24,7 @@ using dnlib.DotNet.Emit; using de4dot.blocks; namespace de4dot.code.deobfuscators { - abstract class ValueInlinerBase : MethodReturnValueInliner { + public abstract class ValueInlinerBase : MethodReturnValueInliner { MethodDefAndDeclaringTypeDict> decrypterMethods = new MethodDefAndDeclaringTypeDict>(); bool removeUnbox = false; @@ -91,7 +91,7 @@ namespace de4dot.code.deobfuscators { } } - class BooleanValueInliner : ValueInlinerBase { + public class BooleanValueInliner : ValueInlinerBase { protected override void InlineReturnValues(IList callResults) { foreach (var callResult in callResults) { var block = callResult.block; @@ -104,7 +104,7 @@ namespace de4dot.code.deobfuscators { } } - class Int32ValueInliner : ValueInlinerBase { + public class Int32ValueInliner : ValueInlinerBase { protected override void InlineReturnValues(IList callResults) { foreach (var callResult in callResults) { var block = callResult.block; @@ -117,7 +117,7 @@ namespace de4dot.code.deobfuscators { } } - class Int64ValueInliner : ValueInlinerBase { + public class Int64ValueInliner : ValueInlinerBase { protected override void InlineReturnValues(IList callResults) { foreach (var callResult in callResults) { var block = callResult.block; @@ -130,7 +130,7 @@ namespace de4dot.code.deobfuscators { } } - class SingleValueInliner : ValueInlinerBase { + public class SingleValueInliner : ValueInlinerBase { protected override void InlineReturnValues(IList callResults) { foreach (var callResult in callResults) { var block = callResult.block; @@ -143,7 +143,7 @@ namespace de4dot.code.deobfuscators { } } - class DoubleValueInliner : ValueInlinerBase { + public class DoubleValueInliner : ValueInlinerBase { protected override void InlineReturnValues(IList callResults) { foreach (var callResult in callResults) { var block = callResult.block; diff --git a/de4dot.code/renamer/DerivedFrom.cs b/de4dot.code/renamer/DerivedFrom.cs index abe4ddc4..19f0acac 100644 --- a/de4dot.code/renamer/DerivedFrom.cs +++ b/de4dot.code/renamer/DerivedFrom.cs @@ -22,7 +22,7 @@ using System.Collections.Generic; using de4dot.code.renamer.asmmodules; namespace de4dot.code.renamer { - class DerivedFrom { + public class DerivedFrom { Dictionary classNames = new Dictionary(StringComparer.Ordinal); Dictionary results = new Dictionary(); diff --git a/de4dot.code/renamer/ExistingNames.cs b/de4dot.code/renamer/ExistingNames.cs index a0716f7d..9d81a79d 100644 --- a/de4dot.code/renamer/ExistingNames.cs +++ b/de4dot.code/renamer/ExistingNames.cs @@ -22,7 +22,7 @@ using System.Collections.Generic; using dnlib.DotNet; namespace de4dot.code.renamer { - class ExistingNames { + public class ExistingNames { Dictionary allNames = new Dictionary(StringComparer.Ordinal); public void Add(string name) { diff --git a/de4dot.code/renamer/MemberInfos.cs b/de4dot.code/renamer/MemberInfos.cs index 86910c61..7418904e 100644 --- a/de4dot.code/renamer/MemberInfos.cs +++ b/de4dot.code/renamer/MemberInfos.cs @@ -21,7 +21,7 @@ using System.Collections.Generic; using de4dot.code.renamer.asmmodules; namespace de4dot.code.renamer { - class MemberInfo { + public class MemberInfo { protected Ref memberRef; public string oldFullName; public string oldName; @@ -50,31 +50,31 @@ namespace de4dot.code.renamer { } } - class GenericParamInfo : MemberInfo { + public class GenericParamInfo : MemberInfo { public GenericParamInfo(MGenericParamDef genericParamDef) : base(genericParamDef) { } } - class PropertyInfo : MemberInfo { + public class PropertyInfo : MemberInfo { public PropertyInfo(MPropertyDef propertyDef) : base(propertyDef) { } } - class EventInfo : MemberInfo { + public class EventInfo : MemberInfo { public EventInfo(MEventDef eventDef) : base(eventDef) { } } - class FieldInfo : MemberInfo { + public class FieldInfo : MemberInfo { public FieldInfo(MFieldDef fieldDef) : base(fieldDef) { } } - class MethodInfo : MemberInfo { + public class MethodInfo : MemberInfo { public MMethodDef MethodDef { get { return (MMethodDef)memberRef; } } @@ -84,7 +84,7 @@ namespace de4dot.code.renamer { } } - class ParamInfo { + public class ParamInfo { MParamDef paramDef; public string oldName; public string newName; @@ -100,7 +100,7 @@ namespace de4dot.code.renamer { } } - class MemberInfos { + public class MemberInfos { Dictionary allTypeInfos = new Dictionary(); Dictionary allPropertyInfos = new Dictionary(); Dictionary allEventInfos = new Dictionary(); diff --git a/de4dot.code/renamer/NameCreators.cs b/de4dot.code/renamer/NameCreators.cs index e326365d..8a7fbf58 100644 --- a/de4dot.code/renamer/NameCreators.cs +++ b/de4dot.code/renamer/NameCreators.cs @@ -22,11 +22,11 @@ using dnlib.DotNet; using de4dot.blocks; namespace de4dot.code.renamer { - interface INameCreator { + public interface INameCreator { string Create(); } - class OneNameCreator : INameCreator { + public class OneNameCreator : INameCreator { string name; public OneNameCreator(string name) { @@ -38,7 +38,7 @@ namespace de4dot.code.renamer { } } - abstract class NameCreatorCounter : INameCreator { + public abstract class NameCreatorCounter : INameCreator { protected int num; public abstract string Create(); @@ -50,7 +50,7 @@ namespace de4dot.code.renamer { } } - class GenericParamNameCreator : NameCreatorCounter { + public class GenericParamNameCreator : NameCreatorCounter { static string[] names = new string[] { "T", "U", "V", "W", "X", "Y", "Z" }; public override string Create() { @@ -60,7 +60,7 @@ namespace de4dot.code.renamer { } } - class NameCreator : NameCreatorCounter { + public class NameCreator : NameCreatorCounter { string prefix; public NameCreator(string prefix) @@ -82,7 +82,7 @@ namespace de4dot.code.renamer { } // Like NameCreator but don't add the counter the first time - class NameCreator2 : NameCreatorCounter { + public class NameCreator2 : NameCreatorCounter { string prefix; const string separator = "_"; @@ -106,11 +106,11 @@ namespace de4dot.code.renamer { } } - interface ITypeNameCreator { + public interface ITypeNameCreator { string Create(TypeDef typeDef, string newBaseTypeName); } - class NameInfos { + public class NameInfos { IList nameInfos = new List(); class NameInfo { @@ -136,7 +136,7 @@ namespace de4dot.code.renamer { } } - class TypeNameCreator : ITypeNameCreator { + public class TypeNameCreator : ITypeNameCreator { ExistingNames existingNames; NameCreator createUnknownTypeName; NameCreator createEnumName; @@ -205,7 +205,7 @@ namespace de4dot.code.renamer { } } - class GlobalTypeNameCreator : TypeNameCreator { + public class GlobalTypeNameCreator : TypeNameCreator { public GlobalTypeNameCreator(ExistingNames existingNames) : base(existingNames) { } diff --git a/de4dot.code/renamer/ResourceKeysRenamer.cs b/de4dot.code/renamer/ResourceKeysRenamer.cs index 25ea4187..75c95dc9 100644 --- a/de4dot.code/renamer/ResourceKeysRenamer.cs +++ b/de4dot.code/renamer/ResourceKeysRenamer.cs @@ -29,7 +29,7 @@ using de4dot.blocks; using de4dot.code.resources; namespace de4dot.code.renamer { - class ResourceKeysRenamer { + public class ResourceKeysRenamer { const int RESOURCE_KEY_MAX_LEN = 50; const string DEFAULT_KEY_NAME = "Key"; diff --git a/de4dot.code/renamer/ResourceRenamer.cs b/de4dot.code/renamer/ResourceRenamer.cs index 9ba72644..8c185646 100644 --- a/de4dot.code/renamer/ResourceRenamer.cs +++ b/de4dot.code/renamer/ResourceRenamer.cs @@ -25,7 +25,7 @@ using de4dot.blocks; using de4dot.code.renamer.asmmodules; namespace de4dot.code.renamer { - class ResourceRenamer { + public class ResourceRenamer { Module module; Dictionary nameToResource; diff --git a/de4dot.code/renamer/TypeInfo.cs b/de4dot.code/renamer/TypeInfo.cs index 58f8dff9..cf827966 100644 --- a/de4dot.code/renamer/TypeInfo.cs +++ b/de4dot.code/renamer/TypeInfo.cs @@ -26,7 +26,7 @@ using de4dot.code.renamer.asmmodules; using de4dot.blocks; namespace de4dot.code.renamer { - class TypeInfo : MemberInfo { + public class TypeInfo : MemberInfo { public string oldNamespace; public string newNamespace; public VariableNameState variableNameState = VariableNameState.Create(); diff --git a/de4dot.code/renamer/TypeNames.cs b/de4dot.code/renamer/TypeNames.cs index 0a9adc28..da8999d2 100644 --- a/de4dot.code/renamer/TypeNames.cs +++ b/de4dot.code/renamer/TypeNames.cs @@ -22,7 +22,7 @@ using System.Collections.Generic; using dnlib.DotNet; namespace de4dot.code.renamer { - abstract class TypeNames { + public abstract class TypeNames { protected Dictionary typeNames = new Dictionary(StringComparer.Ordinal); protected NameCreator genericParamNameCreator = new NameCreator("gparam_"); protected NameCreator fnPtrNameCreator = new NameCreator("fnptr_"); @@ -135,7 +135,7 @@ namespace de4dot.code.renamer { } } - class VariableNameCreator : TypeNames { + public class VariableNameCreator : TypeNames { static Dictionary ourFullNameToShortName; static Dictionary ourFullNameToShortNamePrefix; static VariableNameCreator() { @@ -201,7 +201,7 @@ namespace de4dot.code.renamer { } } - class PropertyNameCreator : TypeNames { + public class PropertyNameCreator : TypeNames { static Dictionary ourFullNameToShortName = new Dictionary(StringComparer.Ordinal); static Dictionary ourFullNameToShortNamePrefix = new Dictionary(StringComparer.Ordinal); diff --git a/de4dot.code/renamer/TypeRenamerState.cs b/de4dot.code/renamer/TypeRenamerState.cs index 03560bbe..8cf3e581 100644 --- a/de4dot.code/renamer/TypeRenamerState.cs +++ b/de4dot.code/renamer/TypeRenamerState.cs @@ -22,7 +22,7 @@ using System.Collections.Generic; using dnlib.DotNet; namespace de4dot.code.renamer { - class TypeRenamerState { + public class TypeRenamerState { ExistingNames existingNames; Dictionary namespaceToNewName; NameCreator createNamespaceName; diff --git a/de4dot.code/renamer/VariableNameState.cs b/de4dot.code/renamer/VariableNameState.cs index 029c433d..1faec72d 100644 --- a/de4dot.code/renamer/VariableNameState.cs +++ b/de4dot.code/renamer/VariableNameState.cs @@ -20,7 +20,7 @@ using dnlib.DotNet; namespace de4dot.code.renamer { - class VariableNameState { + public class VariableNameState { ExistingNames existingVariableNames; ExistingNames existingMethodNames; ExistingNames existingPropertyNames; diff --git a/de4dot.code/renamer/asmmodules/EventDef.cs b/de4dot.code/renamer/asmmodules/EventDef.cs index 8729d0f4..d191b5b8 100644 --- a/de4dot.code/renamer/asmmodules/EventDef.cs +++ b/de4dot.code/renamer/asmmodules/EventDef.cs @@ -21,7 +21,7 @@ using System.Collections.Generic; using dnlib.DotNet; namespace de4dot.code.renamer.asmmodules { - class MEventDef : Ref { + public class MEventDef : Ref { public MMethodDef AddMethod { get; set; } public MMethodDef RemoveMethod { get; set; } public MMethodDef RaiseMethod { get; set; } diff --git a/de4dot.code/renamer/asmmodules/FieldDef.cs b/de4dot.code/renamer/asmmodules/FieldDef.cs index 706cb560..fb57600c 100644 --- a/de4dot.code/renamer/asmmodules/FieldDef.cs +++ b/de4dot.code/renamer/asmmodules/FieldDef.cs @@ -20,7 +20,7 @@ using dnlib.DotNet; namespace de4dot.code.renamer.asmmodules { - class MFieldDef : Ref { + public class MFieldDef : Ref { public FieldDef FieldDef { get { return (FieldDef)memberRef; } } diff --git a/de4dot.code/renamer/asmmodules/GenericParamDef.cs b/de4dot.code/renamer/asmmodules/GenericParamDef.cs index b37f9848..04b72536 100644 --- a/de4dot.code/renamer/asmmodules/GenericParamDef.cs +++ b/de4dot.code/renamer/asmmodules/GenericParamDef.cs @@ -21,7 +21,8 @@ using System.Collections.Generic; using dnlib.DotNet; namespace de4dot.code.renamer.asmmodules { - class MGenericParamDef : Ref { + public class MGenericParamDef : Ref + { public GenericParam GenericParam { get { return (GenericParam)memberRef; } } diff --git a/de4dot.code/renamer/asmmodules/IResolver.cs b/de4dot.code/renamer/asmmodules/IResolver.cs index a4754ae6..b35e456b 100644 --- a/de4dot.code/renamer/asmmodules/IResolver.cs +++ b/de4dot.code/renamer/asmmodules/IResolver.cs @@ -20,7 +20,7 @@ using dnlib.DotNet; namespace de4dot.code.renamer.asmmodules { - interface IResolver { + public interface IResolver { MTypeDef ResolveType(ITypeDefOrRef typeRef); MMethodDef ResolveMethod(IMethodDefOrRef methodRef); MFieldDef ResolveField(MemberRef fieldRef); diff --git a/de4dot.code/renamer/asmmodules/MemberRefFinder.cs b/de4dot.code/renamer/asmmodules/MemberRefFinder.cs index 71425395..4aebc30f 100644 --- a/de4dot.code/renamer/asmmodules/MemberRefFinder.cs +++ b/de4dot.code/renamer/asmmodules/MemberRefFinder.cs @@ -24,7 +24,7 @@ using dnlib.DotNet.Emit; using de4dot.blocks; namespace de4dot.code.renamer.asmmodules { - enum ObjectType { + public enum ObjectType { Unknown, EventDef, FieldDef, @@ -40,7 +40,7 @@ namespace de4dot.code.renamer.asmmodules { ExportedType, } - class MemberRefFinder { + public class MemberRefFinder { public Dictionary customAttributes = new Dictionary(); public Dictionary eventDefs = new Dictionary(); public Dictionary fieldDefs = new Dictionary(); diff --git a/de4dot.code/renamer/asmmodules/MethodDef.cs b/de4dot.code/renamer/asmmodules/MethodDef.cs index 7c9ae288..4e26f4f7 100644 --- a/de4dot.code/renamer/asmmodules/MethodDef.cs +++ b/de4dot.code/renamer/asmmodules/MethodDef.cs @@ -21,7 +21,7 @@ using System.Collections.Generic; using dnlib.DotNet; namespace de4dot.code.renamer.asmmodules { - class MMethodDef : Ref { + public class MMethodDef : Ref { IList genericParams; IList paramDefs = new List(); MParamDef returnParamDef; diff --git a/de4dot.code/renamer/asmmodules/MethodNameGroups.cs b/de4dot.code/renamer/asmmodules/MethodNameGroups.cs index 7b0fbf57..ea826a87 100644 --- a/de4dot.code/renamer/asmmodules/MethodNameGroups.cs +++ b/de4dot.code/renamer/asmmodules/MethodNameGroups.cs @@ -21,7 +21,7 @@ using System; using System.Collections.Generic; namespace de4dot.code.renamer.asmmodules { - class MethodNameGroup { + public class MethodNameGroup { List methods = new List(); public List Methods { @@ -101,7 +101,7 @@ namespace de4dot.code.renamer.asmmodules { } } - class MethodNameGroups { + public class MethodNameGroups { Dictionary methodGroups = new Dictionary(); public void Same(MMethodDef a, MMethodDef b) { diff --git a/de4dot.code/renamer/asmmodules/Module.cs b/de4dot.code/renamer/asmmodules/Module.cs index e1031d5d..2d20a42e 100644 --- a/de4dot.code/renamer/asmmodules/Module.cs +++ b/de4dot.code/renamer/asmmodules/Module.cs @@ -23,7 +23,7 @@ using dnlib.DotNet; using de4dot.blocks; namespace de4dot.code.renamer.asmmodules { - class Module : IResolver { + public class Module : IResolver { IObfuscatedFile obfuscatedFile; TypeDefDict types = new TypeDefDict(); MemberRefFinder memberRefFinder; diff --git a/de4dot.code/renamer/asmmodules/Modules.cs b/de4dot.code/renamer/asmmodules/Modules.cs index b88e81a2..fe6412c1 100644 --- a/de4dot.code/renamer/asmmodules/Modules.cs +++ b/de4dot.code/renamer/asmmodules/Modules.cs @@ -23,7 +23,7 @@ using dnlib.DotNet; using de4dot.blocks; namespace de4dot.code.renamer.asmmodules { - class Modules : IResolver { + public class Modules : IResolver { bool initializeCalled = false; IDeobfuscatorContext deobfuscatorContext; List modules = new List(); diff --git a/de4dot.code/renamer/asmmodules/ParamDef.cs b/de4dot.code/renamer/asmmodules/ParamDef.cs index 1c2c7ffe..01bd4c8d 100644 --- a/de4dot.code/renamer/asmmodules/ParamDef.cs +++ b/de4dot.code/renamer/asmmodules/ParamDef.cs @@ -20,7 +20,7 @@ using dnlib.DotNet; namespace de4dot.code.renamer.asmmodules { - class MParamDef { + public class MParamDef { public Parameter ParameterDef { get; set; } public int Index { get; private set; } public bool IsReturnParameter { diff --git a/de4dot.code/renamer/asmmodules/PropertyDef.cs b/de4dot.code/renamer/asmmodules/PropertyDef.cs index a848972e..2913cbf1 100644 --- a/de4dot.code/renamer/asmmodules/PropertyDef.cs +++ b/de4dot.code/renamer/asmmodules/PropertyDef.cs @@ -21,7 +21,7 @@ using System.Collections.Generic; using dnlib.DotNet; namespace de4dot.code.renamer.asmmodules { - class MPropertyDef : Ref { + public class MPropertyDef : Ref { public MMethodDef GetMethod { get; set; } public MMethodDef SetMethod { get; set; } diff --git a/de4dot.code/renamer/asmmodules/Ref.cs b/de4dot.code/renamer/asmmodules/Ref.cs index 39c9e4e0..85c40713 100644 --- a/de4dot.code/renamer/asmmodules/Ref.cs +++ b/de4dot.code/renamer/asmmodules/Ref.cs @@ -20,7 +20,7 @@ using dnlib.DotNet; namespace de4dot.code.renamer.asmmodules { - abstract class Ref { + public abstract class Ref { public readonly IMemberRef memberRef; public int Index { get; set; } public MTypeDef Owner { get; set; } diff --git a/de4dot.code/renamer/asmmodules/RefDict.cs b/de4dot.code/renamer/asmmodules/RefDict.cs index 60a583a9..237df34c 100644 --- a/de4dot.code/renamer/asmmodules/RefDict.cs +++ b/de4dot.code/renamer/asmmodules/RefDict.cs @@ -21,7 +21,7 @@ using System.Collections.Generic; using de4dot.blocks; namespace de4dot.code.renamer.asmmodules { - static class DictHelper { + public static class DictHelper { public static IEnumerable GetSorted(IEnumerable values) where T : Ref { var list = new List(values); list.Sort((a, b) => a.Index.CompareTo(b.Index)); @@ -29,7 +29,7 @@ namespace de4dot.code.renamer.asmmodules { } } - class TypeDefDict : TypeDefDict { + public class TypeDefDict : TypeDefDict { public IEnumerable GetSorted() { return DictHelper.GetSorted(GetValues()); } @@ -39,7 +39,7 @@ namespace de4dot.code.renamer.asmmodules { } } - class FieldDefDict : FieldDefDict { + public class FieldDefDict : FieldDefDict { public IEnumerable GetSorted() { return DictHelper.GetSorted(GetValues()); } @@ -49,7 +49,7 @@ namespace de4dot.code.renamer.asmmodules { } } - class MethodDefDict : MethodDefDict { + public class MethodDefDict : MethodDefDict { public IEnumerable GetSorted() { return DictHelper.GetSorted(GetValues()); } @@ -59,7 +59,7 @@ namespace de4dot.code.renamer.asmmodules { } } - class PropertyDefDict : PropertyDefDict { + public class PropertyDefDict : PropertyDefDict { public IEnumerable GetSorted() { return DictHelper.GetSorted(GetValues()); } @@ -69,7 +69,7 @@ namespace de4dot.code.renamer.asmmodules { } } - class EventDefDict : EventDefDict { + public class EventDefDict : EventDefDict { public IEnumerable GetSorted() { return DictHelper.GetSorted(GetValues()); } diff --git a/de4dot.code/renamer/asmmodules/TypeDef.cs b/de4dot.code/renamer/asmmodules/TypeDef.cs index 24a62871..dc4637ca 100644 --- a/de4dot.code/renamer/asmmodules/TypeDef.cs +++ b/de4dot.code/renamer/asmmodules/TypeDef.cs @@ -23,7 +23,7 @@ using dnlib.DotNet; using de4dot.blocks; namespace de4dot.code.renamer.asmmodules { - class TypeInfo { + public class TypeInfo { public ITypeDefOrRef typeRef; public MTypeDef typeDef; public TypeInfo(ITypeDefOrRef typeRef, MTypeDef typeDef) { @@ -54,7 +54,7 @@ namespace de4dot.code.renamer.asmmodules { } } - class MethodDefKey { + public class MethodDefKey { public readonly MMethodDef methodDef; public MethodDefKey(MMethodDef methodDef) { @@ -73,7 +73,7 @@ namespace de4dot.code.renamer.asmmodules { } } - class MethodInst { + public class MethodInst { public MMethodDef origMethodDef; public IMethodDefOrRef methodRef; @@ -87,7 +87,7 @@ namespace de4dot.code.renamer.asmmodules { } } - class MethodInstances { + public class MethodInstances { Dictionary> methodInstances = new Dictionary>(MethodEqualityComparer.DontCompareDeclaringTypes); public void InitializeFrom(MethodInstances other, GenericInstSig git) { @@ -119,7 +119,7 @@ namespace de4dot.code.renamer.asmmodules { } // Keeps track of which methods of an interface that have been implemented - class InterfaceMethodInfo { + public class InterfaceMethodInfo { TypeInfo iface; Dictionary ifaceMethodToClassMethod = new Dictionary(); @@ -175,7 +175,7 @@ namespace de4dot.code.renamer.asmmodules { } } - class InterfaceMethodInfos { + public class InterfaceMethodInfos { Dictionary interfaceMethods = new Dictionary(TypeEqualityComparer.Instance); public IEnumerable AllInfos { @@ -223,7 +223,7 @@ namespace de4dot.code.renamer.asmmodules { } } - class MTypeDef : Ref { + public class MTypeDef : Ref { EventDefDict events = new EventDefDict(); FieldDefDict fields = new FieldDefDict(); MethodDefDict methods = new MethodDefDict(); diff --git a/de4dot.code/resources/BuiltInResourceData.cs b/de4dot.code/resources/BuiltInResourceData.cs index ce23a0dc..9ae41bbe 100644 --- a/de4dot.code/resources/BuiltInResourceData.cs +++ b/de4dot.code/resources/BuiltInResourceData.cs @@ -22,7 +22,7 @@ using System.IO; using System.Runtime.Serialization; namespace de4dot.code.resources { - class BuiltInResourceData : IResourceData { + public class BuiltInResourceData : IResourceData { readonly ResourceTypeCode code; readonly object data; diff --git a/de4dot.code/resources/IResourceData.cs b/de4dot.code/resources/IResourceData.cs index b8995e2f..63374a2d 100644 --- a/de4dot.code/resources/IResourceData.cs +++ b/de4dot.code/resources/IResourceData.cs @@ -21,7 +21,7 @@ using System.IO; using System.Runtime.Serialization; namespace de4dot.code.resources { - interface IResourceData { + public interface IResourceData { ResourceTypeCode Code { get; } void WriteData(BinaryWriter writer, IFormatter formatter); } diff --git a/de4dot.code/resources/ResourceDataCreator.cs b/de4dot.code/resources/ResourceDataCreator.cs index 4ebd012b..53258145 100644 --- a/de4dot.code/resources/ResourceDataCreator.cs +++ b/de4dot.code/resources/ResourceDataCreator.cs @@ -25,7 +25,7 @@ using System.Runtime.Serialization.Formatters.Binary; using dnlib.DotNet; namespace de4dot.code.resources { - class ResourceDataCreator { + public class ResourceDataCreator { readonly ModuleDef module; readonly ModuleDefMD moduleMD; readonly Dictionary dict = new Dictionary(StringComparer.Ordinal); diff --git a/de4dot.code/resources/ResourceElement.cs b/de4dot.code/resources/ResourceElement.cs index 8cf6ea95..bb8c85eb 100644 --- a/de4dot.code/resources/ResourceElement.cs +++ b/de4dot.code/resources/ResourceElement.cs @@ -18,7 +18,7 @@ */ namespace de4dot.code.resources { - class ResourceElement { + public class ResourceElement { public string Name { get; set; } public IResourceData ResourceData { get; set; } diff --git a/de4dot.code/resources/ResourceElementSet.cs b/de4dot.code/resources/ResourceElementSet.cs index 128414b8..28c9649c 100644 --- a/de4dot.code/resources/ResourceElementSet.cs +++ b/de4dot.code/resources/ResourceElementSet.cs @@ -21,7 +21,7 @@ using System; using System.Collections.Generic; namespace de4dot.code.resources { - class ResourceElementSet { + public class ResourceElementSet { Dictionary dict = new Dictionary(StringComparer.Ordinal); public int Count { diff --git a/de4dot.code/resources/ResourceReader.cs b/de4dot.code/resources/ResourceReader.cs index 3c4b5a68..7e545800 100644 --- a/de4dot.code/resources/ResourceReader.cs +++ b/de4dot.code/resources/ResourceReader.cs @@ -27,13 +27,13 @@ using dnlib.IO; namespace de4dot.code.resources { [Serializable] - class ResourceReaderException : Exception { + public class ResourceReaderException : Exception { public ResourceReaderException(string msg) : base(msg) { } } - struct ResourceReader { + public struct ResourceReader { IBinaryReader reader; ResourceDataCreator resourceDataCreator; diff --git a/de4dot.code/resources/ResourceTypeCode.cs b/de4dot.code/resources/ResourceTypeCode.cs index 972f1dd6..d1baf198 100644 --- a/de4dot.code/resources/ResourceTypeCode.cs +++ b/de4dot.code/resources/ResourceTypeCode.cs @@ -18,7 +18,7 @@ */ namespace de4dot.code.resources { - enum ResourceTypeCode { + public enum ResourceTypeCode { Null, String, Boolean, diff --git a/de4dot.code/resources/ResourceWriter.cs b/de4dot.code/resources/ResourceWriter.cs index f9e0d7aa..803158e9 100644 --- a/de4dot.code/resources/ResourceWriter.cs +++ b/de4dot.code/resources/ResourceWriter.cs @@ -26,7 +26,7 @@ using System.Text; using dnlib.DotNet; namespace de4dot.code.resources { - class ResourceWriter { + public class ResourceWriter { ModuleDefMD module; BinaryWriter writer; ResourceElementSet resources; diff --git a/de4dot.code/resources/UserResourceData.cs b/de4dot.code/resources/UserResourceData.cs index db515453..8e303e02 100644 --- a/de4dot.code/resources/UserResourceData.cs +++ b/de4dot.code/resources/UserResourceData.cs @@ -22,7 +22,7 @@ using System.IO; using System.Runtime.Serialization; namespace de4dot.code.resources { - abstract class UserResourceData : IResourceData { + public abstract class UserResourceData : IResourceData { readonly UserResourceType type; public string TypeName { @@ -40,7 +40,7 @@ namespace de4dot.code.resources { public abstract void WriteData(BinaryWriter writer, IFormatter formatter); } - class CharArrayResourceData : UserResourceData { + public class CharArrayResourceData : UserResourceData { public static readonly string ReflectionTypeName = "System.Char[],mscorlib"; char[] data; @@ -58,7 +58,7 @@ namespace de4dot.code.resources { } } - class IconResourceData : UserResourceData { + public class IconResourceData : UserResourceData { public static readonly string ReflectionTypeName = "System.Drawing.Icon,System.Drawing"; Icon icon; @@ -76,7 +76,7 @@ namespace de4dot.code.resources { } } - class ImageResourceData : UserResourceData { + public class ImageResourceData : UserResourceData { public static readonly string ReflectionTypeName = "System.Drawing.Bitmap,System.Drawing"; Bitmap bitmap; @@ -94,7 +94,7 @@ namespace de4dot.code.resources { } } - class BinaryResourceData : UserResourceData { + public class BinaryResourceData : UserResourceData { byte[] data; public BinaryResourceData(UserResourceType type, byte[] data) diff --git a/de4dot.code/resources/UserResourceType.cs b/de4dot.code/resources/UserResourceType.cs index 3b7489fc..0bc69ccf 100644 --- a/de4dot.code/resources/UserResourceType.cs +++ b/de4dot.code/resources/UserResourceType.cs @@ -18,7 +18,7 @@ */ namespace de4dot.code.resources { - class UserResourceType { + public class UserResourceType { readonly string name; readonly ResourceTypeCode code; diff --git a/de4dot.cui/Program.cs b/de4dot.cui/Program.cs index c39a49ce..ad2bdb47 100644 --- a/de4dot.cui/Program.cs +++ b/de4dot.cui/Program.cs @@ -23,6 +23,8 @@ using System.Text; using dnlib.DotNet; using de4dot.code; using de4dot.code.deobfuscators; +using System.IO; +using System.Reflection; namespace de4dot.cui { class ExitException : Exception { @@ -35,8 +37,35 @@ namespace de4dot.cui { class Program { static IList deobfuscatorInfos = CreateDeobfuscatorInfos(); + static IList LoadPlugin(string assembly) { + var plugins = new List(); + try { + foreach (Type item in Assembly.LoadFile(assembly).GetTypes()) { + var interfaces = new List(item.GetInterfaces()); + if (item.IsClass && interfaces.Contains(typeof(IDeobfuscatorInfo))) + plugins.Add((IDeobfuscatorInfo)Activator.CreateInstance(item)); + } + } + catch { + } + return plugins; + } + + public static void GetPlugins(string directory, ref Dictionary result) { + var plugins = new List(); + try { + var files = Directory.GetFiles(directory, "deobfuscator.*.dll", SearchOption.TopDirectoryOnly); + foreach (var file in files) + plugins.AddRange(LoadPlugin(Path.GetFullPath(file))); + } + catch { + } + foreach(var p in plugins) + result[p.Type] = p; + } + static IList CreateDeobfuscatorInfos() { - return new List { + var local = new List { new de4dot.code.deobfuscators.Unknown.DeobfuscatorInfo(), new de4dot.code.deobfuscators.Agile_NET.DeobfuscatorInfo(), new de4dot.code.deobfuscators.Babel_NET.DeobfuscatorInfo(), @@ -59,6 +88,12 @@ namespace de4dot.cui { new de4dot.code.deobfuscators.Spices_Net.DeobfuscatorInfo(), new de4dot.code.deobfuscators.Xenocode.DeobfuscatorInfo(), }; + var dict = new Dictionary(); + foreach (var d in local) + dict[d.Type] = d; + string pluginDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"); + GetPlugins(pluginDir, ref dict); + return new List(dict.Values); } public static int Main(string[] args) { @@ -74,6 +109,7 @@ namespace de4dot.cui { Logger.n(""); Logger.n("de4dot v{0} Copyright (C) 2011-2014 de4dot@gmail.com", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version); Logger.n("Latest version and source code: https://github.com/0xd4d/de4dot"); + Logger.n("{0} deobfuscator modules loaded!", deobfuscatorInfos.Count); Logger.n(""); var options = new FilesDeobfuscator.Options(); diff --git a/deobfuscator.Template/Properties/AssemblyInfo.cs b/deobfuscator.Template/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..c3ad883e --- /dev/null +++ b/deobfuscator.Template/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +/* + Copyright (C) 2011-2014 de4dot@gmail.com + + This file is part of de4dot. + + de4dot is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + de4dot is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with de4dot. If not, see . +*/ + +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("deobfuscator.Template")] +[assembly: AssemblyDescription("de4dot Deobfuscator Template Module")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("deobfuscator.Template")] +[assembly: AssemblyCopyright("Copyright (C) 2011-2014 de4dot@gmail.com")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/deobfuscator.Template/deobfuscator.Template.csproj b/deobfuscator.Template/deobfuscator.Template.csproj new file mode 100644 index 00000000..478d2478 --- /dev/null +++ b/deobfuscator.Template/deobfuscator.Template.csproj @@ -0,0 +1,72 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {88AC39C0-4CCF-44C4-9C24-301459E6C0D1} + Library + Properties + deobfuscator.Template + deobfuscator.Template + v2.0 + 512 + + + + true + full + false + ..\Debug\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + ..\Release\bin\ + TRACE + prompt + 4 + + + + + + + + + + + + {FBD84077-9D35-41FE-89DF-8D79EFE0B595} + AssemblyData + + + {045B96F2-AF80-4C4C-8D27-E38635AC705E} + de4dot.blocks + + + {4D10B9EB-3BF1-4D61-A389-CB019E8C9622} + de4dot.code + + + {5C93C5E2-196F-4877-BF65-96FEBFCEFCA1} + de4dot.mdecrypt + + + {FDFC1237-143F-4919-8318-4926901F4639} + dnlib + + + + + \ No newline at end of file diff --git a/deobfuscator.Template/readme.txt b/deobfuscator.Template/readme.txt new file mode 100644 index 00000000..4a59d7a2 --- /dev/null +++ b/deobfuscator.Template/readme.txt @@ -0,0 +1 @@ +This is a template deobfuscator module. Make a copy and rename it to create your own deobfuscator modules with the required references and the correct build directories. \ No newline at end of file