Rating:


==> Hi, I like an algorithm. So, i make a new authentication system.
==> It has a total of 100 stages.
==> Each stage gives a 7 by 7 matrix below sample.
==> Find the smallest path sum in matrix,
by starting in any cell in the left column and finishing in any cell in the right column,
and only moving up, down, and right.
==> The answer for the sample matrix is 12.
==> If you clear the entire stage, you will be able to authenticate.

[sample]
99 99 99 99 99 99 99
99 99 99 99 99 99 99
99 99 99 99 99 99 99
99 99 99 99 99 99 99
99 1 1 1 99 1 1
1 1 99 1 99 1 99
99 99 99 1 1 1 99



#!/bin/env python3

import fileinput
from itertools import accumulate
from socket import socket
from telnetlib import Telnet
import re
from time import sleep

def euler82(matrix):
nrows, ncols = len(matrix), len(matrix[0])
best = [matrix[row][0] for row in range(nrows)]

for col in range(1, ncols):
column = [matrix[row][col] for row in range(nrows)]

best = [
# The cost of each cell, plus...
column[row] +

# the cost of the cheapest approach to it
min([
best[prev_row] + sum(column[prev_row:row:(1 if prev_row <= row else -1)])
for prev_row in range(nrows)
])
for row in range(nrows)
]

#print(best)

return min(best)

def parse_matrix(data,integ):
Matrix = []
print(data)
for i in list(range(7)):
line = data.split("*** STAGE "+ str(integ) + " ***\n")[1].split("\n")[i].strip().split(" ")
Matrix.append(line)
matrix = []
for lines in Matrix:
line = []
for element in lines:
if (element != ''):
line.append(int(element))
matrix.append(line)
return matrix

if __name__ == '__main__':
sock = socket()
sock.connect(('110.10.147.104', 15712))
print("> " + sock.recv(1024).decode("utf-8"))
sock.send(b'G\n')
solution_str = ''
for m in list(range(100)):
stage = sock.recv(1024).decode("utf-8")
print("> " + stage)
matrix = parse_matrix(stage, m+1)
solution = euler82(matrix)
solution_str += str(solution) + " "
sock.send(str(solution).encode() + b'\n')
print(sock.recv(1024).decode("utf-8"))
print(solution_str)



Then convert numbers to ascii and


echo RkxBRyA6IGcwMG9vT09kX2owQiEhIV9fX3VuY29tZm9ydDRibGVfX3MzY3VyaXR5X19pc19fbjB0X180X19zZWN1cml0eSEhISEh | base64 -d


and get flag
FLAG : g00ooOOd_j0B!!!___uncomfort4ble__s3curity__is__n0t__4__security!!!!!