Skip to content

Instantly share code, notes, and snippets.

@yehgdotnet
Last active April 8, 2024 18:30
Show Gist options
  • Star 89 You must be signed in to star a gist
  • Fork 51 You must be signed in to fork a gist
  • Save yehgdotnet/b9dfc618108d2f05845c4d8e28c5fc6a to your computer and use it in GitHub Desktop.
Save yehgdotnet/b9dfc618108d2f05845c4d8e28c5fc6a to your computer and use it in GitHub Desktop.
Get Shodan FAVICON Hash
# https://twitter.com/brsn76945860/status/1171233054951501824
pip install mmh3
-----------------------------
# python 2
import mmh3
import requests
response = requests.get('https://cybersecurity.wtf/favicon.ico')
favicon = response.content.encode('base64')
hash = mmh3.hash(favicon)
print hash
-----------------------------
# python 3
import mmh3
import requests
import codecs
response = requests.get('https://cybersecurity.wtf/favicon.ico')
favicon = codecs.encode(response.content,"base64")
hash = mmh3.hash(favicon)
print(hash)
@bugtestingbb
Copy link

While running the script with https://IP/favicon.ico, make this error, pls take a look. Thank you

Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/urllib3/contrib/pyopenssl.py", line 485, in wrap_socket
cnx.do_handshake()
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1907, in do_handshake
self._raise_ssl_error(self._ssl, result)
File "/usr/lib/python3/dist-packages/OpenSSL/SSL.py", line 1639, in _raise_ssl_error
_raise_current_error()
File "/usr/lib/python3/dist-packages/OpenSSL/_util.py", line 54, in exception_from_error_queue
raise exception_type(errors)
OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 376, in _make_request
self._validate_conn(conn)
File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 994, in validate_conn
conn.connect()
File "/usr/local/lib/python3.8/dist-packages/urllib3/connection.py", line 352, in connect
self.sock = ssl_wrap_socket(
File "/usr/local/lib/python3.8/dist-packages/urllib3/util/ssl
.py", line 383, in ssl_wrap_socket
return context.wrap_socket(sock)
File "/usr/local/lib/python3.8/dist-packages/urllib3/contrib/pyopenssl.py", line 491, in wrap_socket
raise ssl.SSLError("bad handshake: %r" % e)
ssl.SSLError: ("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])",)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.8/dist-packages/urllib3/util/retry.py", line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='113.23.140.252', port=443): Max retries exceeded with url: /favicon.ico (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "fav_hash.py", line 5, in
response = requests.get(input('Enter the URL: '))
File "/usr/local/lib/python3.8/dist-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.8/dist-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/requests/adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='IP', port=443): Max retries exceeded with url: /favicon.ico (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

@seefor
Copy link

seefor commented Jul 7, 2020

Change this:
response = requests.get('https://cybersecurity.wtf/favicon.ico')

to:
response = requests.get('https://cybersecurity.wtf/favicon.ico', verify=False)

That should fix your problem

@vansh1
Copy link

vansh1 commented Feb 9, 2022

Traceback (most recent call last):
File "favfreak.py", line 85, in
a,urls= main()
File "favfreak.py", line 21, in main
if line.strip()[-1] == "/":
IndexError: string index out of range

i am getting this error
cat file.txt | python3 favicon.py

@cherrera0001
Copy link

acá te ofrezco una solución, en la que estoy trabajando para este mismo concepto. https://github.com/cherrera0001/ScriptsPython/blob/main/FavIconShondanToCF.py

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