root@akosibrylle.dev:~$

# capture-the-flag is love!


Trend Micro uCTF 2024 --- This writeup will be covering **Trend Micro Careers Philippine’s University Capture the Flag** challenges which includes both from the qualifier round and the finals round. In this Online CTF, our team ranked 5th out of 187 teams in the qualifier round and 15th out of 30 teams in the finals. I will try to be concise as much as possible while explaining the solving process. ![Trend Micro uCTF Logo](/static/img/writeups/tmctf2024/tmctf.webp) Note that some challenges in this competition are not included here in the writeups for umm... various reasons which may include * I forgot what the instruction was (lol) * I accidentally deleted the challenge file (bruh moment) * Maybe I’m still working on it (really) This is a running list of writeups! I’ll add more in my free time! Last updated Sept 10 [=] QUALIFIERS ================ Aug 30 * * * Warm Up ======= Cryptography We receive a **WarmUP.exe** file. When running the file, it says that we have to crack a certain string. We notice it’s a base64 encoded string so we just decode it to get the flag ![FLAG: TMCTF{D3r3z0}](/static/img/writeups/tmctf2024/tmctf2024-warmup.webp) One Friend ========== OSINT ![OneFriend.png](/static/img/writeups/tmctf2024/tmctf2024-onefriend.webp) A single image named **OneFriend.png** is given to us. Our goal is to find what the name of the building that the picture is taken at. Running the command **exiftool** reveals that it has metadata that tells us where that picture was shot. ![OneFriend.png metadata](/static/img/writeups/tmctf2024/tmctf2024-onefriend2.webp) Though there are multiple buildings surrounding the pin, we notice that it may be this cat cafe named _Koneko_ since the picture also shows a cat. ![FLAG: TMCTF{Koneko}](/static/img/writeups/tmctf2024/tmctf2024-onefriend3.webp) Red Lanterns ============ OSINT ![RedLanterns.jpg](/static/img/writeups/tmctf2024/tmctf2024-redlanterns.webp) Given an image **RedLanterns.jpg**, we have to look for the city where this image is taken. Again similar to the challenge above, there is also a GPS Position metadata. ![RedLanterns.jpg metadata](/static/img/writeups/tmctf2024/tmctf2024-redlanterns2.webp) The picture also shows a tagline: _“FuFa Shoes since 2004”_, when searching for it, you find results of a Taiwanese shoe company. But since we already have the GPS Position let’s just use that instead of doing lengthy OSINT. ![FLAG: TMCTF{NewTaipei}](/static/img/writeups/tmctf2024/tmctf2024-redlanterns3.webp) Magic Key ========= Forensics A single text file **MagicKey.txt** seems to contain multiple lines of hex where our goal is to retrieve the website. We hop on **Cyberchef** to decode it easily. ![First few of many lines of MagicKey.txt](/static/img/tmctf2024-magickey.webp) The magic feature in **Cyberchef** claims it is HTTP chunks, it is just being silly, when we manually decode it from hex we notice that it is a base64 encoded image! ![FLAG: TMCTF{www.thisis3t.com}](/static/img/writeups/tmctf2024/tmctf2024-magickey2.webp) Emergency Message ================= Forensics We have an image, let’s retrieve the flag! ![Emergency.png](/static/img/tmctf2024-emergency.webp) We can use websites to extract the text from the image and decode the base64 text. Be careful though as some websites extracting text from image sometimes mistake similar looking characters like l, 1 and I, 0, o and 0, et cetera. Using **Cyberchef** we see that the decoded base64 is hex, decoding it further reveals the flag. ![FLAG: TMCTF{T3rm1nat0r}](/static/img/writeups/tmctf2024/tmctf2024-emergency2.webp) Hidden Payload ============== Forensics We’re given a hidden\_payload.pcap and our task is to retrieve a website link which has the flag. Firing up our Wireshark we see a network traffic consisting of just an HTTP request and response. ![FLAG: TMCTF{https://google.com/flags/hello_world}](/static/img/writeups/tmctf2024/tmctf2024-hidden.webp) The website contents has an HTML comment that has an encoded base64, decoding it shows us the website link which is also the flag. Mission Impossible ================== Reverse Engineering A binary file named MissionImpossible.exe is provided to us. It’s an executable for Windows so let’s try running it. ![MissionImpossible.exe file type](/static/img/writeups/tmctf2024/tmctf2024-mission.webp) When running the file in Windows, the results says that a certain mission has failed and it stops. ![MissionImpossible.exe output](/static/img/writeups/tmctf2024/tmctf2024-mission2.webp) I checked for strings inside the binary if there’s anything useful, and I notice a file in a directory that doesn’t even exist on my PC. If that file doesn’t exist and it says mission failed, then surely mission successful if it exists? ![Strings inside MissionImpossible.exe](/static/img/writeups/tmctf2024/tmctf2024-mission3.webp) I immediately created a directory with the file and finally , we get the flag ![MissionImpossible.exe results after creating the previously non-existent file](/static/img/writeups/tmctf2024/tmctf2024-mission4.webp) ![FLAG: TMCTF{M3g4byt3}](/static/img/writeups/tmctf2024/tmctf2024-mission5.webp) Cryptic Sound ============= Forensics A file named CrypticSound.wav is given to us. It’s just tweeting birds but something sounds off! ![FLAG: TMCTF{TM-60999fb6–346744–09f766bd}](/static/img/writeups/tmctf2024/tmctf2024-crypticsound.webp) Didn’t know it was that obvious. Lost Passport ============= Forensics A woman said that she lost her passport, the airline gave her a soft copy of her documents, but I don’t think she knows how to open these kind of stuff. Let’s help her. We’re given a **lp.e01** file which is an Encase Image format By using a command-line tool named ewf-tools to handle these kind of files, we mount this encase file to a directory, and there we can see the contents of this file. ewfmount lp.e01 output # make sure output directory exists mount output/ewf1 -o ro,norecovery /mnt # mount to /mnt cd /mnt # results are here ![captionless image](/static/img/writeups/tmctf2024/tmctf2024-lostpassport.webp) We don’t see anything particular when we open **UCTF\_Passport.jpg**, looking at its metadata using **exiftool**, we see the flag. ![FLAG: TMCTF{Inf0tr0n}](/static/img/writeups/tmctf2024/tmctf2024-lostpassport2.webp) Breaking the Seal ================= Forensics We receive a password-protected BreakingTheSeal-encrypted.pdf file. ![Password prompt when opening the file](/static/img/writeups/tmctf2024/tmctf2024-breakingtheseal.webp) Let’s get the hash of this file using pdf2john and crack it using password crackers. I love using **hashcat** as it’s really fast. ![hash of the password-protected file](/static/img/writeups/tmctf2024/tmctf2024-breakingtheseal2.webp) I copied the hash and pasted it ina file named **hash**, then we run **hashcat** and use rockyou.txt as our wordlist (In Kali, it’s located at /usr/share/wordlists/rockyou.txt.gz). hashcat -a 0 hash /home/kali/wl/rockyou.txt ![cracked password](/static/img/writeups/tmctf2024/tmctf2024-breakingtheseal3.webp) In 2 seconds we find out that the password is **password1234**. After entering the password, we open the pdf file and retrieve the flag. ![FLAG: TMCTF{C0sm0s}](/static/img/writeups/tmctf2024/tmctf2024-breakingtheseal4.webp) The Seven Gates =============== Reverse Engineering We receive a Windows executable named **SevenGates.exe**. It seems to be asking for 7 passwords until you can get the flag. In the competition, we tried analyzing the hex bytes of the binary and retrieved 2 passwords. ![2 out of 7 passwords](/static/img/writeups/tmctf2024/tmctf2024-sevengates.webp) We couldn’t find the third password, so we just fired the binary into **Ghidra**. In the main function we see 7 different functions that handle the password verification of each level. ![main function of SevenGates.exe](/static/img/writeups/tmctf2024/tmctf2024-sevengates2.webp) We’re only after the flag anyways so let’s analyze the last level. In level7 function we see that the flag is in local\_98 and the password is in local\_108 which is a combination of local\_98 and local\_90. It is encrypted twice using XOR cipher first using the key 0xAB then (adding 5, then) 0x5F. When the correct password is supplied which is MuLti\_L4Y3r\_0bf, The **printf** function prints local\_98 first, without a null terminator it also reads local\_90 which has the null terminator at the end essentially making the final password and flag the same value. ![FLAG: TMCTF{MuLti_L4y3r_0bf}](/static/img/writeups/tmctf2024/tmctf2024-sevengates3.webp) I reverse engineered the other functions to get the passwords, I won’t be showing exact steps, since we got the flag already but here it is: * Layer 1: easy\_flag (visible in hex dump) * Layer 2: str1ng\_m4nipul4ti0n (2 values in hex dump concatted) * Layer 3: dynamic\_runtime (generated by a separate function) * Layer 4: c0mplex\_l0gic (XOR encrypted but visible in hex dump) * Layer 5: b4s364\_encoded (flag copied to another var, still visible in hex dump) * Layer 6: knowledge\_TM (visible in hex dump) * Layer 7: MuLti\_L4Y3r\_0bf (reverse engineered) After submitting Layer 7, the program ends and closes without prompt. ![Passwords proof](/static/img/writeups/tmctf2024/tmctf2024-sevengates4.webp) [=] FINALS ============ Sep 03 * * * Hello World =========== Forensics ![Hello_World.docm opened in Microsoft Word](/static/img/writeups/tmctf2024/tmctf2024-helloworld.webp) We are given an empty **Hello\_World.docm** file which is a Microsoft Word 2007+ document. We unzip it to unpack its components and **vbaProject.bin,** which is a macro, catches our attention. ![FLAG: TMCTF{Hell0_W3rld}](/static/img/writeups/tmctf2024/tmctf2024-helloworld2.webp) We look for the flag inside the macro and there we find the flag. Buried in Bytes =============== Forensics ![Buried_In_Bytes.pdf opened in Google Chrome's PDF viewer](/static/img/writeups/tmctf2024/tmctf2024-buriedinbytes.webp) We’re given a pdf named Buried\_In\_Bytes.pdf which just has some lyric in it. When opening the pdf file, I notice this opens: ![An alert made by Buried_In_Bytes.pdf](/static/img/writeups/tmctf2024/tmctf2024-buriedinbytes2.webp) So I thought there may be an embedded script here, so I went and ran **strings** command on the pdf file and indeed there is an obfuscated JavaScript code. ![Embedded JavaScript inside Buried_In_Byted.pdf](/static/img/writeups/tmctf2024/tmctf2024-buriedinbytes3.webp) So I cleaned up the code and commented out lines that aren’t necessary. ![FLAG: TMCTF{Dr3J}](/static/img/writeups/tmctf2024/tmctf2024-buriedinbytes4.webp) Untangled ========= Forensics This one is quite simple. The flag is just hidden in a bunch of characters. Simply grepping it won’t do the trick as there is no line breaks so grep just outputs the entire file. Combine **grep** with regex and show exact match shows us the flag ![FLAG: TMCTF{Vultur3}](/static/img/writeups/tmctf2024/tmctf2024-untangled.webp) Obfuscated Trail ================ Forensics Similar to the challenge above, but this time the contents is a large chunk of base64 encoded data. The task is to get the website of the referrer. ![Last few characters inside 'Obfuscated Trail.txt'](/static/img/writeups/tmctf2024/tmctf2024-obfuscatedtrail.webp) Let’s copy this whole thing and hop on to Cyberchef to decode. We’ll see it’s an obfuscated JavaScript code. It’s a whopping 7k+ lines of code. Initially I tried running it, but I get no result, and trying to figure out if this code has bugs or just for distraction is time consuming. ![Decoded base64 result](/static/img/writeups/tmctf2024/tmctf2024-obfuscatedtrail2.webp) I then discovered at the very last line, another base64 encoded text. It turned out to be an image, and this is what we’re looking for! Let’s just look for their website. ![FLAG: TMCTF{https://www.metacrawler.com/}](/static/img/writeups/tmctf2024/tmctf2024-obfuscatedtrail3.webp) Blank File 1 ============ Forensics We receive an empty Excel file. Let’s unpack it and see what’s it hiding ![FLAG: TMCTF{Bl4deRunn3r}](/static/img/writeups/tmctf2024/tmctf2024-blankfile1.webp) The flag is in plain sight, just formatted in XML. Packet Snatcher =============== Forensics We receive a Packet\_Snatcher.pcap file and our goal is to find the name of the image attached to the email. We fire up **Wireshark** to analyze the network traffic and immediately caught my attention was the unencrypted communication at a mail server, following the TCP stream we see this. ![Packet_Snatcher.pcap opened in Wireshark](/static/img/writeups/tmctf2024/tmctf2024-packetsnatcher.webp) I copied the base64 encoded content of **winmail.dat** and paste it on a website that turns it into a binary for us so we can recover the original file for further forensics. ![base64 data converted to binary](/static/img/writeups/tmctf2024/tmctf2024-packetsnatcher2.webp) The winmail.dat is in the format of _Transport Neutral Encapsulation Format_ which we can easily extract the contents using a tool using **tnef.** Immediately we see that **info-16.png** is an image attached within the email. ![FLAG: TMCTF{info-16.png}](/static/img/writeups/tmctf2024/tmctf2024-packetsnatcher3.webp) Mystery GUI =========== Reverse Engineering We receive a mysterious GUI binary named **MysteryGUI.exe**. It seems to be asking for a password, let’s open **Ghidra** and check the source code for any potential passwords. ![MysteryGUI.exe](/static/img/writeups/tmctf2024/tmctf2024-mysterygui.webp) In the list of functions, we see a CheckKey function which may be the mechanism behind this executable. ![CheckKey function](/static/img/writeups/tmctf2024/tmctf2024-mysterygui2.webp) We also find another function named xor\_decrypt which is a XOR cipher using the key 0xAA. This cipher is symmetrical, meaning we can decrypt either the password or flag using the same key. ![xor_decrypt function](/static/img/writeups/tmctf2024/tmctf2024-mysterygui3.webp) Since the flag gets decrypted by the executable if the correct password is supplied, let’s just manually decrypt the password since it’s also shorter. ![Password: Erw3n (nevermind the last 3 bytes)](/static/img/writeups/tmctf2024/tmctf2024-mysterygui4.webp) ![FLAG: TMCTF{N3ur0net}](/static/img/writeups/tmctf2024/tmctf2024-mysterygui5.webp) [=] Conclusion ================ Thanks for reading this far! Despite not winning this competition, I’m still thankful to Trend Micro Careers Philippines for letting us experience these kind of competitions. I also thank them for giving me permission to create and publish writeups of their competition. See you soon folks!:)