zj3t

email: euntaejang@gmail.com

Latest Posts

CodeEngn-RCE basic13

By 오후 10:35 ,









지금까지의 프로그램은 전부 Window에서만 실행이 가능한 PE 파일들이었습니다. 이런 프로그램들은 리눅스에서 실행이 불가능합니다. 하지만, JAVA나 C# 같은 언어는 운영체제(OS: Window, Linux 등)에서 바로 실행되는 것이 아니라 각각 JVM, CLR 등을 통해 실행되기 때문에 올리디버거같은 툴로는 리버싱을 할 수 없고 별도의 툴을 이용하여 해결해야 합니다. 여기서는 ILSpy(디컴파일러) 를 이용하겠습니다. 사용법은 간단합니다.

-디컴파일 결과-


private static void Main(string[] args)
{
string text = "";
string cipherText = "BnCxGiN4aJDE+qUe2yIm8Q==";
string passPhrase = "^F79ejk56$£";
string saltValue = "DHj47&*)$h";
string hashAlgorithm = "MD5";
int passwordIterations = 1024;
string initVector = "&!£$%^&*()CvHgE!";
int keySize = 256;
RijndaelSimple.Encrypt(text, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize);
text = RijndaelSimple.Decrypt(cipherText, passPhrase, saltValue, hashAlgorithm, passwordIterations, initVector, keySize);
while (true)
{
Console.WriteLine("Please enter the password: ");
string a = Console.ReadLine();
if (a == text)
{
break;
}
Console.WriteLine("Bad Luck! Try again!");
}
Console.WriteLine("Well Done! You cracked it!");
Console.ReadLine();
}

public static string Decrypt(string cipherText, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize)
{
byte[] bytes = Encoding.ASCII.GetBytes(initVector);
byte[] bytes2 = Encoding.ASCII.GetBytes(saltValue);
byte[] array = Convert.FromBase64String(cipherText);
PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(passPhrase, bytes2, hashAlgorithm, passwordIterations);
byte[] bytes3 = passwordDeriveBytes.GetBytes(keySize / 8);
ICryptoTransform transform = new RijndaelManaged
{
Mode = CipherMode.CBC
}.CreateDecryptor(bytes3, bytes);
MemoryStream memoryStream = new MemoryStream(array);
CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Read);
byte[] array2 = new byte[array.Length];
int count = cryptoStream.Read(array2, 0, array2.Length);
memoryStream.Close();
cryptoStream.Close();
return Encoding.UTF8.GetString(array2, 0, count);
}

public static string Encrypt(string plainText, string passPhrase, string saltValue, string hashAlgorithm, int passwordIterations, string initVector, int keySize)
{
byte[] bytes = Encoding.ASCII.GetBytes(initVector);
byte[] bytes2 = Encoding.ASCII.GetBytes(saltValue);
byte[] bytes3 = Encoding.UTF8.GetBytes(plainText);
PasswordDeriveBytes passwordDeriveBytes = new PasswordDeriveBytes(passPhrase, bytes2, hashAlgorithm, passwordIterations);
byte[] bytes4 = passwordDeriveBytes.GetBytes(keySize / 8);
ICryptoTransform transform = new RijndaelManaged
{
Mode = CipherMode.CBC
}.CreateEncryptor(bytes4, bytes);
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write);
cryptoStream.Write(bytes3, 0, bytes3.Length);
cryptoStream.FlushFinalBlock();
byte[] inArray = memoryStream.ToArray();
memoryStream.Close();
cryptoStream.Close();
return Convert.ToBase64String(inArray);
}

즉 이런 C#코드인데 빨간 줄을 친것과 같이 test가 비밀번호라는 것을 알 수가있다. 따라서 변수 test를 출력하는 코드를 작성하면 된다. => Console.WriteLine(test); 

Leteminman가 test의 값이다.

You Might Also Like

0 개의 댓글