Skip to content

Instantly share code, notes, and snippets.

@santrancisco
Created November 28, 2023 01:12
Show Gist options
  • Save santrancisco/f2dd662310a3c1ff93e38ce477f04bc6 to your computer and use it in GitHub Desktop.
Save santrancisco/f2dd662310a3c1ff93e38ce477f04bc6 to your computer and use it in GitHub Desktop.
Simple bash script to bruteforce Mac dmg file password with a password list - only useful for when you have a list of passwords that you often use
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: ./bruteforce.sh <dmg file> <password list>"
exit
fi
dmgfile="$1"
passfile="$2"
function TryPassword
{
r=$(echo -n "$1" | hdiutil verify -stdinpass "$dmgfile" 2>&1)
if ! [[ $r =~ "Authentication error" ]]; then
echo ""
echo "Found! The password is: $1"
exit
fi
}
for i in $(cat $2); do
TryPassword "$i"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment