K3rn3l4rmy CTF

K3rn3l4rmy is created in the middle of 2020 with a lot of passion and curiosity for hacking. The guys really soon make steps forward and after continuous partitipations in various ctfs they decided to create their own Jeopardy style CTF. And i was impressed how well it is organized at the end, surprized from the interesting challenges, and even from the sponsors which they managed to get.

They claim that their ctf intents for educational purpose and assistance of learning hacking. ctftime rates them in the 58th position after getting the first position on their last competition. The group for sure loves what they do and the gets some attention. The partitipation was quite high for that first Ctf of the team. Challenges were focused more in cryptography and rev engineering, but i found this more fun. What i also liked was the Kiddie Pool which despite was for the newcomer ctf players, it was quite interesting and challenging without compromise.

Below it is the write up of Progressive Dynamite from the Misc section. AFAIK the challenges will be up until the next competition and they have uploaded all you need to launch the containers to try by yourself.

Progressive Dynamite (100pts)

by DrDoctor

Description

Find the minimal sum of numbers on a path from the top left corner to the bottom right corner. You can only go right or down in each move.

Attachments

https://ctf.k3rn3l4rmy.com/kernelctf-distribution-challs/Progressive-Dynamite/challenge.txt

Walk Through

The file challenge.txt provides a huge nested list. The method to solve this challenge becomes quite clear in the description. it needs the minimum of all the sums on the matrix. This is a [[https://en.wikipedia.org/wiki/Dynamic_programming][Dynamic Programming challenge]].

Python is just perfect for this task, so we will create a py file and read the data from the [[https://ctf.k3rn3l4rmy.com/kernelctf-distribution-challs/Progressive-Dynamite/challenge.txt][challenge.txt]]

one way is with the json module. (another is using [[https://stackoverflow.com/a/1894296][ast]])

import json

with(open('challenge.txt', 'r')) as f:                                                                        
    dp = json.loads(f.read()
    print(dp)

from here we can get the size of the matrix and the size of each list

print(len(dp)) # res: 100
print(len(dp[0]0) # res: 100

Because of the huge size of the matrix and the size of the actual numbers i am going to create a test data to test my script

i used

| 1 | 1 | 5 | | 10 | 5 | 30 | | 31 | 5 | 50 |

Obviously the minimal should be 1+1+5+5+50 = 62 you can use also negative number for your test

first will calculate all the first row then all the matrix[row][0]

| 1 | 2 | 7 | | 11 | 5 | 30 | | 42 | 5 | 50 |

and finally another loop will calculate all the minimals. This will walk through and dp[i][j] will be the number of the min path.

for i in range(1,r):                                                                                           
    for j in range(1,c):                                                                                       
       dp[i][j] += min(dp[i-1][j],dp[i][j-1])

The bottom right now should contain the sum of the path with the minimal sum

print(dp[-1][-1])

Now replace the test data with the actual and run the script Returns a decimal.

Decode the decimal

i tried to submit the flag with the decimal number but it wasnt accepted the hit i got was now how are flags typically converted to numbers? And i had no idea.

first i tried a few things in [[https://gchq.github.io/CyberChef/][CyberChef]] CyberChef is powerful but i could figure out what modules to use. i still havent found the recipe. However going to https://www.rapidtables.com/convert/number/decimal-to-hex.html gives me the right hex. then either in rapidtables or CyberCher converts this to ascii and you get the flag.

Use from_hex on cyberCher and hex to ascii in other case