├── Confuser_Methods_Decryptor.exe.config
├── Confuser_Methods_Decryptor.sln
└── Confuser_Methods_Decryptor
├── Confuser_Methods_Decryptor.csproj
├── MainForm.Designer.cs
├── MainForm.cs
├── MainForm.resx
├── Program.cs
└── Properties
└── AssemblyInfo.cs
/Confuser_Methods_Decryptor.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Confuser_Methods_Decryptor.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | # SharpDevelop 3.2.1.6466
5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Confuser_Methods_Decryptor", "Confuser_Methods_Decryptor\Confuser_Methods_Decryptor.csproj", "{13B4F697-9A2D-41EC-B6DF-DFF2C22868DC}"
6 | EndProject
7 | Global
8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
9 | Debug|x86 = Debug|x86
10 | Release|x86 = Release|x86
11 | EndGlobalSection
12 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
13 | {13B4F697-9A2D-41EC-B6DF-DFF2C22868DC}.Debug|x86.Build.0 = Debug|x86
14 | {13B4F697-9A2D-41EC-B6DF-DFF2C22868DC}.Debug|x86.ActiveCfg = Debug|x86
15 | {13B4F697-9A2D-41EC-B6DF-DFF2C22868DC}.Release|x86.Build.0 = Release|x86
16 | {13B4F697-9A2D-41EC-B6DF-DFF2C22868DC}.Release|x86.ActiveCfg = Release|x86
17 | EndGlobalSection
18 | EndGlobal
19 |
--------------------------------------------------------------------------------
/Confuser_Methods_Decryptor/Confuser_Methods_Decryptor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | {13B4F697-9A2D-41EC-B6DF-DFF2C22868DC}
4 | Debug
5 | x86
6 | WinExe
7 | Confuser_Methods_Decryptor
8 | Confuser_Methods_Decryptor
9 | v2.0
10 | Properties
11 | C:\Documents and Settings\Mihai\Application Data\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis
12 | True
13 | False
14 | 4
15 | false
16 |
17 |
18 | x86
19 | False
20 | Auto
21 | 4194304
22 | 4096
23 |
24 |
25 | bin\Debug\
26 | true
27 | Full
28 | False
29 | False
30 | DEBUG;TRACE
31 |
32 |
33 | bin\Release\
34 | False
35 | None
36 | True
37 | False
38 | TRACE
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | MainForm.cs
52 |
53 |
54 |
55 |
56 | MainForm.cs
57 |
58 |
59 |
--------------------------------------------------------------------------------
/Confuser_Methods_Decryptor/MainForm.Designer.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by SharpDevelop.
3 | * User: Bogdan
4 | * Date: 29.12.2012
5 | * Time: 18:25
6 | *
7 | * To change this template use Tools | Options | Coding | Edit Standard Headers.
8 | */
9 | namespace Confuser_Methods_Decryptor
10 | {
11 | partial class MainForm
12 | {
13 | ///
14 | /// Designer variable used to keep track of non-visual components.
15 | ///
16 | private System.ComponentModel.IContainer components = null;
17 |
18 | ///
19 | /// Disposes resources used by the form.
20 | ///
21 | /// true if managed resources should be disposed; otherwise, false.
22 | protected override void Dispose(bool disposing)
23 | {
24 | if (disposing) {
25 | if (components != null) {
26 | components.Dispose();
27 | }
28 | }
29 | base.Dispose(disposing);
30 | }
31 |
32 | ///
33 | /// This method is required for Windows Forms designer support.
34 | /// Do not change the method contents inside the source code editor. The Forms designer might
35 | /// not be able to load this method if it was changed manually.
36 | ///
37 | private void InitializeComponent()
38 | {
39 | this.textBox1 = new System.Windows.Forms.TextBox();
40 | this.label1 = new System.Windows.Forms.Label();
41 | this.button1 = new System.Windows.Forms.Button();
42 | this.textBox2 = new System.Windows.Forms.TextBox();
43 | this.label4 = new System.Windows.Forms.Label();
44 | this.button3 = new System.Windows.Forms.Button();
45 | this.button2 = new System.Windows.Forms.Button();
46 | this.label2 = new System.Windows.Forms.Label();
47 | this.label3 = new System.Windows.Forms.Label();
48 | this.SuspendLayout();
49 | //
50 | // textBox1
51 | //
52 | this.textBox1.AllowDrop = true;
53 | this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
54 | | System.Windows.Forms.AnchorStyles.Right)));
55 | this.textBox1.Location = new System.Drawing.Point(42, 43);
56 | this.textBox1.Name = "textBox1";
57 | this.textBox1.Size = new System.Drawing.Size(589, 20);
58 | this.textBox1.TabIndex = 21;
59 | this.textBox1.DragDrop += new System.Windows.Forms.DragEventHandler(this.TextBox1DragDrop);
60 | this.textBox1.DragEnter += new System.Windows.Forms.DragEventHandler(this.TextBox1DragEnter);
61 | //
62 | // label1
63 | //
64 | this.label1.BackColor = System.Drawing.Color.Transparent;
65 | this.label1.ForeColor = System.Drawing.Color.Black;
66 | this.label1.Location = new System.Drawing.Point(42, 25);
67 | this.label1.Name = "label1";
68 | this.label1.Size = new System.Drawing.Size(100, 14);
69 | this.label1.TabIndex = 20;
70 | this.label1.Text = "Name of assembly:";
71 | //
72 | // button1
73 | //
74 | this.button1.Location = new System.Drawing.Point(7, 42);
75 | this.button1.Name = "button1";
76 | this.button1.Size = new System.Drawing.Size(29, 20);
77 | this.button1.TabIndex = 19;
78 | this.button1.Text = "...";
79 | this.button1.UseVisualStyleBackColor = true;
80 | this.button1.Click += new System.EventHandler(this.Button1Click);
81 | //
82 | // textBox2
83 | //
84 | this.textBox2.AllowDrop = true;
85 | this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
86 | | System.Windows.Forms.AnchorStyles.Right)));
87 | this.textBox2.Location = new System.Drawing.Point(42, 82);
88 | this.textBox2.Name = "textBox2";
89 | this.textBox2.Size = new System.Drawing.Size(589, 20);
90 | this.textBox2.TabIndex = 37;
91 | this.textBox2.DragDrop += new System.Windows.Forms.DragEventHandler(this.TextBox2DragDrop);
92 | this.textBox2.DragEnter += new System.Windows.Forms.DragEventHandler(this.TextBox2DragEnter);
93 | //
94 | // label4
95 | //
96 | this.label4.BackColor = System.Drawing.Color.Transparent;
97 | this.label4.ForeColor = System.Drawing.Color.Black;
98 | this.label4.Location = new System.Drawing.Point(42, 65);
99 | this.label4.Name = "label4";
100 | this.label4.Size = new System.Drawing.Size(100, 14);
101 | this.label4.TabIndex = 36;
102 | this.label4.Text = "Additional module:";
103 | //
104 | // button3
105 | //
106 | this.button3.Location = new System.Drawing.Point(7, 82);
107 | this.button3.Name = "button3";
108 | this.button3.Size = new System.Drawing.Size(29, 20);
109 | this.button3.TabIndex = 35;
110 | this.button3.Text = "...";
111 | this.button3.UseVisualStyleBackColor = true;
112 | this.button3.Click += new System.EventHandler(this.Button3Click);
113 | //
114 | // button2
115 | //
116 | this.button2.Location = new System.Drawing.Point(42, 144);
117 | this.button2.Name = "button2";
118 | this.button2.Size = new System.Drawing.Size(75, 23);
119 | this.button2.TabIndex = 38;
120 | this.button2.Text = "Decrypt";
121 | this.button2.UseVisualStyleBackColor = true;
122 | this.button2.Click += new System.EventHandler(this.Button2Click);
123 | //
124 | // label2
125 | //
126 | this.label2.Location = new System.Drawing.Point(42, 105);
127 | this.label2.Name = "label2";
128 | this.label2.Size = new System.Drawing.Size(100, 14);
129 | this.label2.TabIndex = 39;
130 | this.label2.Text = "Status:";
131 | //
132 | // label3
133 | //
134 | this.label3.Location = new System.Drawing.Point(42, 119);
135 | this.label3.Name = "label3";
136 | this.label3.Size = new System.Drawing.Size(589, 22);
137 | this.label3.TabIndex = 40;
138 | //
139 | // MainForm
140 | //
141 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
142 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
143 | this.ClientSize = new System.Drawing.Size(668, 192);
144 | this.Controls.Add(this.label3);
145 | this.Controls.Add(this.label2);
146 | this.Controls.Add(this.button2);
147 | this.Controls.Add(this.textBox2);
148 | this.Controls.Add(this.label4);
149 | this.Controls.Add(this.button3);
150 | this.Controls.Add(this.textBox1);
151 | this.Controls.Add(this.label1);
152 | this.Controls.Add(this.button1);
153 | this.Name = "MainForm";
154 | this.Text = "Confuser Methods Decryptor 1.0 by CodeCracker / SnD";
155 | this.ResumeLayout(false);
156 | this.PerformLayout();
157 | }
158 | public System.Windows.Forms.TextBox textBox2;
159 | private System.Windows.Forms.Label label3;
160 | private System.Windows.Forms.Label label2;
161 | private System.Windows.Forms.Button button2;
162 | private System.Windows.Forms.Button button3;
163 | private System.Windows.Forms.Label label4;
164 | private System.Windows.Forms.Button button1;
165 | private System.Windows.Forms.Label label1;
166 | public System.Windows.Forms.TextBox textBox1;
167 |
168 |
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/Confuser_Methods_Decryptor/MainForm.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by SharpDevelop.
3 | * User: Bogdan
4 | * Date: 29.12.2012
5 | * Time: 18:25
6 | *
7 | * To change this template use Tools | Options | Coding | Edit Standard Headers.
8 | */
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Drawing;
12 | using System.Windows.Forms;
13 | using System.IO;
14 | using System.Runtime.InteropServices;
15 | using System.Reflection;
16 |
17 | namespace Confuser_Methods_Decryptor
18 | {
19 | ///
20 | /// Description of MainForm.
21 | ///
22 | public partial class MainForm : Form
23 | {
24 | public MainForm()
25 | {
26 | //
27 | // The InitializeComponent() call is required for Windows Forms designer support.
28 | //
29 | InitializeComponent();
30 |
31 | //
32 | // TODO: Add constructor code after the InitializeComponent() call.
33 | //
34 | }
35 |
36 | public string DirectoryName = "";
37 | void Button1Click(object sender, EventArgs e)
38 | {
39 | label3.Text="";
40 | OpenFileDialog fdlg = new OpenFileDialog();
41 | fdlg.Title = "Browse for target assembly";
42 | fdlg.InitialDirectory = @"c:\";
43 | if (DirectoryName!="") fdlg.InitialDirectory = DirectoryName;
44 | fdlg.Filter = "Executable files (*.exe,*.dll)|*.exe;*.dll";
45 | fdlg.FilterIndex = 2;
46 | fdlg.RestoreDirectory = true;
47 | if(fdlg.ShowDialog() == DialogResult.OK)
48 | {
49 | string FileName = fdlg.FileName;
50 | textBox1.Text = FileName;
51 | int lastslash = FileName.LastIndexOf("\\");
52 | if (lastslash!=-1) DirectoryName = FileName.Remove(lastslash,FileName.Length-lastslash);
53 | if (DirectoryName.Length==2) DirectoryName=DirectoryName+"\\";
54 | }
55 | }
56 |
57 | void Button3Click(object sender, EventArgs e)
58 | {
59 | label3.Text="";
60 | OpenFileDialog fdlg = new OpenFileDialog();
61 | fdlg.Title = "Browse for module";
62 | fdlg.InitialDirectory = @"c:\";
63 | if (DirectoryName!="") fdlg.InitialDirectory = DirectoryName;
64 | fdlg.Filter = "Net module file (*.netmodule)|*.netmodule";
65 | fdlg.FilterIndex = 2;
66 | fdlg.RestoreDirectory = true;
67 | if(fdlg.ShowDialog() == DialogResult.OK)
68 | {
69 | string FileName = fdlg.FileName;
70 | textBox2.Text = FileName;
71 | int lastslash = FileName.LastIndexOf("\\");
72 | if (lastslash!=-1) DirectoryName = FileName.Remove(lastslash,FileName.Length-lastslash);
73 | if (DirectoryName.Length==2) DirectoryName=DirectoryName+"\\";
74 | }
75 | }
76 |
77 | void TextBox1DragEnter(object sender, DragEventArgs e)
78 | {
79 | if (e.Data.GetDataPresent(DataFormats.FileDrop))
80 | e.Effect = DragDropEffects.Copy;
81 | else
82 | e.Effect = DragDropEffects.None;
83 | }
84 |
85 | void TextBox2DragEnter(object sender, DragEventArgs e)
86 | {
87 | if (e.Data.GetDataPresent(DataFormats.FileDrop))
88 | e.Effect = DragDropEffects.Copy;
89 | else
90 | e.Effect = DragDropEffects.None;
91 | }
92 |
93 | void TextBox1DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
94 | {
95 | try
96 | {
97 | Array a = (Array) e.Data.GetData(DataFormats.FileDrop);
98 | if(a != null)
99 | {
100 | string s = a.GetValue(0).ToString();
101 | int lastoffsetpoint = s.LastIndexOf(".");
102 | if (lastoffsetpoint != -1)
103 | {
104 | string Extension = s.Substring(lastoffsetpoint);
105 | Extension=Extension.ToLower();
106 | if (Extension == ".exe"||Extension == ".dll")
107 | {
108 | this.Activate();
109 | textBox1.Text = s;
110 | int lastslash = s.LastIndexOf("\\");
111 | if (lastslash!=-1) DirectoryName = s.Remove(lastslash,s.Length-lastslash);
112 | if (DirectoryName.Length==2) DirectoryName=DirectoryName+"\\";
113 | }
114 | }
115 | }
116 | }
117 | catch
118 | {
119 |
120 | }
121 | }
122 |
123 | void TextBox2DragDrop(object sender, DragEventArgs e)
124 | {
125 | try
126 | {
127 | Array a = (Array) e.Data.GetData(DataFormats.FileDrop);
128 | if(a != null)
129 | {
130 | string s = a.GetValue(0).ToString();
131 | int lastoffsetpoint = s.LastIndexOf(".");
132 | if (lastoffsetpoint != -1)
133 | {
134 | string Extension = s.Substring(lastoffsetpoint);
135 | Extension=Extension.ToLower();
136 | if (Extension == ".netmodule")
137 | {
138 | this.Activate();
139 | textBox2.Text = s;
140 | int lastslash = s.LastIndexOf("\\");
141 | if (lastslash!=-1) DirectoryName = s.Remove(lastslash,s.Length-lastslash);
142 | if (DirectoryName.Length==2) DirectoryName=DirectoryName+"\\";
143 | }
144 | }
145 | }
146 | }
147 | catch
148 | {
149 |
150 | }
151 | }
152 |
153 | const byte CorILMethod_TinyFormat = 0x02;
154 | const byte CorILMethod_FatFormat = 0x03;
155 |
156 | [DllImport("kernel32.dll")]
157 | public static extern Boolean AllocConsole();
158 | [DllImport("kernel32.dll")]
159 | public static extern Boolean FreeConsole();
160 | public static Boolean isConsoleon;
161 |
162 | void Button2Click(object sender, EventArgs e)
163 | {
164 | string inputfile = textBox1.Text;
165 | string modulename = textBox2.Text;
166 | Module mainmodule = null;
167 | Assembly assembly=null;
168 | bool isModule = false;
169 | try
170 | {
171 |
172 | AssemblyName an = AssemblyName.GetAssemblyName(inputfile);
173 | assembly = Assembly.Load(an);
174 | mainmodule = assembly.ManifestModule;
175 | if (File.Exists(modulename))
176 | {
177 | byte[] bytes = File.ReadAllBytes(modulename);
178 | string modname = Path.GetFileName(modulename);
179 | mainmodule = assembly.LoadModule(modname,bytes);
180 | isModule = true;
181 | }
182 | }
183 | catch (Exception loadexception)
184 | {
185 | label3.ForeColor = Color.Red;
186 | label3.Text = loadexception.ToString();
187 | return;
188 | }
189 |
190 | if (File.Exists(modulename))
191 | {
192 | inputfile = modulename;
193 | }
194 |
195 | MetadataReader mr = new MetadataReader();
196 | FileStream input = null;
197 | BinaryReader reader = null;
198 | MethodBase ep = null;
199 | bool isConsoleon = false;
200 |
201 | if (File.Exists(inputfile))
202 | {
203 | input = new FileStream(inputfile, FileMode.Open, System.IO.FileAccess.Read, FileShare.ReadWrite);
204 | reader = new BinaryReader(input);
205 | if (mr.Intialize(reader))
206 | {
207 | if (mr.netdir.EntryPointToken!=0&&
208 | (mr.netdir.EntryPointToken&0x0FF000000)==0x06000000)
209 | {
210 | int internalEntryPointToken = mr.netdir.EntryPointToken&0x0FFFFFF;
211 | if (internalEntryPointToken>0&&internalEntryPointToken<=mr.TableLengths[6])
212 | {
213 | try
214 | { // ResolveMethod since on Framework 4.0 System.Reflection.Assembly.EntryPoint()
215 | // throw new NotImplementedException();
216 | ep = mainmodule.ResolveMethod(mr.netdir.EntryPointToken);
217 | }
218 | catch
219 | {
220 | }
221 | }
222 | if (ep!=null&&mr.inh.ioh.Subsystem==03)
223 | {
224 | try
225 | {
226 |
227 | isConsoleon = AllocConsole();
228 | }
229 | catch
230 | {
231 | }
232 | }
233 | // Invoke the entry point (changed to ret) for initing the protector!
234 | if (ep!=null)//
235 | {
236 | // string[] args -> new string[]{null}
237 | object[] parametersers = new object[] { }; // no parameters
238 |
239 | try
240 | {
241 | if (ep.GetParameters().Length > 0)
242 | {
243 | if (ep.GetParameters()[0].ParameterType != typeof(string[]))
244 | parametersers = new string[]{null};
245 | else
246 | parametersers = new object[] {null};;
247 | }
248 | }
249 | catch
250 | {
251 | }
252 |
253 |
254 | try
255 | {
256 | if (ep.IsStatic)
257 | {
258 | ep.Invoke(null, parametersers);
259 | }
260 | else
261 | {
262 | object obj = Activator.CreateInstance(ep.DeclaringType);
263 | ep.Invoke(obj, parametersers);
264 | }
265 | }
266 | catch
267 | {
268 |
269 | }
270 | }
271 | if (isConsoleon)
272 | {
273 |
274 | try
275 | {
276 | FreeConsole();
277 | }
278 | catch
279 | {
280 | }
281 |
282 | }
283 | }
284 | }
285 | reader.Close();
286 | input.Close();
287 | }
288 |
289 |
290 | byte[] filebytes = File.ReadAllBytes(inputfile);
291 | input = new FileStream(inputfile, FileMode.Open, System.IO.FileAccess.Read, FileShare.ReadWrite);
292 | reader = new BinaryReader(input);
293 | mr = new MetadataReader();
294 | if (mr.Intialize(reader))
295 | {
296 | long MethodPosition = mr.TablesOffset;
297 | for (int g=0;g<06;g++)
298 | MethodPosition = MethodPosition+mr.tablesize[g].TotalSize*mr.TableLengths[g];
299 |
300 | IntPtr hinstance = Marshal.GetHINSTANCE(mainmodule);
301 | for (int i = 0; i < mr.TableLengths[06]; i++)
302 | {
303 | reader.BaseStream.Position=(long)MethodPosition + mr.tablesize[06].TotalSize*i;
304 | int methodRVA = reader.ReadInt32();
305 | if (methodRVA<=0)
306 | continue;
307 |
308 | int methodsoffset = mr.Rva2Offset(methodRVA);
309 | if (methodsoffset<=0)
310 | continue;
311 |
312 | byte Flag = 0;
313 | if (isModule)
314 | Flag = (byte)(Marshal.ReadByte(hinstance,methodsoffset)&255);
315 | else
316 | Flag = (byte)(Marshal.ReadByte(hinstance,methodRVA)&255);
317 | int codesize=0;
318 |
319 | if (( Flag & 3)==CorILMethod_FatFormat)
320 | {
321 | if (isModule)
322 | codesize = Marshal.ReadInt32(hinstance,methodsoffset+4);
323 | else
324 | codesize = Marshal.ReadInt32(hinstance,methodRVA+4);
325 | codesize = codesize+12;
326 |
327 | }
328 | else if (( Flag & 3)==CorILMethod_TinyFormat)
329 | {
330 | codesize=Flag>>2;
331 | codesize = codesize+1;
332 | }
333 |
334 |
335 | try
336 | {
337 | byte[]methodbody = new byte[codesize];
338 | for (int j=0;j= rva))
886 | return (sections[i].pointer_to_raw_data + (rva - sections[i].virtual_address));
887 | }
888 |
889 | return 0;
890 | }
891 |
892 | public int Offset2Rva(int uOffset)
893 | {
894 | for (int i = 0; i < sections.Length; i++)
895 | {
896 | if ((sections[i].pointer_to_raw_data <= uOffset) && ((sections[i].pointer_to_raw_data + sections[i].size_of_raw_data) >= uOffset))
897 | return (sections[i].virtual_address + (uOffset - sections[i].pointer_to_raw_data));
898 | }
899 |
900 | return 0;
901 | }
902 |
903 | public int GetTypeSize(Types trans)
904 | {
905 | if (trans == Types.UInt16) return 2;
906 | if (trans == Types.UInt32) return 4;
907 |
908 | // Heap
909 | if (trans == Types.String) return GetStringIndexSize();
910 | if (trans == Types.Guid) return GetGuidIndexSize();
911 | if (trans == Types.Blob) return GetBlobIndexSize();
912 |
913 | // Rid
914 | if ((int)trans < 64)
915 | {
916 | if (TableLengths[(int)trans] > 65535) return 4;
917 | else return 2;
918 | }
919 | // Coded token (may need to be uncompressed from 2-byte form)
920 | else if ((int)trans < 97)
921 | {
922 | int index = (int)trans-64;
923 | int codedtokenbits = codedTokenBits[reftables[index].refindex.Length];
924 | int maxsizekeeped = 65535;
925 | maxsizekeeped = maxsizekeeped >> codedtokenbits;
926 | for (int i=0;i maxsizekeeped) return 4;
929 | }
930 | return 2;
931 |
932 | }
933 |
934 | return 0;
935 | }
936 |
937 | public int GetStringIndexSize()
938 | {
939 | return ((tableheader.HeapOffsetSizes & 0x01) != 0) ? 4 : 2;
940 | }
941 |
942 | public int GetGuidIndexSize()
943 | {
944 | return ((tableheader.HeapOffsetSizes & 0x02) != 0) ? 4 : 2;
945 | }
946 |
947 | public int GetBlobIndexSize()
948 | {
949 | return ((tableheader.HeapOffsetSizes & 0x04) != 0) ? 4 : 2;
950 | }
951 |
952 | public unsafe bool Intialize(BinaryReader reader)
953 | {
954 | reader.BaseStream.Position=0;
955 | byte[] buffer;
956 | IntPtr pointer;
957 | long NewPos;
958 |
959 | try
960 | {
961 | buffer = reader.ReadBytes(sizeof(IMAGE_DOS_HEADER));
962 |
963 | fixed (byte* p = buffer)
964 | {
965 | pointer = (IntPtr)p;
966 | }
967 | idh = (IMAGE_DOS_HEADER)Marshal.PtrToStructure(pointer, typeof(IMAGE_DOS_HEADER));
968 | if (idh.e_magic!=0x5A4D) return false;
969 | reader.BaseStream.Position=idh.e_lfanew;
970 | buffer = reader.ReadBytes(sizeof(IMAGE_NT_HEADERS));
971 |
972 | fixed (byte* p = buffer)
973 | {
974 | pointer = (IntPtr)p;
975 | }
976 | inh = (IMAGE_NT_HEADERS)Marshal.PtrToStructure(pointer, typeof(IMAGE_NT_HEADERS));
977 | if (inh.Signature!=0x4550) return false;
978 |
979 | reader.BaseStream.Position=idh.e_lfanew+4+sizeof(IMAGE_FILE_HEADER)+inh.ifh.SizeOfOptionalHeader;
980 | sections=new image_section_header[inh.ifh.NumberOfSections];
981 | buffer = reader.ReadBytes(sizeof(image_section_header)*inh.ifh.NumberOfSections);
982 | fixed (byte* p = buffer)
983 | {
984 | pointer = (IntPtr)p;
985 | }
986 |
987 | for (int i = 0; i < sections.Length; i++)
988 | {
989 | sections[i] = (image_section_header)Marshal.PtrToStructure(pointer, typeof(image_section_header));
990 | pointer = (IntPtr)(pointer.ToInt32() + Marshal.SizeOf(typeof(image_section_header)));
991 | }
992 |
993 |
994 | // NET Directory
995 | if (inh.ioh.MetaDataDirectory.RVA==0) return false;
996 | NewPos = (long)Rva2Offset(inh.ioh.MetaDataDirectory.RVA);
997 | if (NewPos==0) return false;
998 | reader.BaseStream.Position=NewPos;
999 | buffer = reader.ReadBytes(sizeof(NETDirectory));
1000 |
1001 | fixed (byte* p = buffer)
1002 | {
1003 | pointer = (IntPtr)p;
1004 | }
1005 | // After .NET Directory comes body of methods!
1006 | netdir = (NETDirectory)Marshal.PtrToStructure(pointer, typeof(NETDirectory));
1007 |
1008 | reader.BaseStream.Position=(long)Rva2Offset(netdir.MetaDataRVA);
1009 | mh = new MetadataReader.MetaDataHeader();
1010 | mh.Signature = reader.ReadInt32();
1011 | mh.MajorVersion = reader.ReadInt16();
1012 | mh.MinorVersion = reader.ReadInt16();
1013 | mh.Reserved = reader.ReadInt32();
1014 | mh.VerionLenght = reader.ReadInt32();
1015 | mh.VersionString = reader.ReadBytes(mh.VerionLenght);
1016 | mh.Flags = reader.ReadInt16();
1017 | mh.NumberOfStreams = reader.ReadInt16();
1018 |
1019 | streams = new MetaDataStream[mh.NumberOfStreams];
1020 |
1021 | for(int i=0; i< mh.NumberOfStreams;++i)
1022 | {
1023 | streams[i].Offset=reader.ReadInt32();
1024 | streams[i].Size=reader.ReadInt32();
1025 | char[] chars = new char[32];
1026 | int index = 0;
1027 | byte character = 0;
1028 | while ((character = reader.ReadByte()) != 0)
1029 | chars[index++] = (char) character;
1030 |
1031 | index++;
1032 | int padding = ((index % 4) != 0) ? (4 - (index % 4)) : 0;
1033 | reader.ReadBytes(padding);
1034 |
1035 | streams[i].Name = new String(chars).Trim(new Char[] {'\0'});
1036 |
1037 | if (streams[i].Name == "#~"||streams[i].Name == "#-")
1038 | {
1039 | MetadataRoot.Name=streams[i].Name;
1040 | MetadataRoot.Offset=streams[i].Offset;
1041 | MetadataRoot.Size=streams[i].Size;
1042 | }
1043 |
1044 | if (streams[i].Name == "#Strings")
1045 | {
1046 | long savepoz = reader.BaseStream.Position;
1047 | reader.BaseStream.Position = (long)(Rva2Offset(netdir.MetaDataRVA)+streams[i].Offset);
1048 | StringOffset=reader.BaseStream.Position;
1049 | Strings = reader.ReadBytes(streams[i].Size);
1050 | reader.BaseStream.Position = savepoz;
1051 | }
1052 |
1053 | if (streams[i].Name == "#US")
1054 | {
1055 | long savepoz = reader.BaseStream.Position;
1056 | reader.BaseStream.Position = (long)(Rva2Offset(netdir.MetaDataRVA)+streams[i].Offset);
1057 | US = reader.ReadBytes(streams[i].Size);
1058 | reader.BaseStream.Position = savepoz;
1059 | }
1060 |
1061 | if (streams[i].Name == "#Blob")
1062 | {
1063 | long savepoz = reader.BaseStream.Position;
1064 | reader.BaseStream.Position = (long)(Rva2Offset(netdir.MetaDataRVA)+streams[i].Offset);
1065 | BlobOffset=reader.BaseStream.Position;
1066 | Blob = reader.ReadBytes(streams[i].Size);
1067 | reader.BaseStream.Position = savepoz;
1068 | }
1069 |
1070 | if (streams[i].Name == "#GUID")
1071 | {
1072 | long savepoz = reader.BaseStream.Position;
1073 | reader.BaseStream.Position = (long)(Rva2Offset(netdir.MetaDataRVA)+streams[i].Offset);
1074 | GUID = reader.ReadBytes(streams[i].Size);
1075 | reader.BaseStream.Position = savepoz;
1076 | }
1077 |
1078 | }
1079 |
1080 | reader.BaseStream.Position=(long)(Rva2Offset(netdir.MetaDataRVA)+MetadataRoot.Offset);
1081 | buffer = reader.ReadBytes(sizeof(TableHeader));
1082 | fixed (byte* p = buffer)
1083 | {
1084 | pointer = (IntPtr)p;
1085 | }
1086 | tableheader = (TableHeader)Marshal.PtrToStructure(pointer, typeof(TableHeader));
1087 | TableLengths = new int[64];
1088 |
1089 |
1090 | //read as many uints as there are bits set in maskvalid
1091 | for (int i = 0; i < 64; i++)
1092 | {
1093 | int count = (((tableheader.MaskValid >> i) & 1) == 0) ? 0 : reader.ReadInt32();
1094 | TableLengths[i] = count;
1095 | }
1096 |
1097 | TablesOffset = reader.BaseStream.Position;
1098 | InitTablesInfo();
1099 | // Get Table sizes and all Tables
1100 | tablesize = new TableSize[0x2D];
1101 |
1102 | for (int i=0;i
2 |
3 |
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 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/Confuser_Methods_Decryptor/Program.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Created by SharpDevelop.
3 | * User: Bogdan
4 | * Date: 29.12.2012
5 | * Time: 18:25
6 | *
7 | * To change this template use Tools | Options | Coding | Edit Standard Headers.
8 | */
9 | using System;
10 | using System.Windows.Forms;
11 |
12 | namespace Confuser_Methods_Decryptor
13 | {
14 | ///
15 | /// Class with program entry point.
16 | ///
17 | internal sealed class Program
18 | {
19 | ///
20 | /// Program entry point.
21 | ///
22 | [STAThread]
23 | private static void Main(string[] args)
24 | {
25 | Application.EnableVisualStyles();
26 | Application.SetCompatibleTextRenderingDefault(false);
27 | Application.Run(new MainForm());
28 | }
29 |
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Confuser_Methods_Decryptor/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | #region Using directives
2 |
3 | using System;
4 | using System.Reflection;
5 | using System.Runtime.InteropServices;
6 |
7 | #endregion
8 |
9 | // General Information about an assembly is controlled through the following
10 | // set of attributes. Change these attribute values to modify the information
11 | // associated with an assembly.
12 | [assembly: AssemblyTitle("Confuser_Methods_Decryptor")]
13 | [assembly: AssemblyDescription("")]
14 | [assembly: AssemblyConfiguration("")]
15 | [assembly: AssemblyCompany("")]
16 | [assembly: AssemblyProduct("Confuser_Methods_Decryptor")]
17 | [assembly: AssemblyCopyright("Copyright 2012")]
18 | [assembly: AssemblyTrademark("")]
19 | [assembly: AssemblyCulture("")]
20 |
21 | // This sets the default COM visibility of types in the assembly to invisible.
22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type.
23 | [assembly: ComVisible(false)]
24 |
25 | // The assembly version has following format :
26 | //
27 | // Major.Minor.Build.Revision
28 | //
29 | // You can specify all the values or you can use the default the Revision and
30 | // Build Numbers by using the '*' as shown below:
31 | [assembly: AssemblyVersion("1.0.*")]
32 |
--------------------------------------------------------------------------------