Magnet Weekly CTF Challenge Week 5 Writeup a.k.a. Fun with Hadoop

Another week (and month) has gone and the Magnet Weekly CTF Challenge has entered week 5. As announced by the CTF organisers, Linux images prepared by Prof. Ali Hadi would be used for November's CTF challenges and they could be downloaded from here.

The first November challenge question is not a long one, yet still an interesting one:


It is worth mentioning that the Linux images (3 in total, 1 HDFS primary and 2 HDFS secondary nodes) came from a "Hadoop Distributed File System" (HDFS) environment. Since the phrase "Had-A-Loop" rhymes with "Hadoop", it would be a no-brainer to look at the HDFS first. 

Diving into the HDFS Storage

The HDFS primary node image was examined first. The Hadoop was installed under "/usr/local/hadoop/" directory and the HDFS data storage location was designated by the directory value in "dfs.datanode.data.dir" property in a "hdfs-site.xml", which could be found in the "/usr/local/hadoop/etc/hadoop" directory:



From this point, it was clear that the HDFS data was stored under the "/usr/local/hadoop/hadoop2_data/hdfs/datanode" directory. However, there was no data under the HDFS data node directory on the HDFS primary node image. Therefore, the HDFS secondary mode 1 image was examined to look for the HDFS data nodes.

Spotting the HDFS Data Node Block File


A file called "blk_1073741825" could be found under one of the subdirectories under the datanode location (/usr/local/hadoop/hadoop2_data/hdfs/datanode/current/BP-1479872265-192.168.2.100-1510165901692/current/finalized/subdir0/subdir0/). Judging from the filename, "blk_1073741825" should be the file stored at block 1073741825 on the HDFS. The contents of the "blk_1073741825" looked like a typical Linux Apt SourceList file, which was usually found as the "/etc/apt/sources.list" file. 

At this moment, the answer of this challenge seemed to be "sources.list".

Much to my surprise, it was not the case. So there must be something different about this file. Was the challenge asking for the full filepath (i.e. "/etc/apt/sources.list")? Unsurprisingly, it was also wrong. 

Getting Back on the Right Track

I decided to take a look at the Hadoop logs folder at "/usr/local/hadoop/logs", so the Hadoop logs folders from all 3 hosts were exported and a bit of grep magic (grep -r 1073741825 *) was used. A file referred as "/text/AptSource._COPYING_" was copied from HDFS primary node to HDFS secondary node 1 and was allocated on block 1073741825.


With the support of log lines, I am very certain the answer should be "AptSource._COPYING_" and eventually became the first person to crack this week's challenge. To be honest, even though there was no bonus point awarded for being the 1st solver, it was still an enjoyable and pleasant moment for myself.

Tying Up All Loose Ends

I was still curious about the "._COPYING_" file extension as I have never seen this kind of file extension. Then this Hadoop Issues page explained that the  "._COPYING_" file extension would be created when a file was copied from HDFS or local to another file system implementation. Perhaps the perfect answer should be "AptSource", after all.


Lessons Learnt

Observe, don't just see. What you see may not be the whole truth.


Coincidence?

Evernote featured in week 4 had an elephant on its logo, whereas Hadoop featured in week 5 also had an elephant on its logo. Perhaps there would be also an elephant on week 6?😎











Comments

Popular posts from this blog

Dumpster Diving in Google Photos Android App: "local_trash.db"

Hexordia Weekly CTF Challenge 2024 - Week 1 Writeup

An Android Casting (Device) Story: "cast.db"