Monday, July 9, 2012

Solution for Crackmes.de - HonestGamer's Crackme

Solution for Crackmes.de - Beezdul's Keygenme #1

This is the link to the original crackme: http://www.crackmes.de/users/honestgamer/crackme/

However, you will need to register before you can download the binary. 

Hints:
Crackme is coded in C# (.NET) using Visual Studio 2010.

=========================

The User ID should be an integer that is less than 4 digits.

The User Code should be an integer as well...

=========================

This crackme is no big deal, so best of luck! :)

Regards,
HonestGamer
Difficulty: 1 - Very easy, for newbies
Platform: Windows
Language: .NET

Published: 15. Feb, 2011

Tools Required:
ilSpy - http://wiki.sharpdevelop.net/ilspy.ashx



This is another of those level 1 as difficulty type of crackme and is a .NET binary, let's open it with ilSpy immediately and we immediately found the portion that is required to code our KeyGenMe. :D

Let's take a look at the main function for this binary.

private static void Main(string[] args){
            Console.WriteLine("Crackme By HonestGamer");
            int num = 0;
            char c;
            do
            {
                Keygen keygen = new Keygen();
                keygen.Generate();
                keygen.Check(ref num);
                if (num == 0)
                {
                    Console.Write("\nInvalid Code, Try Again (Y/N)? ");
                    c = Convert.ToChar(Console.ReadLine());
                }
                else
                {
                    c = 'N';
                    Console.WriteLine("\nValid Code, Well Done! Write A Keygen Now...");
                }
            }
            while (c == 'Y' || c == 'y');
            Console.WriteLine("\nHit The Enter Key To End...");
            Console.ReadLine();
}


As we can see from the above code snippet that we have extracted with ilSpy, it is doing a keygen.Generate and keygen before validation.

Let's take a look at the 2 functions.

private Keygen(){
            do
            {
                Console.Write("\nEnter User ID: ");
                this.UserID = Convert.ToInt32(Console.ReadLine());
                if (this.UserID > 0 && this.UserID < 10000)
                {
                    this.UFlag = 1;
                }
                else
                {
                    this.UFlag = 0;
                    Console.WriteLine("\nUser ID Is Out Of Range! Please Enter Number Less Than 4 Digits...");
                }
            }
            while (this.UFlag == 0);
            Console.Write("\nEnter Code: ");
            this.UserCode = Convert.ToInt32(Console.ReadLine());
}


private void Generate(){
            int num = this.UserID * 786;
            this.ValidCode = num * 17;
            num = this.ValidCode / 12;
            this.ValidCode = num + 1991;
}


private void Check(ref int RFlag){
            if (this.ValidCode == this.UserCode)
            {
                RFlag = 1;
            }
            else
            {
                RFlag = 0;
            }
}


Judging from the above code snippets, the UserID had to be bigger than 0 and less than 1000.
Then it uses the user's input value for UserID to generate the serial and validate it with Check function.


Based on the Generate function, it's pretty easy for us to code the solution for this KeyGenMe now that we know the inner algorithm for it.

I have developed the solution to this crackme and placed it here.
But i will release the source code later.


I do hope that people will learn from this and find it enriching. xDDD


Cheers
0x4A61636F62

No comments:

Post a Comment