Skip to content

Commit

Permalink
Fix cookies update
Browse files Browse the repository at this point in the history
  • Loading branch information
macronut authored Apr 13, 2023
1 parent 4062e51 commit 56b50d2
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions header/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,23 @@ func TCPRecv(address string, forward bool) {
}

if info != nil && info.Option&OPT_TFO != 0 {
ackNum := binary.BigEndian.Uint32(packet.Raw[ipheadlen+8:])
ackNum = info.SeqNum + 1
binary.BigEndian.PutUint32(packet.Raw[ipheadlen+8:], ackNum)
packet.CalcNewChecksum(winDivert)
tcpheadlen := int(packet.Raw[ipheadlen+12]>>4) * 4
optStart := ipheadlen + 20
option := packet.Raw[optStart : ipheadlen+tcpheadlen]
cookies := getCookies(option)
if cookies != nil {
tmp_cookies := make([]byte, len(cookies))
copy(tmp_cookies, cookies)
CookiesMap[packet.SrcIP().String()] = tmp_cookies
continue
} else {
ackNum := binary.BigEndian.Uint32(packet.Raw[ipheadlen+8:])
ackNum = info.SeqNum + 1
binary.BigEndian.PutUint32(packet.Raw[ipheadlen+8:], ackNum)
packet.CalcNewChecksum(winDivert)
}
}
}

} else if packet.Raw[ipheadlen+13]|TCP_RST != 0 {
if DetectEnable {
dstPort, _ := packet.DstPort()
Expand Down

0 comments on commit 56b50d2

Please sign in to comment.