PyMISP/pymisp/tools/urlobject.py

27 lines
747 B
Python
Raw Permalink Normal View History

2019-12-04 15:18:27 +01:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from .abstractgenerator import AbstractMISPObjectGenerator
import logging
2020-01-23 10:27:40 +01:00
from pyfaup.faup import Faup # type: ignore
2019-12-04 15:18:27 +01:00
from urllib.parse import unquote_plus
logger = logging.getLogger('pymisp')
faup = Faup()
class URLObject(AbstractMISPObjectGenerator):
def __init__(self, url: str, **kwargs):
super().__init__('url', **kwargs)
2019-12-04 15:18:27 +01:00
faup.decode(unquote_plus(url))
self.generate_attributes()
def generate_attributes(self):
self.add_attribute('url', value=faup.url.decode())
if faup.get_host():
self.add_attribute('host', value=faup.get_host())
if faup.get_domain():
self.add_attribute('domain', value=faup.get_domain())