Ejemplo n.º 1
0
 def __init__(self, acc=False):
     self.geodir = os.path.join(get_data_path(), 'GeoIP')
     self.geoccfile = os.path.join(self.geodir, 'GeoLite2-City.mmdb')
     self.geoasnfile = os.path.join(self.geodir, 'GeoLite2-ASN.mmdb')
     self.geoccdb = geoip2.database.Reader(self.geoccfile)
     self.geoasndb = geoip2.database.Reader(self.geoasnfile)
     self.geo_asn_cache = DshellGeoIPCache(
         max_cache_size=self.MAX_CACHE_SIZE)
     self.geo_loc_cache = DshellGeoIPCache(
         max_cache_size=self.MAX_CACHE_SIZE)
     self.acc = acc
Ejemplo n.º 2
0
 def premodule(self):
     # Create a mapping of MAC address prefix to organization
     # http://standards-oui.ieee.org/oui.txt
     ouifilepath = os.path.join(get_data_path(), 'oui.txt')
     try:
         with open(ouifilepath, encoding="utf-8") as ouifile:
             for line in ouifile:
                 if "(hex)" not in line:
                     continue
                 line = line.strip().split(None, 2)
                 prefix = line[0].replace('-', ':')
                 org = line[2]
                 self.oui_map[prefix] = org
     except FileNotFoundError:
         # user probably did not download it
         # print warning and continue
         self.warn(
             "Could not find {} (see README). Will not be able to determine MAC organizations."
             .format(ouifilepath))
Ejemplo n.º 3
0
 def __init__(self, logger=logging.getLogger("dshellgeoip.py")):
     self.logger = logger
     self.geodir = os.path.join(get_data_path(), 'GeoIP')
     self.geoccdb = None
     self.geoasndb = None
Ejemplo n.º 4
0
 def __init__(self):
     self.geodir = os.path.join(get_data_path(), 'GeoIP')
     self.geoccdb = None
     self.geoasndb = None