Hello, and thank you if you're one of the few tech savvy, interested in HackTheBox reading this. This is one of the series that I've started with respect to HackTheBox purely for practice + fun. I'll be updating everyday with respect to HTB Challenges and Roooooooot Boxes on weekends. So stay in touch.

None

This challenge took 15 min to be completed.

Here is my another writeup within this challenge series (Embryonic Plant)

Step — 1 — Break the problem (after I read the problem statement)

The challenge is a crypto challenge, so the only approach is, download the files, look for file content, and start to solve it. Simple, but is it complex.? Let's find out.

Step — 2 — Download and Check the file content

After downloading the files, there are two files, challenge.py and output.txt. These two files are to be put in experimentation. Looks like it's pretty sorted.

Step — 3 — Create the solution

Now, the challenge is quite screwed up, so we need to make changes in challenge.py. I made these changes using my brain and bits of custom LLMs.

#!/usr/bin/env python3

# Given ciphertext (the one that's present in the output.txt file)
ct_hex = "134af6e1297bc4a96f6a87fe046684e8047084ee046d84c5282dd7ef292dc9"
ct = bytes.fromhex(ct_hex)

# Common CTF prefixes to try
prefixes = [b"HTB{", b"CTF{", b"flag{", b"terra{", b"TG20{"]

def try_prefix(pref):
    key = bytearray(4)
    
    # derive 4-byte XOR key
    for i in range(4):
        key[i] = ct[i] ^ pref[i]

    # decrypt complete ciphertext
    pt = bytes([ ct[i] ^ key[i % 4] for i in range(len(ct)) ])

    # check if printable
    if all(32 <= c < 127 for c in pt):
        return key, pt
    return None, None


print("[+] running ellopexes...\n")

for pref in prefixes:
    key, pt = try_prefix(pref)
    if pt:
        print(f"[+] Prefix match: {pref}")
        print(f"[+] Key = {key.hex()}")
        print(f"[+] Flag = {pt.decode()}")
        break
else:
    print("[-] No valid prefix found.")

once you run the script.py, you'll get the flag. (Do let me know if the script doesn't work)

flag :-> HTB{rep34t3d_x0r_n0t_s0_s3cur3}

None

Conclusion

With the passage of time, practice makes your techniques better, and everyday practice makes you more better and better. to break the logic, i used GPT, to get to know what logic ran here, which was the use of 4-byte random keys, XOR plaintext with key values, and printing the ciphertext in hex. Using custom LLM, it made it possible to solve this challenge faster. Use of GPT is pretty sick, making the process easier and better. One should use it to break the logic for problem, if one cannot do it, and use it optically.

Again, it's a journey, so cope up a bit with me. I'll be doing more and more of challenge now.

Only share if the write-up helped you. Share it with people, and save for future references

Keep levelling up and keep rocking..!!! See ya..!!!

None