Skip to content

Instantly share code, notes, and snippets.

@dr4k0nia
Created January 25, 2022 20:12
Show Gist options
  • Save dr4k0nia/e595ef2b63c417610879f61a78a2ab81 to your computer and use it in GitHub Desktop.
Save dr4k0nia/e595ef2b63c417610879f61a78a2ab81 to your computer and use it in GitHub Desktop.
Simple crackme example
// Simple crackme example by drakonia
Console.WriteLine("Enter the correct password:");
string? solution = null;
while (solution == null)
{
string? input = Console.ReadLine();
solution = Verify(input);
}
Console.WriteLine($"The password is: {solution} Good job :)");
Console.ReadKey();
static string? Verify(string? input)
{
// Skip any checks if the input is invalid
if (input == null)
return null;
// This is our key in encrypted form
char[] secret =
{
'ä', 'ù', 'å', 'è', 'î', 'æ', 'î', 'Õ', 'Ý', 'è', 'þ', 'Ñ', 'ì', 'ø', 'â', 'ù', 'Ì', 'ù', 'Ö', 'É', 'æ', 'Ç',
'×', 'Û', 'Þ', 'ā',
};
// hint that the password is the same length as secret
if (input.Length != secret.Length)
return null;
// Buffer that will hold the encrypted form of input
char[] buffer = new char[input.Length];
// Encrypt the user input
for (int i = 0; i < input.Length; i++)
{
char c = input[i];
c += (char) 0xEA;
c ^= (char) 0x7E;
c -= (char) (0x5B + i);
buffer[i] = c;
}
int sum = 0;
// Compare the encrypted user input to secret
for (int i = 0; i < buffer.Length; i++)
{
sum |= buffer[i] ^ secret[i];
}
if (sum == 0)
return input;
// Return null if input does not match secret
return null;
}
@dr4k0nia
Copy link
Author

This is an example of how to make a .net crackme without using string equality comparisons

Article about the topic: https://dr4k0nia.github.io/dotnet/reverse-engineering/2022/01/25/Some-thoughts-on-making-a-crackme.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment