Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to calculate hash of favicon.ico for Shodan #13

Merged
merged 3 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/scripts/recon/shodan_favicon_hash/__main__.py
Original file line number Diff line number Diff line change
@@ -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}",
)
7 changes: 7 additions & 0 deletions src/scripts/recon/shodan_favicon_hash/requirements.txt
Original file line number Diff line number Diff line change
@@ -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