-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to calculate hash of favicon.ico for Shodan (#13)
* Add script to calculate hash of favicon.ico * Remove '\n' * Change variable name
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |