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):
|
|
|
|
|
2020-06-30 12:40:08 +02:00
|
|
|
def __init__(self, url: str, **kwargs):
|
2021-01-11 11:49:12 +01:00
|
|
|
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())
|