Last active
July 17, 2022 20:38
-
-
Save pramos/06bb938e66e4e298f8d4ec56060a39a0 to your computer and use it in GitHub Desktop.
Go Script to enumerate all available network interfaces on a machine. Relies on gopacket.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"github.com/google/gopacket/pcap" | |
) | |
func main() { | |
devices, err := pcap.FindAllDevs() | |
if err != nil { | |
log.Fatalf("error retrieving devices - %v", err) | |
} | |
for _, device := range devices { | |
fmt.Printf("Device Name: %s\n", device.Name) | |
fmt.Printf("Device Description: %s\n", device.Description) | |
fmt.Printf("Device Flags: %d\n", device.Flags) | |
for _, iaddress := range device.Addresses { | |
fmt.Printf("\tInterface IP: %s\n", iaddress.IP) | |
fmt.Printf("\tInterface NetMask: %s\n", iaddress.Netmask) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment