-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
283 lines (247 loc) · 10.1 KB
/
Form1.cs
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
using dnlib.DotNet;
using dnlib.DotNet.Writer;
using MindLated.Protection.Anti;
using MindLated.Protection.Arithmetic;
using MindLated.Protection.CtrlFlow;
using MindLated.Protection.INT;
using MindLated.Protection.InvalidMD;
using MindLated.Protection.LocalF;
using MindLated.Protection.Other;
using MindLated.Protection.Proxy;
using MindLated.Protection.Renamer;
using MindLated.Protection.String;
using MindLated.Protection.StringOnline;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Threading;
using System.Windows.Forms;
namespace MindLated;
public partial class Form1 : Form
{
public static MethodDef? Init;
public static MethodDef? Init2;
private readonly List<Action> _func = new();
private string _directoryName = string.Empty;
public Form1() => InitializeComponent();
private ModuleDefMD Md { get; set; } = null!;
private static void AppendMsg(RichTextBox rtb, Color color, string text, bool autoTime)
{
rtb.BeginInvoke(new ThreadStart(() =>
{
lock (rtb)
{
rtb.Focus();
if (rtb.TextLength > 100000) rtb.Clear();
using var temp = new RichTextBox();
temp.SelectionColor = color;
if (autoTime)
temp.AppendText(DateTime.Now.ToString("HH:mm:ss") + " ");
temp.AppendText(text);
rtb.Select(rtb.Rtf.Length, 0);
rtb.SelectedRtf = temp.Rtf;
}
}));
}
private void TextBox1_DragDrop(object sender, DragEventArgs e)
{
try
{
textBox1.Clear();
var array = (Array)e.Data?.GetData(DataFormats.FileDrop)!;
var text = array.GetValue(0)!.ToString();
var num = text!.LastIndexOf(".", StringComparison.Ordinal);
if (num == -1)
return;
var text2 = text[num..];
text2 = text2.ToLower();
if (string.Compare(text2, ".exe", StringComparison.Ordinal) != 0 &&
string.Compare(text2, ".dll", StringComparison.Ordinal) != 0) return;
Activate();
textBox1.Text = text;
var num2 = text.LastIndexOf("\\", StringComparison.Ordinal);
if (num2 != -1) _directoryName = text.Remove(num2, text.Length - num2);
if (_directoryName.Length == 2) _directoryName += "\\";
}
catch
{
/* ignored */
}
}
private void TextBox1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = e.Data != null && e.Data.GetDataPresent(DataFormats.FileDrop)
? DragDropEffects.Copy
: DragDropEffects.None;
}
private void Button1_Click(object sender, EventArgs e)
{
Md = ModuleDefMD.Load(textBox1.Text);
foreach (var func in _func) func();
var text2 = Path.GetDirectoryName(textBox1.Text);
if (text2 != null && !text2.EndsWith("\\"))
text2 += "\\";
var path =
$"{text2}{Path.GetFileNameWithoutExtension(textBox1.Text)}_protected{Path.GetExtension(textBox1.Text)}";
var opts = new ModuleWriterOptions(Md)
{
Logger = DummyLogger.NoThrowInstance
};
Md.Write(path, opts);
AppendMsg(richTextBox1, Color.Red, $"Save: {path}", true);
}
private void CheckProcess(CheckBox check, Action action, string str)
{
if (check.Checked)
{
_func.Add(action);
listBox1.Items.Add(str);
}
else
{
_func.Remove(action);
listBox1.Items.Remove(str);
}
}
private void RunProtection(Protection protect)
{
switch (protect)
{
case Protection.Calli:
Calli.Execute(Md);
break;
case Protection.ControlFlow:
ControlFlowObfuscation.Execute(Md);
break;
case Protection.InvalidMd:
InvalidMDPhase.Execute(Md.Assembly);
break;
case Protection.StringProtect:
StringEncPhase.Execute(Md);
break;
case Protection.OnlineString:
OnlinePhase.Execute(Md);
break;
case Protection.LocalToField:
L2F.Execute(Md);
break;
case Protection.LocalToFieldV2:
L2FV2.Execute(Md);
break;
case Protection.Arithmetic:
Arithmetic.Execute(Md);
break;
case Protection.IntConfusion:
AddIntPhase.Execute2(Md);
break;
case Protection.ProxyString:
ProxyString.Execute(Md);
break;
case Protection.ProxyInt:
ProxyInt.Execute(Md);
break;
case Protection.AntiDebug:
AntiDebug.Execute(Md);
break;
case Protection.AntiDump:
AntiDump.Execute(Md);
break;
case Protection.AntiTamper:
AntiTamper.Execute(Md);
break;
case Protection.AntiDe4dot:
AntiDe4dot.Execute(Md.Assembly);
break;
case Protection.AntiManyThing:
Antimanything.Execute(Md);
break;
case Protection.ProxyMeth:
ProxyMeth.Execute(Md);
break;
case Protection.Watermark:
Watermark.Execute(Md);
break;
case Protection.Renamer:
RenamerPhase.ExecuteNamespaceRenaming(Md);
RenamerPhase.ExecuteModuleRenaming(Md);
RenamerPhase.ExecuteClassRenaming(Md);
RenamerPhase.ExecutePropertiesRenaming(Md);
RenamerPhase.ExecuteFieldRenaming(Md);
RenamerPhase.ExecuteMethodRenaming(Md);
break;
case Protection.StackUnf:
StackUnfConfusion.Execute(Md);
break;
case Protection.JumpCflow:
JumpCFlow.Execute(Md);
break;
default:
throw new NotImplementedException();
}
}
private void CheckBox1_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox1, () => { RunProtection(Protection.StringProtect); }, "-> String Encrypt");
private void checkBox2_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox2, () => { RunProtection(Protection.OnlineString); }, "-> OnlineStrDecrypt");
private void checkBox3_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox3, () => { RunProtection(Protection.ControlFlow); }, "-> ControlFlow");
private void checkBox4_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox4, () => { RunProtection(Protection.IntConfusion); }, "-> IntConfusion");
private void checkBox5_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox5, () => { RunProtection(Protection.Arithmetic); }, "-> Arithmetic");
private void checkBox6_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox6, () => { RunProtection(Protection.LocalToField); }, "-> L2F");
private void checkBox7_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox7, () => { RunProtection(Protection.LocalToFieldV2); }, "-> L2F");
private void checkBox8_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox8, () => { RunProtection(Protection.Calli); }, "-> Calli");
private void checkBox9_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox9, () => { RunProtection(Protection.ProxyMeth); }, "-> ProxyMeth");
private void checkBox10_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox10, () => { RunProtection(Protection.ProxyInt); }, "-> ProxyInt");
private void checkBox11_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox11, () => { RunProtection(Protection.ProxyString); }, "-> ProxyString");
private void checkBox12_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox12, () => { RunProtection(Protection.Renamer); }, "-> Renamer");
private void checkBox13_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox13, () => { RunProtection(Protection.JumpCflow); }, "-> JumpCflow");
private void checkBox14_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox14, () => { RunProtection(Protection.AntiDebug); }, "-> Anti Debug");
private void checkBox15_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox15, () => { RunProtection(Protection.AntiDump); }, "-> Anti Dump");
private void checkBox16_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox16, () => { RunProtection(Protection.AntiTamper); }, "-> Anti Tamper");
private void checkBox17_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox17, () => { RunProtection(Protection.InvalidMd); }, "-> InvalidMD");
private void checkBox18_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox18, () => { RunProtection(Protection.AntiDe4dot); }, "-> AntiDe4dot");
private void checkBox19_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox19, () => { RunProtection(Protection.StackUnf); }, "-> StackUnfConfusion");
private void checkBox20_CheckedChanged(object sender, EventArgs e)
=> CheckProcess(checkBox20, () => { RunProtection(Protection.AntiManyThing); }, "-> Anti manything");
private enum Protection
{
Calli,
ControlFlow,
InvalidMd,
LocalToField,
LocalToFieldV2,
Arithmetic,
IntConfusion,
StackUnf,
ProxyString,
ProxyMeth,
StringProtect,
OnlineString,
AntiDebug,
AntiDump,
AntiTamper,
AntiDe4dot,
AntiManyThing,
Watermark,
Renamer,
JumpCflow,
ProxyInt
}
}