墨者学院-逆向分析实训-dll(第1题)
1.下载文件,解压得到ClassLibrary1.dll
2.利用dnSpy对ClassLibrary1.dll做逆向分析。
3.在vs 2010 中创建新项目dll,语言选择C#,代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
namespace dll1
{
class Program
{
private static string GetAesKey(int index)
{
string result;
if (index >= 0 && index < 10)
{
string[] array = new string[]
{
"VZ6MvKGnCvDSjqDK8v2XUeKaVtqhdpxv",
"qz1y3YtZ4NrzKgmxdhADn4pgp4VGfyBT",
"BmfnYp8l8fvnTa93fByUkq7pPDQu9KsS",
"ZlVjJThM6z8qc3nSWqcm22vqbycFFy4S",
"yZJfLzMJEx7ykmBmEPkbXBEb5lUnmaHW",
"6DQqrGzSft8PVpJP826F6kL9zD2SQgZu",
"NYmEN7fUdQ6azhXtaN87mFauhl2fjBfj",
"zl6Ccl6brngPDCy4waMlxE8AH9VFFj1Q",
"UzM5er77PnedGxtCFDS3Pp2nk5SGL2Em",
"RfCFclQgXBydflxZ3njg4akzySDZC2Cb"
};
result = array[index];
}
else
{
result = "";
}
return result;
}
static void Main(string[] args)
{
string result;
string toDecrypt = "K0sUkIPChQ1825EQmCO8i_NiDA6atB94/Nc1NF96s2M1IT9w6nS8teUneBJbNIcya";
try
{
int index = Convert.ToInt32(toDecrypt.Substring(19, 1));
string text = toDecrypt.Substring(0, 19) + toDecrypt.Substring(20);
byte[] bytes = Encoding.UTF8.GetBytes(GetAesKey(index));
byte[] array = Convert.FromBase64String(text.Replace("_", "+"));
byte[] bytes2 = new RijndaelManaged
{
Key = bytes,
Mode = CipherMode.ECB,
Padding = PaddingMode.PKCS7
}.CreateDecryptor().TransformFinalBlock(array, 0, array.Length);
result = Encoding.UTF8.GetString(bytes2);
}
catch
{
result = "";
}
Console.WriteLine(result);
Console.ReadKey();
}
}
}
4.得到结果: