-
-
看雪CTF2019Q1-第10题
-
发表于: 2019-3-18 20:57 2752
-
.net程序, 直接丢reflector
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | using System; using System.IO; using System.Security.Cryptography; using System.Text; namespace ConsoleApp1 { class Program { public static String decrypt(String cipherText, String password) { byte[] bufIv = Encoding.UTF8.GetBytes( "Kanxue2019CTF-Q1" ); byte[] bufCipher = Convert.FromBase64String(cipherText); byte[] bufKey = new PasswordDeriveBytes(password, null).GetBytes(0x20); ICryptoTransform transform = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(bufKey, bufIv); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, transform, CryptoStreamMode.Write); cs.Write(bufCipher, 0, bufCipher.Length); cs.FlushFinalBlock(); String plainText = Encoding.UTF8.GetString(ms.ToArray()); ms.Close(); cs.Close(); return plainText; } static void Main(string[] args) { Console.WriteLine(decrypt( "4RTlF9Ca2+oqExJwx68FiA==" , "Kanxue2019" )); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | using System; using System.IO; using System.Security.Cryptography; using System.Text; namespace ConsoleApp1 { class Program { public static String decrypt(String cipherText, String password) { byte[] bufIv = Encoding.UTF8.GetBytes( "Kanxue2019CTF-Q1" ); byte[] bufCipher = Convert.FromBase64String(cipherText); byte[] bufKey = new PasswordDeriveBytes(password, null).GetBytes(0x20); ICryptoTransform transform = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(bufKey, bufIv); MemoryStream ms = new MemoryStream(); CryptoStream cs = new CryptoStream(ms, transform, CryptoStreamMode.Write); cs.Write(bufCipher, 0, bufCipher.Length); cs.FlushFinalBlock(); String plainText = Encoding.UTF8.GetString(ms.ToArray()); ms.Close(); cs.Close(); return plainText; } static void Main(string[] args) { Console.WriteLine(decrypt( "4RTlF9Ca2+oqExJwx68FiA==" , "Kanxue2019" )); } } } |
赞赏
他的文章
- KCTF2022春季赛 第三题 石像病毒 8923
- KCTF2022春季赛 第二题 末日邀请 16245
- KCTF2021秋季赛 第二题 迷失丛林 18909
- KCTF2020秋季赛 第十题 终焉之战 8976
- KCTF2020秋季赛 第九题 命悬一线 6521
看原图
赞赏
雪币:
留言: