exiftool in CTF: extracting file metadata part 1

Depov

Moderator
Staff member
MODERATOR
ULTIMATE
SUPREME
PREMIUM
MEMBER
Joined
Feb 18, 2025
Messages
646
Reaction score
1,454
What metadata hide in CTF tasks

Metadata — file information embedded in the file itself. Depending on the format, they live in different containers, and each is a potential place for a flag.

EXIF (Exchangeable Image File Format) is the standard for JPEG, TIFF, RAW. Camera model, date of shooting, exposure parameters, GPS coordinates. According to a study by Forensic Value of Exif Data (SciEPublish, 2025), EXIF is automatically generated by the device and includes dozens of fields, some of which the average user never sees. These invisible fields (Comment, UserComment, Artist) become containers for flags.

XMP (Extensible Metadata Platform) – Adobe format, embedded in JPEG, PNG, PDF, PSD. Edit history, authorship, arbitrary user fields. XMP is an XML structure, and can be found even through strings by characteristic tag <x:xmpmeta>.

IPTC is used in photojournalism. Caption, Keywords, City fields are another level of metadata that CTF compilers sometimes use.

PDF Internal Metadata – PDF stores metadata in two locations: Info Dictionary (Author, Creator, Producer, CreationDate) and XMP stream inside objects. PDF itself is a container with numbered objects, each of which can contain embedded files, JavaScript or hidden data streams.

Office XML Properties – .docx, .xlsx, .pptx files are ZIP archives. Inside the XML file: docProps/core.xml (author, date, audit), docProps/app.xml (app, total editing time) and word/document.xml (text with history of edits). The real doll.

In forensic CTF tasks, metadata is used in three ways: a direct flag in the Comment/Artist/Copyright field; a hint for the next step (GPS-coordinates of the city or the author's name as a password to the archive); hidden data in non-standard fields - base64 line in MakerNote or custom XMP-tag. Trail of Bits CTF Field Guide explicitly says, “the easy initial analysis is to check on image file’s metadata fields with exiftool” – and it works more often than it seems.
Exiftool Installation and First Start

ExifTool is a cross-platform utility on Perl by Phil Harvey. Reads and writes metadata for hundreds of formats: JPEG, PNG, PDF, DOCX, MP4, executable files and dozens of others.

In Kali exiftool is pre-installed. On pure Ubuntu or Debian: sudo apt install libimage-exiftool-perl. On macOS: brew install exiftool. On Windows — standalone-exe from the official website exiftool.org. Check: exiftool -ver – version not lower than 12.x, otherwise some of the tags may not be read.

Basic launch: exiftool challenge.jpg. The utility displays all found tags in the format "NameTega : Value". The conclusion can take dozens of lines. For CTF, key fields are in order of priority:

Comment / User Comment is the most popular place for flags. Not an empty field - read carefully.
Artist / Author / Copyright – Organizers often write a hint or flag.
GPS Position / GPS Latitude / GPS Longitude – if the task asks “where?”, the coordinates will give the city. Filtering: exiftool -gps:all challenge.jpg.
Image Description / Title / Subject — text fields with arbitrary content.
Thumbnail Image – built-in thumbnail: exiftool -b -ThumbnailImage challenge.jpg > thumb.jpg. Sometimes the thumbnail contains a very different image – a classic CTF reception.
Warning – exiftool warnings indicate damaged or intentionally modified headlines. If the exiftool swears, dig deeper.

Extracting EXIF data from images: step-by-step disassembly

Typical CTF scenario: file received suspicious.jpg, we need to find the flag.

Step 1 – define the real format. Before you start exiftool, check: file suspicious.jpg. If the utility says JPEG image data The format coincides with the extension. If data – Extension lies. Team file relying on magic bytes: JPEG starts with FF D8 FF, PNG — with 89 50 4E 47, PDF — with 25 50 44 46. If file show “data” – see the first bytes manually through xxd suspicious.jpg | head -5 and compare with the signature table.

Step 2 – extract the metadata. Launch exiftool suspicious.jpg and study the conclusion:

ExifTool Version Number : 12.76
File Name : suspicious.jpg
File Size : 2.1 MB
MIME Type : image/jpeg
Camera Model Name : Canon EOS 5D Mark IV
GPS Latitude : 48 deg 51' 24.00" N
GPS Longitude : 2 deg 21' 7.00" E
Comment : flag{m3tadata_1s_th3_k3y}
User Comment : Check the thumbnail too

The flag lies right in the Comment field. GPS coordinates point to Paris – if the task asks for a city, the answer is obvious. User Comment hints: you need to check thumbnail.

Step 3 – extract the thumbnail. Team exiftool -b -ThumbnailImage suspicious.jpg > thumb.jpg saves the built-in thumbnail to a separate file. If you see another image when you open thumb.jpg, this is the second part of the task. Launch exiftool thumb.jpg for the analysis of metadata already the miniature itself.

Step 4 – non-standard fields. The flag may be hidden in less obvious tags. Use exiftool -G -s -u suspicious.jpg: flag -G adds a tag group, -s shows short names, -u includes unknown tags. The latter is critical: it outputs tags that exiftool did not recognize by name, but pulled out of the binary structure of the file.

Step 5 – GPS and geolocation. For exiftool location tasks, outputs coordinates in degree-minute-second format. To get a decimal format for Google Maps: exiftool -n -gps:all suspicious.jpg. Flag -n disables conversion and shows numerical values - copy directly to the card search bar.
Features of PNG

PNG does not formally support EXIF. But PNG stores metadata in text chanks: tEXt, zTXt (compressed), iTXt (Unicode). ExifTool reads them all. Modern phones and editors also introduce an XMP-block in PNG, which exiftool also parsits. If the exiftool on the PNG file shows an empty output, use strings challenge.png | grep -i flag as a backup option: PNG text chanks are visible through strings. This is how the “EXIF-Metadata” task is arranged on root-me: PNG file contains GPS Position and other attributes that are invisible in standard Windows properties, but are available through exiftool.
 
Top Bottom