obfuscation / deobfuscation
Một khái niệm cơ bản của reCompile, người ta sẽ biến đổi exec thành một dạng khác và đặt dấu ở chỗ khác
- biến đổi : nén, mã hoá, ...
- đặt dấu : trong resource, DLL, data, ...
Khi cần thực thi (run) nó sẽ lấy ra, biến đổi ngược lại (có thể không hoàn toàn) về exec ban đầu, nạp (load) để thực hiện.
Ví dụ đơn giản, với dự án sau:
using System.Windows.Forms;
[STAThread]
Application.EnableVisualStyles();
Application
.SetCompatibleTextRenderingDefault(false); Application
.Run(new Form1
()); }
}
//===
InitializeComponent();
timer1.Start();
}
label1.Text = receiveAbc();
}
return DateTime
.Now.ToString(); }
timer1.Stop();
}
}
//===
if (disposing
&& (components
!= null)) components.Dispose();
}
void InitializeComponent
(){ this.components = new System.ComponentModel.Container(); this.timer1 = new System.Windows.Forms.Timer(this.components); this.label1 = new System.Windows.Forms.Label(); this.button1 = new System.Windows.Forms.Button(); //
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick); //
// label1
//
this.label1.Location = new System.Drawing.Point(29,
25); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(35,
13); this.label1.TabIndex = 0; this.label1.Text = "label1"; //
// button1
//
this.button1.Location = new System.Drawing.Point(102,
54); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75,
23); this.button1.TabIndex = 1; this.button1.Text = "&Stop"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F
); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(292,
100);
}
System.ComponentModel.IContainer components
= null; System.Windows.Forms.Timer timer1;
System.Windows.Forms.Label label1;
System.Windows.Forms.Button button1;
}
}
Nó được biên dịch thành exec :
Prog.exe được biến đổi thành data và đặt trong file :
aExec.dat
Để đơn giản, nó chỉ là đổi tên file, chưa nén cũng không mã hoá
Chương trình có nhiệm vụ nạp để chương trình trên thực hiện :
using System.Windows.Forms;
byte[] bys
= System.IO.File.ReadAllBytes("aExec.dat"); //unZip, hay giải mã gì đó nữa, sao cho nó về dạng ban đầu
Assembly asm = Assembly.Load(bys);
Type typ = asm.GetType("nsA.nsSub.Program"); // namespace.className
MethodBase mb
= typ
.GetMethod("Main", BindingFlags
.NonPublic | BindingFlags
.Static); //entrypoint
if (ts
.Length != 0) ts
[0] = ts
;
} catch (Exception ex
) { MessageBox
.Show(ex
.StackTrace, ex
.Message); } //
MessageBox.Show("Abc", "Done");
}
}
Xem full code trong file đính kèm : _Exam.rar
Phọt mô xa 2017