本帖最后由 asq56747277 于 2021-5-9 14:06 编辑
对称加密没有Key怎么办,只能是通过对明文结果反向加密,之后加密结果与目标结果对比来暴力枚举出Key么
既然楼主直接说了混淆器,那就直接用de4dot来反混淆,不过官方版本用不了,在论坛翻了翻找到一个对.NET Reactor特攻的de4dot版本
首先先对函数以及用到的变量进行重命名方便后续分析
byte_0 => EncryptedResult
byte_1 => Rijndael_IV
string_0 => Key_Dynamic
smethod_0 => MD5Encrypt
smethod_1 => Encrypt8bitText
smethod_2 => DecryptRijndael
method_0 => RepeatEncrypt
分析之后了解到了验证的流程
private void button1_Click(object sender, EventArgs e)
{
try
{
byte[] bytes = Form1.DecryptRijndael(Form1.EncryptedResult, this.textBox1.Text.Substring(0, 3) + this.Key_Dynamic.Substring(3));
string @string = Encoding.UTF8.GetString(bytes);
MessageBox.Show(@string);
}
catch (Exception)
{
MessageBox.Show("密码错误");
}
}
在输出结果的函数 button1_Click 内, 对 EncryptedResult 也就是加密后的 密码正确 这个字符串 进行解密, 以第一个文本框前3位加循环加密后的 Key_Dynamic 的3位之后的组成Key来进行解密. 假如Key不对会抛出 Padding is invalid and cannot be removed. 这个错误之后会到catch块中最终输出 密码错误
循环加密的实现
private void RepeatEncrypt(ref int EncryptCount, string Result)
{
if (EncryptCount <= 0)
{
EncryptCount = this.textBox2.Text.Length;
this.Key_Dynamic = Result;
}
else
{
EncryptCount--;
Result = Form1.Encrypt8bitText(Result);
this.RepeatEncrypt(ref EncryptCount, Result);
}
}
private static string Encrypt8bitText(string Text2Encrypt)
{
return BitConverter.ToString(new MD5CryptoServiceProvider().ComputeHash(Encoding.Default.GetBytes(Text2Encrypt)), 4, 8).Replace("-", "");
}
加密次数为第二个文本框的文本长度, 每次加密会对需要加密的文本进行MD5处理, 之后从第5个字节(MD5结果)取8个字节并转换为文本. 一共循环 EncryptCount 次, 最终将结果保存到全局字段 Key_Dynamic 中.
|