forked from 0xInfection/TIDoS-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimgext.py
More file actions
93 lines (78 loc) · 2.89 KB
/
Copy pathimgext.py
File metadata and controls
93 lines (78 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#-:-:-:-:-:-:-:-:-:-:-:-:#
# TIDoS Framework #
#-:-:-:-:-:-:-:-:-:-:-:-:#
#Author: @_tID
#This module requires TIDoS Framework
#https://github.com/0xInfection/TIDoS-Framework
from __future__ import print_function
import time
import PIL.ExifTags
from PIL.ExifTags import TAGS, GPSTAGS
from PIL import Image
from core.Core.colors import *
from collections import namedtuple
import os
Header= namedtuple('Header',
"profile_size,cmm_type,version,device_class,colour_space,"
"PCS,date_time,signature,sig_platform,flags,dev_manufacturer,"
"dev_model,dev_attributes,intent,illuminant,sig_creator,"
"id"
)
def gps(exif):
gpsinfo = {}
if 'GPSInfo' in exif:
Nsec = exif['GPSInfo'][2][2][0] / float(exif['GPSInfo'][2][2][1])
Nmin = exif['GPSInfo'][2][1][0] / float(exif['GPSInfo'][2][1][1])
Ndeg = exif['GPSInfo'][2][0][0] / float(exif['GPSInfo'][2][0][1])
Wsec = exif['GPSInfo'][4][2][0] / float(exif['GPSInfo'][4][2][1])
Wmin = exif['GPSInfo'][4][1][0] / float(exif['GPSInfo'][4][1][1])
Wdeg = exif['GPSInfo'][4][0][0] / float(exif['GPSInfo'][4][0][1])
if exif['GPSInfo'][1] == 'N':
Nmult = 1
else:
Nmult = -1
if exif['GPSInfo'][1] == 'E':
Wmult = 1
else:
Wmult = -1
Lat = Nmult * (Ndeg + (Nmin + Nsec/60.0)/60.0)
Lng = Wmult * (Wdeg + (Wmin + Wsec/60.0)/60.0)
exif['GPSInfo'] = {"Lat" : Lat, "Lng" : Lng}
def exif1meta(image_path):
ret = {}
image = Image.open(image_path)
if hasattr(image, '_getexif'):
exifinfo = image._getexif()
if exifinfo is not None:
for tag, value in exifinfo.items():
decoded = TAGS.get(tag, tag)
ret[decoded] = value
gps(ret)
return ret
def exif3meta(image_path):
print(GR+'\n [*] Reading METADATA info...')
for tag, value in Image.open(image_path)._getexif().iteritems():
print(O+' [+] '+str(TAGS.get(tag))+' : '+C+str(value))
def imgext():
print(R+'\n =============================')
print(R+' I M A G E A N A L Y S I S')
print(R+' =============================\n')
name = raw_input(O+' [#] Enter path to image file :> ')
if os.path.exists(name):
print(GR+" [+] Metadata for file: %s " %(name))
try:
print(O+' [!] Extracting METADATA info...\n')
time.sleep(0.7)
exifData = {}
exif = exif1meta(name)
for metadata in exif:
print(G+" [+] "+str(metadata)+O+ " - Value :"+C+" %s " %(str(exif[metadata])))
time.sleep(0.1)
exif3meta(name)
except Exception as e:
print(R+' [-] Caught Exception : '+str(e))
else:
print(R+' [-] No such file/directory present...')
print(G+'\n [+] Forensic Image Analysis Done!\n')