diff options
Diffstat (limited to 'badpass')
| -rwxr-xr-x | badpass | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -1,9 +1,13 @@ #!/bin/sh -# Requires expect +# A bad password derivation scheme, hopefully portable. +# Requires `expect' to enable `keychain' key unlocking. +# Read source for detail. -PREFIX="THIS IS TOTALLY SUPER SECRET" -PHRASE="THIS IS TOTALLY SUPER SECRET" +PREFIX="Prepended to every password, usually special chars + uppercase" +MIDFIX="A not-necessarily-secret string to prevent pre-baked rainbow tables" + +echo -n "Master password: " # Supress echo, and trap exit for correct restoration stty -echo @@ -16,10 +20,7 @@ read -r MASTER # Restore state stty echo trap - EXIT - -USEECHO () { - echo $1 $2 -} +echo USEKEYCHAIN () { expect - <<EOF @@ -30,13 +31,13 @@ expect { EOF } -CALL=USEECHO +CALL=echo if [ "$1" = "-k" ]; then CALL=USEKEYCHAIN shift fi; for NAME in "$@"; do - PREPASS=$(echo $NAME$PHRASE$MASTER | sha256sum | cut -b -24) + PREPASS=$(echo $NAME$MIDFIX$MASTER | sha256sum | cut -b -24) $CALL $NAME $PREFIX$PREPASS done |
