diff --git a/src/scripts/recon/shodan_favicon_hash/__main__.py b/src/scripts/recon/shodan_favicon_hash/__main__.py new file mode 100644 index 0000000..c53b946 --- /dev/null +++ b/src/scripts/recon/shodan_favicon_hash/__main__.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 + +from base64 import encodebytes + +from mmh3 import hash +from requests import get +from requests.exceptions import RequestException + +from src.core.base.recon import ReconRunner, PossibleKeys +from src.core.utils.response import ScriptResponse +from src.core.utils.validators import validate_kwargs + + +class Runner(ReconRunner): + def __init__(self, logger: str = __name__): + super(Runner, self).__init__(logger) + + @validate_kwargs(PossibleKeys.KEYS) + def run(self, *args, **kwargs): + """ + Returns hash of favicon.ico of given url. + :param args: args from core runner + :param kwargs: kwargs from core runner + :return: ScriptResponse message + """ + url = kwargs.get("url") + + try: + response = get(f"{url}/favicon.ico") + except RequestException as req_err: + return ScriptResponse.error( + result=None, + message=f"Can't connect to {url}!" + f"Error message: {req_err}", + ) + + favicon = encodebytes(response.content) + favicon_hash = hash(favicon) + + return ScriptResponse.success( + result=favicon_hash, + message=f"Successfully made favicon hash of {url}! " + f"Use https://www.shodan.io/search?query=http.favicon.hash:{favicon_hash}", + ) diff --git a/src/scripts/recon/shodan_favicon_hash/requirements.txt b/src/scripts/recon/shodan_favicon_hash/requirements.txt new file mode 100644 index 0000000..6269fa5 --- /dev/null +++ b/src/scripts/recon/shodan_favicon_hash/requirements.txt @@ -0,0 +1,7 @@ +certifi==2020.6.20 +chardet==3.0.4 +idna==2.10 +mmh3==2.5.1 +pkg-resources==0.0.0 +requests==2.24.0 +urllib3==1.25.9 \ No newline at end of file