-
Notifications
You must be signed in to change notification settings - Fork 7
/
googleapicheck
258 lines (233 loc) · 13.6 KB
/
googleapicheck
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#!/usr/bin/env python3
# usage: python3 googleapicheck or ./googleapicheck -api "APIKEY"
import requests
import warnings
import json
import sys
import os
def scan_gmaps(apikey):
vulnerable_apis = []
url = "https://www.googleapis.com/customsearch/v1?cx=017576662512468239146:omuauf_lfve&q=lectures&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("errors") < 0:
print("\033[1;32;40m vulnerable \033[0m for Custom Search API!")
print(url)
vulnerable_apis.append("customsearch || $5 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Custom Search API.")
# print("Reason: "+ str(response.json()["error"]["errors"][0]["message"]) + "\n")
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("\033[1;32;40m vulnerable \033[0m for Staticmap API!")
print(url)
vulnerable_apis.append("Staticmap || $2 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Staticmap API.")
# print("Reason: "+ str(response.content) + "\n")
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("\033[1;32;40m vulnerable \033[0m for Streetview API!")
print(url)
vulnerable_apis.append("Streetview || $7 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Streetview API.")
# print("Reason: "+ str(response.content) + "\n")
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("\033[1;32;40m vulnerable \033[0m for Directions API!")
print(url)
vulnerable_apis.append("Directions || $5 per 1000 requests")
vulnerable_apis.append("Directions (Advanced) || $10 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Directions API.")
# print("Reason: "+ response.json()["error_message"] + "\n")
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("\033[1;32;40m vulnerable \033[0m for Geocode API!")
print(url)
vulnerable_apis.append("Geocode || $5 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Geocode API.")
# print("Reason: "+ response.json()["error_message"] + "\n")
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("\033[1;32;40m vulnerable \033[0m for Distance Matrix API!")
print(url)
vulnerable_apis.append("Distance Matrix || $5 per 1000 elements")
vulnerable_apis.append("Distance Matrix (Advanced) || $10 per 1000 elements")
else:
print("\033[1;31;40m notvuln \033[0m for Distance Matrix API.")
# print("Reason: "+ response.json()["error_message"] + "\n")
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("\033[1;32;40m vulnerable \033[0m for Find Place From Text API!")
print(url)
vulnerable_apis.append("Find Place From Text || $17 per 1000 elements")
else:
print("\033[1;31;40m notvuln \033[0m for Find Place From Text API.")
# print("Reason: "+ response.json()["error_message"] + "\n")
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("\033[1;32;40m vulnerable \033[0m for Autocomplete API!")
print(url)
vulnerable_apis.append("Autocomplete || $2.83 per 1000 requests")
vulnerable_apis.append("Autocomplete Per Session || $17 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Autocomplete API.")
# print("Reason: "+ response.json()["error_message"] + "\n")
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("\033[1;32;40m vulnerable \033[0m for Elevation API!")
print(url)
vulnerable_apis.append("Elevation || $5 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Elevation API.")
# print("Reason: "+ response.json()["error_message"] + "\n")
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("\033[1;32;40m vulnerable \033[0m for Timezone API!")
print(url)
vulnerable_apis.append("Timezone || $5 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Timezone API.")
# print("Reason: "+ response.json()["errorMessage"] + "\n")
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("\033[1;32;40m vulnerable \033[0m for Nearest Roads API!")
print(url)
vulnerable_apis.append("Nearest Roads || $10 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Nearest Roads API.")
# print("Reason: "+ response.json()["error"]["message"] + "\n")
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("\033[1;32;40m vulnerable \033[0mfor Geolocation API!")
print("curl -i -s -k -X $'POST' -H $'Host: www.googleapis.com' -H $'Content-Length: 22' --data-binary $'{\"considerIp\": \"true\"}' $'"+url+"'")
vulnerable_apis.append("Geolocation || $5 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Geolocation API.")
# print("Reason: "+ response.json()["error"]["message"] + "\n")
url = "https://roads.googleapis.com/v1/snapToRoads?path=-35.27801,149.12958|-35.28032,149.12907&interpolate=true&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error") < 0:
print("\033[1;32;40m vulnerable \033[0m for Route to Traveled API!")
print(url)
vulnerable_apis.append("Route to Traveled || $10 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Route to Traveled API.")
# print("Reason: "+ response.json()["error"]["message"] + "\n")
url = "https://roads.googleapis.com/v1/speedLimits?path=38.75807927603043,-9.03741754643809&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error") < 0:
print("\033[1;32;40m vulnerable \033[0m for Speed Limit-Roads API!")
print(url)
vulnerable_apis.append("Speed Limit-Roads || $20 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Speed Limit-Roads API.")
# print("Reason: "+ response.json()["error"]["message"] + "\n")
url = "https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJN1t_tDeuEmsRUsoyG83frY4&fields=name,rating,formatted_phone_number&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error_message") < 0:
print("\033[1;32;40m vulnerable \033[0m for Place Details API!")
print(url)
vulnerable_apis.append("Place Details || $17 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Place Details API.")
# print("Reason: "+ response.json()["error_message"] + "\n")
url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=100&types=food&name=harbour&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error_message") < 0:
print("\033[1;32;40m vulnerable \033[0m for Nearby Search-Places API!")
print(url)
vulnerable_apis.append("Nearby Search-Places || $32 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Nearby Search-Places API.")
# print("Reason: "+ response.json()["error_message"] + "\n")
url = "https://maps.googleapis.com/maps/api/place/textsearch/json?query=restaurants+in+Sydney&key="+apikey
response = requests.get(url, verify=False)
if response.text.find("error_message") < 0:
print("\033[1;32;40m vulnerable \033[0m for Text Search-Places API!")
print(url)
vulnerable_apis.append("Text Search-Places || $32 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Text Search-Places API.")
# print("Reason: "+ response.json()["error_message"] + "\n")
url = "https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=CnRtAAAATLZNl354RwP_9UKbQ_5Psy40texXePv4oAlgP4qNEkdIrkyse7rPXYGd9D_Uj1rVsQdWT4oRz4QrYAJNpFX7rzqqMlZw2h2E2y5IKMUZ7ouD_SlcHxYq1yL4KbKUv3qtWgTK0A6QbGh87GB3sscrHRIQiG2RrmU_jF4tENr9wGS_YxoUSSDrYjWmrNfeEHSGSc3FyhNLlBU&key="+apikey
response = requests.get(url, verify=False, allow_redirects=False)
if response.status_code == 302:
print("\033[1;32;40m vulnerable \033[0m for Places Photo API!")
print(url)
vulnerable_apis.append("Places Photo || $7 per 1000 requests")
else:
print("\033[1;31;40m notvuln \033[0m for Places Photo API.")
# print("Reason: Verbose responses are not enabled for this API, cannot determine the reason.\n")
url = "https://playablelocations.googleapis.com/v3:samplePlayableLocations?key="+apikey
postdata = {'area_filter':{'s2_cell_id':7715420662885515264},'criteria':[{'gameObjectType':1,'filter':{'maxLocationCount':4,'includedTypes':['food_and_drink']},'fields_to_return': {'paths': ['name']}},{'gameObjectType':2,'filter':{'maxLocationCount':4},'fields_to_return': {'paths': ['types', 'snapped_point']}}]}
response = requests.post(url, data=postdata, verify=False)
if response.text.find("error") < 0:
print("\033[1;32;40m vulnerable \033[0mfor Playable Locations API!")
print("curl -i -s -k -X $'POST' -H $'Host: playablelocations.googleapis.com' -H $'Content-Length: 302' --data-binary $'{\"area_filter\":{\"s2_cell_id\":7715420662885515264},\"criteria\":[{\"gameObjectType\":1,\"filter\":{\"maxLocationCount\":4,\"includedTypes\":[\"food_and_drink\"]},\"fields_to_return\": {\"paths\": [\"name\"]}},{\"gameObjectType\":2,\"filter\":{\"maxLocationCount\":4},\"fields_to_return\": {\"paths\": [\"types\", \"snapped_point\"]}}]}' $'"+url+"'")
vulnerable_apis.append("Playable Locations || $10 per 1000 daily active users")
else:
print("\033[1;31;40m notvuln \033[0m for Playable Locations API.")
# print("Reason: "+ response.json()["error"]["message"] + "\n")
url = "https://fcm.googleapis.com/fcm/send"
postdata = "{'registration_ids':['ABC']}"
response = requests.post(url, data=postdata, verify=False, headers={'Content-Type':'application/json','Authorization':'key='+apikey})
if response.status_code == 200:
print("\033[1;32;40m vulnerable \033[0mfor FCM API!")
print("curl --header \"Authorization: key="+apikey+"\" --header Content-Type:\"application/json\" https://fcm.googleapis.com/fcm/send -d '{\"registration_ids\":[\"ABC\"]}'")
vulnerable_apis.append("FCM Takeover || https://abss.me/posts/fcm-takeover/")
else:
print("\033[1;31;40m notvuln \033[0m for FCM API.")
# for lines in response.iter_lines():
# if(("TITLE") in str(lines)):
# print("Reason: "+str(lines).split("TITLE")[1].split("<")[0].replace(">",""))
print("---------------------------------------------------------------------")
print(" Results || Cost Table/Reference to Exploit:")
print("---------------------------------------------------------------------")
for i in range (len(vulnerable_apis)):
print("- " + vulnerable_apis[i])
print("---------------------------------------------------------------------")
print("Reference for up-to-date pricing:")
print("https://cloud.google.com/maps-platform/pricing")
print("https://developers.google.com/maps/billing/gmp-billing")
warnings.filterwarnings("ignore")
banner = """ .-. _______
{}``; |==|_______D
/ (' /|\ Google API Key
( / | / | \ Checker
\(_)_]] / | \
github.com/abaykan
"""
if len(sys.argv) > 1:
if sys.argv[1] == "-api" or sys.argv[1] == "-a":
if len(sys.argv) > 2:
print(banner)
print("API Key: " + sys.argv[2] + "\n")
scan_gmaps(sys.argv[2])
else:
print("Missing api key, aborting.")
print("Either use -api as argument such \"python3 googleapicheck -api KEY\" or directly run script as \"python3 googleapicheck\" and supply API key via input.")
elif sys.argv[1] == "--help" or sys.argv[1] == "-h":
print("Either use -api as argument such \"python3 googleapicheck -api KEY\" or directly run script as \"python3 googleapicheck\" and supply API key via input.")
else:
print("Invalid arguments, aborting.")
print("Either use -api as argument such \"python3 googleapicheck -api KEY\" or directly run script as \"python3 googleapicheck\" and supply API key via input.")
else:
apikey = input("Please enter the Google API Key key you wanted to test: ")
print("\n" + banner)
print("API Key: " + apikey + "\n")
scan_gmaps(apikey)