mirror of
https://github.com/drwetter/testssl.sh.git
synced 2025-01-10 10:40:57 +01:00
Modernize code2network()
This function had before a mixture of sed and tr commands which was now replaced by bash internal functions. It makes the code better, performance gain in the LAN is neglectable (1s). This brings code2network somewhat in line with socksend(). This function does basically the same (and thus is probably prone to extinction ;-) ). Albeit there the good thing is it does conversion and sending in one shot.
This commit is contained in:
parent
5aadc1951d
commit
0d8abd131e
16
testssl.sh
16
testssl.sh
@ -10462,8 +10462,18 @@ send_close_notify() {
|
|||||||
# Format string properly for socket
|
# Format string properly for socket
|
||||||
# ARG1: any commented sequence of two bytes hex, separated by commas. It can contain comments, new lines, tabs and white spaces
|
# ARG1: any commented sequence of two bytes hex, separated by commas. It can contain comments, new lines, tabs and white spaces
|
||||||
# NW_STR holds the global with the string prepared for printf, like '\x16\x03\x03\'
|
# NW_STR holds the global with the string prepared for printf, like '\x16\x03\x03\'
|
||||||
|
# As opposed to socksend() below this is the function where the hexbytes are NOT preceeded by x (mainly they are @ heartbleed,
|
||||||
|
# ccs and # ticketbleed). Best would be to settle on one function and remove the need for NW_STR, i.e. do everything in one shot.
|
||||||
code2network() {
|
code2network() {
|
||||||
NW_STR=$(sed -e 's/,/\\\x/g' <<< "$1" | sed -e 's/# .*$//g' -e 's/ //g' -e '/^$/d' | tr -d '\n' | tr -d '\t')
|
local temp="" line=""
|
||||||
|
|
||||||
|
NW_STR=$(while read -r line; do
|
||||||
|
[[ -z "$line" ]] && continue # blank line
|
||||||
|
temp="${line%%\#*}" # remove comments
|
||||||
|
temp="${temp//,/\\\x}" # comma to \x
|
||||||
|
temp="${temp//[\t ]/}" # blank and tabs
|
||||||
|
printf "%s" "$temp"
|
||||||
|
done <<< "$1")
|
||||||
}
|
}
|
||||||
|
|
||||||
# sockets inspired by http://blog.chris007.de/?p=238
|
# sockets inspired by http://blog.chris007.de/?p=238
|
||||||
@ -14708,7 +14718,7 @@ tls_sockets() {
|
|||||||
finished_msg="$(sym-encrypt "$cipher" "$key" "$(get-nonce "$iv" 0)" "${finished_msg}16" "")"
|
finished_msg="$(sym-encrypt "$cipher" "$key" "$(get-nonce "$iv" 0)" "${finished_msg}16" "")"
|
||||||
fi
|
fi
|
||||||
finished_msg="$aad$finished_msg"
|
finished_msg="$aad$finished_msg"
|
||||||
|
|
||||||
len=${#finished_msg}
|
len=${#finished_msg}
|
||||||
for (( i=0; i < len; i+=2 )); do
|
for (( i=0; i < len; i+=2 )); do
|
||||||
data+=", ${finished_msg:i:2}"
|
data+=", ${finished_msg:i:2}"
|
||||||
@ -14716,7 +14726,7 @@ tls_sockets() {
|
|||||||
debugme echo -e "\nsending finished..."
|
debugme echo -e "\nsending finished..."
|
||||||
socksend_clienthello "${data}"
|
socksend_clienthello "${data}"
|
||||||
sleep $USLEEP_SND
|
sleep $USLEEP_SND
|
||||||
|
|
||||||
# Compute application traffic keys and IVs.
|
# Compute application traffic keys and IVs.
|
||||||
master_secret="$(derive-master-secret "$cipher" "$handshake_secret")"
|
master_secret="$(derive-master-secret "$cipher" "$handshake_secret")"
|
||||||
master_traffic_keys="$(derive-application-traffic-keys "$cipher" "$master_secret" "$msg_transcript" server)"
|
master_traffic_keys="$(derive-application-traffic-keys "$cipher" "$master_secret" "$msg_transcript" server)"
|
||||||
|
Loading…
Reference in New Issue
Block a user