From 7ae4eb13c934d3d4f501e0f80ecdef272d39e383 Mon Sep 17 00:00:00 2001 From: tsosunchia <59512455+tsosunchia@users.noreply.github.com> Date: Wed, 17 Apr 2024 19:34:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B1=E4=BA=8E=E9=83=A8=E5=88=86=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E6=88=AA=E6=96=ADicmp=20data=E6=95=85ttl=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E5=9C=A8seq=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trace/icmp_ipv4.go | 5 +++-- trace/icmp_ipv6.go | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/trace/icmp_ipv4.go b/trace/icmp_ipv4.go index 5b9065ec..d93aa25c 100644 --- a/trace/icmp_ipv4.go +++ b/trace/icmp_ipv4.go @@ -150,7 +150,7 @@ func (t *ICMPTracer) listenICMP() { } continue } - ttl := int(msg.Msg[36]) + ttl := int64(binary.BigEndian.Uint16(msg.Msg[34:36])) packet_id := strconv.FormatInt(int64(binary.BigEndian.Uint16(msg.Msg[32:34])), 2) if process_id, _, err := reverseID(packet_id); err == nil { if process_id == int64(os.Getpid()&0x7f) { @@ -271,7 +271,8 @@ func (t *ICMPTracer) send(ttl int) error { id := gernerateID(0) // log.Println("发送的", id) - data := []byte{byte(ttl)} + //data := []byte{byte(ttl)} + data := []byte{byte(0)} data = append(data, bytes.Repeat([]byte{1}, t.Config.PktSize-5)...) data = append(data, 0x00, 0x00, 0x4f, 0xff) diff --git a/trace/icmp_ipv6.go b/trace/icmp_ipv6.go index ecb4a705..f46be27e 100644 --- a/trace/icmp_ipv6.go +++ b/trace/icmp_ipv6.go @@ -171,7 +171,7 @@ func (t *ICMPTracerv6) listenICMP() { } } - ttl := int(msg.Msg[56]) + ttl := int64(binary.BigEndian.Uint16(msg.Msg[54:56])) packet_id := strconv.FormatInt(int64(binary.BigEndian.Uint16(msg.Msg[52:54])), 2) if process_id, _, err := reverseID(packet_id); err == nil { if process_id == int64(os.Getpid()&0x7f) { @@ -264,7 +264,8 @@ func (t *ICMPTracerv6) send(ttl int) error { //id := gernerateID(ttl) id := gernerateID(0) - data := []byte{byte(ttl)} + //data := []byte{byte(ttl)} + data := []byte{byte(0)} data = append(data, bytes.Repeat([]byte{1}, t.Config.PktSize-5)...) data = append(data, 0x00, 0x00, 0x4f, 0xff)