forked from ozguralp/gmapsapiscanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
maps_api_scanner.py
103 lines (90 loc) · 5.85 KB
/
maps_api_scanner.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import requests
import warnings
warnings.filterwarnings("ignore")
apikey = raw_input("Please enter the Google Maps API key you wanted to test: ")
url = "https://maps.googleapis.com/maps/api/staticmap?center=45%2C10&zoom=7&size=400x400&key="+apikey
response = requests.get(url, verify=False)
if response.status_code == 200:
print "API key is vulnerable for Staticmap API! Here is the PoC link which can be used directly via browser:"
print url
else:
print "API key is not vulnerable for Staticmap API."
url = "https://maps.googleapis.com/maps/api/streetview?size=400x400&location=40.720032,-73.988354&fov=90&heading=235&pitch=10&key="+apikey
response = requests.get(url, verify=False)
if response.status_code == 200:
print "API key is vulnerable for Streetview API! Here is the PoC link which can be used directly via browser:"
print url
else:
print "API key is not vulnerable for Streetview API."
url = "https://www.google.com/maps/embed/v1/place?q=place_id:ChIJyX7muQw8tokR2Vf5WBBk1iQ&key="+apikey
response = requests.get(url, verify=False)
if response.status_code == 200:
print "API key is vulnerable for Embed API! Here is the PoC HTML code which can be used directly via browser:"
print "<iframe width=\"600\" height=\"450\" frameborder=\"0\" style=\"border:0\" src=\""+url+"\" allowfullscreen></iframe>"
else:
print "API key is not vulnerable for Embed API."
url = "https://maps.googleapis.com/maps/api/directions/json?origin=Disneyland&destination=Universal+Studios+Hollywood4&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error_message") < 0:
print "API key is vulnerable for Directions API! Here is the PoC link which can be used directly via browser:"
print url
else:
print "API key is not vulnerable for Directions API."
url = "https://maps.googleapis.com/maps/api/geocode/json?latlng=40,30&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error_message") < 0:
print "API key is vulnerable for Geocode API! Here is the PoC link which can be used directly via browser:"
print url
else:
print "API key is not vulnerable for Geocode API."
url = "https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=40.6655101,-73.89188969999998&destinations=40.6905615%2C-73.9976592%7C40.6905615%2C-73.9976592%7C40.6905615%2C-73.9976592%7C40.6905615%2C-73.9976592%7C40.6905615%2C-73.9976592%7C40.6905615%2C-73.9976592%7C40.659569%2C-73.933783%7C40.729029%2C-73.851524%7C40.6860072%2C-73.6334271%7C40.598566%2C-73.7527626%7C40.659569%2C-73.933783%7C40.729029%2C-73.851524%7C40.6860072%2C-73.6334271%7C40.598566%2C-73.7527626&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error_message") < 0:
print "API key is vulnerable for Distance Matrix API! Here is the PoC link which can be used directly via browser:"
print url
else:
print "API key is not vulnerable for Distance Matrix API."
url = "https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Museum%20of%20Contemporary%20Art%20Australia&inputtype=textquery&fields=photos,formatted_address,name,rating,opening_hours,geometry&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error_message") < 0:
print "API key is vulnerable for Find Place From Text API! Here is the PoC link which can be used directly via browser:"
print url
else:
print "API key is not vulnerable for Find Place From Text API."
url = "https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Bingh&types=%28cities%29&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error_message") < 0:
print "API key is vulnerable for Autocomplete API! Here is the PoC link which can be used directly via browser:"
print url
else:
print "API key is not vulnerable for Autocomplete API."
url = "https://maps.googleapis.com/maps/api/elevation/json?locations=39.7391536,-104.9847034&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error_message") < 0:
print "API key is vulnerable for Elevation API! Here is the PoC link which can be used directly via browser:"
print url
else:
print "API key is not vulnerable for Elevation API."
url = "https://maps.googleapis.com/maps/api/timezone/json?location=39.6034810,-119.6822510×tamp=1331161200&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("errorMessage") < 0:
print "API key is vulnerable for Timezone API! Here is the PoC link which can be used directly via browser:"
print url
else:
print "API key is not vulnerable for Timezone API."
url = "https://roads.googleapis.com/v1/nearestRoads?points=60.170880,24.942795|60.170879,24.942796|60.170877,24.942796&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error") < 0:
print "API key is vulnerable for Roads API! Here is the PoC link which can be used directly via browser:"
print url
else:
print "API key is not vulnerable for Roads API."
url = "https://www.googleapis.com/geolocation/v1/geolocate?key="+apikey
postdata = {'considerIp': 'true'}
response = requests.post(url, data=postdata, verify=False)
if response.text.find("error") < 0:
print "API key is vulnerable for Geolocation API! Here is the PoC curl command which can be used from terminal:"
print "curl -i -s -k -X $'POST' -H $'Host: www.googleapis.com' -H $'Content-Length: 22' --data-binary $'{\"considerIp\": \"true\"}' $'"+url+"'"
else:
print "API key is not vulnerable for Geolocation API."
print "Because JavaScript API needs manual confirmation from a web browser, tests are not conducted for that API. If the script didn't found any vulnerable endpoints above, to be sure, manual checks can be conducted on this API. For that, go to https://developers.google.com/maps/documentation/javascript/tutorial URL, copy HTML code and change 'key' parameter with the one wanted to test. If loaded without errors on the browser, then it is vulnerable for JavaScript API."