Всем доброго времени суток!
Сегодня мы разберем ещё 2 таска с BackdoorCTF.Hide_and_Seek
Нам дается аудио файл. После прослушивания первых 5 секунд я понял, что там декодирование частоты 145.800 МГц с помощью MMSSTV (разбор таска от codeby.games с таким же принципом).Открыл, декодировал, и тут выявился первый подвох:
Это была только вторая часть флага! И судя по ней, существовали как минимум ещё 2 части: первая и третья.
Огорчившись от того, что всё оказалось не так просто как хотелось бы, я начал искать недостающие части.
Первая часть флага была найдена в спектограмме звука:
Оставалось найти 3 часть.
Я полез смотреть метаданные - пусто. Смотрел в hex-редакторе - пусто.
И до меня дошло. Третья (и последняя) часть флага была спрятана с помощью утилиты DeepSound:
Оставалось только склеить эти 3 части.
Флаг:
flag{aud105_4r3_c00l_4r5n't_th3y?}
Beginner/Not So Guessy
Нам даны 3 файла: игра версии 1970 года, обновленная игра 2020 года и логи.Задача: найти победную комбинацию в игре "камень-ножницы-бумага" и обыграть бота.
Взаимодействие происходит по netcat, но так как ctf прошёл, то подключиться к ним не получиться.
Python:
Secret_Number = "REDACTED"
Flag = "REDACTED"
coin = {1:'Heads', 0:'Tails'}
wins = 0
print("Welcome to The Guessy Game.")
print("To get The Flag, you have to beat me in Heads and Tails until I admit defeat.")
print("However if you lose once, You Lose.")
while Secret_Number:
draw = coin[Secret_Number % 2]
Secret_Number//=2
print(f"You drew {draw}.")
print(f"The secret number is {Secret_Number}.")
print()
print(f"Wins : {wins}")
print('Heads or Tails?')
guess = input()
if guess == draw:
wins += 1
if Secret_Number==0 :
print('Fine. I give up. You have beaten me.')
print('Here is your Flag. Take it!')
print()
print(Flag)
print()
exit()
print('Okay you guessed right this time. But its not enough to defeat me.')
else :
print("Haha. I knew you didn't have it in you.")
print("You guessed wrong. Bye byee")
exit()
Python:
Secret_Number = "REDACTED"
Flag = "REDACTED"
AI = {2:'Scissors', 1:'Paper', 0:'Rock'}
win = {'Rock':'Paper','Paper':'Scissors','Scissors':'Rock'}
draws = 0
wins = 0
print("Welcome to The Guessy Game.")
print("To get The Flag, you have to beat the AI I made in Rock, Paper, Scissors until it can't take the losses and self-destructs.")
print("However if you lose once, You Lose.")
print("Beware! If the AI draws you twice, it will analyse your mind and you will never be able to defeat it ever.")
win_combinations = []
while Secret_Number:
hand = AI[Secret_Number % 3]
Secret_Number//=3
print(win[hand])
win_combinations.append(win[hand])
print()
print(f"Wins : {wins}, Draws : {draws}")
print('Rock, Paper, Scissors!')
guess = win[hand]
if guess == hand:
print("Ah, Seems like its a draw.")
draws += 1
if draws == 2:
print("The AI now knows your every move. You will never win.")
exit()
elif guess == win[hand]:
wins += 1
if Secret_Number==0 :
print("Fine. You got me. It wasn't an AI it was just a simple Python Code.")
print('Here is your Flag. Take it!')
print()
print(Flag)
print()
print(win_combinations)
print()
exit()
print('Okay you guessed right this time. But its not enough to defeat my AI.')
else :
print("Haha. I knew you didn't have it in you.")
print("You guessed wrong. Bye byee")
exit()
The Guessy Game:
This Game was a piece of cake. Lucky those People at Guessy Inc. are Idiots. They never change the Secret_Number.
It only took me 30 tries to get every guess right.
I remember my father's stories about our lineage being cursed by this game. That we were damned to choose 0 for eternity.
Anyways, I guess the saviour of this family was finally born. Haha.
Here are the correct Guess for the game:
Heads, Tails, Heads, Tails, Tails, Heads, Tails, Heads, Heads, Heads, Tails, Heads, Tails, Heads, Tails, Heads, Heads, Tails, Heads, Heads, Heads, Heads, Tails, Heads, Tails, Heads, Tails, Heads, Heads, Heads
This Game was a piece of cake. Lucky those People at Guessy Inc. are Idiots. They never change the Secret_Number.
It only took me 30 tries to get every guess right.
I remember my father's stories about our lineage being cursed by this game. That we were damned to choose 0 for eternity.
Anyways, I guess the saviour of this family was finally born. Haha.
Here are the correct Guess for the game:
Heads, Tails, Heads, Tails, Tails, Heads, Tails, Heads, Heads, Heads, Tails, Heads, Tails, Heads, Tails, Heads, Heads, Tails, Heads, Heads, Heads, Heads, Tails, Heads, Tails, Heads, Tails, Heads, Heads, Heads
Логи тут играют ключевую роль, ведь известно, что Secret_Number не был изменен, и дана победная комбинация для игры 1970 года.
Логика кода в двух вариантах игры различается тем, что в первой берется остаток от деления на 2 (игра орёл-решка), а во второй игре - от деления на 3 (камень-ножницы-бумага). Числу остатка соответственно присвоены
{1:'Heads', 0:'Tails'}
и {2:'Scissors', 1:'Paper', 0:'Rock'}
соответственно.Вектор решения примерно следующий: с помощью данной нам комбинации старой игры находим Secret_Number и используем его для нахождения победной комбинации для новой игры.
Код для нахождения Secret_Number предельно простой:
Python:
Secret_Number = 0
win_sequence = ['Heads', 'Tails', 'Heads', 'Tails', 'Tails', 'Heads', 'Tails', 'Heads', 'Heads', 'Heads', 'Tails', 'Heads', 'Tails', 'Heads', 'Tails', 'Heads', 'Heads', 'Tails', 'Heads', 'Heads', 'Heads', 'Heads', 'Tails', 'Heads', 'Tails', 'Heads', 'Tails', 'Heads', 'Heads', 'Heads']
win_sequence.reverse()
for outcome in win_sequence:
if outcome == 'Heads':
Secret_Number = Secret_Number * 2 + 1
else:
Secret_Number = Secret_Number * 2
print("The secret number is:", Secret_Number)
Получаем
The secret number is: 985508773
и вставляем в изменённый код новой игры:
Python:
Secret_Number = 985508773
Flag = "REDACTED"
AI = {2:'Scissors', 1:'Paper', 0:'Rock'}
win = {'Rock':'Paper','Paper':'Scissors','Scissors':'Rock'}
draws = 0
wins = 0
win_combinations = []
while Secret_Number:
hand = AI[Secret_Number % 3]
Secret_Number//=3
win_combinations.append(win[hand])
guess = win[hand]
if guess == hand:
print("Ah, Seems like its a draw.")
draws += 1
if draws == 2:
print("The AI now knows your every move. You will never win.")
exit()
elif guess == win[hand]:
wins += 1
if Secret_Number==0 :
print("Fine. You got me. It wasn't an AI it was just a simple Python Code.")
print('Here is your Flag. Take it!')
print(win_combinations)
Получаем выигрышную комбинацию и вводим поочередно в netcat.
Флаг:
flag{M0d_0n3_1s_4lw4ys_z3r0}