2
0

Added some scripts to do math on password strength and generate random dictionary passphrases.

This commit is contained in:
Maarten Billemont 2017-09-14 16:30:06 -04:00
parent 8c9c4ef7b2
commit dfa67bdca9
8 changed files with 19557 additions and 0 deletions

View File

@ -0,0 +1,42 @@
#!/usr/bin/env bash
categories=( adj adv noun verb )
declare -A categoriesByWord=()
echo "Parsing category lists.."
for (( c = 0; c < ${#categories[@]}; ++c )); do
printf '\rCategory: %s.. ' "${categories[c]}"
while read -r word _; do
categoriesByWord["$word"]+="$c "
done < ~/.dictionary.d/"index.${categories[c]}"
done
echo
echo "Processing words list.."
{
fdByCategory=()
for (( c = 0; c < ${#categories[@]}; ++c )); do
exec {fdByCategory[c]}>"words.txt.${categories[c]}"
done
w=0
while IFS= read -r word _; do
let ++w
if (( ${#word} < 3 )) || [[ $word != *[aeiou]* ]]; then
continue
fi
wordCategories=${categoriesByWord["$word"]}
for c in $wordCategories; do
printf '%d %s\n' "$w" "$word" >&"${fdByCategory[c]}"
done
done < words.txt
for fd in "${fdByCategory[@]}"; do
exec {fd}>&-
done
}
echo

View File

@ -0,0 +1,48 @@
#!/usr/bin/env bash
getword() {
local cat=$1 pop_limit=$2 words=()
while read pop word; do
(( pop_limit && pop > pop_limit )) && break
words+=( "$word" )
done < "words.txt.$cat"
(( ${#words[@]} )) || { echo '1 -'; return 1; }
echo "${#words[@]} ${words[RANDOM % ${#words[@]}]}"
}
declare -A categoryByCharacter=(
['a']=adj
['r']=adv
['n']=noun
['v']=verb
)
templates=(
nvan
anvr
anavan
)
permutations=1
while getopts :t:p: arg; do
case $arg in
# The sentence template to use.
t) template=$OPTARG ;;
# Use only the top N most popular words.
p) pop_limit=$OPTARG ;;
esac
done
template=${template:-${templates[$((RANDOM % ${#templates[@]}))]}}
printf 'sentence: '
while read -n1 character && [[ $character ]]; do
category=${categoryByCharacter["$character"]}
read p word < <(getword "$category" "$pop_limit")
(( permutations *= p ))
printf '%s ' "$word"
done <<< "$template"
echo
printf 'permutations: %s, entropy: ~%.1f bit\n' "$permutations" "$(bc -l <<< "l($permutations) / l(2)")"

View File

@ -0,0 +1,130 @@
#!/usr/bin/env bash
source bashlib
calc() { python -c "import math; print $1"; }
inf 'Calculate the maximum amount of time required to brute-force search for a password.'
## CLASSES
V="AEIOU"
C="BCDFGHJKLMNPQRSTVWXYZ"
v="aeiou"
c="bcdfghjklmnpqrstvwxyz"
A="$V$C"
a="$V$v$C$c"
n="0123456789"
o="&@%?,=[]_:-+*\$#!'^~;()/."
x="$a$n$o"
w="@~/.dictionary"
## METRICS
# 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 can be bought for about 950$ used. (ref. amazon.com)
#hardwareName='GTX Titan X (SHA1)' hardwareSpeed='5302M'
#hardwareName='GTX Titan X (SHA1 @ 5k$)' hardwareSpeed='5302M * 5k / 950'
#hardwareName='GTX Titan X (SHA1 @ 20k$)' hardwareSpeed='5302M * 20k / 950'
#hardwareName='GTX Titan X (SHA1 @ 20M$)' hardwareSpeed='5302M * 20M / 950'
#hardwareName='GTX Titan X (SHA1 @ 5B$)' hardwareSpeed='5302M * 5B / 950'
hardwareName='GTX Titan X (HMAC-SHA-256 @ 950$)' hardwareSpeed='403M'
#hardwareName='GTX Titan X (HMAC-SHA-256 @ 5k$)' hardwareSpeed='403M * 5k / 950'
#hardwareName='GTX Titan X (HMAC-SHA-256 @ 20k$)' hardwareSpeed='403M * 20k / 950'
#hardwareName='GTX Titan X (HMAC-SHA-256 @ 20M$)' hardwareSpeed='403M * 20M / 950'
#hardwareName='GTX Titan X (HMAC-SHA-256 @ 5B$)' hardwareSpeed='403M * 5B / 950'
# mpw-bench
#hardwareName='2.3 GHz i7, 8GB (MPW)' hardwareSpeed=7.46
# ASICs
hardwareName='AntMiner L3+ (scrypt)' hardwareSpeed='1M'
#hardwareName='AntMiner L3+ (scrypt @ 5k$)' hardwareSpeed='1M * 5k / 2500'
#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'
second='1'
secondsInHour='3600'
secondsInDay='3600 * 24'
secondsInMonth='3600 * 24 * 30'
secondsInYear='3600 * 24 * 356'
hardwareSpeed=${hardwareSpeed//k/000}
hardwareSpeed=${hardwareSpeed//M/000000}
hardwareSpeed=${hardwareSpeed//G/000000000}
hardwareSpeed=${hardwareSpeed//T/000000000000}
## SEARCH SPACE
hr
inf 'SEARCH SPACE'
inf 'You can use the following variables:'
for _c in V C v c A a n o x w; do
cc=${!_c}
if [[ $cc = @* ]]; then
file=${cc#@} file=${file/#~\//$HOME\/}
read cs < <(wc -l < "$file")
else
cs=${#cc}
fi
inf '%s: Class contains %d entities: %s' "$_c" "$cs" "$cc"
done
spaceString=${1:-$(ask -d "x ** 12" "Amount of space?")}
case "$spaceString" in
-mp*) mpmode=${spaceString#-mp} mpmode=${mpmode:-long}
case "$mpmode" in
long|l) spaceString='(CvcvnoCvcvCvcv+CvcvCvcvnoCvcv+CvcvCvcvCvcvno+CvccnoCvcvCvcv+CvccCvcvnoCvcv+CvccCvcvCvcvno+CvcvnoCvccCvcv+CvcvCvccnoCvcv+CvcvCvccCvcvno+CvcvnoCvcvCvcc+CvcvCvcvnoCvcc+CvcvCvcvCvccno+CvccnoCvccCvcv+CvccCvccnoCvcv+CvccCvccCvcvno+CvcvnoCvccCvcc+CvcvCvccnoCvcc+CvcvCvccCvccno+CvccnoCvcvCvcc+CvccCvcvnoCvcc+CvccCvcvCvccno)' ;;
max|secure|x) spaceString='aonxxxxxxxxxxxxxxxxx+axxxxxxxxxxxxxxxxxon' ;;
med|m) spaceString='CvcnoCvc+CvcCvcno' ;;
basic|b) spaceString='aaanaaan+aannaaan+aaannaaa' ;;
esac ;;
esac
space=$spaceString
for _c in V C v c A a n o x w; do
cc=${!_c}
if [[ $cc = @* ]]; then
file=${cc#@} file=${file/#~\//$HOME\/}
read cs < <(wc -l < "$file")
else
cs=${#cc}
fi
space=${space//$_c/ 0$cs }
done
# 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")
space=$(tr -s ' ' <<< "$space") space=${space# } space=${space% }
inf ''
inf "Search space: %s = %s = %'.f possibilities to try (~%.1f bit)." "$spaceString" "$space" "$(calc "$space")" "$(bc -l <<< "l($(calc "$space")) / l(2)")"
## CLUSTER SIZE
hr
inf 'CLUSTER SIZE'
inf "Simulating %s at a rate of about %'.1f attempts per second." "$hardwareName" "$(calc "$hardwareSpeed")"
cluster=$(ask -d 1 "Amount of GPUs?")
## CALCULATE
hr
inf 'TIMING'
inf "Time to search the entire space using %d GPUs of type %s (rate=%'.1f/s)" "$cluster" "$hardwareName" "$(calc "$hardwareSpeed")"
timing() {
local title=$1 unit=$2 precision=$3 seconds=$4
time=$(calc "1.0 * ($space) / ($hardwareSpeed * $cluster) / ($seconds)")
percent=$(calc "100.0 * ($hardwareSpeed * $cluster) * ($seconds) / ($space)")
amount=$(calc "$percent / 100.0")
if [[ $amount = 0.* ]]; then
inf "%10s to crack: %'0.${precision}f (search rate is %0.0f%% / %s)" \
"$title" "$time" "$percent" "$unit"
else
inf "%10s to crack: %'0.${precision}f (completes %0.1fx / %s)" \
"$title" "$time" "$amount" "$unit"
fi
}
timing Seconds s 0 "$second"
timing Hours h 2 "$secondsInHour"
timing Days d 3 "$secondsInDay"
timing Months m 4 "$secondsInMonth"
timing Years y 4 "$secondsInYear"

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,426 @@
17 not
25 all
27 new
28 more
33 home
36 about
42 free
43 but
60 out
62 any
63 there
65 only
70 here
74 also
75 now
83 first
92 some
103 back
109 just
110 over
121 next
126 last
127 most
144 such
145 please
150 after
151 best
153 then
155 good
157 well
164 high
166 through
168 each
174 very
189 under
195 full
202 way
206 part
211 real
213 item
224 off
229 before
233 right
250 within
259 between
263 long
269 even
278 much
283 today
285 south
310 down
325 north
329 big
349 small
379 non
389 still
397 little
401 low
425 around
427 course
435 too
443 west
447 left
460 live
461 large
465 however
471 really
485 second
494 better
514 again
519 never
532 below
534 less
546 above
575 east
595 hard
609 always
612 light
620 easy
631 needs
635 yet
696 away
702 once
707 least
713 sure
721 further
729 already
732 close
743 short
753 daily
755 past
758 due
776 pro
780 direct
796 ever
798 early
804 either
805 ago
827 true
831 third
837 bad
843 usually
845 together
848 fast
856 far
862 often
870 though
899 currently
903 clear
913 wide
924 half
930 quick
931 none
937 whole
940 later
959 enough
961 along
985 near
1042 double
1048 soon
1053 across
1086 inside
1090 rather
1095 nothing
1110 fine
1152 actually
1186 outside
1205 super
1210 almost
1227 late
1299 therefore
1300 simply
1304 round
1311 recently
1312 probably
1360 express
1367 thus
1372 extra
1373 especially
1384 quite
1396 forward
1403 retail
1406 directly
1447 instead
1473 likely
1515 pop
1519 longer
1523 behind
1535 deep
1537 otherwise
1582 maybe
1589 pretty
1610 throughout
1657 fair
1663 wrong
1667 finally
1681 fully
1690 dead
1725 sometimes
1728 beyond
1754 flat
1770 monthly
1797 clean
1813 weekly
1822 square
1839 lots
1842 firm
1893 lowest
1894 highly
1913 perhaps
1927 particularly
1935 easily
1991 generally
2003 quickly
2013 wild
2037 soft
2039 alone
2069 fresh
2121 immediately
2128 heavy
2228 approximately
2257 counter
2265 automatically
2306 yesterday
2309 wholesale
2319 completely
2343 earlier
2368 powerful
2371 false
2421 straight
2442 clearly
2445 sweet
2460 frequently
2485 exactly
2491 nearly
2504 faster
2508 con
2616 gratis
2622 slightly
2721 originally
2777 ahead
2822 previously
2850 nearby
2863 outdoors
2869 certainly
2870 indeed
2876 slow
2888 mostly
2946 specifically
2969 yeah
2977 fourth
3064 sharp
3129 totally
3147 extremely
3164 anyway
3176 anywhere
3198 plain
3330 warm
3447 truly
3509 properly
3517 newly
3532 tomorrow
3540 downtown
3549 absolutely
3570 significantly
3578 tonight
3579 dear
3607 northwest
3630 forth
3657 twice
3670 normally
3692 relatively
3715 effectively
3722 bright
3728 piano
3837 possibly
3839 typically
3938 successfully
3945 primarily
3946 tight
3985 eventually
4011 bang
4044 forever
4123 worst
4142 unfortunately
4143 respectively
4163 quiet
4173 carefully
4179 underground
4201 apart
4211 strongly
4241 mainly
4277 ill
4306 thin
4320 collect
4325 nationwide
4327 definitely
4343 necessarily
4352 apparently
4373 obviously
4379 worse
4388 somewhat
4418 passing
4441 okay
4458 closer
4491 pat
4522 hence
4524 entirely
4538 closely
4541 seriously
4552 elsewhere
4559 abroad
4578 overseas
4597 nearest
4652 southwest
4666 personally
4669 plenty
4670 solo
4680 somewhere
4715 fairly
4735 regardless
4752 thick
4801 regularly
4816 partly
4943 correctly
4962 widely
4986 overnight
5021 slowly
5061 quarterly
5173 loose
5184 southeast
5212 increasingly
5217 basically
5232 herein
5267 besides
5368 opposite
5370 rapidly
5420 moreover
5426 aside
5459 greatly
5465 commonly
5479 largely
5490 rough
5499 suddenly
5506 merely
5516 furthermore
5622 everywhere
5713 northeast
5739 initially
5811 perfectly
5814 instantly
5853 ultimately
5856 equally
5869 naturally
5883 potentially
5900 anymore
5917 constantly
5923 cod
5972 hopefully
5995 thereof
6020 virtually
6030 formerly
6039 strictly
6066 similarly
6069 solely
6249 offshore
6261 occasionally
6297 timely
6329 precious
6331 annually
6357 essentially
6423 locally
6509 separately
6544 somehow
6646 accordingly
6714 hardly
6774 additionally
6814 loud
6858 nevertheless
6864 surely
6881 reasonably
6916 exclusively
6955 actively
6963 fastest
6997 rarely
7014 thereby
7102 steady
7118 publicly
7119 hourly
7137 heavily
7161 meanwhile
7177 decent
7181 shortly
7244 substantially
7447 deeply
7507 hereby
7515 simultaneously
7528 officially
7545 safely
7548 periodically
7578 independently
7653 beneath
7673 soonest
7696 consistently
7708 subsequently
7726 mighty
7755 partially
7832 alias
7834 individually
7836 literally
7852 overhead
7921 closest
8026 consequently
8072 yea
8075 freely
8087 readily
8098 legally
8111 briefly
8123 barely
8124 wherever
8184 sheer
8236 roughly
8241 physically
8246 consecutive
8274 accurately
8312 thoroughly
8323 namely
8465 explicitly
8528 efficiently
8588 precisely
8619 alike
8713 internationally
8755 specially
8811 differently
8944 gradually
8957 afterwards
9017 manually
9025 yearly
9050 importantly
9109 deadly
9115 longest
9200 kinda
9213 proudly
9230 nationally
9237 flush
9256 continuously
9288 nowhere
9297 lately
9303 likewise
9369 dramatically
9413 alternatively
9420 gently
9473 securely
9517 temporarily
9531 sic
9573 promptly
9580 sexually
9605 badly
9611 continually
9636 presently
9668 thereafter
9680 awful
9703 bolt
9767 beautifully
9817 earliest
9828 sufficiently

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff