etc~ scripts and random things |
| git clone https://github.com/djnnvx/etc.git |
| log | files | refs | archive |
keepass4brute.sh (2820B)
1 #!/bin/bash 2 3 # https://github.com/r3nt0n/keepass4brute 4 # Name: keepass4brute.sh 5 # Author: r3nt0n 6 # Version: 1.0 (25/11/2022) 7 8 version="1.3" 9 /bin/echo -e "keepass4brute $version by r3nt0n" 10 /bin/echo -e "https://github.com/r3nt0n/keepass4brute\n" 11 12 if [ $# -ne 2 ] 13 then 14 /bin/echo "Usage $0 <kdbx-file> <wordlist>" 15 exit 2 16 fi 17 18 dep="keepassxc-cli" 19 command -v $dep >/dev/null 2>&1 || { /bin/echo >&2 "Error: $dep not installed. Aborting."; exit 1; } 20 21 n_total=$( wc -l < $2 ) 22 start_time=$(date +%s) 23 24 IFS='' 25 while read -r line; do 26 n_tested=$((n_tested + 1)) 27 current_time=$(date +%s) 28 elapsed_time=$((current_time - start_time)) 29 30 if [ $elapsed_time -gt 0 ]; then 31 attempts_per_minute=$((n_tested * 60 / elapsed_time)) 32 remaining_attempts=$((n_total - n_tested)) 33 estimated_time_remaining_seconds=$((remaining_attempts * 60 / attempts_per_minute)) 34 35 estimated_time_remaining_minutes=$((estimated_time_remaining_seconds / 60)) 36 estimated_time_remaining_seconds=$((estimated_time_remaining_seconds % 60)) 37 38 estimated_time_remaining_hours=$((estimated_time_remaining_minutes / 60)) 39 estimated_time_remaining_minutes=$((estimated_time_remaining_minutes % 60)) 40 41 estimated_time_remaining_days=$((estimated_time_remaining_hours / 24)) 42 estimated_time_remaining_hours=$((estimated_time_remaining_hours % 24)) 43 44 estimated_time_remaining_weeks=$((estimated_time_remaining_days / 7)) 45 estimated_time_remaining_days=$((estimated_time_remaining_days % 7)) 46 47 if [ $estimated_time_remaining_weeks -gt 0 ]; then 48 estimated_time_remaining="$estimated_time_remaining_weeks weeks, $estimated_time_remaining_days days" 49 elif [ $estimated_time_remaining_days -gt 0 ]; then 50 estimated_time_remaining="$estimated_time_remaining_days days, $estimated_time_remaining_hours hours" 51 elif [ $estimated_time_remaining_hours -gt 0 ]; then 52 estimated_time_remaining="$estimated_time_remaining_hours hours, $estimated_time_remaining_minutes minutes" 53 elif [ $estimated_time_remaining_minutes -gt 0 ]; then 54 estimated_time_remaining="$estimated_time_remaining_minutes minutes, $estimated_time_remaining_seconds seconds" 55 else 56 estimated_time_remaining="$estimated_time_remaining_seconds seconds" 57 fi 58 else 59 attempts_per_minute=0 60 estimated_time_remaining="Calculating..." 61 fi 62 63 /bin/echo -e "\e[2K\r[+] Words tested: $n_tested/$n_total - Attempts per minute: $attempts_per_minute - Estimated time remaining: $estimated_time_remaining" 64 /bin/echo -e "\e[2K\r[+] Current attempt: $line" 65 66 /bin/echo $line | keepassxc-cli open $1 &> /dev/null 67 if [ $? -eq 0 ] 68 then 69 /bin/echo -ne "\n" 70 /bin/echo "[*] Password found: $line"; exit 0; 71 fi 72 /bin/echo -ne "\e[2A" 73 done < $2 74 75 /bin/echo -ne "\n" 76 /bin/echo "[!] Wordlist exhausted, no match found"; exit 3;