1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

CpawCTF Q10.[Forensics] River - Exif情報を解析して撮影場所を特定する

Last updated at Posted at 2025-11-10

1. はじめに

デジタル機器で撮影した写真には、Exchangeable image file format ($=$ Exif) と呼ばれるメタデータが記録される。今回はこのデータを解析できる ExifTool を使用し、写真から撮影場所を特定する。最後に、CTF の問題を通してその手順を実際に確認する。

2. ExifTool の準備

解析に当たって使用するツール ExifTool を、次のサイトからダウンロードする。

3. 写真データの解析

3.1. 写真データの選定

SNSなどの写真には Exif データがないものも多い。そのため今回の解析にあたって、flickr の写真を利用した。

このページには、すでに撮影場所の情報が載っているが、解析で求めていく。この写真を Original サイズで保存する。

3.2. 解析

ここからは、写真データの解析を行う。

解析する写真を、ExifTool と同じ階層にいれる。

image.png
図3-2. ExifTool 実行ファイルと同じフォルダに写真を配置

このフォルダでコマンドプロンプトを立ち上げ、次のコマンドを入力する。

exiftool [写真の名前].jpg

その結果次のような情報が表示される。

ExifTool Version Number         : 13.41
File Name                       : sample.jpg
Directory                       : .
File Size                       : 3.1 MB
Zone Identifier                 : Exists
File Modification Date/Time     : 2025:11:11 04:19:01+09:00
File Access Date/Time           : 2025:11:11 04:27:23+09:00
File Creation Date/Time         : 2025:11:11 04:19:09+09:00
File Permissions                : -rw-rw-rw-
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
JFIF Version                    : 1.01
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone 14 Pro
Orientation                     : Horizontal (normal)
X Resolution                    : 72
Y Resolution                    : 72
Resolution Unit                 : inches
Software                        : 16.0.2
Modify Date                     : 2022:10:16 09:16:53
Artist                          : Richard J. Payette
Host Computer                   : iPhone 14 Pro
Y Cb Cr Positioning             : Centered
Copyright                       : 2022 Richard J. Payette
Exposure Time                   : 1/1639
F Number                        : 1.8
Exposure Program                : Program AE
ISO                             : 80
Exif Version                    : 0232
Date/Time Original              : 2022:10:16 09:16:53
Create Date                     : 2022:10:16 09:16:53
Offset Time                     : -04:00
Offset Time Original            : -04:00
Offset Time Digitized           : -04:00
Components Configuration        : Y, Cb, Cr, -
Shutter Speed Value             : 1/1639
Aperture Value                  : 1.8
Brightness Value                : 8.226688378
Exposure Compensation           : 0
Metering Mode                   : Multi-segment
Flash                           : Off, Did not fire
Focal Length                    : 6.9 mm
Subject Area                    : 2011 1508 2323 1330
Maker Note Version              : 14
Run Time Flags                  : Valid
Run Time Value                  : 397724880869083
Run Time Scale                  : 1000000000
Run Time Epoch                  : 0
AE Stable                       : Yes
AE Target                       : 177
AE Average                      : 179
AF Stable                       : Yes
Acceleration Vector             : -1.02300775 0.0248408541 -0.0527721755
Focus Distance Range            : 0.23 - 0.47 m
Image Capture Type              : Scene
Live Photo Video Index          : 5251076
Photos App Feature Flags        : 0
HDR Headroom                    : 1.591882348
AF Performance                  : 383 1 37
Signal To Noise Ratio           : 58.6270523
Photo Identifier                : AC72B0EB-2FC5-4C6B-8BEA-7194A7AAD878
Color Temperature               : 5535
Camera Type                     : Back Normal
Focus Position                  : 44
HDR Gain                        : 0
AF Measured Depth               : 530
AF Confidence                   : 0
Semantic Style                  : {_0=1,_1=0,_2=0,_3=0}
Sub Sec Time Original           : 771
Sub Sec Time Digitized          : 771
Flashpix Version                : 0100
Color Space                     : Uncalibrated
Exif Image Width                : 4032
Exif Image Height               : 3024
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Focal Length In 35mm Format     : 24 mm
Scene Capture Type              : Standard
Lens Info                       : 2.220000029-9mm f/1.779999971-2.8
Lens Make                       : Apple
Lens Model                      : iPhone 14 Pro back triple camera 6.86mm f/1.78
Composite Image                 : General Composite Image
Offset Schema                   : 4248
GPS Latitude Ref                : North
GPS Longitude Ref               : West
GPS Altitude Ref                : Above Sea Level
GPS Speed Ref                   : km/h
GPS Speed                       : 0
GPS Img Direction Ref           : True North
GPS Img Direction               : 296.5869751
GPS Dest Bearing Ref            : True North
GPS Dest Bearing                : 296.5869751
GPS Horizontal Positioning Error: 4.701163844 m
XP Author                       : Richard J. Payette
XP Keywords                     : iPhone 14 Pro;Coventry;outdoors;Autumn;bikepath
Padding                         : (Binary data 2060 bytes, use -b option to extract)
MPF Version                     : 0100
Number Of Images                : 2
MP Image Flags                  : (none)
MP Image Format                 : JPEG
MP Image Type                   : Undefined
MP Image Length                 : 293412
MP Image Start                  : 3127414
Dependent Image 1 Entry Number  : 0
Dependent Image 2 Entry Number  : 0
Profile CMM Type                : Apple Computer Inc.
Profile Version                 : 4.0.0
Profile Class                   : Display Device Profile
Color Space Data                : RGB
Profile Connection Space        : XYZ
Profile Date Time               : 2022:01:01 00:00:00
Profile File Signature          : acsp
Primary Platform                : Apple Computer Inc.
CMM Flags                       : Not Embedded, Independent
Device Manufacturer             : Apple Computer Inc.
Device Model                    :
Device Attributes               : Reflective, Glossy, Positive, Color
Rendering Intent                : Perceptual
Connection Space Illuminant     : 0.9642 1 0.82491
Profile Creator                 : Apple Computer Inc.
Profile ID                      : ecfda38e388547c36db4bd4f7ada182f
Profile Description             : Display P3
Profile Copyright               : Copyright Apple Inc., 2022
Media White Point               : 0.96419 1 0.82489
Red Matrix Column               : 0.51512 0.2412 -0.00105
Green Matrix Column             : 0.29198 0.69225 0.04189
Blue Matrix Column              : 0.1571 0.06657 0.78407
Red Tone Reproduction Curve     : (Binary data 32 bytes, use -b option to extract)
Chromatic Adaptation            : 1.04788 0.02292 -0.0502 0.02959 0.99048 -0.01706 -0.00923 0.01508 0.75168
Blue Tone Reproduction Curve    : (Binary data 32 bytes, use -b option to extract)
Green Tone Reproduction Curve   : (Binary data 32 bytes, use -b option to extract)
About                           : uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b
Creator                         : Richard J. Payette
Rights                          : 2022 Richard J. Payette
Subject                         : iPhone 14 Pro, Coventry, outdoors, Autumn, bikepath
Warning                         : [minor] Fixed incorrect URI for xmlns:MicrosoftPhoto [x2]
Last Keyword XMP                : iPhone 14 Pro, Coventry, outdoors, Autumn, bikepath
Image Width                     : 4032
Image Height                    : 2268
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)
Run Time Since Power Up         : 4 days 14:28:45
Aperture                        : 1.8
Image Size                      : 4032x2268
Megapixels                      : 9.1
Scale Factor To 35 mm Equivalent: 3.5
Shutter Speed                   : 1/1639
Create Date                     : 2022:10:16 09:16:53.771-04:00
Date/Time Original              : 2022:10:16 09:16:53.771-04:00
Modify Date                     : 2022:10:16 09:16:53-04:00
GPS Altitude                    : 79.5 m Above Sea Level
GPS Latitude                    : 41 deg 41' 59.62" N
GPS Longitude                   : 71 deg 35' 43.30" W
MP Image 2                      : (Binary data 293412 bytes, use -b option to extract)
Circle Of Confusion             : 0.009 mm
Field Of View                   : 73.7 deg
Focal Length                    : 6.9 mm (35 mm equivalent: 24.0 mm)
GPS Position                    : 41 deg 41' 59.62" N, 71 deg 35' 43.30" W
Hyperfocal Distance             : 3.08 m
Light Value                     : 12.7
Lens ID                         : iPhone 14 Pro back triple camera 6.86mm f/1.78

このうちGPSの情報を見てみると、次のようになっている。

GPS Altitude                    : 79.5 m Above Sea Level
GPS Latitude                    : 41 deg 41' 59.62" N
GPS Longitude                   : 71 deg 35' 43.30" W
GPS Position                    : 41 deg 41' 59.62" N, 71 deg 35' 43.30" W

この表記はDMS形式と呼ばれ、地理座標(緯度・経度)を表す3要素のうち、度、分、秒の単位に分けて表現している。それぞれの値は次のように読むことができる。

項目 説明
緯度 (Latitude) 北緯 41度41分59.62秒 41°41′59.62″ N
経度 (Longitude) 西経 71度35分43.30秒 71°35′43.30″ W

3.3. 座標の変換

Google Maps のような地図サービスでは、緯度経度を10進法で表す DEG 形式が一般的に使われているので、変換を行う。変換式は次の通り。

$$
DEG = 度 + \dfrac{分}{60} + \dfrac{秒}{3600}
$$

この式をPythonで実装すると、次のようになる。

def dms_to_deg(dms_str):
    parts = dms_str.split()
    
    nums = []
    
    for p in parts:
        num = ""
        
        for ch in p:
            if ch.isdigit() or ch == ".":
                num += ch
        
        if num:
            nums.append(float(num))
            
    d = nums[0] if len(nums) > 0 else 0
    m = nums[1] if len(nums) > 1 else 0
    s = nums[2] if len(nums) > 2 else 0
    
    sign = 1
    
    if 'S' in dms_str.upper() or 'W' in dms_str.upper():
        sign = -1
        
    return sign * (d + m / 60 + s / 3600)

このコードを使って、次のように実行する。

lat = dms_to_deg('41 deg 41\' 59.62" N')
lon = dms_to_deg('71 deg 35\' 43.30" W')
print(f"{lat:.4f}, {lon:.4f}")

出力は次のようになる。

41.6999, -71.5954

4. 解析結果の検証

4.1. Google Maps による位置確認

3章で求めた緯度と経度を Google Maps を使って検索すると次のような結果が得られる。

image.png
図4-1. Google Maps 上での表示結果(ロードアイランド州コベントリー付近)

この結果から、撮影場所は アメリカ合衆国ロードアイランド州コベントリー(Coventry, Rhode Island, USA) であることがわかる。

4.2. Flickr 情報との比較

これは、Flickr のページに記載されている撮影地情報と一致していることが確認できる。

image.png
図4-2. Flickr ページに記載された撮影地情報

以上より、Exif に含まれていた GPS 情報から正確に撮影地を特定することができた。

5. CTFの問題を解く

これまでの手法を使ったCTFの問題について解説する。

問題名: Q10. [Forensics] River
出典: CpawCTF 2016
問題文:JPEGという画像ファイルのフォーマットでは、撮影時の日時、使われたカメラ、位置情報など様々な情報(Exif情報)が付加されることがあるらしい。

この情報から、写真に写っている川の名前を特定して欲しい。
問題ファイル: river.jpg

5.1. コマンドの実行と結果

ここまでの説明した手順と同様に、写真ファイルを ExifTool と同じ階層に入れて、コマンドを実行する。

exiftool river.jpg

出力の一部を次に示す。

GPS Latitude                    : 31 deg 35' 2.76" N
GPS Longitude                   : 130 deg 32' 51.73" E
GPS Position                    : 31 deg 35' 2.76" N, 130 deg 32' 51.73" E

5.2. GPS情報の解析

得られたGPS情報を10進法(DEG形式)に変換する。

31.5841, 130.5477

これを Google Maps に入力して位置を確認する。

image.png
図5-2(a). Google Maps上での表示結果

さらに周辺を拡大すると、次のように川の名前が表示される。

image.png
図5-2(b). 表示された地名「甲突川」

以上より、写真に写っていた川の名前は甲突川であると特定することができる。

6. まとめ

本記事では、写真に埋め込まれた Exif 情報を解析し、GPS データから撮影地を特定する手法を示した。

7. 参考資料

[1]. CpawCTF Q10.[Forensics] River

[2]. DMS(度分秒)とDEG(度10進)表記

[3]. Google Maps

[4]. Flickr

[5]. Wikipedia: Exchangeable image file format

[6]. 写真に自動登録される「Exif情報」って何? 知っておくべき安全な使い方

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?