Multiple protocols on one port: example with TLS1.1 & TLS1.2 #728
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to add the possibility to retry with another protocol when the first one failed. The implemented example is for TLS: if we have an alert when trying TLS 1.1, we want to retry on the same host, port with TLS 1.2.
The result is that the x509 certificate of a server that only supports TLS1.2 will now be successfully grabbed by
masscanned
(while before it would not have been):However, I am not 100% confident this PR does not have important drawbacks on the performances or even if it breaks things, so any review/testing/feedback/suggestion is welcome.
Here is an overview on how it is implemented:
next
in theProtocolParserStream
struct, we can already link several protocols in one port (see code):ProtocolState
state, calledtry_next
, which is set by a protocol parser when it fails (this tells that the next one should be tried) -- for instance, the TLS 1.1 parsing function settry_next
to1
(true
) when it parses an SSL alert (see diff):SYN
packet in the sending queue when the fieldtry_next
of the protocol state is set to1
(see diff):SYN-ACK
from the server). What we suggest here is to compute the syn-cookie of the second attempt withentropy + 1
as a key instead ofentropy
. Of course, this implies to try both keys when we receive a packet, but this allows for the receiving thread to know the index of the protocol to try in the linked-list of protocols: