summaryrefslogtreecommitdiff
path: root/badpass
diff options
context:
space:
mode:
Diffstat (limited to 'badpass')
-rwxr-xr-xbadpass42
1 files changed, 42 insertions, 0 deletions
diff --git a/badpass b/badpass
new file mode 100755
index 0000000..6a350cf
--- /dev/null
+++ b/badpass
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# Requires expect
+
+PREFIX="THIS IS TOTALLY SUPER SECRET"
+PHRASE="THIS IS TOTALLY SUPER SECRET"
+
+# Supress echo, and trap exit for correct restoration
+stty -echo
+trap 'stty echo' EXIT
+
+# Read without processing at all
+IFS=""
+read -r MASTER
+
+# Restore state
+stty echo
+trap - EXIT
+
+USEECHO () {
+ echo $1 $2
+}
+
+USEKEYCHAIN () {
+ expect - <<EOF
+spawn keychain --nogui --quiet $1
+expect {
+ "Enter passphrase for $HOME/.ssh/$1:"; { send "$2\n"; }
+}
+EOF
+}
+
+CALL=USEECHO
+if [ "$1" = "-k" ]; then
+ CALL=USEKEYCHAIN
+ shift
+fi;
+
+for NAME in "$@"; do
+ PREPASS=$(echo $NAME$PHRASE$MASTER | sha256sum | cut -b -24)
+ $CALL $NAME $PREFIX$PREPASS
+done