Created
June 29, 2021 15:30
-
-
Save manasmbellani/667d1434a09d582170a2a4b331d58200 to your computer and use it in GitHub Desktop.
get_favicon_hash.py - Get Favicon hash from website
This file contains hidden or 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
| #!/usr/bin/python3 | |
| import mmh3 | |
| import requests | |
| import codecs | |
| import argparse | |
| parser = argparse.ArgumentParser(description='Calculate the favicon hash from a domain') | |
| parser.add_argument('-d', '--domain', required=True, help='Path under which favicon.ico sits e.g. www.google.com OR www.google.com/path/to/favicon') | |
| parser.add_argument('-p', '--protocol', default='https', help='HTTP Protocol') | |
| args = parser.parse_args() | |
| url = f'{args.protocol}://{args.domain}/favicon.ico' | |
| response = requests.get(url, verify=False) | |
| if response.status_code >= 200 and response.status_code < 300: | |
| favicon = codecs.encode(response.content,"base64") | |
| hash = mmh3.hash(favicon) | |
| print(hash) | |
| else: | |
| print(f"[-] Error getting hash for URL: {url}. Response: {response.status_code}, {response.text}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment