Simple Geometry
Simple Geometry
Platform: CUSTOM | Category: Reversing | Type: Challenge | Difficulty: Medium | OS: N/A | **Author: XESXOR Techniques: geometry_constraints, static_analysis, vector_math
Summary
Walkthrough of the CUSTOM Reversing Simple Geometry. The simple_geo program (64-bit ELF, stripped) requests coordinates of 6 points on a plane (12 double values) and validates them against a set of geometric constraints. Upon passing all checks, the
Description
The simple_geo program (64-bit ELF, stripped) requests coordinates of 6 points on a plane (12 double values) and validates them against a set of geometric constraints. Upon passing all checks, the server returns the flag.
Analysis
Static analysis revealed that the program reads 12 floating-point numbers that form three line segments:
- s1: from $P_1$ to $P_2$
- s2: from $P_3$ to $P_4$
- s3: from $P_5$ to $P_6$
Validation conditions:
- Length of s1: $4.0 \le \text{dist}(P_1, P_2) < 5.0$
- Length of s2: $5.0 \le \text{dist}(P_3, P_4) < 6.0$
- Length of s3: $\text{dist}(P_5, P_6) \approx 4.0$ (absolute difference from 4.0 must be $< 10^{-5}$)
- Relationship between s1 and s2: $|\cos(s_1, s_2)| < 1.0$. This means segments $s_1$ and $s_2$ must not be parallel.
- Relationship between s1 and s3: $0.5 \le |\cos(s_1, s_3)| \le 1.0$. This corresponds to an angle between segments in the range from 0° to 60°.
The program uses standard formulas:
- Distance: $\sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}$
- Cosine of angle: $\frac{|\vec{v_1} \cdot \vec{v_2}|}{|\vec{v_1}| \cdot |\vec{v_2}|}$
Solution
To satisfy all conditions, we choose the simplest possible coordinates using coordinate axes:
- For s1: $P_1=(0,0), P_2=(4,0)$.
- Length = 4.0 (falls within $[4.0, 5.0)$).
- For s2: $P_3=(0,0), P_4=(0,5)$.
- Length = 5.0 (falls within $[5.0, 6.0)$).
- Vector $s_1 = (4, 0)$, vector $s_2 = (0, 5)$.
- $\cos(s_1, s_2) = 0$ (perpendicular, $0 < 1.0$, condition satisfied).
- For s3: $P_5=(0,0), P_6=(4,0)$.
- Length = 4.0 (difference from 4.0 equals 0, which is $< 10^{-5}$).
- Vector $s_3 = (4, 0)$.
- $\cos(s_1, s_3) = 1.0$ (parallel, $0.5 \le 1.0 \le 1.0$, condition satisfied).
Script to obtain the flag:
python read-only • copy allowed#!/usr/bin/env python3 from pwn import * # Connection configuration host = 'tasks.duckerz.ru' port = 30005 # Point coordinates (x1, y1, x2, y2, ...) # p1=(0,0), p2=(4,0) -> s1 # p3=(0,0), p4=(0,5) -> s2 # p5=(0,0), p6=(4,0) -> s3 coords = [ 0, 0, 4, 0, 0, 0, 0, 5, 0, 0, 4, 0 ] payload = " ".join(map(str, coords)) try: r = remote(host, port) r.sendline(payload.encode()) response = r.recvall(timeout=5).decode() print(response) except Exception as e: print(f"Error: {e}")
Key Takeaways / Lessons
- Mastering geometry_constraints, static_analysis, vector_math was key to this challenge.
- Always check for common misconfigurations and verify assumptions.
Crafted by XESXOR Research • 2026-01-09 • CUSTOM • Simple Geometry • Difficulty: Medium