Post

HackTheBox Perfect Synchronization Writeup

Explore the basics of cybersecurity in the Perfect Synchronization Challenge on Hack The Box. This very-easy-level Challenge introduces encryption reversal and file handling concepts in a clear and accessible way, perfect for beginners.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def get_plaintext(ciphertext_file):
    # Known mappings from analysis
    mappings = {
        "0fbf645baa0ecce12ed52071a4ed0d1d": "F",
        "ce2e2acd1155ac79105dcabcdb4fbbff": "R", 
        "d78843699ad962a2a7c513d193d27ab4": "E",
        "9a2f91dbedaa39d9b53f8146c2301098": "Q",
        "3ea6ab81fee5f5c718f48b86e8680732": "U",
        "b403c6f30eec7075d0643b5d4125de1b": "N",
        "9e520d83ca02f81ab980ed7ff9a16526": "C",
        "9b9233be563be442bf2edf0e3e42848d": "Y",
        "a952cfc1d886d6084113d5f3e13508f0": " ",
        "00273fa04b9b836c553d876502e9a1e2": "A",
        "d3eae0ab73225a3d841241af5d8a0654": "L",
        "4ca1a8b8e8ca22b70d69ca257d79e5ed": "S",
        "98c50ceddda78b850757dc37c1c0814d": "I",
        "cb20a26ba8411b2e0072e7438ed67e54": "B",
        "4065e6b94c150f4137af46b752e25204": "D",
        "495c118c128a67d8a0f022e3f001775e": "O",
        "d395fedae9dca912da1b1b50b0aca161": "T",
        "c98f7e77e918e98833b8fa19de4b1653": "H",
        "e3372f2164f66ea750b5b14f8166b0b9": "G",
        "473a4eb8c699b9141c7d0bb4fa691674": "V",
        "b1119ba67f26c30144e9cea6a6d7059c": "W",
        "a33f02cf75488a76efb91511a0111982": "M",
        "48654fae441fee7cd607d8cb90c1de44": "P",
        "3321154f7ace2161b8cafb37c6307e6b": "K",
        "4fdd58bb71f5f8c882eaa592d51cf647": "X",
        "ddfdaa01baab48baf54067dd3a3de527": "Z",
        "8115f6662bacddd86db1ae8dc533c46c": "J",
        "d4dde50295a8c036709603b3c216e44d": "{",
        "97038e93767664edf41312c98285ba94": "_",
        "25581e56ea570e8f68c9dab82f24f36e": "}"
    }
    with open(ciphertext_file) as f:
        blocks = [line.strip() for line in f if line.strip()]

    plaintext = ""
    for block in blocks:
        if block in mappings:
            plaintext += mappings[block]
        else:
            plaintext += "?"
    return plaintext

try:
    plaintext = get_plaintext("output.txt")
    print("Plaintext message:")
    print("-" * 50)
    print(plaintext)
    flag_start = plaintext.find("HTB{")
    flag_end = plaintext.find("}") + 1
    if flag_start != -1 and flag_end != -1:
        flag = plaintext[flag_start:flag_end]
        print("\nFlag found:", flag)
except FileNotFoundError:
    print("Error: output.txt file not found")
except Exception as e:
    print(f"Error occurred: {e}")

Summary

The Perfect Synchronization Challenge on Hack The Box is a very-easy-level challenge that introduces encryption reversal and file handling. The provided Python script maps encrypted ciphertext blocks to their corresponding plaintext characters and reconstructs the message. It then extracts the flag from the decoded message, demonstrating basic decryption techniques and file manipulation for beginners.

This post is licensed under CC BY 4.0 by the author.