2 Ocak 2019 Çarşamba

TCP Header - Sequence Number Alanı

Giriş
32 bit uzunluğundadır. Açıklaması şöyle.
Represents either (if the SYN bit is set)  the initial sequence number or (if the SYN bit is not set) the sequence number of the current packet. 
Bu alanla ilgili açıklama şöyle. Yani ilk başlangıç değeri tam random olmasa bile tahmin etmesi zor bir değerdir.
The first standard specifying modern TCP is RFC793 from 1981 (with predecessors dating back to 1974), which says about initial sequence number selection
...
So they recognized that the sequence number has to be relatively unique, to avoid accidental collision between separate sessions. It didn't, however, consider deliberate attack.

Possible attacks against TCP sequence numbers were first described in 1985, and there were various vendor-specific fixes for it. Finally in 1996, RFC1948 standardized one fix, which uses a cryptographic hash of ports, addresses and secret key to decide the initial sequence number.

This is still the method that is used in e.g. Linux kernel secure_tcp_seq. So it is not really random (which would risk random collisions), but just difficult to predict without knowing the secret key (net_secret in Linux kernel).
Birçok kaynakta aşağıdaki alıntı gibi bu alanın rastgele seçildiği söyleniyor. Ancak rastgele değildir.
The initial sequence number is randomly selected to avoid connection hijacking. Without randomly selecting the initial sequence number, this number would be easily guessable, allowing an attacker to blindly send a sequences of packets that the receiver would believe to come from a different IP address.
Wireshark
Wireshark gösterim için TCP Sequence Number değeri yerine kendisinin ürettiği bir sayı kullanıyor. Bu özellik "Edit > Preferences > Protocols > TCP" penceresindeki "Relative sequence numbers" seçeneği ile açılıp kapatılabilir.

Gerçek TCP
Gerçek TCP'de şöyle çalışıyor.
Paket 1 için Seq # 1 olsun. Payload 25 olsun
Paket 2 için Seq # 26 olur. Payload 10 olsun
Paket 3 için Seq # 36 olur.
Yani bir sonraki sequence sayısı paketteki sayı + byte cinsinden payload büyüklüğü olarak hesaplanır.





Hiç yorum yok:

Yorum Gönder