Knight CTF

trustie_rity
3 min readJan 22, 2022

It is a jeopardy style CTF . I played under urchinsec community. Both teams did good ,i was in urchinsec 2.

So in this write up i will talk about the programming challenges .

Keep Calculating

One of our clients needs a command line tool to do some math tasks. Can you create the tool by following pseudo code ?Let x =  1Let y =  2Let answer += (x * y) + xy [here xy = 12]Repeat this calculation till you have x = 666The final answer will be the flag when x = 666Flag Format : KCTF{answer_here}

i figured out the easiest way to do it is writing a script .

Time Complexity

Find the time complexity of Algorithms.procedure max (a1, a2, …, an: integers) 
max := a1
for i :=2 to n
if max < a1 then max := ai
{max is the largest element}
Flag Format: KCTF{θ(...)

For any loop, we find out the runtime of the block inside them and multiply it by the number of times the program will repeat the loop. All loops that grow proportionally to the input size have a linear time complexity O(n) . If you loop through only half of the array, that’s still O(n)

Reverse The Answer

Let x = 1
Let calculation = (x*(x+1)) + (2 *(x + 1))
Let reversed_calc = reversed number of calculation [for example if calculation = 123, reversed_calc will be 321]
If reversed_calc can be divided by 4 without reminder then answer = answer + reversed_calc
Repeat all the calculations until you have x = 543
The final answer will be the flag when x = 543
Flag Format : KCTF{answer_here}

i did a script for this too .

Square Sum

Have you ever heard the term "The sum of two squares"?
It's like the following :
4 = 0^2 + 2^2
8 = 2^2 + 2^2
16 = 0^2 + 4^2
----------------------------
5002 = 39^2 + 59^2 => 49^2 + 51^2 => 51^2 + 49^2 => 59^2 + 39^2
And so on. In the example of 16, if we add the square of 0 & 4 we get 16. So here we are getting two values 0 & 4. So that's the answer.
So write a program & find out the two values of 25000. Conditions are the following :
* Remove the duplicates
* Pick the third one
Flag Format : KCTF{0,1}

script:

Something In Common

Find the GCD of the following numbers and add up the all integers of that GCD and multiply with 1234.
Number 1: 21525625
Number 2: 30135875
Example: The GCD of 50 & 75 is 25.
Here, 2 + 5 = 7
So, the flag will be 7 x 1234 = 8638.
Flag Format: KCTF{8638}

This was the easiest.

taking the similar characters : 2³ * 11* 31 *101

GCD = 4305125 adding the numbers 4+3+0+5+1+2+5 =20

20*1234 = flag = 24680

Find The Number

What would be the output if we input 25 in the function that is shown in the flowchart?

so i wrote a script for this too :

Thanks for your time .

--

--

trustie_rity

Offensive Penetration Tester | M4lici0s Lif3 | Find video walkthroughs on my yt channel: https://www.youtube.com/@trustie_rity