Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_custom_icon(self):
"""Test CustomIcon."""
self.setup()
icon_image = 'http://leafletjs.com/docs/images/leaf-green.png'
shadow_image = 'http://leafletjs.com/docs/images/leaf-shadow.png'
self.m = folium.Map([45, -100], zoom_start=4)
i = folium.features.CustomIcon(icon_image,
icon_size=(38, 95),
icon_anchor=(22, 94),
shadow_image=shadow_image,
shadow_size=(50, 64),
shadow_anchor=(4, 62),
popup_anchor=(-3, -76),)
mk = folium.Marker([45, -100], icon=i,
popup=folium.Popup('Hello'))
self.m.add_child(mk)
self.m._parent.render()
bounds = self.m.get_bounds()
assert bounds == [[45, -100], [45, -100]], bounds
folium.Marker([lat, long], icon=icon,
popup=popup).add_to(marker_cluster)
else:
folium.Marker([lat, long], icon=icon,
popup=popup).add_to(folium_map)
except Exception as e:
pass
repeats.append(str_coordinates)
if service == 'twitter':
twitter_icon = "https://cdn2.iconfinder.com/data/icons/metro-uinvert-dock/256/Twitter_NEW.png"
help = 0
for photo, coords in results.items():
icon = folium.features.CustomIcon(twitter_icon, icon_size=(35, 35)) # bug
try:
if coords in repeats:
if photo.startswith("https://"):
twitter_icon_green = "https://www.iconsdb.com/icons/preview/green/twitter-xxl.png"
icon = folium.features.CustomIcon(twitter_icon_green, icon_size=(35, 35)) # bug
html = '<img src="{}" style="width:100%; height:100%;">'.format(photo)
popup = folium.Popup(branca.element.IFrame(html=html, width=420, height=320), max_width=2137)
folium.Marker([coords[1], coords[0]], icon=icon,
popup=popup).add_to(marker_cluster)
else:
test = folium.Html(photo, script=False)
popup = folium.Popup(test, max_width=2650)
folium.Marker([coords[1], coords[0]], icon=icon,
pass
repeats.append(str_coordinates)
if service == 'twitter':
twitter_icon = "https://cdn2.iconfinder.com/data/icons/metro-uinvert-dock/256/Twitter_NEW.png"
help = 0
for photo, coords in results.items():
icon = folium.features.CustomIcon(twitter_icon, icon_size=(35, 35)) # bug
try:
if coords in repeats:
if photo.startswith("https://"):
twitter_icon_green = "https://www.iconsdb.com/icons/preview/green/twitter-xxl.png"
icon = folium.features.CustomIcon(twitter_icon_green, icon_size=(35, 35)) # bug
html = '<img src="{}" style="width:100%; height:100%;">'.format(photo)
popup = folium.Popup(branca.element.IFrame(html=html, width=420, height=320), max_width=2137)
folium.Marker([coords[1], coords[0]], icon=icon,
popup=popup).add_to(marker_cluster)
else:
test = folium.Html(photo, script=False)
popup = folium.Popup(test, max_width=2650)
folium.Marker([coords[1], coords[0]], icon=icon,
popup=popup).add_to(marker_cluster)
else:
if photo.startswith("https://"):
twitter_icon_green = "https://www.iconsdb.com/icons/preview/green/twitter-xxl.png"
icon = folium.features.CustomIcon(twitter_icon_green, icon_size=(35, 35)) # bug
if recursive:
if ip not in all_ips:
print("Checking " + ip)
details = get_host_info(ip)
str1 = ','.join(details['hostnames'])
popup_text = popup_text + "<br> Hostnames: " + str1 + "<br> "
str2 = ','.join(str(e) for e in details['ports'])
popup_text = popup_text + "Ports: " + str2
all_ips.append(ip)
popup = folium.Popup(popup_text, max_width=2137)
#Check if device returns 200 OK, i.e. if it's open
if "200 OK" not in printer['data']:
shodan_icon = folium.features.CustomIcon(closed_printer_icon, icon_size=(35, 35)) # bug
else:
shodan_icon = folium.features.CustomIcon(open_printer_icon, icon_size=(35, 35)) # bug
#if there is more than one device with the same coordinates, add it to cluster
if coordinates in repeats:
folium.Marker([printer['location']['latitude'], printer['location']['longitude']], icon=shodan_icon,
popup=popup).add_to(marker_cluster)
else:
folium.Marker([printer['location']['latitude'], printer['location']['longitude']], icon=shodan_icon,
popup=popup,
).add_to(folium_map)
repeats.append(coordinates) # make list of lists of coordinates
if service == 'camera':
closed_camera_icon = "https://www.iconsdb.com/icons/preview/red/security-camera-xxl.png"
if recursive:
if ip not in all_ips:
print("Checking " + ip)
details = get_host_info(ip)
str1 = ','.join(details['hostnames'])
popup_text = popup_text + "<br> Hostnames: " + str1 + "<br> "
str2 = ','.join(str(e) for e in details['ports'])
popup_text = popup_text + "Ports: " + str2
all_ips.append(ip)
popup = folium.Popup(popup_text, max_width=2137)
#Check if device returns 200 OK, i.e. if it's open
if "Connection Code: 0" not in device['data']:
shodan_icon = folium.features.CustomIcon(mqtt_closed_icon, icon_size=(35, 35)) # bug
else:
shodan_icon = folium.features.CustomIcon(mqtt_open_icon, icon_size=(35, 35)) # bug
#if there is more than one device with the same coordinates, add it to cluster
if coordinates in repeats:
folium.Marker([device['location']['latitude'], device['location']['longitude']], icon=shodan_icon,
popup=popup).add_to(marker_cluster)
else:
folium.Marker([device['location']['latitude'], device['location']['longitude']], icon=shodan_icon,
popup=popup,
).add_to(folium_map)
repeats.append(coordinates) # make list of lists of coordinates
if service == "printer":
popup_text = ip + "<br>" + str(distance_compare)[
0:5] + "" + unit + " from target" + "<br><a href="https://shodan.io/host/"">Lookup on Shodan</a>" + " <br> <a href="https://bgp.he.net/ip/""> Check ownership </a><br>"
if recursive:
print("Checking " + ip)
details = get_host_info(ip)
str1 = ','.join(details['hostnames'])
popup_text = popup_text + "<br> Hostnames: " + str1 + "<br> "
str2 = ','.join(str(e) for e in details['ports'])
popup_text = popup_text + "Ports: " + str2
all_ips.append(ip)
popup = folium.Popup(html=popup_text, max_width=2137)
if "200 OK" not in camera['data']:
shodan_icon = folium.features.CustomIcon(closed_rtsp_icon, icon_size=(35, 35)) # bug
else:
shodan_icon = folium.features.CustomIcon(open_rtsp_icon, icon_size=(35, 35)) # bug
if coordinates in repeats:
folium.Marker([camera['location']['latitude'], camera['location']['longitude']], icon=shodan_icon,
popup=popup).add_to(marker_cluster)
else:
folium.Marker([camera['location']['latitude'], camera['location']['longitude']], icon=shodan_icon,
popup=popup,
).add_to(folium_map)
repeats.append(coordinates)
if service == 'instagram':
insta_icon = "http://icons-for-free.com/free-icons/png/512/2329265.png"
for photo, coordinates in results.items():
org = printer['org']
version = printer['version']
popup_text = "<b>" + product + " " + version + "</b> <br>" + org + "<br>" + ip + ":" + str(
port) + "<br>" + ports_html + "<a href="http://maps.google.com/maps?q=&layer=c&cbll="+str(printer['location']['latitude'])+","+str(printer['location']['longitude'])"> Go for a walk</a>" + "<br><a href="https://shodan.io/host/"+ip">Shodan details</a>" + html
except:
popup_text = ip + ":" + str(
port) + "<br>" + ports_html + "<a href="http://maps.google.com/maps?q=&layer=c&cbll="+str(printer['location']['latitude'])+","+str(printer['location']['longitude'])"> Go for a walk</a>" + "<br><a href="https://shodan.io/host/"+ip">Shodan details</a>" + html
if "img" in html:
popup = folium.Popup(branca.element.IFrame(html=popup_text, width=450, height=500), max_width=2137)
else:
popup = folium.Popup(popup_text, max_width=2137)
shodan_icon = folium.features.CustomIcon(factory_icon, icon_size=(35, 35)) # bug
#if there is more than one device with the same coordinates, add it to cluster
if coordinates in repeats:
folium.Marker([printer['location']['latitude'], printer['location']['longitude']], icon=shodan_icon,
popup=popup).add_to(marker_cluster)
else:
folium.Marker([printer['location']['latitude'], printer['location']['longitude']], icon=shodan_icon,
popup=popup,
).add_to(folium_map)
repeats.append(coordinates)
# make list of lists of coordinates
for i in repeats:
if i not in unique_coordinates_ics:
unique_coordinates_ics.append(i)
if ip not in all_ips:
print("Checking " + ip)
details = get_host_info(ip)
str1 = ','.join(details['hostnames'])
popup_text = popup_text + "<br> Hostnames: " + str1 + "<br> "
str2 = ','.join(str(e) for e in details['ports'])
popup_text = popup_text + "Ports: " + str2
all_ips.append(ip)
popup = folium.Popup(html=popup_text, max_width=2137)
if "200 OK" not in camera['data']:
shodan_icon = folium.features.CustomIcon(closed_camera_icon, icon_size=(35, 35)) # bug
else:
shodan_icon = folium.features.CustomIcon(open_camera_icon, icon_size=(35, 35)) # bug
#Check if coordinates are repetitives and if camera has screenshot
if coordinates in repeats and has_screenshot ==1:
folium.Marker([camera['location']['latitude'], camera['location']['longitude']], icon=shodan_icon, popup=popup).add_to(marker_cluster)
elif coordinates in repeats and has_screenshot ==0:
folium.Marker([camera['location']['latitude'], camera['location']['longitude']],icon=shodan_icon,
popup=popup,
).add_to(marker_cluster)
elif coordinates not in repeats and has_screenshot ==1:
folium.Marker([camera['location']['latitude'], camera['location']['longitude']], icon=shodan_icon, popup=popup,
).add_to(folium_map)
else:
folium.Marker([camera['location']['latitude'], camera['location']['longitude']], icon=shodan_icon, popup=popup).add_to(folium_map)
repeats.append(coordinates) # make list of lists of coordinates
shodan_icon = folium.features.CustomIcon(open_rtsp_icon, icon_size=(35, 35)) # bug
if coordinates in repeats:
folium.Marker([camera['location']['latitude'], camera['location']['longitude']], icon=shodan_icon,
popup=popup).add_to(marker_cluster)
else:
folium.Marker([camera['location']['latitude'], camera['location']['longitude']], icon=shodan_icon,
popup=popup,
).add_to(folium_map)
repeats.append(coordinates)
if service == 'instagram':
insta_icon = "http://icons-for-free.com/free-icons/png/512/2329265.png"
for photo, coordinates in results.items():
icon = folium.features.CustomIcon(insta_icon, icon_size=(35, 35)) # bug
html = '<img src="{}" style="width:100%; height:100%;">'.format(str(photo))
popup = folium.Popup(branca.element.IFrame(html=html, width=420, height=320), max_width=2137)
if coordinates in repeats:
folium.Marker([coordinates[0], coordinates[1]], icon=icon,
popup=popup).add_to(marker_cluster)
else:
folium.Marker([coordinates[0], coordinates[1]], icon=icon,
popup=popup).add_to(folium_map)
repeats.append(coordinates)
if service == 'flickr':
flickr_icon = "http://www.myiconfinder.com/uploads/iconsets/f425a318030877cc09cb7832bea3e2c8.png"
for flickr_photo in results:
icon = folium.features.CustomIcon(flickr_icon, icon_size=(35, 35))