Skip to content

Commit e09d79a

Browse files
committed
Fix error message on UI when testing Opossum
As `wait_kill()` returns with 0 when a TCP reset is encountered and the process is not killed, we need to open the socket again in a sub shell. Which is safe in the foreground. If then the subshell returns with 0 we can safely connect to port 80.
1 parent ea3cc37 commit e09d79a

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

testssl.sh

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,26 +1942,31 @@ http_head_printf() {
19421942
# This is a subshell, so fd 8 is not inherited
19431943
bash -c "exec 8<>/dev/tcp/$node/80" 2>/dev/null &
19441944
wait_kill $! $HEADER_MAXSLEEP
1945-
if [[ $? -eq 0 ]]; then
1946-
exec 33<>/dev/tcp/$node/80
1947-
# not killed --> socket open. Now we connect to the virtual host "$node"
1948-
printf -- "%b" "HEAD ${proto}//${node}/${query} HTTP/1.1\r\nUser-Agent: ${useragent}\r\nHost: ${node}\r\n${request_header}\r\nAccept: */*\r\n\r\n\r\n" >&33 2>$errfile
1949-
ret=0
1950-
if [[ $DEBUG -eq 0 ]] ; then
1951-
cat <&33
1952-
else
1953-
cat <&33 >$tmpfile
1954-
cat $tmpfile
1955-
fi
1956-
else
1957-
if [[ -n "$PROXY" ]]; then
1958-
ret=3
1945+
if [[ $? -ne 3 ]]; then
1946+
# process with pid !$ wasn't killed but was that a reject? So we try again
1947+
# to make sure there wasn't a TCP reset
1948+
bash -c "exec 8<>/dev/tcp/$node/80" 2>/dev/null
1949+
if [[ $? -eq 0 ]]; then
1950+
exec 33<>/dev/tcp/$node/80
1951+
# not killed --> socket open. Now we connect to the virtual host "$node"
1952+
printf -- "%b" "HEAD ${proto}//${node}/${query} HTTP/1.1\r\nUser-Agent: ${useragent}\r\nHost: ${node}\r\n${request_header}\r\nAccept: */*\r\n\r\n\r\n" >&33 2>$errfile
1953+
ret=0
1954+
if [[ $DEBUG -eq 0 ]] ; then
1955+
cat <&33
1956+
else
1957+
cat <&33 >$tmpfile
1958+
cat $tmpfile
1959+
fi
19591960
else
1960-
ret=1
1961+
if [[ -n "$PROXY" ]]; then
1962+
ret=3
1963+
else
1964+
ret=1
1965+
fi
19611966
fi
1967+
exec 33<&-
1968+
exec 33>&-
19621969
fi
1963-
exec 33<&-
1964-
exec 33>&-
19651970
return $ret
19661971
}
19671972

0 commit comments

Comments
 (0)