Lab 03 - Common structures and constant arithmetic

Supporting files

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

  1. Analyze the program to identify how arguments and/or variables are being multiplied by constants
  2. Determine what values you need to input to make the program output "Felicidades!!!!"
  3. 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

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

  1. Analyze the assembly code for lab03B to understand how compiler optimizations have changed the implementation of arithmetic operations in the pig function
  2. Compare this implementation with the one from exercise 1 (lab03A) which used the -O0 flag
  3. Determine the password(s) needed to successfully run the program
  4. Document in your writeup how the pig function 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

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

  1. Analyze the assembly code of lab03C to identify the encryption/cyphering scheme being used
  2. Reverse the encryption algorithm to determine the password
  3. Document your reverse engineering process and findings

Success Criteria

  1. Successfully cracking the password and making the program run correctly. Showing evidence (screenshot)
  2. Clear explanation of the encryption scheme and how you deduced it.