-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathProgram.cs
More file actions
59 lines (54 loc) · 2.53 KB
/
Program.cs
File metadata and controls
59 lines (54 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using dnlib.DotNet;
using dnlib.DotNet.Writer;
namespace AntiDecompiler_Cleaner {
internal static class Program {
private static void Main(string[] args) {
Console.Title = "Anti Decompiler Cleaner - Prab ";
Console.ForegroundColor = ConsoleColor.Yellow;
ModuleDefMD module = null;
try {
module = ModuleDefMD.Load(args[0]);
Console.WriteLine("[?] File Loaded: {0}", module);
foreach (var dependencies in module.GetAssemblyRefs())
Console.WriteLine($"[?] Dependencies : {dependencies.Name}");
}
catch {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[^] Drag n Drop ! ");
Console.ReadKey();
Environment.Exit(0);
}
foreach (var type in module.GetTypes())
foreach (var method in type.Methods)
if (method != null && method.HasBody && method.Body.HasInstructions)
try {
AntiDecompilerPhase.Execute(method);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("[*] Cleaning method 0x{0:X2} {1}", method.MDToken.Raw, method.Name);
}
catch (Exception ex) {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[x] Failed to clean method {0}\n {1}", method.Name, ex.Message);
}
var savingPath = module.Kind == ModuleKind.Dll
? args[0].Replace(".dll", "-noAnti.dll")
: args[0].Replace(".exe", "-noAnti.exe");
if (module.IsILOnly) {
var opts = new ModuleWriterOptions(module) {
MetadataOptions = {Flags = MetadataFlags.PreserveAll}, Logger = DummyLogger.NoThrowInstance
};
module.Write(savingPath, opts);
}
else {
var opts = new NativeModuleWriterOptions(module, true) {
MetadataOptions = {Flags = MetadataFlags.PreserveAll}, Logger = DummyLogger.NoThrowInstance
};
module.NativeWrite(savingPath, opts);
}
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("[+] Finished !\n[+] File Saved at : {0}", savingPath);
Console.ReadLine();
}
}
}