Lab 03 - Common structures and constant arithmetic
Supporting files
- Lab archive.
- Unzip using:
unzip lab03.zip. Password islab03. - Then you can uncompress using
tar xvzf lab03.tgz.
Exercises
1. Multiply this
The exectable lab03A was compiled with the -O0 option (no optimization), making it inefficient with memory usage—it stores most variables on the stack frame rather than in registers. However, even at this optimization level, the compiler still uses bit-shifting and addition operations to perform multiplication by constants instead of using the more expensive multiplication instruction.
Your Task
- Analyze the program to identify how arguments and/or variables are being multiplied by constants
- Determine what values you need to input to make the program output "Felicidades!!!!"
- Test your solution by running the program with your calculated inputs
Hint: Focus on identifying the specific multiplication factors being applied to the program's inputs or variables. Look for patterns of shift and add operations in the assembly code that effectively multiply values by specific constants.
Success Criteria
- Correctly identified passwords that make the program run successfully and show evidence.
- Clear explanation of how the multiplication is achieved
2. Multiply that
Executable lab03B contains the same pig function as in the previous exercise, but it was compiled using the -O1 option, which applies basic optimizations. This changes how arithmetic operations are implemented in the assembly code.
Your Task
- Analyze the assembly code for
lab03Bto understand how compiler optimizations have changed the implementation of arithmetic operations in thepigfunction - Compare this implementation with the one from exercise 1 (lab03A) which used the
-O0flag - Determine the password(s) needed to successfully run the program
- Document in your writeup how the
pigfunction achieves the same functionality using different assembly code patterns
Hint: You may need to use an online calculator to determine the exact values required for the passwords. Pay close attention to how arithmetic operations (especially multiplications) are implemented differently with the -O1 optimization.
Success Criteria
- Correctly identified passwords that make the program run successfully and shows evidence.
- Clear explanation of how the optimized code achieves the same functionality
3. Mongo cypher
lab03C implements a simple cyphering scheme in an attempt to obscure its password checking mechanism. This obfuscation is intentionally weak, making it possible to analyze and reverse engineer with proper assembly code analysis.
Your Task
- Analyze the assembly code of
lab03Cto identify the encryption/cyphering scheme being used - Reverse the encryption algorithm to determine the password
- Document your reverse engineering process and findings
Success Criteria
- Successfully cracking the password and making the program run correctly. Showing evidence (screenshot)
- Clear explanation of the encryption scheme and how you deduced it.