-
Notifications
You must be signed in to change notification settings - Fork 9
/
metadata.py
69 lines (60 loc) · 1.9 KB
/
metadata.py
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
import webbrowser
from PIL import Image
from PIL.ExifTags import *
R = '\033[31m' # red
G = '\033[32m' # green
C = '\033[36m' # cyan
W = '\033[0m' # white
def get_exif(fn):
try:
ret = {}
print ( W + '[+]' + G + 'Checking the Metadata...' + '\n')
i = Image.open(fn)
info = i._getexif()
if str(info) == "None":
print(R+"Metadata is not Much Informative:")
return -1
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
ret[decoded] = value
return ret
except IOError:
print('')
print(R+"ERROR : File not found"+W)
exit()
def gps_analyzer():
img_path = input(C+"root@osint:"+W+"~/#Enter the image path to analyze : ")
a = get_exif(img_path)
if a==-1:
return
for x,y in a.items():
print("%s : %s" %(x, y))
if "GPSInfo" in a:
lat = [float(x) / float(y) for x, y in a['GPSInfo'][2]]
latref = a['GPSInfo'][1]
lon = [float(x) / float(y) for x, y in a['GPSInfo'][4]]
lonref = a['GPSInfo'][3]
lat = lat[0] + lat[1] / 60 + lat[2] / 3600
lon = lon[0] + lon[1] / 60 + lon[2] / 3600
if latref == 'S':
lat = -lat
if lonref == 'W':
lon = -lon
map_it(lat, lon)
else:
print('')
print("GPS location not found")
def map_it(lat, lon):
# Prints latitude and longitude values
print('')
print("Accurate Latitude : %s" % lat)
print("Accurate Longitude : %s" % lon)
print('')
# Creates the URL for the map using the latitude and longitude values
maps_url = "https://maps.google.com/maps?q=%s,+%s" % (lat, lon)
# Prompts the user to launch a web browser with the map
openWeb = input("Open GPS location in web broser? (Y/N) ")
if openWeb.upper() == 'Y':
webbrowser.open(maps_url, new=2)
def metadata():
gps_analyzer()