summaryrefslogtreecommitdiffstats
path: root/utils/hexstream2cipher.sh
diff options
context:
space:
mode:
Diffstat (limited to 'utils/hexstream2cipher.sh')
-rwxr-xr-xutils/hexstream2cipher.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/utils/hexstream2cipher.sh b/utils/hexstream2cipher.sh
new file mode 100755
index 0000000..fff0689
--- /dev/null
+++ b/utils/hexstream2cipher.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env bash
+
+hs="$1"
+len=${#hs}
+echo "# ciphers: $((len/4))"
+
+mapfile="etc/cipher-mapping.txt"
+[ -s $mapfile ] || mapfile="../$mapfile"
+[ -s $mapfile ] || exit 255
+
+cip=""
+first=true
+
+for ((i=0; i<len ; i+=4)); do
+ printf "%02d" "$i"
+ echo -n ": ${hs:$i:4}"
+ grepstr="0x${hs:$i:2},0x${hs:$((i+2)):2}"
+ echo -n " --> $grepstr --> "
+ cip=$(grep -i -E "^ *${grepstr}" $mapfile | awk '{ print $3 }')
+ if [[ $grepstr == 0x00,0xff ]]; then
+ echo TLS_EMPTY_RENEGOTIATION_INFO_SCSV
+ else
+ echo $cip
+ fi
+ if "$first"; then
+ ciphers="$cip"
+ first=false
+ else
+ ciphers="$ciphers:$cip"
+ fi
+done
+
+echo
+# remove leading : because of GREASE, and trailing because of TLS_EMPTY_RENEGOTIATION_INFO_SCSV
+ciphers="${ciphers%:}"
+echo ${ciphers#:}
+
+# vim:ts=5:sw=5:expandtab