Time to crack script updates.
[ADDED] Calculate cost for cracking a password. [UPDATED] Hardware cost data based on various GPUs with updated hashcat metrics. [ADDED] Ability to calculate the strength of an arbitrary password.
This commit is contained in:
		@@ -1,6 +1,20 @@
 | 
				
			|||||||
#!/usr/bin/env bash
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
source bashlib
 | 
					source bashlib
 | 
				
			||||||
calc() { python -c "import math; print $1"; }
 | 
					calc() { python -c "import math; print $1"; }
 | 
				
			||||||
 | 
					scale() {
 | 
				
			||||||
 | 
					    local number=$1 precision=$2 definition unit weight; shift 2
 | 
				
			||||||
 | 
					    for definition in "$@"; do
 | 
				
			||||||
 | 
					        definition=$definition
 | 
				
			||||||
 | 
					        weight=${definition#*:}
 | 
				
			||||||
 | 
					        [[ ! $weight || $(calc "($number) > ($weight)") = True ]] || break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        number=$(calc "(1.0 * $number) / (1.0 * ${weight:-1})") unit=${definition%:*}
 | 
				
			||||||
 | 
					    done
 | 
				
			||||||
 | 
					    printf "%'0.${precision}f %s" "$number" "$unit"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					scaleTime()     { scale "$1" "${2:-2}" 'Seconds:' "Hours:3600" "Days:24" "Months:30" "Years:356/30" "K Years:1000" "M Years:1000" "B Years:1000" "T Years:1000"; }
 | 
				
			||||||
 | 
					scaleEnergy()   { scale "$1" "${2:-2}" 'Wh:' 'kWh:1000' 'MWh:1000' 'GWh:1000' 'TWh:1000'; }
 | 
				
			||||||
 | 
					scaleCost()     { scale "$1" "${2:-2}" '$US:' 'K$US:1000' 'M$US:1000' 'B$US:1000' 'T$US:1000'; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
inf 'Calculate the maximum amount of time required to brute-force search for a password.'
 | 
					inf 'Calculate the maximum amount of time required to brute-force search for a password.'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -17,44 +31,45 @@ x="$a$n!@#\$%^&*()"
 | 
				
			|||||||
w="@words.txt"
 | 
					w="@words.txt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## METRICS
 | 
					## METRICS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Last update: 2016-09
 | 
					# Last update: 2016-09
 | 
				
			||||||
# GTX Titan X can generate about 402.7M HMAC-SHA-256 hashes per second (5301.7M SHA1).  (ref. https://hashcat.net/forum/thread-4314.html)
 | 
					# GTX Titan X -- https://gist.github.com/epixoip/1f26f43e9036d9ce0eb8
 | 
				
			||||||
# GTX Titan X can be bought for about 950$ used. (ref. amazon.com)
 | 
					#hardwareName='GTX Titan X (SHA1)'          hardwareHPS='5302M'     hardwareCost='950'  hardwareWatt='250' # -mpl: 4.67 m
 | 
				
			||||||
#hardwareName='GTX Titan X (SHA1)'                  hardwareSpeed='5302M'
 | 
					#hardwareName='GTX Titan X (HMAC-SHA-256)'  hardwareHPS='2113M'     hardwareCost='950'  hardwareWatt='250' # -mpl: 0.99 y
 | 
				
			||||||
#hardwareName='GTX Titan X (SHA1 @ 5k$)'            hardwareSpeed='5302M * 5k / 950'
 | 
					#hardwareName='GTX Titan X (bcrypt-10)'     hardwareHPS='14440/32'  hardwareCost='950'  hardwareWatt='250' # -mpl: 4.62 My
 | 
				
			||||||
#hardwareName='GTX Titan X (SHA1 @ 20k$)'           hardwareSpeed='5302M * 20k / 950'
 | 
					# GTX 980 Ti -- https://gist.github.com/epixoip/d34245293ccecbfcc7c7
 | 
				
			||||||
#hardwareName='GTX Titan X (SHA1 @ 20M$)'           hardwareSpeed='5302M * 20M / 950'
 | 
					#hardwareName='GTX 980 Ti (SHA1)'           hardwareHPS='5366M'     hardwareCost='450'  hardwareWatt='250' # -mpl: 4.61 m
 | 
				
			||||||
#hardwareName='GTX Titan X (SHA1 @ 5B$)'            hardwareSpeed='5302M * 5B / 950'
 | 
					#hardwareName='GTX 980 Ti (SHA256)'         hardwareHPS='2032M'     hardwareCost='450'  hardwareWatt='250' # -mpl: 1.03 y
 | 
				
			||||||
 hardwareName='GTX Titan X (HMAC-SHA-256 @ 950$)'   hardwareSpeed='403M'
 | 
					#hardwareName='GTX 980 Ti (bcrypt-10)'      hardwareHPS='14521/32'  hardwareCost='450'  hardwareWatt='250' # -mpl: 4.60 My
 | 
				
			||||||
#hardwareName='GTX Titan X (HMAC-SHA-256 @ 5k$)'    hardwareSpeed='403M * 5k / 950'
 | 
					# GTX 1060 -- https://gist.github.com/derpasaurusz/817638385a35026383331b22e6f2d490
 | 
				
			||||||
#hardwareName='GTX Titan X (HMAC-SHA-256 @ 20k$)'   hardwareSpeed='403M * 20k / 950'
 | 
					#hardwareName='GTX 1060 (SHA1)'             hardwareHPS='4218M'     hardwareCost='400'  hardwareWatt='120' # -mpl: 5.87 m
 | 
				
			||||||
#hardwareName='GTX Titan X (HMAC-SHA-256 @ 20M$)'   hardwareSpeed='403M * 20M / 950'
 | 
					#hardwareName='GTX 1060 (SHA256)'           hardwareHPS='1632M'     hardwareCost='400'  hardwareWatt='120' # -mpl: 1.28 y
 | 
				
			||||||
#hardwareName='GTX Titan X (HMAC-SHA-256 @ 5B$)'    hardwareSpeed='403M * 5B / 950'
 | 
					#hardwareName='GTX 1060 (bcrypt-10)'        hardwareHPS='8046/32'   hardwareCost='400'  hardwareWatt='120' # -mpl: 8.30 My
 | 
				
			||||||
 | 
					# GTX 1080 Ti -- https://gist.github.com/epixoip/ace60d09981be09544fdd35005051505
 | 
				
			||||||
 | 
					#hardwareName='GTX 1080 Ti (SHA1)'          hardwareHPS='12696M'    hardwareCost='1200' hardwareWatt='250' # -mpl: 1.95 m
 | 
				
			||||||
 | 
					#hardwareName='GTX 1080 Ti (SHA256)'        hardwareHPS='4967M'     hardwareCost='1200' hardwareWatt='250' # -mpl: 4.99 m
 | 
				
			||||||
 | 
					#hardwareName='GTX 1080 Ti (bcrypt-10)'     hardwareHPS='23266/32'  hardwareCost='1200' hardwareWatt='250' # -mpl: 2.87 My
 | 
				
			||||||
 | 
					 hardwareName='GTX 1080 Ti (mpw?)'          hardwareHPS='56*3'      hardwareCost='1200' hardwareWatt='250' # -mpl: 2.87 My
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ASICs
 | 
					# ASICs
 | 
				
			||||||
 hardwareName='AntMiner L3+ (scrypt)'               hardwareSpeed='1M'
 | 
					#hardwareName='AntMiner L3+ (scrypt)'       hardwareHPS='1M'    hardwareCost='2500' hardwareWatt='800'
 | 
				
			||||||
#hardwareName='AntMiner L3+ (scrypt @ 5k$)'         hardwareSpeed='1M * 5k / 2500'
 | 
					#hardwareName='AntMiner S9 (SHA256)'        hardwareHPS='14T'   hardwareCost='1288' hardwareWatt='1400'
 | 
				
			||||||
#hardwareName='AntMiner L3+ (scrypt @ 20k$)'        hardwareSpeed='1M * 20k / 2500'
 | 
					 | 
				
			||||||
#hardwareName='AntMiner L3+ (scrypt @ 20M$)'        hardwareSpeed='1M * 20M / 2500'
 | 
					 | 
				
			||||||
#hardwareName='AntMiner L3+ (scrypt @ 5B$)'         hardwareSpeed='1M * 5B / 2500'
 | 
					 | 
				
			||||||
 hardwareName='AntMiner S9 (SHA256)'                hardwareSpeed='14T'
 | 
					 | 
				
			||||||
#hardwareName='AntMiner S9 (SHA256 @ 5k$)'          hardwareSpeed='14T * 5k / 1288'
 | 
					 | 
				
			||||||
#hardwareName='AntMiner S9 (SHA256 @ 20k$)'         hardwareSpeed='14T * 20k / 1288'
 | 
					 | 
				
			||||||
#hardwareName='AntMiner S9 (SHA256 @ 20M$)'         hardwareSpeed='14T * 20M / 1288'
 | 
					 | 
				
			||||||
#hardwareName='AntMiner S9 (SHA256 @ 5B$)'          hardwareSpeed='14T * 5B / 1288'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# mpw-bench
 | 
					# mpw-bench
 | 
				
			||||||
#hardwareName='2.3 GHz i7, 8GB (MPW)'               hardwareSpeed=7.46
 | 
					#hardwareName='2.3 GHz i7, 8GB (MPW)'       hardwareHPS=7.46
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					costPerKWh='0.1' # ~0.1$/kWh
 | 
				
			||||||
 | 
					hardwareQuantity=$(calc "5000000000 / ($hardwareCost)")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
second='1'
 | 
					second='1'
 | 
				
			||||||
secondsInHour='3600'
 | 
					secondsInHour='3600'
 | 
				
			||||||
secondsInDay='3600 * 24'
 | 
					secondsInDay='3600 * 24'
 | 
				
			||||||
secondsInMonth='3600 * 24 * 30'
 | 
					secondsInMonth='3600 * 24 * 30'
 | 
				
			||||||
secondsInYear='3600 * 24 * 356'
 | 
					secondsInYear='3600 * 24 * 356'
 | 
				
			||||||
hardwareSpeed=${hardwareSpeed//k/000}
 | 
					hardwareHPS=${hardwareHPS//k/000}
 | 
				
			||||||
hardwareSpeed=${hardwareSpeed//M/000000}
 | 
					hardwareHPS=${hardwareHPS//M/000000}
 | 
				
			||||||
hardwareSpeed=${hardwareSpeed//G/000000000}
 | 
					hardwareHPS=${hardwareHPS//G/000000000}
 | 
				
			||||||
hardwareSpeed=${hardwareSpeed//T/000000000000}
 | 
					hardwareHPS=${hardwareHPS//T/000000000000}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## SEARCH SPACE
 | 
					## SEARCH SPACE
 | 
				
			||||||
hr
 | 
					hr
 | 
				
			||||||
@@ -74,7 +89,7 @@ for _c in V C v c A a n o x w; do
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    inf '%s: Class contains %d entities: %s' "$_c" "$cs" "$cc"
 | 
					    inf '%s: Class contains %d entities: %s' "$_c" "$cs" "$cc"
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
spaceString=${1:-$(ask -d "x ** 12" "Amount of space?")}
 | 
					spaceString=${1:-$(ask -d "x ** 12" "Size of the space?")}
 | 
				
			||||||
case "$spaceString" in
 | 
					case "$spaceString" in
 | 
				
			||||||
    -mp*) mpmode=${spaceString#-mp} mpmode=${mpmode:-long}
 | 
					    -mp*) mpmode=${spaceString#-mp} mpmode=${mpmode:-long}
 | 
				
			||||||
        case "$mpmode" in
 | 
					        case "$mpmode" in
 | 
				
			||||||
@@ -82,9 +97,18 @@ case "$spaceString" in
 | 
				
			|||||||
            max|secure|x) spaceString='aonxxxxxxxxxxxxxxxxx+axxxxxxxxxxxxxxxxxon' ;;
 | 
					            max|secure|x) spaceString='aonxxxxxxxxxxxxxxxxx+axxxxxxxxxxxxxxxxxon' ;;
 | 
				
			||||||
            med|m) spaceString='CvcnoCvc+CvcCvcno' ;;
 | 
					            med|m) spaceString='CvcnoCvc+CvcCvcno' ;;
 | 
				
			||||||
            basic|b) spaceString='aaanaaan+aannaaan+aaannaaa' ;;
 | 
					            basic|b) spaceString='aaanaaan+aannaaan+aaannaaa' ;;
 | 
				
			||||||
 | 
					            *) ftl 'Unknown mode: %s' "$mpmode" || exit
 | 
				
			||||||
        esac ;;
 | 
					        esac ;;
 | 
				
			||||||
 | 
					    -pw*) password=${spaceString#-pw} spaceString=
 | 
				
			||||||
 | 
					        while read -N1 pwchar; do
 | 
				
			||||||
 | 
					            for _c in v c a n x; do
 | 
				
			||||||
 | 
					                cc=${!_c}
 | 
				
			||||||
 | 
					                [[ $cc = *$pwchar* ]] && spaceString+=$_c && break
 | 
				
			||||||
 | 
					            done || spaceString+=" 256 "
 | 
				
			||||||
 | 
					        done <<< "$password"
 | 
				
			||||||
 | 
					        ;;
 | 
				
			||||||
esac
 | 
					esac
 | 
				
			||||||
space=$spaceString
 | 
					spaceSize=$spaceString
 | 
				
			||||||
for _c in V C v c A a n o x w; do
 | 
					for _c in V C v c A a n o x w; do
 | 
				
			||||||
    cc=${!_c}
 | 
					    cc=${!_c}
 | 
				
			||||||
    if [[ $cc = @* ]]; then
 | 
					    if [[ $cc = @* ]]; then
 | 
				
			||||||
@@ -94,35 +118,39 @@ for _c in V C v c A a n o x w; do
 | 
				
			|||||||
        cs=${#cc}
 | 
					        cs=${#cc}
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    space=${space//$_c/ 0$cs }
 | 
					    spaceSize=${spaceSize//$_c/ 0$cs }
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
# Replace sequences of numbers by multiplication of those numbers.  Then, pretty-print.
 | 
					# Replace sequences of numbers by multiplication of those numbers.  Then, pretty-print.
 | 
				
			||||||
space=$(sed -e 's/\([[:digit:]]\)  *\([[:digit:]]\)/\1 * \2/g' -e 's/ 00*\([1-9]\)/ \1/g' <<< "$space")
 | 
					spaceSize=$(sed -e 's/\([[:digit:]]\)  *\([[:digit:]]\)/\1 * \2/g' -e 's/ 00*\([1-9]\)/ \1/g' <<< "$spaceSize")
 | 
				
			||||||
space=$(tr -s ' ' <<< "$space") space=${space# } space=${space% }
 | 
					spaceSize=$(tr -s ' ' <<< "$spaceSize") spaceSize=${spaceSize# } spaceSize=${spaceSize% }
 | 
				
			||||||
inf ''
 | 
					inf ''
 | 
				
			||||||
inf "Search space: %s = %s = %'.f possibilities to try (~%.1f bit)." "$spaceString" "$space" "$(calc "$space")" "$(bc -l <<< "l($(calc "$space")) / l(2)")"
 | 
					inf "Search space: %s = %s = %'.f possibilities to try (~%.1f bit)." "$spaceString" "$spaceSize" "$(calc "$spaceSize")" "$(bc -l <<< "l($(calc "$spaceSize")) / l(2)")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## CLUSTER SIZE
 | 
					## CLUSTER SIZE
 | 
				
			||||||
hr
 | 
					hr
 | 
				
			||||||
inf 'CLUSTER SIZE'
 | 
					inf 'CLUSTER SIZE'
 | 
				
			||||||
inf "Simulating %s at a rate of about %'.1f attempts per second." "$hardwareName" "$(calc "$hardwareSpeed")"
 | 
					inf "Simulating %s at a rate of about %'.1f attempts per second." "$hardwareName" "$(calc "$hardwareHPS")"
 | 
				
			||||||
cluster=$(ask -d 1 "Amount of GPUs?")
 | 
					cluster=$(ask -d "$hardwareQuantity" "Amount of units?")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## CALCULATE
 | 
					## CALCULATE
 | 
				
			||||||
hr
 | 
					hr
 | 
				
			||||||
inf 'TIMING'
 | 
					inf 'TIMING'
 | 
				
			||||||
inf "Time to search the entire space using %d GPUs of type %s (rate=%'.1f/s)" "$cluster" "$hardwareName" "$(calc "$hardwareSpeed")"
 | 
					inf "Time to search the entire space using %dx %s units (unit rate=%'.1f H/s)" "$cluster" "$hardwareName" "$(calc "$hardwareHPS")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					seconds=$(calc "(1.0 * $spaceSize) / (1.0 * $hardwareHPS * $cluster)")
 | 
				
			||||||
 | 
					inf "Time to crack: %s (ie. %s Seconds)" "$(scale "$seconds" 2 'Seconds:' "Hours:3600" "Days:24" "Months:30" "Years:356/30")" "$seconds"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
timing() {
 | 
					timing() {
 | 
				
			||||||
    local title=$1 unit=$2 precision=$3 seconds=$4
 | 
					    local title=$1 unit=$2 precision=$3 seconds=$4
 | 
				
			||||||
    time=$(calc "1.0 * ($space) / ($hardwareSpeed * $cluster) / ($seconds)")
 | 
					    time=$(calc "(1.0 * $spaceSize) / (1.0 * $hardwareHPS * $cluster) / ($seconds)")
 | 
				
			||||||
    percent=$(calc "100.0 * ($hardwareSpeed * $cluster) * ($seconds) / ($space)")
 | 
					    percent=$(calc "(100.0 * $hardwareHPS * $cluster * $seconds) / (1.0 * $spaceSize)")
 | 
				
			||||||
    amount=$(calc "$percent / 100.0")
 | 
					    amount=$(calc "$percent / 100.0")
 | 
				
			||||||
    if [[ $amount = 0.* ]]; then
 | 
					    if [[ $(calc "$percent < 100") = True ]]; then
 | 
				
			||||||
        inf "%10s to crack: %'0.${precision}f (search rate is %0.0f%% / %s)" \
 | 
					        inf "    - %10s: %'0.${precision}f (ie. %0.1f%% / %s)" \
 | 
				
			||||||
            "$title" "$time" "$percent" "$unit"
 | 
					            "$title" "$time" "$percent" "$unit"
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
        inf "%10s to crack: %'0.${precision}f (completes %0.1fx / %s)" \
 | 
					        inf "    - %10s: %'0.${precision}f (ie. %0.1fx / %s)" \
 | 
				
			||||||
            "$title" "$time" "$amount" "$unit"
 | 
					            "$title" "$time" "$amount" "$unit"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -131,3 +159,17 @@ timing Hours h 2 "$secondsInHour"
 | 
				
			|||||||
timing Days d 3 "$secondsInDay"
 | 
					timing Days d 3 "$secondsInDay"
 | 
				
			||||||
timing Months m 4 "$secondsInMonth"
 | 
					timing Months m 4 "$secondsInMonth"
 | 
				
			||||||
timing Years y 4 "$secondsInYear"
 | 
					timing Years y 4 "$secondsInYear"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					hr
 | 
				
			||||||
 | 
					inf 'COST'
 | 
				
			||||||
 | 
					inf "Budget required to search the entire space using %dx %s units (unit cost=%s + %s / year => %s annum, %s / HPS)" \
 | 
				
			||||||
 | 
					    "$cluster" "$hardwareName" "$(scaleCost "$hardwareCost")" "$(scaleCost "1.0 * $hardwareWatt * 356 * 24 * $costPerKWh / 1000")" "$(scaleCost "$hardwareCost + 1.0 * $hardwareWatt * 356 * 24 * $costPerKWh / 1000")" "$(scaleCost "$hardwareCost / (1.0 * $hardwareHPS)")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fixedCost=$(calc "(1.0 * $cluster * $hardwareCost)")
 | 
				
			||||||
 | 
					energyCost=$(calc "(1.0 * $cluster * $hardwareWatt * $seconds) / 3600") # Wh
 | 
				
			||||||
 | 
					totalCost=$(calc "1.0 * $fixedCost + ($energyCost * $costPerKWh) / 1000.0")
 | 
				
			||||||
 | 
					inf "Time cost  : %s" "$(scaleTime "$seconds")"
 | 
				
			||||||
 | 
					inf "Fixed costs: %s" "$(scaleCost "$fixedCost")"
 | 
				
			||||||
 | 
					inf "Energy cost: %s" "$(scaleEnergy "$energyCost")"
 | 
				
			||||||
 | 
					inf "Budget cost: %s" "$(scaleCost "$totalCost")"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user