repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
fakexif534 lines21.3 KiBraw download
#!/usr/bin/env zsh
#
# fakexif — strip real metadata from a file, stamp on a decoy location,
#           camera fingerprint and message, then rename it.
#
# Run with no flags and it does the North Korea default. Everything is
# overridable; -t Tag=Value writes any exiftool tag you like.

emulate -L zsh
setopt local_options pipe_fail extended_glob

VERSION="1.1.0"

# ---- rose pine ---------------------------------------------------------
if [[ -t 1 ]]; then
  r_love=$'\033[38;2;235;111;146m'; r_gold=$'\033[38;2;246;193;119m'
  r_rose=$'\033[38;2;235;188;186m'; r_pine=$'\033[38;2;49;116;143m'
  r_foam=$'\033[38;2;156;207;216m'; r_iris=$'\033[38;2;196;167;231m'
  r_mute=$'\033[38;2;110;106;134m'; r_off=$'\033[0m'; r_b=$'\033[1m'
else
  r_love=""; r_gold=""; r_rose=""; r_pine=""; r_foam=""; r_iris=""
  r_mute=""; r_off=""; r_b=""
fi

info() { print -r -- "${r_foam}::${r_off} $*" }
ok()   { print -r -- "${r_pine}ok${r_off} $*" }
warn() { print -r -- "${r_gold}!!${r_off} $*" }
die()  { print -r -u2 -- "${r_love}xx${r_off} $*"; exit 1 }

# ---- decoy locations ---------------------------------------------------
# lat|lon|place|city|country|category      (lat/lon signed decimal, WGS-84)
typeset -A PRESETS=(
  # --- DPRK ---
  camp14     "39.6109|126.0508|Kwan-li-so No. 14, Kaechon|Kaechon|North Korea|dprk"
  camp15     "39.6667|126.8500|Kwan-li-so No. 15, Yodok|Yodok|North Korea|dprk"
  camp16     "41.2667|129.3500|Kwan-li-so No. 16, Hwasong|Hwasong|North Korea|dprk"
  camp18     "39.5500|126.0500|Kyo-hwa-so No. 18, Bukchang|Bukchang|North Korea|dprk"
  camp22     "42.5667|129.8167|Kwan-li-so No. 22, Hoeryong|Hoeryong|North Korea|dprk"
  camp25     "41.8167|129.7667|Kwan-li-so No. 25, Chongjin|Chongjin|North Korea|dprk"
  pyongyang  "39.0392|125.7625|Pyongyang|Pyongyang|North Korea|dprk"
  ryugyong   "39.0364|125.7306|Ryugyong Hotel|Pyongyang|North Korea|dprk"
  panmunjom  "37.9558|126.6769|Joint Security Area, Panmunjom|Panmunjom|North Korea|dprk"

  # --- Gulag / Soviet ---
  kolyma     "62.0000|152.0000|Kolyma Highway, Road of Bones|Magadan Oblast|Russia|gulag"
  magadan    "59.5638|150.8035|Sevvostlag HQ, Magadan|Magadan|Russia|gulag"
  vorkuta    "67.4977|64.0570|Vorkutlag|Vorkuta|Russia|gulag"
  norilsk    "69.3558|88.1893|Norillag|Norilsk|Russia|gulag"
  solovki    "65.0245|35.7097|Solovki Special Camp (SLON)|Solovetsky Islands|Russia|gulag"
  perm36     "58.2686|57.4358|Perm-36 Corrective Labour Colony|Kuchino|Russia|gulag"
  belomor    "64.5333|34.7667|Belomorkanal Labour Camp|Povenets|Russia|gulag"
  kolyma2    "61.7500|147.9167|Butugychag Tin Mine|Magadan Oblast|Russia|gulag"
  karlag     "49.8022|72.9880|Karlag, Dolinka|Dolinka|Kazakhstan|gulag"
  alzhir     "51.0447|71.0272|ALZhIR Camp for Wives of Traitors|Akmol|Kazakhstan|gulag"
  steplag    "47.8000|67.7000|Steplag, Kengir|Kengir|Kazakhstan|gulag"
  butovo     "55.5378|37.5972|Butovo Firing Range|Moscow|Russia|gulag"
  lubyanka   "55.7606|37.6283|Lubyanka Building|Moscow|Russia|gulag"
  kremlin    "55.7520|37.6175|Moscow Kremlin|Moscow|Russia|gulag"

  # --- other detention sites ---
  gitmo      "19.9033|-75.0967|Camp Delta, Guantanamo Bay|Guantanamo Bay|Cuba|detention"
  dabancheng "43.3600|88.3100|Dabancheng Re-education Centre|Dabancheng|China|detention"
  alcatraz   "37.8270|-122.4230|Alcatraz Federal Penitentiary|San Francisco|United States|detention"
  robben     "-33.8067|18.3667|Robben Island Prison|Cape Town|South Africa|detention"
  supermax   "38.3597|-104.6989|ADX Florence|Florence|United States|detention"

  # --- exclusion zones / hazard ---
  chernobyl  "51.3890|30.0990|Chernobyl Nuclear Power Plant|Chernobyl|Ukraine|zone"
  pripyat    "51.4045|30.0542|Pripyat Exclusion Zone|Pripyat|Ukraine|zone"
  fukushima  "37.4211|141.0328|Fukushima Daiichi Exclusion Zone|Okuma|Japan|zone"
  bikini     "11.5860|165.3800|Bikini Atoll Test Site|Bikini Atoll|Marshall Islands|zone"
  semipalat  "50.4200|77.8100|Semipalatinsk Polygon|Kurchatov|Kazakhstan|zone"

  # --- classified / spook ---
  area51     "37.2350|-115.8111|Homey Airport, Groom Lake|Rachel|United States|spook"
  pentagon   "38.8719|-77.0563|The Pentagon|Arlington|United States|spook"
  langley    "38.9517|-77.1467|George Bush Center for Intelligence|Langley|United States|spook"
  gchq       "51.8994|-2.1244|GCHQ Doughnut|Cheltenham|United Kingdom|spook"
  whitehouse "38.8977|-77.0365|The White House|Washington|United States|spook"
  roswell    "33.3943|-104.5230|Roswell Crash Site|Roswell|United States|spook"

  # --- nowhere ---
  nullisland "0.0000|0.0000|Null Island|Null Island|Nowhere|nowhere"
  pointnemo  "-48.8767|-123.3933|Point Nemo, Oceanic Pole of Inaccessibility|Point Nemo|International Waters|nowhere"
  mariana    "11.3733|142.5917|Challenger Deep, Mariana Trench|Challenger Deep|International Waters|nowhere"
  southpole  "-90.0000|0.0000|Amundsen-Scott South Pole Station|South Pole|Antarctica|nowhere"
  northpole  "90.0000|0.0000|Geographic North Pole|North Pole|Arctic Ocean|nowhere"
  mcmurdo    "-77.8419|166.6863|McMurdo Station|Ross Island|Antarctica|nowhere"
  everest    "27.9881|86.9250|Mount Everest Summit|Solukhumbu|Nepal|nowhere"
  vatican    "41.9029|12.4534|Vatican City|Vatican City|Holy See|nowhere"
  lochness   "57.3229|-4.4244|Loch Ness|Drumnadrochit|United Kingdom|nowhere"
)

typeset -A CATEGORY_LABEL=(
  dprk      "north korea"
  gulag     "gulag / soviet"
  detention "detention sites"
  zone      "exclusion zones"
  spook     "classified"
  nowhere   "nowhere in particular"
)

# ---- camera fingerprints ------------------------------------------------
# make|model|lens|fnumber|exposure|iso|focal|software
typeset -A CAMERAS=(
  iphone15 "Apple|iPhone 15 Pro|iPhone 15 Pro back triple camera 6.765mm f/1.78|1.78|1/121|64|6.765|17.5.1"
  iphone12 "Apple|iPhone 12|iPhone 12 back dual wide camera 4.2mm f/1.6|1.6|1/60|32|4.2|14.8.1"
  pixel8   "Google|Pixel 8 Pro|Pixel 8 Pro back camera 6.9mm f/1.68|1.68|1/100|55|6.9|HDR+ 1.0.610245361"
  galaxy   "Samsung|SM-S928B|Samsung Galaxy S24 Ultra Rear Camera|1.7|1/120|50|6.3|S928BXXU1AXBB"
  canon    "Canon|Canon EOS 5D Mark IV|EF24-70mm f/2.8L II USM|2.8|1/250|400|50.0|Digital Photo Professional"
  nikon    "NIKON CORPORATION|NIKON D850|24.0-70.0 mm f/2.8|4.0|1/500|200|35.0|Ver.1.10"
  sony     "SONY|ILCE-7RM4|FE 24-105mm F4 G OSS|4.0|1/320|320|105.0|ILCE-7RM4 v2.00"
  gopro    "GoPro|HERO12 Black|GoPro Hero Lens|2.8|1/480|100|3.0|H23.01.02.32.00"
  dji      "DJI|FC3582|DJI Mini 3 Pro Camera|1.7|1/1000|100|6.7|01.00.0500"
  none     ""
)

# ---- defaults ----------------------------------------------------------
preset="camp14"
msg="cant dox me im in NKs labour camp"
camera="none"
artist="nobody"
copyright="nobody"
basename_out=""
outdir=""
altitude="120"
fakedate=""
tz_offset=""
custom_coords=""
custom_place=""
typeset -a extra_tags=()
keep_png=0
force_jpeg=0
keep_name=0
no_strip=0
strip_only=0
show_only=0
make_backup=0
dry_run=0
quiet=0
random_pick=""
jpeg_quality=92

usage() {
  cat <<EOF
${r_b}fakexif${r_off} ${r_mute}v${VERSION}${r_off} — strip real metadata, stamp a decoy, rename.

${r_b}usage${r_off}
  fakexif [options] <file> [file...]

${r_b}location${r_off}
  -c, --camp <key>       decoy preset (default: camp14)
  -r, --random [cat]     random preset, optionally from one category
  -g, --coords <la,lo>   explicit signed decimal coords, overrides preset
  -P, --place <text>     override the place label written to XMP/IPTC
  -a, --alt <metres>     GPS altitude (default: 120)
  -l, --list [cat]       list presets and exit

${r_b}content${r_off}
  -m, --msg <text>       message written to every comment field
  -C, --camera <key>     fake camera fingerprint (default: none)
      --artist <name>    Artist / Creator     (default: nobody)
      --copyright <txt>  Copyright            (default: nobody)
  -d, --date <ts>        "YYYY:MM:DD HH:MM:SS" (default: now, local to decoy)
  -t, --tag Tag=Value    write any exiftool tag; repeatable, wins over presets
      --cameras          list camera fingerprints and exit

${r_b}output${r_off}
  -n, --name <base>      output basename, no extension
  -k, --keep-name        do not rename, keep the original filename
  -o, --out <dir>        output directory (default: alongside input)
  -b, --backup           keep a .orig copy of the untouched input
  -j, --jpeg             force convert to JPEG (best GPS support)
  -p, --png              keep PNG as PNG (XMP only, many viewers ignore it)
  -q, --quality <1-100>  JPEG quality when converting (default: 92)

${r_b}modes${r_off}
  -s, --strip            strip metadata only, write nothing
  -A, --no-strip         overlay the decoy, keep existing metadata
  -S, --show             print the metadata of each file and exit
  -N, --dry-run          say what would happen, touch nothing
  -Q, --quiet            only print the final path per file
  -h, --help             this text
  -V, --version          version

${r_b}examples${r_off}
  fakexif photo.jpg                        # NK labour camp default
  fakexif -r gulag -C iphone15 *.jpg       # random gulag, iPhone fingerprint
  fakexif -c area51 -m "nice try" pic.png
  fakexif -g 51.5074,-0.1278 -P "London" -t Rating=5 pic.jpg
  fakexif -s -k leak.jpg                   # scrub only, keep the name
EOF
}

list_presets() {
  local filter="${1:-}" cat key
  print -r -- "${r_b}${r_iris}decoy locations${r_off}"
  for cat in dprk gulag detention zone spook nowhere; do
    [[ -n "$filter" && "$filter" != "$cat" ]] && continue
    print
    print -r -- "  ${r_b}${r_gold}${CATEGORY_LABEL[$cat]}${r_off} ${r_mute}(${cat})${r_off}"
    for key in ${(ko)PRESETS}; do
      local -a f; f=("${(@s:|:)PRESETS[$key]}")
      [[ "${f[6]}" == "$cat" ]] || continue
      printf "    ${r_foam}%-11s${r_off} %-46s ${r_mute}%s, %s${r_off}\n" \
        "$key" "${f[3]}" "${f[1]}" "${f[2]}"
    done
  done
}

list_cameras() {
  local key
  print -r -- "${r_b}${r_iris}camera fingerprints${r_off}"
  for key in ${(ko)CAMERAS}; do
    local -a f; f=("${(@s:|:)CAMERAS[$key]}")
    if [[ -z "${f[1]:-}" ]]; then
      printf "  ${r_foam}%-9s${r_off} ${r_mute}no camera tags written${r_off}\n" "$key"
    else
      printf "  ${r_foam}%-9s${r_off} %s %s\n" "$key" "${f[1]}" "${f[2]}"
    fi
  done
}

# ---- args --------------------------------------------------------------
while (( $# )); do
  case "$1" in
    -c|--camp|--preset) preset="${2:?-c needs a value}"; shift 2 ;;
    -r|--random)
      if [[ -n "${2:-}" && "$2" != -* && -n "${CATEGORY_LABEL[${2:-x}]:-}" ]]; then
        random_pick="$2"; shift 2
      else
        random_pick="any"; shift
      fi ;;
    -g|--coords) custom_coords="${2:?-g needs lat,lon}"; shift 2 ;;
    -P|--place)  custom_place="${2:?-P needs a value}"; shift 2 ;;
    -a|--alt)    altitude="${2:?-a needs a value}"; shift 2 ;;
    -l|--list)
      if [[ -n "${2:-}" && "$2" != -* ]]; then list_presets "$2"; else list_presets; fi
      exit 0 ;;
    -m|--msg)    msg="${2:?-m needs a value}"; shift 2 ;;
    -C|--camera) camera="${2:?-C needs a value}"; shift 2 ;;
    --artist)    artist="${2:?--artist needs a value}"; shift 2 ;;
    --copyright) copyright="${2:?--copyright needs a value}"; shift 2 ;;
    -d|--date)   fakedate="${2:?-d needs a value}"; shift 2 ;;
    -t|--tag)    extra_tags+=("-${2:?-t needs Tag=Value}"); shift 2 ;;
    --cameras)   list_cameras; exit 0 ;;
    -n|--name)   basename_out="${2:?-n needs a value}"; shift 2 ;;
    -k|--keep-name) keep_name=1; shift ;;
    -o|--out)    outdir="${2:?-o needs a value}"; shift 2 ;;
    -b|--backup) make_backup=1; shift ;;
    -j|--jpeg)   force_jpeg=1; shift ;;
    -p|--png)    keep_png=1; shift ;;
    -q|--quality) jpeg_quality="${2:?-q needs a value}"; shift 2 ;;
    -s|--strip)  strip_only=1; shift ;;
    -A|--no-strip) no_strip=1; shift ;;
    -S|--show)   show_only=1; shift ;;
    -N|--dry-run) dry_run=1; shift ;;
    -Q|--quiet)  quiet=1; shift ;;
    -h|--help)   usage; exit 0 ;;
    -V|--version) print -r -- "fakexif $VERSION"; exit 0 ;;
    --) shift; break ;;
    -*) die "unknown option: $1  ${r_mute}(-h for help)${r_off}" ;;
    *)  break ;;
  esac
done

(( $# )) || { usage; exit 1 }
command -v exiftool >/dev/null \
  || die "exiftool not found. brew install exiftool"

# ---- show mode ---------------------------------------------------------
if (( show_only )); then
  for f in "$@"; do
    [[ -f "$f" ]] || { warn "not a file: $f"; continue }
    print -r -- "${r_b}${r_iris}${f}${r_off}"
    exiftool -G -a -s -- "$f"
    print
  done
  exit 0
fi

# ---- resolve the decoy -------------------------------------------------
if [[ -n "$random_pick" ]]; then
  typeset -a pool=()
  typeset -a rf
  for key in ${(ko)PRESETS}; do
    rf=("${(@s:|:)PRESETS[$key]}")
    [[ "$random_pick" == "any" || "${rf[6]}" == "$random_pick" ]] && pool+=("$key")
  done
  (( ${#pool} )) || die "no presets in category '${random_pick}'"
  preset="${pool[$(( RANDOM % ${#pool} + 1 ))]}"
fi

[[ -n "${PRESETS[$preset]:-}" ]] || {
  warn "unknown preset '${preset}'"; list_presets; exit 1
}
typeset -a pf; pf=("${(@s:|:)PRESETS[$preset]}")
lat="${pf[1]}"; lon="${pf[2]}"; place="${pf[3]}"; city="${pf[4]}"; country="${pf[5]}"

if [[ -n "$custom_coords" ]]; then
  [[ "$custom_coords" == *,* ]] || die "-g wants lat,lon (e.g. 51.5074,-0.1278)"
  lat="${custom_coords%%,*}"; lon="${custom_coords##*,}"
  lat="${lat// /}"; lon="${lon// /}"
  [[ "$lat" == <->(.<->)# || "$lat" == -<->(.<->)# ]] || die "bad latitude: $lat"
  [[ "$lon" == <->(.<->)# || "$lon" == -<->(.<->)# ]] || die "bad longitude: $lon"
  # explicit coords mean the preset's place labels no longer apply
  place="${custom_place:-${lat}, ${lon}}"; city=""; country=""
fi
[[ -n "$custom_place" ]] && place="$custom_place"

# hemisphere refs from the sign, so preset entries can never disagree
latref="N"; [[ "$lat" == -* ]] && { latref="S"; lat="${lat#-}" }
lonref="E"; [[ "$lon" == -* ]] && { lonref="W"; lon="${lon#-}" }

[[ -n "${CAMERAS[$camera]:-}" || "$camera" == none ]] \
  || { warn "unknown camera '${camera}'"; list_cameras; exit 1 }

# ---- timestamp ---------------------------------------------------------
# pick a plausible local zone for the decoy so the offset matches the place
typeset -A ZONES=(
  "North Korea"      "Asia/Pyongyang"
  "Russia"           "Europe/Moscow"
  "Kazakhstan"       "Asia/Almaty"
  "China"            "Asia/Shanghai"
  "Ukraine"          "Europe/Kyiv"
  "Japan"            "Asia/Tokyo"
  "Cuba"             "America/Havana"
  "United States"    "America/New_York"
  "United Kingdom"   "Europe/London"
  "South Africa"     "Africa/Johannesburg"
  "Nepal"            "Asia/Kathmandu"
  "Holy See"         "Europe/Rome"
  "Marshall Islands" "Pacific/Majuro"
  "Antarctica"       "Pacific/Auckland"
)
zone="${ZONES[$country]:-UTC}"
[[ -n "$fakedate" ]] || fakedate="$(TZ="$zone" date '+%Y:%m:%d %H:%M:%S')"
[[ "$fakedate" == <->:<->:<->" "<->:<->:<-> ]] \
  || die "-d wants \"YYYY:MM:DD HH:MM:SS\", got \"$fakedate\""
tz_offset="$(TZ="$zone" date '+%z')"
tz_offset="${tz_offset[1,3]}:${tz_offset[4,5]}"
stamp="${fakedate}${tz_offset}"
gps_date="${fakedate%% *}"
gps_time="${fakedate##* }"

# ---- banner ------------------------------------------------------------
if (( ! quiet )); then
  if (( strip_only )); then
    info "mode     ${r_rose}strip only, no decoy written${r_off}"
  else
    info "decoy    ${r_rose}${place}${r_off} ${r_mute}(${preset})${r_off}"
    info "coords   ${r_rose}${lat} ${latref}, ${lon} ${lonref}${r_off}"
    info "message  ${r_rose}${msg}${r_off}"
    info "taken    ${r_rose}${stamp}${r_off} ${r_mute}${zone}${r_off}"
    [[ "$camera" != none ]] && {
      typeset -a cm; cm=("${(@s:|:)CAMERAS[$camera]}")
      info "camera   ${r_rose}${cm[1]} ${cm[2]}${r_off}"
    }
    (( ${#extra_tags} )) && info "extra    ${r_rose}${${extra_tags[@]#-}}${r_off}"
  fi
  (( dry_run )) && warn "dry run, nothing will be written"
  print
fi

# imagemagick: v7 ships 'magick', v6 ships 'convert'
converter=""
command -v magick  >/dev/null && converter="magick"
[[ -z "$converter" ]] && command -v convert >/dev/null && converter="convert"

# exiftool wrapper: surface stderr only when the call actually fails
run_et() {
  local out rc
  out="$(exiftool "$@" 2>&1)"; rc=$?
  (( rc == 0 )) || { warn "exiftool: ${out}" }
  return $rc
}

idx=0; failed=0
for src in "$@"; do
  [[ -f "$src" ]] || { warn "skipping, not a file: ${src}"; continue }
  (( ++idx ))

  ext="${src:e:l}"
  dest_dir="${outdir:-${src:h}}"
  is_video=0
  [[ "$ext" == (mp4|mov|m4v|avi|mkv) ]] && is_video=1

  # target extension: PNG becomes JPEG unless told otherwise, since PNG has
  # no native EXIF block and most readers ignore the eXIf chunk.
  tgt_ext="$ext"
  if (( force_jpeg )) && (( ! is_video )); then
    tgt_ext="jpg"
  elif [[ "$ext" == png ]] && (( ! keep_png )); then
    tgt_ext="jpg"
  fi

  # target name
  if (( keep_name )); then
    stem="${src:t:r}"
  elif [[ -n "$basename_out" ]]; then
    stem="$basename_out"; (( $# > 1 )) && stem="${stem}-${idx}"
  elif (( strip_only )); then
    stem="${src:t:r}"
  else
    dnum="${fakedate//[: ]/}"
    stem="${preset}-${dnum[1,8]}-${dnum[9,14]}"
    (( $# > 1 )) && stem="${stem}-${idx}"
  fi

  # -ef compares inodes, so "./x.jpg" and "x.jpg" count as the same file and
  # an in-place edit does not get suffixed into x-1.jpg
  out="${dest_dir}/${stem}.${tgt_ext}"
  n=1
  while [[ -e "$out" ]] && [[ ! "$out" -ef "$src" ]]; do
    out="${dest_dir}/${stem}-${n}.${tgt_ext}"; (( ++n ))
  done

  (( quiet )) || info "${r_b}${src:t}${r_off} ${r_mute}->${r_off} ${r_b}${out:t}${r_off}"

  if (( dry_run )); then
    ok "${out}  ${r_mute}(dry run)${r_off}"
    continue
  fi

  [[ -d "$dest_dir" ]] || mkdir -p "$dest_dir" || { (( ++failed )); continue }
  (( make_backup )) && cp -- "$src" "${src}.orig" && \
    { (( quiet )) || info "  backup ${r_mute}${src:t}.orig${r_off}" }

  # 1. materialise the output. converting re-encodes, which drops every
  #    original chunk including any thumbnail carrying the real GPS.
  if [[ "$ext" != "$tgt_ext" ]]; then
    [[ -n "$converter" ]] || {
      warn "need imagemagick to convert ${ext}->${tgt_ext} (brew install imagemagick), or pass -p"
      (( ++failed )); continue
    }
    "$converter" "$src" -quality "$jpeg_quality" -strip "$out" || {
      warn "convert failed: ${src}"; (( ++failed )); continue
    }
  elif [[ ! "$out" -ef "$src" ]]; then
    cp -- "$src" "$out" || { (( ++failed )); continue }
  fi

  # 2. scrub whatever survived
  if (( ! no_strip )); then
    run_et -all= -overwrite_original -q -m -- "$out" || (( ++failed ))
  fi

  if (( strip_only )); then
    ok "${out}"
    (( quiet )) || print
    continue
  fi

  # 3. build the decoy tag set
  typeset -a tags=(
    -GPSLatitude="$lat"   -GPSLatitudeRef="$latref"
    -GPSLongitude="$lon"  -GPSLongitudeRef="$lonref"
    -GPSAltitude="$altitude" -GPSAltitudeRef="Above Sea Level"
    -GPSMapDatum="WGS-84" -GPSProcessingMethod="GPS"
    -GPSDateStamp="$gps_date" -GPSTimeStamp="$gps_time"
    -XMP:GPSLatitude="$lat"  -XMP:GPSLongitude="$lon"
    -XMP:GPSAltitude="$altitude"
    -XMP:Location="$place"
    -XMP-photoshop:City="$city" -XMP-photoshop:Country="$country"
    -XMP-iptcExt:LocationCreatedSublocation="$place"
    -XMP-iptcExt:LocationCreatedCity="$city"
    -XMP-iptcExt:LocationCreatedCountryName="$country"
    -IPTC:Sub-location="$place"
    -IPTC:City="$city"
    -IPTC:Country-PrimaryLocationName="$country"
    -ImageDescription="$msg" -UserComment="$msg"
    -XMP:Description="$msg"  -XMP:Title="$msg"
    -IPTC:Caption-Abstract="$msg"
    -Artist="$artist" -XMP:Creator="$artist"
    -Copyright="$copyright" -XMP:Rights="$copyright"
    -AllDates="$fakedate"
    -XMP:CreateDate="$fakedate" -XMP:ModifyDate="$fakedate"
  )

  # video carries GPS in the QuickTime atom instead
  if (( is_video )); then
    vsign_lat="$lat"; [[ "$latref" == S ]] && vsign_lat="-$lat"
    vsign_lon="$lon"; [[ "$lonref" == W ]] && vsign_lon="-$lon"
    tags+=( -QuickTime:GPSCoordinates="${vsign_lat}, ${vsign_lon}, ${altitude}" )
    tags+=( -Keys:GPSCoordinates="${vsign_lat}, ${vsign_lon}, ${altitude}" )
  fi

  # camera fingerprint. a photo with no Make/Model at all reads as scrubbed,
  # so a coherent fake body is more convincing than "Unknown".
  if [[ "$camera" != none ]]; then
    typeset -a cm; cm=("${(@s:|:)CAMERAS[$camera]}")
    tags+=(
      -Make="${cm[1]}" -Model="${cm[2]}" -LensModel="${cm[3]}"
      -FNumber="${cm[4]}" -ExposureTime="${cm[5]}" -ISO="${cm[6]}"
      -FocalLength="${cm[7]}" -Software="${cm[8]}"
      -XMP:Make="${cm[1]}" -XMP:Model="${cm[2]}"
    )
  fi

  # user tags last so -t always wins
  (( ${#extra_tags} )) && tags+=("${extra_tags[@]}")

  run_et -q -m -overwrite_original "${tags[@]}" -- "$out" || (( ++failed ))

  # 4. filesystem timestamps leak just as loudly as EXIF.
  #    FileCreateDate is macOS/Windows only, so a Linux failure is expected.
  run_et -q -m -overwrite_original -FileModifyDate="$stamp" -- "$out" || true
  exiftool -q -m -overwrite_original -FileCreateDate="$stamp" -- "$out" &>/dev/null || true

  if (( quiet )); then
    print -r -- "$out"
  else
    ok "${out}"
    exiftool -q -s -f -GPSPosition -XMP:Location -ImageDescription -- "$out" 2>/dev/null \
      | while IFS= read -r line; do print -r -- "    ${r_mute}${line}${r_off}"; done
    print
  fi
done

if (( quiet )); then
  exit $(( failed > 0 ))
fi

if (( failed )); then
  warn "${failed} file(s) hit errors"
else
  print -r -- "${r_iris}done.${r_off} ${r_mute}inspect with: exiftool -G -a -s <file>${r_off}"
fi

if [[ "$tgt_ext" == png ]] && (( ! strip_only )); then
  warn "PNG kept: GPS lives in XMP only, many viewers will not show it. -j converts to JPEG."
fi

exit $(( failed > 0 ))