more bug fix lol
This commit is contained in:
@@ -22,3 +22,5 @@ Optional charset format
|
|||||||
* Example: upper alpha and symbols+space: `us` ex. `bash bd_crack.sh c8ea28d3285e468961a76b5de75871fbe539808a passp us`
|
* Example: upper alpha and symbols+space: `us` ex. `bash bd_crack.sh c8ea28d3285e468961a76b5de75871fbe539808a passp us`
|
||||||
* Example: `bash bd_crack.sh c8ea28d3285e468961a76b5de75871fbe539808a passp lud`
|
* Example: `bash bd_crack.sh c8ea28d3285e468961a76b5de75871fbe539808a passp lud`
|
||||||
* Example: `bash bd_crack.sh c8ea28d3285e468961a76b5de75871fbe539808a passp`
|
* Example: `bash bd_crack.sh c8ea28d3285e468961a76b5de75871fbe539808a passp`
|
||||||
|
|
||||||
|
Thanks to [Tak](https://taksshack.com/members/thumbtak/) for some bug fixes!
|
||||||
+37
-22
@@ -1,4 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# set -e # Exit immediately if a command exits with a non-zero status.
|
||||||
# Cracking helper for breachdirectory.org
|
# Cracking helper for breachdirectory.org
|
||||||
# Usage: ./bd_crack.sh <hash> <known 5 chars> <optional charset>
|
# Usage: ./bd_crack.sh <hash> <known 5 chars> <optional charset>
|
||||||
# Optional charset format:
|
# Optional charset format:
|
||||||
@@ -16,58 +17,72 @@
|
|||||||
# Example: bash bd_crack.sh c8ea28d3285e468961a76b5de75871fbe539808a passp lud
|
# Example: bash bd_crack.sh c8ea28d3285e468961a76b5de75871fbe539808a passp lud
|
||||||
# Example: bash bd_crack.sh c8ea28d3285e468961a76b5de75871fbe539808a passp
|
# Example: bash bd_crack.sh c8ea28d3285e468961a76b5de75871fbe539808a passp
|
||||||
|
|
||||||
if [ -z $1 -o -z $2 ]; then # check to maek sure both required args are present
|
if [ -z "$1" ] || [ -z "$2" ]; then # check to make sure both required args are present
|
||||||
echo -e "Mandatory arguments missing!\nPlease see README for more details\nUsage:\n\tbd_crack.sh <hash> <known five characters> <optional charset>\nexiting"
|
echo -e "Mandatory arguments missing!\nPlease see README for more details\nUsage:\n\tbd_crack.sh <hash> <known five characters> <optional charset>\nexiting"
|
||||||
exit # die on fail after printing usage bullshit :lmao:
|
exit 1 # die on fail after printing usage bullshit :lmao:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${#1} -ne 40 ]; then # check da length of da hashie boi
|
if [ ${#1} -ne 40 ]; then # check da length of da hashie boi
|
||||||
echo -e "First arguement should be the SHA1 hash, exactly 40 hex characters long!\nPlease see README for more details\nUsage:\n\tbd_crack.sh <hash> <known five characters> <optional charset>\nexiting"
|
echo -e "First arguement should be the SHA1 hash, exactly 40 hex characters long!\nPlease see README for more details\nUsage:\n\tbd_crack.sh <hash> <known five characters> <optional charset>\nexiting"
|
||||||
exit
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ${#2} -ne 5 ]; then # maek sure da known chars are precisely 5 chars otherwise fail
|
if [ ${#2} -ne 5 ]; then # make sure da known chars are precisely 5 chars otherwise fail
|
||||||
echo -e "Second argument should be exactly five characters!\nPlease see README for more details\nUsage:\n\tbd_crack.sh <hash> <known five characters> <optional charset>\nexiting"
|
echo -e "Second argument should be exactly five characters!\nPlease see README for more details\nUsage:\n\tbd_crack.sh <hash> <known five characters> <optional charset>\nexiting"
|
||||||
exit
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -z $3 ]; then # if charset is specified
|
# Initialize charset_formatted early
|
||||||
|
charset_formatted=""
|
||||||
|
|
||||||
|
if [ -n "$3" ]; then # if charset is specified (using -n for non-empty string)
|
||||||
charset="$3" # just rename $3 for whatever reason lmfao im so high
|
charset="$3" # just rename $3 for whatever reason lmfao im so high
|
||||||
charset_formatted="?" # start with da ? at the start frong
|
|
||||||
valid_charsets="ludhHsb" # regex bit of valid charsssssss
|
valid_charsets="ludhHsb" # regex bit of valid charsssssss
|
||||||
|
|
||||||
if [[ "$charset" =~ ^["$valid_charsets"]+$ ]]; then # sanity checkan da stupid chars :wheeze: just some shitty regex bullsh8it
|
if [[ "$charset" =~ ^["$valid_charsets"]+$ ]]; then # sanity checkan da stupid chars :wheeze: just some shitty regex bullsh8it
|
||||||
|
# Unique and sorted characters, removed newline (as original script did)
|
||||||
charset=$(grep -o . <<< "$charset" | sort -u | tr -d '\n')
|
charset=$(grep -o . <<< "$charset" | sort -u | tr -d '\n')
|
||||||
|
|
||||||
|
# Construct hashcat's custom charset string (e.g., "?l?u?d")
|
||||||
|
for (( i=0; i<${#charset}; i++ )); do
|
||||||
|
if [ $i -eq 0 ]; then
|
||||||
|
charset_formatted+="?" # Start with '?'
|
||||||
|
fi
|
||||||
|
charset_formatted+="${charset:$i:1}" # Add current char
|
||||||
|
if [ $i -lt $((${#charset}-1)) ]; then
|
||||||
|
charset_formatted+="?" # Add '?' between chars
|
||||||
|
fi
|
||||||
|
done
|
||||||
else
|
else
|
||||||
echo -e "INVALID CHARSET, DEFAULTING TO DEFAULT CHARSET"
|
echo -e "INVALID CHARSET, DEFAULTING TO DEFAULT CHARSET"
|
||||||
charset_formatted="?l?u?d?s" # just replicate da default charset here because lazy as fucxk lmafao
|
charset_formatted="?l?u?d?s" # just replicate da default charset here because lazy as fucxk lmafao
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for (( i=0; i<${#charset}; i++ )); do
|
|
||||||
charset_formatted+="${charset:$i:1}" # add current char to charset_formatted
|
|
||||||
|
|
||||||
# add ? after each character except da last char in da string
|
|
||||||
if [ $i -lt $((${#charset}-1)) ]; then
|
|
||||||
charset_formatted+="?"
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
|
||||||
else # if charset is not specified default to digit, upper alpha, lower alpha, and symbols+space
|
else # if charset is not specified default to digit, upper alpha, lower alpha, and symbols+space
|
||||||
charset_formatted="?l?u?d?s"
|
charset_formatted="?l?u?d?s"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
outfile="$2-$1-$(date +"%d-%m-%Y-%H%M")-cracked.txt" # using a fookin outfile because da hashcat.potsmoke or whatever the fuck is stupid
|
outfile="$2-$1-$(date +"%d-%m-%Y-%H%M")-cracked.txt" # using a fookin outfile because da hashcat.potsmoke or whatever the fuck is stupid
|
||||||
|
|
||||||
hashcat -a3 -m100 $1 -1 $charset_formatted "$2?1?1?1?1?1?1?1?1" --increment --increment-min=5 -O -o "$outfile"
|
hashcat -a3 -m100 "$1" -1 "$charset_formatted" "$2?1?1?1?1?1?1?1?1" --increment --increment-min=5 -O -o "$outfile"
|
||||||
retcode=$? # jus gettin da return code from hashcat rq
|
retcode=$? # jus gettin da return code from hashcat rq
|
||||||
|
|
||||||
if [ $retcode -eq 0 ]; then # check if hashcat exited with a 0 meaning successful crack\
|
if [ $retcode -eq 0 ]; then # check if hashcat exited with a 0 meaning successful crack
|
||||||
|
# THIS IS THE CRITICAL ADDITION: Check if the file ACTUALLY exists
|
||||||
|
if [ -f "$outfile" ]; then # Explicitly check if the file was created
|
||||||
# real_user="${SUDO_USER:-$USER}" # stupid hack to get the real current user regardless of any sudo usage
|
# real_user="${SUDO_USER:-$USER}" # stupid hack to get the real current user regardless of any sudo usage
|
||||||
# sudo chown $real_user:$real_user "$outfile" # fix da fuckin perms jfc lmao
|
# sudo chown "$real_user":"$real_user" "$outfile" # fix da fuckin perms jfc lmao
|
||||||
|
|
||||||
echo -e "\nCracked! Result:\n\t$(cat "$outfile")\n" # show da contents of da outfile for helpfuls
|
echo -e "\nCracked! Result:\n\t$(cat "$outfile")\n" # show da contents of da outfile for helpfuls
|
||||||
|
|
||||||
echo "Cracked Successfully! Password will be in ./${outfile}!"
|
echo "Cracked Successfully! Password will be in ./${outfile}!"
|
||||||
else # otherwise inform of failure
|
else
|
||||||
echo "Stopped or Ended! Password not found!"
|
# Hashcat returned 0, but no file. This means no crack was found.
|
||||||
|
echo "Stopped or Ended! Password not found within the specified mask/charset. Hashcat completed without errors."
|
||||||
|
echo "Output file '$outfile' was not created because no crack was found."
|
||||||
|
exit 1 # Exit with an error
|
||||||
|
fi
|
||||||
|
else # otherwise inform of failure (hashcat returned a non-zero error code)
|
||||||
|
echo "Hashcat encountered an error or was stopped unexpectedly (exit code: $retcode)."
|
||||||
|
echo "Please review hashcat's output above for details."
|
||||||
|
exit 1 # Exit with an error
|
||||||
fi
|
fi
|
||||||
Reference in New Issue
Block a user