Last active
January 17, 2020 06:29
-
-
Save redmcg/571bc4f1f67aeb1cf016af278205c12f to your computer and use it in GitHub Desktop.
Revisions
-
redmcg revised this gist
Jan 17, 2020 . 1 changed file with 29 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/usr/bin/env bash host=$1 awk -v host=$host ' function pad_key(pad, i, val) { for (i = 0; i < 64; i++) { val = sprintf("%s%02x", val, xor(strtonum("0x" substr(hexkey, i*2+1, 2)), pad)) } return val } /^|1/ { split($1, a, /\|/) key=a[3] hmac=a[4] "echo " key " | base64 -d | xxd -p " | getline hexkey o_key_pad = pad_key(0x5c) i_key_pad = pad_key(0x36) "bash -c '\''cat <(echo -n " o_key_pad " | xxd -r -p) <(cat <(echo -n " i_key_pad " | xxd -r -p) <(echo -n " host ") | sha1sum | xxd -r -p) | sha1sum | xxd -r -p | base64'\''" | getline myhmac if (hmac == myhmac) { print "# Host " host " found: line " NR print } }' ~/.ssh/known_hosts -
redmcg revised this gist
Jan 17, 2020 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,4 +2,16 @@ host=$1 awk -v host=$host ' /^|1/ { split($1, a, /\|/) key=a[3] hmac=a[4] "echo -n " host " | openssl sha1 -mac HMAC -macopt hexkey:$(echo " key " | base64 -d | xxd -p) -binary | base64" | getline myhmac if (hmac == myhmac) { print "# Host " host " found: line " NR print } }' ~/.ssh/known_hosts -
redmcg created this gist
Jan 17, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ #!/usr/bin/env bash host=$1 awk -v host=$host ' /^|1/ { split($1, a, /\|/); key=a[3]; hmac=a[4]; "echo -n " host " | openssl sha1 -mac HMAC -macopt hexkey:$(echo " key " | base64 -d | xxd -p) -binary | base64" | getline myhmac; if (hmac == myhmac) { print "# Host " host " found: line " NR; print $0 } } ' ~/.ssh/known_hosts