learning ping by intercepting the response
- Dominant language
- Go
- Stars
- 6.8k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
I am new to tunnels and network level coding, however there are some great examples using gopacket specifically i found this one [Decoding Packet Layers here](https://www.devdungeon.com/content/packet-capture-injection-and-analysis-gopacket).
I am interested in understanding PING specifically so I slightly adjusted the code to
```go
ipLayer := packet.Layer(layers.LayerTypeIPv4)
if ipLayer != nil {
fmt.Println("IPv4 layer detected.")
ip, _ := ipLayer.(*layers.IPv4)
if ip.Protocol == layers.IPProtocolICMPv4 {
fmt.Println("icmp")
fmt.Println("payload ", string(ip.Payload))
fmt.Printf("From %s to %s\n", ip.SrcIP, ip.DstIP)
fmt.Println()
fmt.Printf("packet %+v\r\n", packet.Dump())
}
return
}
```
What I'm interested in is manipulating the ping response in this case. I.e when my computer is pinged from another device on the network (or the internet if thats configured on the router) can I hijack the response that my machine makes, i.e maybe by changing the payload or the latency (time it takes to respond). I.e can I get the pinger to receive data that is incorrect.
I tried adding a `time.Sleep(1 * time.Second)` in the above, however it doesn't slow the response down - so what I figure is I am reading the incoming data, but not hijacking the network to manipulate the returned data.
Can gopacket do this? What would the interception of the response look like so that I can add in an arbitrary delay and get ping latency of 1s +
Thanks for all/any help.
Contributor guide
Assessment
This issue has not been assessed yet.