Skip to content

Commit

Permalink
Add script to calculate hash of favicon.ico for Shodan (#13)
Browse files Browse the repository at this point in the history
* Add script to calculate hash of favicon.ico

* Remove '\n'

* Change variable name
  • Loading branch information
Cravtos committed Jul 17, 2020
1 parent d3bbb9b commit 01b2b3e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
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

0 comments on commit 01b2b3e

Please sign in to comment.