Skip to content

Instantly share code, notes, and snippets.

@manasmbellani
Created June 29, 2021 15:30
Show Gist options
  • Select an option

  • Save manasmbellani/667d1434a09d582170a2a4b331d58200 to your computer and use it in GitHub Desktop.

Select an option

Save manasmbellani/667d1434a09d582170a2a4b331d58200 to your computer and use it in GitHub Desktop.
get_favicon_hash.py - Get Favicon hash from website
#!/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