Path: blob/master/tutorials-and-examples/feature-tutorials/FoliumMap.ipynb
3253 views
Kernel: Python (condadev)
Title: msticpy - Folium Map Plotting
Introduction
This module contains a class that wraps the folium package to plot geo-location data.
Read the Folium documentation
You must have msticpy installed to run this notebook:
In [1]:
FoliumMap class
In [2]:
Out[2]:
The underlying folium map object is accessible as the folium_map attribute
In [3]:
Out[3]:
folium.folium.Map
Adding IP Entities to the map
In [4]:
Out[4]:
In [13]:
Out[13]:
In [14]:
Out[14]:
[IpAddress(Address=65.55.44.109, Location={ 'AdditionalData': {},
'City': 'Boydton',
'C...),
IpAddress(Address=13.71.172.128, Location={ 'AdditionalData': {},
'City': 'Toronto',
'...),
IpAddress(Address=13.71.172.130, Location={ 'AdditionalData': {},
'City': 'Toronto',
'...),
IpAddress(Address=40.124.45.19, Location={ 'AdditionalData': {},
'City': 'San Antonio',
...),
IpAddress(Address=104.43.212.12, Location={ 'AdditionalData': {},
'City': 'Des Moines',
...)]
In [15]:
Out[15]:
array([(36.6534, -78.375), (43.6644, -79.4195), (43.6644, -79.4195),
(29.4247, -98.4935), (41.6006, -93.6112), (41.1399, -104.8193),
(36.6534, -78.375), (43.6644, -79.4195), (38.7095, -78.1539),
(38.7095, -78.1539), (36.6534, -78.375), (47.6742, -122.1243),
(38.7095, -78.1539), (53.3338, -6.2488), (29.4247, -98.4935),
(41.6006, -93.6112), (41.6006, -93.6112), (41.6006, -93.6112),
(38.7095, -78.1539), (36.6534, -78.375), (36.6534, -78.375),
(37.3388, -121.8914), (37.3388, -121.8914), (38.7095, -78.1539),
(38.7095, -78.1539), (38.7095, -78.1539), (38.7095, -78.1539),
(38.7095, -78.1539), (38.7095, -78.1539), (38.7095, -78.1539),
(53.3338, -6.2488), (41.6006, -93.6112), (38.7095, -78.1539),
(38.7095, -78.1539), (38.7095, -78.1539), (36.6534, -78.375),
(38.7095, -78.1539), (41.6006, -93.6112), (41.6006, -93.6112),
(41.6006, -93.6112), (38.7095, -78.1539), (37.3388, -121.8914),
(37.3388, -121.8914), (38.7095, -78.1539), (41.6006, -93.6112),
(40.4953, -111.9439), (41.6006, -93.6112), (41.6006, -93.6112),
(36.6534, -78.375), (38.7095, -78.1539), (38.7095, -78.1539)],
dtype=object)
Plot IPAddress entities with location data
In [16]:
Out[16]:
Use different colors and icons
In [17]:
Out[17]:
Custom Icons
By default folium uses the information icon (i). Icons can be taken from the default Bootstrap set. See the default list here glyphicons
Alternatively you can use icons from the Font Awesome collection by adding prefx="fa" and icon="icon_name" to the call to add_ip_cluster or add_geo_cluster.
In [18]:
Out[18]:
Utility Functions
Calculate center point of entity locations
In [19]:
Out[19]:
(38.7095, -78.375)
(39.70266078431372, -85.0484019607843)
(40.15505, -78.26445)
(39.9247, -79.4195)
(39.9247, -79.4195)
Calculate distance between entity locations
In [27]:
Out[27]:
Distance between
{ 'AdditionalData': {},
'Address': '65.55.44.109',
'Location': { 'AdditionalData': {},
'City': 'Boydton',
'CountryCode': 'US',
'CountryName': 'United States',
'Latitude': 36.6534,
'Longitude': -78.375,
'State': 'Virginia',
'Type': 'geolocation',
'edges': set()},
'ThreatIntelligence': [],
'Type': 'ipaddress',
'edges': set()} { 'AdditionalData': {},
'Address': '13.71.172.128',
'Location': { 'AdditionalData': {},
'City': 'Toronto',
'CountryCode': 'CA',
'CountryName': 'Canada',
'Latitude': 43.6644,
'Longitude': -79.4195,
'State': 'Ontario',
'Type': 'geolocation',
'edges': set()},
'ThreatIntelligence': [],
'Type': 'ipaddress',
'edges': set()}
784.604908273247 km
Distance between
{ 'AdditionalData': {},
'Address': '65.55.44.109',
'Location': { 'AdditionalData': {},
'City': 'Boydton',
'CountryCode': 'US',
'CountryName': 'United States',
'Latitude': 36.6534,
'Longitude': -78.375,
'State': 'Virginia',
'Type': 'geolocation',
'edges': set()},
'ThreatIntelligence': [],
'Type': 'ipaddress',
'edges': set()} { 'AdditionalData': {},
'Address': '40.77.226.250',
'Location': { 'AdditionalData': {},
'City': 'Dublin',
'CountryCode': 'IE',
'CountryName': 'Ireland',
'Latitude': 53.3338,
'Longitude': -6.2488,
'State': 'Leinster',
'Type': 'geolocation',
'edges': set()},
'ThreatIntelligence': [],
'Type': 'ipaddress',
'edges': set()}
5699.044784950343 km