ctf-writeup/KnightCTF 2023/Xorathrust
Muhammad Daffa e510464bfe feat: added knightctf 2023 2023-01-24 23:02:54 +07:00
..
README.md feat: added knightctf 2023 2023-01-24 23:02:54 +07:00
decrypt.py feat: added knightctf 2023 2023-01-24 23:02:54 +07:00
encrypt.py feat: added knightctf 2023 2023-01-24 23:02:54 +07:00

README.md

Xorathrust

Read the script and solve the problem.

About the Challenge

We have been given a python script to encrypt the flag and the encrypted file. And if we open the script, the script will be look like this

def main():

    flag_enc = ""

    with open("flag.txt", "r") as infile:
        flag = infile.read()
        flag = list(flag)

        for each in flag:
            each = chr(ord(each) ^ 0x66)
            flag_enc += each

    with open("flag.enc", "w") as outfile:
        outfile.write(flag_enc)

if __name__ == "__main__":
    main()

The program will applies bitwise XOR on each character using 0x66. (You can get the script here)

How to Solve?

Well, its very easy. You just need to re run the script to get the flag (You can get the script here)

def main():

    flag_enc = ""

    with open("flag.enc.txt", "r") as infile:
        flag = infile.read()
        flag = list(flag)

        for each in flag:
            each = chr(ord(each) ^ 0x66)
            flag_enc += each

    print(flag_enc)

if __name__ == "__main__":
    main()

And the flag will be printed in the terminal

KCTF{ju5t_4_b45ic_x0r}