













Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!














Group Number: _________ Member Names: ___________________ _______________________ Date Assigned: x Date Due: x Last Edited: November 26th, 2007 Lab Authored By: Jason Fritts, Zener Bayudan, Utsav Kanani Please read the entire lab and any extra materials carefully before starting. Be sure to start early enough so that you will have time to complete the lab. Answer ALL questions in the Answer Sheet and be sure you turn in ALL materials listed in the Turn-in Checklist on or before the Date Due.
cracks often contain code injection. We will show you how easy it is to inject any type of code (ie. Malware) in a program and the user will never know it has been executed. We will show you the different concepts commonly used by software crackers to bypass any type of authentication the software writer implements, and how a software writer can prevent this from happening.
this program using different concepts, and then analyze the results. You will also inject code into a program and have both the host and the injected program run.
to remove protection methods: copy prevention, trial/demo version, serial number, hardware key, CD check or software annoyances like nag screens and adware.” (http://en.wikipedia.org/wiki/Software_cracking) Software cracking has become widespread on the Internet, where one can find a crack for almost any commercial software program available on the market. Thousands of websites dedicated to providing programs which will crack commercial software have appeared on the Internet in the last ten years, making it easier than ever before to pirate software. “The most common software crack is the modification of an application's binary to cause or prevent a specific key branch in the program's execution. This is accomplished by reverse engineering the compiled program code using a debugger such as SoftICE, OllyDbg, GDB, or MacsBug until the software cracker reaches the subroutine that contains the primary method of protecting the software (or by disassembling an executable file with a program such as IDA). The binary is then modified using the debugger or a hex editor in a manner that replaces a prior branching opcode with its complement or a NOP opcode so the key branch will either always execute a specific subroutine or skip over it. Almost all common software cracks are a variation
of this type. Proprietary software developers are constantly developing techniques such as code obfuscation, encryption, and self-modifying code to make this modification increasingly difficult.” Software cracks often contain viruses. This is done through code injection. A virus writer will find a popular crack on the internet, inject his virus code inside of this crack, and then rerelease it on the internet for others to download.
user to authenticate themselves using a serial number. Next you will be cracking this program using a disassembler and hex editor. You will also be writing a serial key generator so there is no need to modify the original sample program. After doing both of these examples you will be given a brief overview of common cracking countermeasures using the program EXEcryptor. Finally the dangers of using publicly available cracks on the Internet will be discussed, including cracks which have viruses and backdoors embedded in them.
For this section you will need the following tools:
First we will write a program that requires the user to enter a serial number for authentication before continuing. For this example we will be showing the concepts crackers use to get past this authentication check, and therefore this program doesn't need to be very complicated. Our program will ask the user for their serial number and perform a numerical check versus the defined serial number. Note: This entire lab will be done within your Windows XP Vmware virtual image.
Screenshot 1: Example of a crackable program requesting user authentication. You should notice that typing any serial number other than the defined serial “12345” will not authenticate you to the program.
Now that we have created a simple program to crack, we will crack it using the reverse engineering program modification technique. The reverse engineering program modification technique is very simple. First, using a program disassembler the cracker views the assembly code of the program he wants to crack. Next, he uses some means to find the assembly code which compares his typed in serial number with the serial number defined by the program. Next he wants to completely bypass this comparison and jump directly to whatever function an authenticated user will enter after a successful comparison. To accomplish this the cracker notes the program offset (line number) the comparison takes place at and finds this location of the program after opening the program in a hex editor. He will then replace the Jump instruction in the program with a NOP instruction. Now after typing an invalid serial key, the program will not jump to a “invalid serial key” function, it will continue to the “valid serial key” function of an authenticated user.
1. Open up W32dsm: ~\W32dsm\W32dsm87.exe 2. Load Example1.exe compiled earlier: Disassembler-Open file to disassemble- example1.exe As shown in Screenshot 2.
Note: You may need to change your system font: Disassembler-Select Font
3. Find the comparison assembly code: Refs-String data references-”valid serial number, type any”. And double click this line to be taken to it. Note: You should be taken to a “push” instruction, this is the instruction that prepares to print “valid serial number”. Which is the location which will be executed after a successful serial number comparison. We will now find this comparison. 4. Scroll a few lines above the “push” instruction, and you should see an instruction “cmp eax, dword ptr ...”. This is the serial key comparison instruction, below it is the instruction “JNE”, or a jump not equal instruction, meaning it will jump to the memory location specified if the previous comparison failed. Note that the memory instruction this JNE jumps to is the “invalid serial number” print function. 5. Find the offset of the JNE instruction by highlighting it using the Up/Down arrow keys, and noting the “@Offset 00000###h” at the very bottom of the screen. Screenshot 2. Example1.exe loaded in w32dasm.
Note: We will now edit the program so this JNE instruction is completely skipped.
In this section we just want to show how a more secure program can be written and the way it can be bypassed. We will write a simple program that requires the user to enter a product id and a serial key for authentication before continuing. Then using a simple algebraic expression the product id (pid) is used to generate a variable. This variable is then matched with the key entered .If there is a perfect match it means the user has been successfully authenticated.
In this case too, you should notice that typing any product id or serial key other than the defined will not authenticate you to the program. Thus this adds double protection.
In this section we will see how easy it is to get around the above mentioned security measure using a keygen. The advantage of using a keygen is that it is automated and the user just has to provide an input and the key is outputted. There is no need for the user to disassemble the software code and make changes. Thus there is no need of having any knowledge about assembly level programming. In the following part we will show with the help of a simple C++ program, the basic idea behind the making of a key generator. Code Example: Keygen.exe, code for a key generator for Example2.exe The basic procedure followed while building a keygen is:
which will make code disassembly painfully long for a cracker. However, given enough time any protection scheme will eventually be cracked. In this section we will be looking at one example of a commercial encryption program named EXEcryptor. From the EXEcryptor website: “EXECryptor uses a conceptually new approach to protect software applications. The core of the protection technology is a brand new concept of the code transformation called "Code Morphing". This technology protects the code on the CPU-command level. It is known the x86 processors command system is redundant and allows the execution of the same 'code' using various different system commands. EXECryptor breaks up the protected code into several processor commands or small command snippets and replace them by others, while maintaining the same end result. Thus EXECryptor obfuscates the code not on the source level but on the level of the CPU commands. The Code Morphing is multilevel technology containing hundreds of unique code transformation patterns. In addition this technology includes the special layer that transforms some commands into Virtual Machine commands (like P-Code). EXECryptor's Code Morphing turns binary code into an undecipherable mess that is not similar to normal compiled code, and completely hides execution logic of the protected code. Unlike other code protectors, there is no concept of code decryption with EXECryptor. Protected code blocks are always in the executable state, and they are executed as a transformed code. The original code is completely lost and code restoration is an NP-hard problem.”
Screenshot 4: Default options for EXECryptor.
Now that we have created a program which is protected by EXECryptor’s code encryption, we will test to see if it is possible to still bypass the authentication check using the methods in section 1. First we will attempt to disassemble the program using w32dsm.
You need to turn in: Answer sheet. 4 screenshots Any corrections or additions to the lab.
Q 2.3 If any other expression is used in Example1.cpp will the serial key outputted by the keygen work. Justify your answer. Q 2.4 How would you prevent such type of cracking if you were a software manufacturer? Q 3.1 What is different about the assembly code shown by w32dsm now? Q 3.2 Do you have access to the actual program? Q 3.3 What occurs after your 3rd^ trial run? Q4.1.1 What is the address of “ECE 4112” string? (e.g., 0046090C) Q4.1.2 What is the address of “Success!” string? (e.g., 00460915)
**Q4.1.3 What is the address of the next DB 00? (e.g., 0046091E) Q4.1.4 What is the address of the instruction just below your new JMP entry? (e.g.,
Q4.5. Which viruses were found by AVG? Q4.6. What types of activities are performed by these viruses?**