DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

karapto
karapto

Posted on

picoCTF 2022 ~transposition-trial writeup~

Description

Our data got corrupted on the way here. Luckily, nothing got replaced, but every block of 3 got scrambled around! The first word seems to be three letters long, maybe you can use that to recover the rest of the message. Download the corrupted message here.

First, open message.txt.

heTfl g as iicpCTo{7F4NRP051N5_16_35P3X51N3_V9AAB1F8}7% 
Enter fullscreen mode Exit fullscreen mode

To be honest, this challenge needs a bit of an inspiration, but if you replace spaces with underscores (_) and look carefully, you can see the encrypting rules.

"heT" : "The"
"fl_" : "_fl"
"g_a" : "ag_"
"s_i" : "is_"
"icp" : "pic"
"CTo" : "oCT"
Enter fullscreen mode Exit fullscreen mode

If you connect them, you can read The_flag_is_picoCT. Let's separate message.txt by three characters (3-gram) and decode it.

def main():
    f = open("message.txt", "r", encoding="UTF-8")
    txt = f.read()

    n=3
    txt3gram = [txt[i:i+n] for i in range(0, len(txt), n)]
    decode_lst = []

    for i in range(len(txt3gram)):
        decode_lst.append(txt3gram[i][2]+txt3gram[i][0]+txt3gram[i][1])

    print(''.join(decode_lst))


if __name__ == '__main__':
    main()
Enter fullscreen mode Exit fullscreen mode

You can get The flag is picoCTF{7R4N5P051N6_15_3XP3N51V3_A9AFB178}, submit it!

Top comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.