sCTF.io 2016 Q1 // Tracking (85 points)

Capture the Flag, sCTF.io 0 Comment 351

This challenge required a program that would take analyze all of the values, and some math to manipulate the given equations.

First off, we are given the location of all 4 satellites. They are;

A: (0, 0, 0)
B: (2000, 0, 0)
C: (2000, 2000, 0)
D: (3000, 1500, 1700)

We are also given equations to find the locations of the input points. These equations are;

d^2_{1}=x^2+y^2+z^2
d^2_{2}=(x-p)^2+y^2+z^2
d^2_{3}=(x-q)^2+(y-r)^2+z^2
d^2_{4}=(x-s)^2+(y-t)^2+(z-u)^2

Finally, we have the input. There are multiple lines, but each one gives distances from all 4 satellites. Here is a sample input line;

1247.9110545227172 1556.0469144598437 1620.2721993541702 2729.337282198739

As we can see, there are spaces between the lines, and therefore it can be read with a Java scanner’s nextDouble().

First off, we needed to understand the equations. We can see that there are common variables, x, y and z through all them. We want to solve for these. Next, there are some other variables, p, q, r, s, t and u. These are variables that represent the coordinates of their respective satellites, and variables that are given to us.

We want to solve for one of the coordinates. Our strategy was to solve for x first, as we could easily eliminate y and z using the first 2 equations.

d^2_{1} = x^2 + y^2 + z^2

d^2_{1} - x^2 = y^2 + z^2

d^2_{2} = (x - p)^2 + y^2 + z^2

d^2_{2} - (x-p)^2 = y^2 + z^2

Now we can set these two equations equal to each other, then solve for x.

d^2_{1} - x^2 = d^2_{2} - (x-p)^2

d^2_{1} - x^2 = d^2_{2} - x^2 + 2xp - p^2

d^2_{1} - d^2_{2} + p^2 = 2xp

(d^2_{1} - d^2_{2} + p^2) / (2p) = x

Now we have an equation for the x variable. Let’s find one for y. We can do this by using the first and third equations.

d^2_{1} = x^2 + y^2 + z^2

d^2_{1} - x^2 - y^2 = z^2

d^2_{3} = (x - q)^2 + (y - r)^2 + z^2

d^2_{3} - (x - q)^2 - (y - r)^2 = z^2

And set them equal.

d^2_{1} - x^2 - y^2 = d^2_{3} - (x - q)^2 - (y - r)^2

Even though there are 2 unknowns, x and y, we can use the value we had just found for x. Now let’s solve for y.

d^2_{1} - x^2 - y^2 = d^2_{3} - (x - q)^2 - (y - r)^2

d^2_{1} - x^2 - y^2 = d^2_{3} - x^2 + 2xq -q^2 - y^2 + 2yr - r^2

d^2_{1} - d^2_{3} - 2xq + q^2 + r^2 = 2yr

(d^2_{1} - d^2_{3} - 2xq + q^2 + r^2) / (2r) = y

And now we just need to solve for z. Since we know x and y, we can just use the first equation.

d^2_{1} = x^2 + y^2 + z^2

d^2_{1} - x^2 - y^2 = z^2

sqrt(d^2_{1} - x^2 - y^2) = z

Now that we have all of the equations, we just need to plug them into our program. After finding each coordinate, we need to keep track of the answer so we can find the average of all of the coordinates. When we put all of this together, we got these results;

536.3778, 515.75555, 486.93332

The flag is the rounded up value of each coordinate, so we submitted this flag;

sctf{537, 516, 487}

And got 85 points.

Links

  1. Java Program
  2. Input values
  3. Challenge Description

Author

Leave a Reply

Search

Back to Top