August 2019
Beginner to intermediate
798 pages
17h 2m
English
In this subsection, you will learn how to use the syscall package to capture raw ICMP network data and syscall.SetsockoptInt() in order to set the options of a socket.
Keep in mind that sending raw ICMP data is much more difficult, as you will have to construct the raw network packets on your own. The name of the utility is syscallNet.go, and it will be shown in four parts.
The first part of syscallNet.go is as follows:
package main
import (
"fmt"
"os"
"syscall"
)
The second segment of syscallNet.go contains the following Go code:
func main() { fd, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_RAW, syscall.IPPROTO_ICMP) if err != nil { fmt.Println("Error in syscall.Socket:", err) return } f := os.NewFile(uintptr(fd), ...Read now
Unlock full access