Skip to content

Instantly share code, notes, and snippets.

@Esonhugh
Forked from yehgdotnet/get-shodan-favicon-hash.py
Last active December 7, 2021 15:49
Show Gist options
  • Save Esonhugh/f5fe4b62be97da51a51b53c814026deb to your computer and use it in GitHub Desktop.
Save Esonhugh/f5fe4b62be97da51a51b53c814026deb to your computer and use it in GitHub Desktop.
Get Shodan FAVICON Hash (Eson modified)
# https://twitter.com/brsn76945860/status/1171233054951501824
# pip install mmh3
#
# in python 3
# Author: https://gist.github.com/yehgdotnet
#
# Author: Esonhugh (https://gist.github.com/Esonhugh) more automatic
# date: 2021/12/07 23:38 UTC+0800
import mmh3
import requests
import codecs
import sys
content = b""
def figerprintize( content = content ):
base64ed_favicon = codecs.encode( content, "base64" )
return mmh3.hash(base64ed_favicon)
def main():
if len(sys.argv) != 3:
print("usage:",sys.argv[0],"[f(ile)/h(ttp)] param(filename or website)")
else:
if sys.argv[1] in ["f","file"] :
with open(sys.argv[2],"rb") as f:
content = f.read()
elif sys.argv[1] in ["h","http"] :
resp = requests.get(sys.argv[2] + "/favicon.ico")
content = resp.content
else:
print("wrong input")
print( "ICO hash:",figerprintize(content) )
if __name__ == "__main__":
main()
# real works part at the frist version
# response = requests.get('https://cybersecurity.wtf/favicon.ico')
# favicon = codecs.encode(response.content,"base64")
# hash = mmh3.hash(favicon)
# print(hash)
@Esonhugh
Copy link
Author

Esonhugh commented Dec 7, 2021

use the script like
python3 script.py file xxx.ico
python3 script.py http http://example.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment