Binary Analysis with IDA Pro
When analyzing check_in.exe, the following key observations were made:
- The program requires
flag.jpgas input - It performs XOR operations between file contents and a hardcoded key
- Output is written to
hint.txt
// Simplified decompiled code snippet
void process_file() {
FILE *input = fopen("flag.jpg", "rb");
FILE *output = fopen("hint.txt", "wb");
// Read file contents into buffer
fseek(input, 0, SEEK_END);
size_t size = ftell(input);
rewind(input);
char *data = malloc(size);
char *output_buffer = malloc(size);
fread(data, 1, size, input);
// XOR transformation
for (int i = 0; i < size; i++) {
output_buffer[i] = key[i] ^ data[i];
}
fwrite(output_buffer, 1, size, output);
fclose(input);
fclose(output);
}
License Validation Challenge
The zerothree.exe binary implements a complex license validation system:
- Accepts username and license as input
- Performs XOR between username (repeated as needed) and license
- Validates result against 36 linear equations
# Matrix equation solver implementation
import numpy as np
def solve_license_equations(equations):
# Parse equations into matrix form
A = np.zeros((36, 36), dtype=int)
b = np.zeros(36, dtype=int)
for i, eq in enumerate(equations):
# Process each equation to extract coefficients
terms = parse_equation(eq)
for coeff, var_idx in terms:
A[i, var_idx - 4] = coeff # v4 is index 0
b[i] = eq.constant
# Solve the system
solution = np.linalg.solve(A, b)
return np.round(solution).astype(int)
# Example usage:
username = "or4nge"
solution_vector = solve_license_equations(parsed_equations)
license = "".join([chr(ord(c) ^ s) for c, s in zip(username*(36//6+1), solution_vector)])
print(f"Valid license: {license}")
Key Techniques Demonstrated
-
Binary Analysis:
- IDA Pro for disassembly and decompilation
- Understadning file I/O operations
- Recognizing cryptographic patterns (XOR)
-
Mathematical Solving:
- Linear algebra for equation systems
- Regular expressions for text processing
- Numerical computation with NumPy
-
Problem-Solving Approach:
- Pattern recognition in binary behavior
- Systematic transformation of constraints
- Verification of intermediate results