ppforge/cmd/packetsend/main.go

25 lines
434 B
Go

package main
import (
"fmt"
"net"
"syscall"
)
// [poc->feat~send-packets~1]
func main() {
fd, err := syscall.Socket(syscall.AF_PACKET, syscall.SOCK_RAW, syscall.ETH_P_ALL)
if err != nil {
fmt.Println("Error: " + err.Error())
return
}
fmt.Println("Got fd", fd)
defer syscall.Close(fd)
ifaces, err := net.Interfaces()
for _, e := range ifaces {
fmt.Printf("Interface: %s %s\n", e.Name, e.HardwareAddr.String())
}
}