More correct calculation of dc for obfuscated2 frame

This commit is contained in:
9seconds
2021-04-01 14:19:52 +03:00
parent 03d98ee256
commit 26070d5b3e
2 changed files with 28 additions and 6 deletions
@@ -1,7 +1,5 @@
package obfuscated2
import "encoding/binary"
const (
DefaultDC = 2
@@ -10,14 +8,12 @@ const (
handshakeFrameLenKey = 32
handshakeFrameLenIV = 16
handshakeFrameLenConnectionType = 4
handshakeFrameLenDC = 2
handshakeFrameOffsetStart = 8
handshakeFrameOffsetKey = handshakeFrameOffsetStart
handshakeFrameOffsetIV = handshakeFrameOffsetKey + handshakeFrameLenKey
handshakeFrameOffsetConnectionType = handshakeFrameOffsetIV + handshakeFrameLenIV
handshakeFrameOffsetDC = handshakeFrameOffsetConnectionType + handshakeFrameLenConnectionType
handshakeFrameOffsetEnd = handshakeFrameOffsetDC + handshakeFrameLenDC
)
// Connection-Type: Secure. We support only fake tls.
@@ -38,8 +34,7 @@ type handshakeFrame struct {
}
func (h *handshakeFrame) dc() int {
data := h.data[handshakeFrameOffsetDC:handshakeFrameOffsetEnd]
idx := int16(binary.LittleEndian.Uint16(data))
idx := int16(h.data[handshakeFrameOffsetDC]) | int16(h.data[handshakeFrameOffsetDC+1])<<8 // nolint: gomnd, lll // little endian for int16 is here
switch {
case idx > 0: