google / google/gopacket

The packet sent on the window did not respond

Open
#927 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
6.8k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

The same code that sends ICMP packets on Linux responds, but not on Windows。

Any friends with the same problem???

`
import (
"fmt"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"net"
"time"
)

func send1(handle *pcap.Handle, l ...gopacket.SerializableLayer) error {
serializeOptions := gopacket.SerializeOptions{
FixLengths: true,
ComputeChecksums: true,
}
buf := gopacket.NewSerializeBuffer()
if err := gopacket.SerializeLayers(buf, serializeOptions, l...); err != nil {
return err
}
return handle.WritePacketData(buf.Bytes())
}

func Scan(dst string,port int) {
devices, _ := pcap.FindAllDevs()
face := devices[4]
networkInterfaces, _ := net.Interfaces()
networkInterface := networkInterfaces[4]
networkInterface.Name = face.Name
hwaddr := net.HardwareAddr{0x80, 0x05, 0x88, 0x59, 0x74, 0x5d}
handle, _ := pcap.OpenLive(networkInterface.Name, 65535, true, pcap.BlockForever)
// Construct all the network layers we need.
eth := layers.Ethernet{
SrcMAC: networkInterface.HardwareAddr,
DstMAC: hwaddr,
EthernetType: layers.EthernetTypeIPv4,
}
ip4 := layers.IPv4{
SrcIP: net.ParseIP("10.50.xxx.xxx"),
DstIP: net.ParseIP(dst),
Version: 4,
TTL: 128,
Protocol: layers.IPProtocolICMPv4,
Id: 0xa793,
}
icmp := layers.ICMPv4{
BaseLayer: layers.BaseLayer{},
TypeCode: layers.CreateICMPv4TypeCode(8,0),
Checksum: 0,
Id: 0x000d,
Seq: 37,
}

errs := send1(handle, ð, &ip4, &icmp)

fmt.Println(errs)
time.Sleep(time.Second*10)
}
`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.