Addition

Posted on Mon 05 August 2024 in ctf

This is a writeup of the misc challenge Addition in the n00bz CTF 2024.

50a990ae7b78413e996d6dd6b6b6e02d.png

The attached server.py contained the following code:

import time
import random

questions = int(input("how many questions do you want to answer? "))

for i in range(questions):
    a = random.randint(0, 10)
    b = random.randint(0, 10)

    yourans = int(input("what is " + str(a) + ' + ' + str(b) + ' = '))

    print("calculating")

    totaltime = pow(2, i)

    print('.')
    time.sleep(totaltime / 3)
    print('.')
    time.sleep(totaltime / 3)
    print('.')
    time.sleep(totaltime / 3)

    if yourans != a + b:
        print("You made my little brother cry 😭")
        exit(69)

f = open('/flag.txt', 'r')
flag = f.read()
print(flag[:questions])

We can skip the whole for loop by stating that we want to anser -1 questions:

423998c372a44f21a3142d4368c4616e.png