Relatively simple. The file is a large nested compression - it's been gzipped, tarred and zipped hundreds of times. gzip and tar dont have passwords so any gz or tar file we come accross we can simply decompress. The zips however, do have passwords. Luckily, these passwords are on an 100 word wordlist, allowing for easy brute force.
I wrote a script, the script: uses magic bytes to find out whether the file is a zip, gzip or tar decompresses it accordingly, cracking the password with a wordlist if it's a zipfile go onto the next iteration
At the end, you'll be left with a file called 0, containing the flag.
rtcp{z1pPeD_4_c0uPl3_t00_M4Ny_t1m3s_a1b8c687}
import os, zipfilewordlist = []withopen("/home/isaac/CTFs/houseplant/wordlist.txt", 'r')as f: data = f.read() wordlist = data.split('\n')defgunzip(filename):if"gz"notin filename: os.system(f"mv {filename}{filename}.gz") filename = filename +".gz" os.system(f"gunzip {filename}")deftar(filename): os.system(f"tar -xvf {filename}")iflen(os.listdir('.'))>1: os.system(f"rm {filename}")defzipcrack(filename):# More complicated. Must brute force password via the wordlist. tocrack = zipfile.ZipFile(filename) cracked =Falsefor password in wordlist: pwd = password.encode()try: tocrack.extractall(pwd = pwd) cracked =Truebreakexcept:passif cracked: os.system(f"rm {filename}")else:raiseException("Was not able to crack zip.")zipheader =bytes([0x50, 0x4b, 0x03, 0x04])gzipheader =bytes([0x1f,0x8b])# Tar headers vary, but we know it's tar if it's not zip or gzip.for _ inrange(1816): ourfile = os.listdir('.')[0]# Find out whether it's gzip, tar or zip. Then open accordingly.withopen(ourfile,'rb')as check: first = check.read(4)if first == zipheader:zipcrack(ourfile)elif first[:2]== gzipheader:gunzip(ourfile)else:tar(ourfile)