Tags: cryptography 

Rating:

solve.py

# Given output
s = [216, 215, 218, 225, 206, 187, 153, 163, 166, 174, 217, 167, 169, 199, 153, 173, 227, 156, 155, 199, 203, 156, 96, 155, 222, 210, 207, 163, 148, 196, 200, 171, 187, 225, 233]

# Initialize an empty list to hold the ASCII values of the flag characters
ord_flag = []

# We need to guess the first character's ASCII value
# Let's assume the first character is a lowercase letter (ASCII 97 to 122)
for first_char in range(97, 123):
    ord_flag.append(first_char)  # ord(f[0])
    
    # Calculate the rest of the characters based on the sums
    for i in range(len(s)):
        if i == 0:
            ord_flag.append(s[i] - ord_flag[0])  # ord(f[1])
        else:
            ord_flag.append(s[i] - ord_flag[i])  # ord(f[i+1])
    
    # Check if all calculated values are valid ASCII characters
    if all(0 <= val <= 255 for val in ord_flag):
        # Convert ASCII values to characters
        flag = ''.join(chr(val) for val in ord_flag)
        print(f"Possible flag: {flag}")
    
    # Clear the list for the next iteration
    ord_flag.clear()

# uctf{Sh1r4z_Haf3zi3h_l00ks_p3aceFul}