Last active
August 30, 2024 12:03
-
-
Save jhyland87/e6385e2f8ea25067000469618cd103c3 to your computer and use it in GitHub Desktop.
Function to check if a string (password) can be found in online reverse sha1/md5 checksum dictionaries.
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
function checkmd5 { | |
local string="${1?No string provided to test}" | |
local checksum=$(printf "${string}" | md5sum | awk '{print $1}') | |
printf "%10s: %s\n" "string" "${string}" | |
printf "%10s: %s\n" "checksum" "${checksum}" | |
printf "%10s: %s\n" "type" "MD5" | |
printf "%10s: %s" "result" "Checking..." | |
local result=$(reversemd5 "${checksum}") | |
if [[ ${#result} -eq 0 ]]; then | |
printf "\e[11D%s\033[K\n" "No match found" | |
return | |
fi | |
printf "\e[11D%s\033[K\n" "${result}" | |
} | |
# sha1lookip 4233137d1c510f2e55ba5cb220b864b11033f156 | |
function reversesha1 { | |
# Check https://www.whatsmyip.org/hash-lookup/ | |
curl --silent 'https://www.whatsmyip.org/data/hash-lookup.php' \ | |
-H 'Accept: */*' \ | |
-H 'Accept-Language: en-US,en;q=0.9' \ | |
-H 'Connection: keep-alive' \ | |
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \ | |
-H 'Origin: https://www.whatsmyip.org' \ | |
-H 'Referer: https://www.whatsmyip.org/hash-lookup/' \ | |
-H 'Sec-Fetch-Dest: empty' \ | |
-H 'Sec-Fetch-Mode: cors' \ | |
-H 'Sec-Fetch-Site: same-origin' \ | |
-H 'Sec-GPC: 1' \ | |
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36' \ | |
-H 'X-Requested-With: XMLHttpRequest' \ | |
-H 'sec-ch-ua: "Not/A)Brand";v="8", "Chromium";v="126", "Brave";v="126"' \ | |
-H 'sec-ch-ua-mobile: ?0' \ | |
-H 'sec-ch-ua-platform: "macOS"' \ | |
--data-raw "hash=${1?No checksum provided}" | cut -d\| -f2 | |
} | |
function checksha1 { | |
local string="${1?No string provided to test}" | |
local checksum=$(printf "${string}" | sha1sum | awk '{print $1}') | |
printf "%10s: %s\n" "string" "${string}" | |
printf "%10s: %s\n" "checksum" "${checksum}" | |
printf "%10s: %s\n" "type" "SHA1" | |
printf "%10s: %s" "result" "Checking..." | |
local result=$(reversesha1 "${checksum}") | |
if [[ ${#result} -eq 0 ]]; then | |
printf "\e[11D%s\e[K\n" "No match found" | |
return | |
fi | |
printf "\e[11D%s\e[K\n" "${result}" | |
} | |
function reversechecksum { | |
local string="${1?No string provided to test}" | |
local md5_checksum=$(printf "${string}" | md5sum | awk '{print $1}') | |
local sha1_checksum=$(printf "${string}" | sha1sum | awk '{print $1}') | |
printf "%10s: %s\n" "string" "${string}" | |
printf "%10s: %s\n" "md5sum" "${md5_checksum}" | |
printf "%10s: %s\n" "sha1sum" "${sha1_checksum}" | |
printf "%10s: %s" "result" "Checking..." | |
local sha1_result=$(reversesha1 "${sha1_checksum}") | |
local md5_result=$(reversemd5 "${md5_checksum}") | |
if [[ ${#sha1_result} -eq 0 && ${#md5_result} -eq 0 ]]; then | |
printf "\e[11D\e[32;1m%s\e[0m\e[K\n" "No matches found" | |
return 1 | |
fi | |
printf "\e[11D\e[31;1m%s\e[0m\e[K\n" "Matches found!" | |
[[ ${#md5_result} -ne 0 ]] && printf "%10s: %s\n" "md5" "${md5_result}" | |
[[ ${#sha1_result} -ne 0 ]] && printf "%10s: %s\n" "sha1" "${sha1_result}" | |
return 0 | |
} | |
# Examples: | |
# $ reversechecksum Hello123 | |
# string: Hello123 | |
# md5sum: d0aabe9a362cb2712ee90e04810902f3 | |
# sha1sum: 836babddc66080e01d52b8272aa9461c69ee0496 | |
# result: Matches found! | |
# md5: Hello123 | |
# sha1: Hello123 | |
# $ reversechecksum Hello123@*^\& | |
# string: Hello123@*^& | |
# md5sum: 2579dde733ae9276d3394ddf3f2ef812 | |
# sha1sum: 8722ab1569e3eb0eee741c4728f30e62c8131572 | |
# result: No matches found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment