首页
论坛
课程
招聘
[原创]第十题 初入好望角WriteUp
2019-3-14 22:48 982

[原创]第十题 初入好望角WriteUp

2019-3-14 22:48
982
使用dnSpy 打开程序
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;

// Token: 0x02000003 RID: 3
internal class a
{
// Token: 0x06000004 RID: 4 RVA: 0x0000209B File Offset: 0x0000029B
private static void a(string[] A_0)
{
Console.WriteLine("Please Input Serial:");
if (global::a.a(Console.ReadLine(), "Kanxue2019") == "4RTlF9Ca2+oqExJwx68FiA==")
{
Console.WriteLine("Congratulations!  : )");
Console.ReadLine();
}
}

// Token: 0x06000005 RID: 5 RVA: 0x000020D4 File Offset: 0x000002D4
public static string a(string A_0, string A_1)
{
byte[] bytes = Encoding.UTF8.GetBytes("Kanxue2019CTF-Q1");
byte[] bytes2 = Encoding.UTF8.GetBytes(A_0);
byte[] bytes3 = new PasswordDeriveBytes(A_1, null).GetBytes(32);
ICryptoTransform transform = new RijndaelManaged
{
Mode = CipherMode.CBC
}.CreateEncryptor(bytes3, bytes);
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write);
cryptoStream.Write(bytes2, 0, bytes2.Length);
cryptoStream.FlushFinalBlock();
byte[] inArray = memoryStream.ToArray();
memoryStream.Close();
cryptoStream.Close();
return Convert.ToBase64String(inArray);
}

// Token: 0x04000003 RID: 3
private const string a = "Kanxue2019CTF-Q1";

// Token: 0x04000004 RID: 4
private const int b = 256;
}
AES CBC 模式加密
然后copy代码,略加修改,进行解密
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace HelloWorldApplication
{
   class HelloWorld
   {
      static void Main(string[] args)
      {
         //Console.ReadKey();
String A_0="4RTlF9Ca2+oqExJwx68FiA==";
String A_1="Kanxue2019";
byte[] bytes = Encoding.UTF8.GetBytes("Kanxue2019CTF-Q1");
//byte[] bytes2 = Encoding.UTF8.GetBytes(A_0);
byte[] bytes2 = Convert.FromBase64String(A_0);
byte[] bytes3 = new PasswordDeriveBytes(A_1, null).GetBytes(32);
ICryptoTransform transform = new RijndaelManaged
{
Mode = CipherMode.CBC
}.CreateDecryptor(bytes3, bytes);
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write);
cryptoStream.Write(bytes2, 0, bytes2.Length);
cryptoStream.FlushFinalBlock();
byte[] inArray = memoryStream.ToArray();
memoryStream.Close();
cryptoStream.Close();
//Console.WriteLine(Convert.ToBase64String(inArray));
Console.WriteLine(System.Text.Encoding.UTF8.GetString(inArray));
//return Convert.ToBase64String(inArray);
      }
   }
}
在线运行https://c.runoob.com/compile/14
得到结果:Kanxue2019Q1CTF

2020 KCTF秋季赛【攻击篇】正在火热进行中!

收藏
点赞0
打赏
分享
最新回复 (0)
游客
登录 | 注册 方可回帖
返回