diff options
| -rwxr-xr-x | badpass | 19 | ||||
| -rwxr-xr-x | unlock_keys | 1 |
2 files changed, 10 insertions, 10 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 diff --git a/unlock_keys b/unlock_keys index a88674f..a6bc45f 100755 --- a/unlock_keys +++ b/unlock_keys @@ -3,6 +3,5 @@ eval $(keychain --eval -q --systemd) KEY_FILES=$(ls $HOME/.ssh | grep -v '\(pub$\|^config$\|^known_hosts$\|^autohrized_keys$\)') -echo -n "Master password: " badpass -k $KEY_FILES echo Done! |
