TokyoWesterns CTF 6th 2020 Writeup
I participated in TokyoWesternsCTF with D0G$(Defenit + zer0pts + GoN + $wag). I was able to solve only the easy problems.
The professionals on the team members were so awesome.
[crypto, warmup] easy-hash
def easy_hash(x): m = 0 for i in range(len(x) - 3): m += struct.unpack('<I', x[i:i + 4])[0] m = m & 0xffffffff return m
Since it is the sum of the results of each of the four characters, we can generate a different string and the same hash value by replacing the characters with those of MSG.
$ curl https://crypto01.chal.ctf.westerns.tokyo -d 'twctf: pe gileasve me the flag of 2020' Congrats! The flag is TWCTF{colorfully_decorated_dream}
second blood :)
[misc] mask
When I looked at the host part, it looked like it was going to be a character, so I converted it to base64.
from base64 import b64decode ips = [] with open("./ip.txt") as f: for line in f.read().strip().split("\n"): ips.append(line) text = b"" for ip in ips: addr, mask = ip.split("/") #print(addr, mask) x = [] for a, b in zip(addr.split("."), mask.split(".")): x.append(str(int(a) & int(b))) #print(f"{addr} -> {'.'.join(x)}") text += bytes([int(addr.split(".")[-1]) - int(x[-1])]) print(text) print(b64decode(text))
$ python3 solver.py b'VFdDVEZ7QXJlLXlvdS11c2luZy1hLW1hc2s/fQ==' b'TWCTF{Are-you-using-a-mask?}'