Three-Way Handshake
1. SYN/ACK
Section titled “1. SYN/ACK”Processo responsável pelo estabelecimento de conexão através do protocolo TCP. Para que isso se concretize, é importante que essa técnica atua com os seguintes passos:
-
SYN= (Synchronize) -
ACK= (Acknowledgement)
Os processos são os seguintes:
- O cliente envia um pacote com a flag SYN ativa junto de uma sequência randômica de números (ISN);
- O cliente entra em estado de SYN-SENT;
- O servidor responde com uma pacote com as flags SYN + ACK (ACK = Client ISN + 1) e providenciando seu próprio ISN;
- O servidor entra em estado de SYN-RCVD;
- O cliente responde com um pacote ACK (ACK = Server ISN + 1).
- Ambos os participantes entram em estado de ESTABLISHED e os dados podem ser transferidos.
Administradores de rede, pentesters e engenheiros de segurança pode observar a three-way handshake por meio do Shell Linux.
Comandos mais comuns:
1.1. Tcpdump
Section titled “1.1. Tcpdump”It can capture network traffic to display the SYN, SYN-ACK, and ACK packets in real-time.
tcpdump1.2. Nestat
Section titled “1.2. Nestat”It shows the various connection states (SYN-SENT, SYN-RCVD, CLOSE_WAIT, TIME_WAIT and ESTABLISHED) within the kernel’s state machine. A more recent variation of this command is ss.
nestatResultado:
Active Internet connections (w/o servers)Proto Recv-Q Send-Q Local Address Foreign Address Statetcp 0 0 GLB01TIDP13274:54128 151.101.1.91:https ESTABLISHEDtcp 0 0 localhost:xtel localhost:40702 TIME_WAITtcp 0 0 localhost:xtel localhost:47702 TIME_WAITtcp 0 0 GLB01TIDP13274:52122 93.243.107.34.bc.:https ESTABLISHEDtcp 0 0 localhost:53914 localhost:xtel ESTABLISHEDtcp 0 0 localhost:40686 localhost:xtel ESTABLISHEDtcp 0 0 GLB01TIDP13274:52116 93.243.107.34.bc.:https ESTABLISHEDtcp 0 0 GLB01TIDP13274:39248 upload-lb.magru.w:https ESTABLISHEDA aplicação Wireshark também permite a mesma visualização, sendo desta vez através de interface gráfica, capturando arquivos
.pcape visualizando o processo de handshake com detalhes.
1. Por que o comando netstat deve ser utilizado?
Section titled “1. Por que o comando netstat deve ser utilizado?”-
Monitor connection status: identify if connections are successfully moving to the
ESTABLISHEDstate or if they are stuck int intermediate states; -
Troubleshoot failures: if connections remain in
SYN_SENT(client side) orSYN_RCVD(server side), it suggests a firewall might be blocking traffic, a service ins’t listening, or there’s a potential _SYN Flood Attack; -
Detect security threads: a large number of connections in the
SYN_RCVDstate on a server can indicate a Denial of Service (DoS) attack.