├── ax_chara.ico
├── SinUnfuscator.csproj.user
├── README.md
├── Properties
└── AssemblyInfo.cs
├── SinUnfuscator.csproj
└── Program.cs
/ax_chara.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/miso-xyz/SinUnfuscator/HEAD/ax_chara.ico
--------------------------------------------------------------------------------
/SinUnfuscator.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SinUnfuscator
2 | Basic Deobfuscator for SaintFuscator
3 |
4 | # Protection Supported
5 |
6 | Supported:
7 | - String Encryption
8 | - Anti-Debug
9 | - Anti-de4dot
10 | - Junk
11 | - Anti-dump
12 |
13 | Not Supported:
14 | - ControlFlow (you can use CCFlow)
15 | - Renamer (the renaming is random, you cannot reverse the original name)
16 |
17 |
18 | # Usage
19 | Just Drag & Drop the protected file to clean it
20 |
21 | # Screenshot
22 | 
23 | 
24 | 
25 |
26 | # Control Flow cleaned with CCFlow
27 | 
28 |
29 | # Credits
30 | 0xd4d - dnlib
31 | ZeptarTeam - SaintFuscator
32 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SinUnfuscator")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SinUnfuscator")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("9025aba8-60df-40d4-804f-6538880714fe")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/SinUnfuscator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | x86
6 | 8.0.30703
7 | 2.0
8 | {BDA5D9C2-E6B1-44CC-B143-FB921188A13B}
9 | Exe
10 | Properties
11 | SinUnfuscator
12 | SinUnfuscator
13 | v4.0
14 | Client
15 | 512
16 |
17 |
18 | x86
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | x86
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 | ax_chara.ico
38 |
39 |
40 |
41 | False
42 | bin\Debug\dnlib.dll
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
67 |
--------------------------------------------------------------------------------
/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using dnlib.DotNet;
7 | using dnlib.DotNet.Emit;
8 | using dnlib.DotNet.Writer;
9 |
10 | namespace SinUnfuscator
11 | {
12 | class Program
13 | {
14 | public static ModuleDefMD asm;
15 | public static string path;
16 |
17 | static void fixLengthCalls()
18 | {
19 | foreach (TypeDef type in asm.Types)
20 | {
21 | foreach (MethodDef methods in type.Methods)
22 | {
23 | if (!methods.HasBody) { continue; }
24 | for (int x = 0; x < methods.Body.Instructions.Count; x++)
25 | {
26 | Instruction inst = methods.Body.Instructions[x];
27 | if (inst.OpCode.Equals(OpCodes.Call))
28 | {
29 | if (inst.Operand.ToString().Contains("System.String::get_Length"))
30 | {
31 | int newLen = inst.Operand.ToString().Length;
32 | methods.Body.Instructions[x - 1].OpCode = OpCodes.Ldc_I4;
33 | methods.Body.Instructions[x - 1].Operand = newLen;
34 | methods.Body.Instructions.Remove(inst);
35 | }
36 | }
37 | }
38 | }
39 | }
40 | }
41 |
42 | static void removeJunk()
43 | {
44 | asm.EntryPoint.DeclaringType.Name = "Entrypoint";
45 | for (int x_type = 0; x_type < asm.Types.Count; x_type++)
46 | {
47 | TypeDef type = asm.Types[x_type];
48 | if (type.IsGlobalModuleType) { type.Name = ""; }
49 | if (type.HasInterfaces)
50 | {
51 | bool wasInterfaceObf = false;
52 | foreach (InterfaceImpl intrface in type.Interfaces)
53 | {
54 | if (intrface.Interface == type)
55 | {
56 | asm.Types.RemoveAt(x_type);
57 | x_type--;
58 | wasInterfaceObf = true;
59 | break;
60 | }
61 | }
62 | if (wasInterfaceObf) { continue; }
63 | }
64 | for (int x_methods = 0; x_methods < type.Methods.Count; x_methods++)
65 | {
66 | MethodDef methods = type.Methods[x_methods];
67 | if (!methods.HasBody) { continue; }
68 | methods.Body.KeepOldMaxStack = true;
69 | for (int x_inst = 0; x_inst < methods.Body.Instructions.Count; x_inst++)
70 | {
71 | Instruction inst = methods.Body.Instructions[x_inst];
72 | switch (inst.OpCode.Code)
73 | {
74 | case Code.Ret:
75 | if (methods.Body.Instructions[x_inst - 1].OpCode.Equals(OpCodes.Ldc_I4) && methods.Body.Instructions[x_inst - 2].OpCode.Equals(OpCodes.Ldc_I4))
76 | {
77 | type.Methods.RemoveAt(x_methods);
78 | x_methods--;
79 | }
80 | break;
81 | case Code.Call:
82 | if (inst.Operand.ToString().Contains("System.Convert::FromBase64String")) { methods.Name = "StringDecoder"; }
83 | if (inst.Operand.ToString().Contains("::Initialize")) { methods.Name = ".cctor"; }
84 | break;
85 | }
86 | }
87 | }
88 | if (!type.HasMethods) { asm.Types.RemoveAt(x_type); x_type--; }
89 | }
90 | }
91 |
92 | static void fixStrings()
93 | {
94 | foreach (TypeDef type in asm.Types)
95 | {
96 | foreach (MethodDef methods in type.Methods)
97 | {
98 | if (!methods.HasBody) { continue; }
99 | for (int x = 0; x < methods.Body.Instructions.Count; x++)
100 | {
101 | if (x + 1 >= methods.Body.Instructions.Count) { continue; }
102 | Instruction inst = methods.Body.Instructions[x];
103 | if (inst.OpCode.Equals(OpCodes.Ldstr) && methods.Body.Instructions[x + 1].OpCode.Equals(OpCodes.Call))
104 | {
105 | if (methods.Body.Instructions[x + 1].Operand.ToString().Contains("::StringDecoder"))
106 | {
107 | inst.Operand = Encoding.UTF8.GetString(Convert.FromBase64String(inst.Operand.ToString()));
108 | methods.Body.Instructions.RemoveAt(x + 1);
109 | }
110 | }
111 | }
112 | }
113 | }
114 | }
115 |
116 | static void disableProtections()
117 | {
118 | foreach (TypeDef type in asm.Types)
119 | {
120 | if (type.IsGlobalModuleType)
121 | {
122 | type.Methods.Clear();
123 | }
124 | }
125 | }
126 |
127 | static void Main(string[] args)
128 | {
129 | Console.Title = "SinUnfuscator";
130 | Console.WriteLine();
131 | Console.WriteLine(" SinUnfuscator by misonothx - SaintFuscator Deobfuscator");
132 | Console.WriteLine(" |- https://github.com/miso-xyz/SinUnfuscator/");
133 | Console.WriteLine();
134 | path = args[0];
135 | asm = ModuleDefMD.Load(args[0]);
136 | Console.ForegroundColor = ConsoleColor.Yellow;
137 | Console.WriteLine(" Removing Junk...");
138 | removeJunk();
139 | Console.WriteLine(" Decoding Strings...");
140 | fixStrings();
141 | Console.WriteLine(" Simplifying Length Calls...");
142 | fixLengthCalls();
143 | Console.WriteLine(" Removing Protections...");
144 | disableProtections();
145 | ModuleWriterOptions moduleWriterOptions = new ModuleWriterOptions(asm);
146 | moduleWriterOptions.MetadataOptions.Flags |= MetadataFlags.PreserveAll;
147 | moduleWriterOptions.Logger = DummyLogger.NoThrowInstance;
148 | NativeModuleWriterOptions nativeModuleWriterOptions = new NativeModuleWriterOptions(asm, true);
149 | nativeModuleWriterOptions.MetadataOptions.Flags |= MetadataFlags.PreserveAll;
150 | nativeModuleWriterOptions.Logger = DummyLogger.NoThrowInstance;
151 | if (asm.IsILOnly) { asm.Write(Path.GetFileNameWithoutExtension(path) + "-SinUnfuscator" + Path.GetExtension(path)); }
152 | else { asm.NativeWrite(Path.GetFileNameWithoutExtension(path) + "-SinUnfuscator" + Path.GetExtension(path)); }
153 | Console.ForegroundColor = ConsoleColor.Green;
154 | Console.WriteLine(" Successfully cleaned! (saved as '" + Path.GetFileNameWithoutExtension(path) + "-SinUnfuscator" + Path.GetExtension(path) + "')");
155 | Console.ResetColor();
156 | Console.WriteLine(" Press any key to exit...");
157 | Console.ReadKey();
158 | }
159 | }
160 | }
--------------------------------------------------------------------------------