Skip to content

Instantly share code, notes, and snippets.

@JarbasAl
Created April 12, 2021 09:52
Show Gist options
  • Select an option

  • Save JarbasAl/6865961676a638ed5ed8be21cbec35b3 to your computer and use it in GitHub Desktop.

Select an option

Save JarbasAl/6865961676a638ed5ed8be21cbec35b3 to your computer and use it in GitHub Desktop.
short and simple, but basically tells you if rainbow tables can crack your password
import hashlib
import requests
def search_hexdigest(hexdigest):
url = f"https://www.google.ca/search?q={hexdigest}"
html = requests.get(url, headers={
"User-Agent": "Mozilla/5.0 (X11; Linux i586; rv:34.0) "
"Gecko/20100101 Firefox/31.0"
}).text
not_found = f"Your search - <em>{hexdigest}</em> - did not match any " \
f"documents"
if not_found in html:
return False
return True
def is_leaked(password, libs=None):
libs = libs or ("md5", "sha1", "sha256")
for lib in libs:
print("searching", lib, "password hash:", password)
digest = getattr(hashlib, lib)(password.encode("utf-8"))
if search_hexdigest(digest.hexdigest()):
print(lib, "is all over the web!!!")
return True
return False
print(is_leaked("password1!"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment