https://app.hackthebox.com/challenges/410

Description

You’ve made contact with a spirit from beyond the grave! Unfortunately, they speak in an ancient tongue of flags, so you can’t understand a word. You’ve enlisted a medium who can translate it, but they like to take their time…

Exploitation

#!/usr/bin/env python3

def decrypt():
    encrypted = "ZLT{Kdwhafy_ak_fgl_gtxmkuslagf}"
    key = 18
    decrypted = ""
    for c in encrypted:
        if c.islower():
            if ord(c) - key <= 96:
                c = chr(ord(c) + 26)
            dec = chr(ord(c) - key)
            decrypted += dec
        elif c.isupper():
            if ord(c) - key <= 64:
                c = chr(ord(c) + 26)
            dec = chr(ord(c) - key)
            decrypted += dec
        else:
            decrypted += c     
    return decrypted

print("Flag:", decrypt())

Summary

Ouija: reverse the validation logic, model the transform, and recover the accepted input.