-
Notifications
You must be signed in to change notification settings - Fork 6
/
scanners.py
605 lines (492 loc) · 20 KB
/
scanners.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
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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
import requests
def custom_search(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(
"API key is \033[1;31;40m vulnerable \033[0m for Custom Search API! Here is the PoC link which \
can be used directly via browser:"
)
print(url)
api = ("custom search", "5$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Custom Search API.")
print("Reason: " + str(response.json()["error"]["errors"][0]["message"]))
return vulnerable_apis
def static_map(apikey, vulnerable_apis):
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 \033[1;31;40m vulnerable \033[0m for Staticmap API! Here is the PoC link which \
can be used directly via browser:"
)
print(url)
api = ("static map", "2$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Staticmap API.")
print("Reason: " + str(response.content))
return vulnerable_apis
def street_view(apikey, vulnerable_apis):
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 \033[1;31;40m vulnerable \033[0m for Streetview API! Here is the PoC \
link which can be used directly via browser:"
)
print(url)
api = ("Streetview", "7$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Streetview API.")
print("Reason: " + str(response.content))
return vulnerable_apis
def embed_basic(apikey, vulnerable_apis):
url = "https://www.google.com/maps/embed/v1/place?q=Seattle&key=" + apikey
response = requests.get(url, verify=False)
if response.status_code == 200:
print(
"API key is \033[1;31;40m vulnerable \033[0m for Embed (Basic) 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>'
)
poc = (
'<iframe width="600" height="450" frameborder="0" style="border:0" src="'
+ url
+ '" allowfullscreen></iframe>'
)
api = ("embed basic", "Free", poc)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Embed (Basic) API.")
print("Reason: " + str(response.content))
return vulnerable_apis
def embed_advanced(apikey, vulnerable_apis):
url = (
"https://www.google.com/maps/embed/v1/search?q=record+stores+in+Seattle&key="
+ apikey
)
response = requests.get(url, verify=False)
if response.status_code == 200:
print(
"API key is \033[1;31;40m vulnerable \033[0m for Embed (Advanced) 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>'
)
poc = (
'<iframe width="600" height="450" frameborder="0" style="border:0" src="'
+ url
+ '" allowfullscreen></iframe>'
)
api = ("embed advanced", "Free", poc)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Embed (Advanced) API.")
if len(str(response.content).split('"')) < 77:
print("Reason: " + str(response.content))
else:
print("Reason: " + str(response.content).split('"')[77])
return vulnerable_apis
def directions(apikey, vulnerable_apis):
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 \033[1;31;40m vulnerable \033[0m for Directions API! Here is the PoC link which \
can be used directly via browser:"
)
print(url)
api1 = ("Directions", "5$/1000 reqs.", url)
api2 = ("Directions (Advanced)", "5$/1000 reqs.", url)
vulnerable_apis.append(api1)
vulnerable_apis.append(api2)
else:
print("API key is not vulnerable for Directions API.")
print("Reason: " + response.json()["error_message"])
return vulnerable_apis
def geocode(apikey, vulnerable_apis):
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 \033[1;31;40m vulnerable \033[0m for Geocode API! Here is the PoC link which \
can be used directly via browser:"
)
print(url)
api = ("Geocode", "5$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Geocode API.")
print("Reason: " + response.json()["error_message"])
return vulnerable_apis
def distance_matrix(apikey, vulnerable_apis):
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 \033[1;31;40m vulnerable \033[0m for Distance Matrix API! Here is the PoC link \
which can be used directly via browser:"
)
print(url)
api1 = ("Distance Matrix", "5$/1000 reqs.", url)
api2 = ("Distance Matrix (Advanced)", "10$/1000 reqs.", url)
vulnerable_apis.append(api1)
vulnerable_apis.append(api2)
else:
print("API key is not vulnerable for Distance Matrix API.")
print("Reason: " + response.json()["error_message"])
return vulnerable_apis
def find_place_from_text(apikey, vulnerable_apis):
url = (
"https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Museum%20of%20Contemp\
orary%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 \033[1;31;40m vulnerable \033[0m for Find Place From Text API! Here is the \
PoC link which can be used directly via browser:"
)
print(url)
api = ("Find place from text", "17$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Find Place From Text API.")
print("Reason: " + response.json()["error_message"])
return vulnerable_apis
def autocomplete(apikey, vulnerable_apis):
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 \033[1;31;40m vulnerable \033[0m for Autocomplete API! Here is the PoC link \
which can be used directly via browser:"
)
print(url)
api1 = ("Autocomplete", "2.83$/1000 reqs", url)
api2 = ("Autocomplete Per Session", "17$/1000 reqs", url)
vulnerable_apis.append(api1)
vulnerable_apis.append(api2)
else:
print("API key is not vulnerable for Autocomplete API.")
print("Reason: " + response.json()["error_message"])
return vulnerable_apis
def elevation(apikey, vulnerable_apis):
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 \033[1;31;40m vulnerable \033[0m for Elevation API! Here is the PoC link which \
can be used directly via browser:"
)
print(url)
api = ("Elevation", "5$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Elevation API.")
print("Reason: " + response.json()["error_message"])
return vulnerable_apis
def timezone(apikey, vulnerable_apis):
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 \033[1;31;40m vulnerable \033[0m for Timezone API! Here is the PoC link which \
can be used directly via browser:"
)
print(url)
api = ("Timezone", "5$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Timezone API.")
print("Reason: " + response.json()["errorMessage"])
return vulnerable_apis
def nearest_roads(apikey, vulnerable_apis):
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 \033[1;31;40m vulnerable \033[0m for Nearest Roads API! Here is the PoC link which \
can be used directly via browser:"
)
print(url)
api = ("Nearest roads", "10$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Nearest Roads API.")
print("Reason: " + response.json()["error"]["message"])
return vulnerable_apis
def geolocation(apikey, vulnerable_apis):
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 \033[1;31;40m vulnerable \033[0mfor Geolocation API! Here is the PoC curl command \
which can be used from terminal:"
)
poc = (
"curl -i -s -k -X $'POST' -H $'Host: www.googleapis.com' -H $'Content-Length: 22' --data-binary \
$'{\"considerIp\": \"true\"}' $'"
+ url
+ "'"
)
print(poc)
api = ("Geolocation", "5$/1000 reqs.", poc)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Geolocation API.")
print("Reason: " + response.json()["error"]["message"])
return vulnerable_apis
def route_to_traveled(apikey, vulnerable_apis):
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(
"API key is \033[1;31;40m vulnerable \033[0m for Route to Traveled API! Here is the PoC \
link which can be used directly via browser:"
)
print(url)
api = ("Route to traveled", "10$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Route to Traveled API.")
print("Reason: " + response.json()["error"]["message"])
return vulnerable_apis
def speed_limit_roads(apikey, vulnerable_apis):
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(
"API key is \033[1;31;40m vulnerable \033[0m for Speed Limit-Roads API! Here is the PoC \
link which can be used directly via browser:"
)
print(url)
api = ("Speed Limit Roads", "20$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Speed Limit-Roads API.")
print("Reason: " + response.json()["error"]["message"])
return vulnerable_apis
def place_details(apikey, vulnerable_apis):
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(
"API key is \033[1;31;40m vulnerable \033[0m for Place Details API! Here is the PoC \
link which can be used directly via browser:"
)
print(url)
api = ("Place Details", "17$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Place Details API.")
print("Reason: " + response.json()["error_message"])
return vulnerable_apis
def nearby_search_places(apikey, vulnerable_apis):
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(
"API key is \033[1;31;40m vulnerable \033[0m for Nearby Search-Places API! Here is the \
PoC link which can be used directly via browser:"
)
print(url)
api = ("Nearby Search Places", "32$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Nearby Search-Places API.")
print("Reason: " + response.json()["error_message"])
return vulnerable_apis
def text_search_places(apikey, vulnerable_apis):
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(
"API key is \033[1;31;40m vulnerable \033[0m for Text Search-Places API! Here is the PoC \
link which can be used directly via browser:"
)
print(url)
api = ("Text Search Places", "32$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Text Search-Places API.")
print("Reason: " + response.json()["error_message"])
return vulnerable_apis
def places_photo(apikey, vulnerable_apis):
url = (
"https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&photoreference=CnRtAAAATLZNl354RwP_\
9UKbQ_5Psy40texXePv4oAlgP4qNEkdIrkyse7rPXYGd9D_Uj1rVsQdWT4oRz4QrYAJNpFX7rzqqMlZw2h2E2y5IKMUZ7ouD_SlcHxYq1yL\
4KbKUv3qtWgTK0A6QbGh87GB3sscrHRIQiG2RrmU_jF4tENr9wGS_YxoUSSDrYjWmrNfeEHSGSc3FyhNLlBU&key="
+ apikey
)
response = requests.get(url, verify=False, allow_redirects=False)
if response.status_code == 302:
print(
"API key is \033[1;31;40m vulnerable \033[0m for Places Photo API! Here is the PoC link \
which can be used directly via browser:"
)
print(url)
api = ("Places Photo", "7$/1000 reqs.", url)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Places Photo API.")
print(
"Reason: Verbose responses are not enabled for this API, cannot determine the reason."
)
return vulnerable_apis
def playable_locations(apikey, vulnerable_apis):
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(
"API key is \033[1;31;40m vulnerable \033[0mfor Playable Locations API! Here is the \
PoC curl command which can be used from terminal:"
)
poc = (
'curl -i -s -k -X $\'POST\' -H $\'Host: playablelocations.googleapis.com\' \
-H $\'Content-Length: 302\' --data-binary $\'{"area_filter":{"s2_cell_id":77154206628855152\
64},"criteria":[{"gameObjectType":1,"filter":{"maxLocationCount":4,"includedTypes":["fo\
od_and_drink"]},"fields_to_return": {"paths": ["name"]}},{"gameObjectType":2,"filter":{"maxLoca\
tionCount":4},"fields_to_return": {"paths": ["types", "snapped_point"]}}]}\' $\''
+ url
+ "'"
)
print(poc)
api = ("Playable Locations", "10$/1000 daily active users", poc)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for Playable Locations API.")
print("Reason: " + response.json()["error"]["message"])
return vulnerable_apis
def fcm_takeover(apikey, vulnerable_apis):
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(
"API key is \033[1;31;40m vulnerable \033[0mfor FCM API! Here is the PoC curl \
command which can be used from terminal:"
)
poc = (
'curl --header "Authorization: key='
+ apikey
+ '" --header Content-Type:"application/json" https://fcm.googleapis.com/fc\
m/send -d \'{"registration_ids":["ABC"]}\''
)
print(poc)
api = ("FCM Takeover", "https://abss.me/posts/fcm-takeover/", poc)
vulnerable_apis.append(api)
else:
print("API key is not vulnerable for FCM API.")
for lines in response.iter_lines():
if ("TITLE") in str(lines):
print(
"Reason: "
+ str(lines).split("TITLE")[1].split("<")[0].replace(">", "")
)
return vulnerable_apis
def js_test(apikey):
f = open("jsapi_test.html", "w+")
f.write(
'<!DOCTYPE html><html><head><script src="https://maps.googleapis.com/maps/api/js?key='
+ apikey
+ '&callback=initMap&libraries=&v=weekly" defer></script><style type="text/cs\
s">#map{height:100%;}html,body{height:100%;margin:0;padding:0;}</style><script>let map;func\
tion initMap(){map=new google.maps.Map(document.getElementById("map"),{center:{lat:-34\
.397,lng:150.644},zoom:8,});}</script></head><body><div id="map"></div></body></html>'
)
f.close()
print(
"jsapi_test.html file is created for manual confirmation. Open it at your \
browser and observe whether the map is successfully loaded or not."
)
print(
"If you see 'Sorry! Something went wrong.' error on the page, it means \
that API key is not allowed to be used at JavaScript API."
)