Skip to content

Commit

Permalink
Use available interface in decoys example
Browse files Browse the repository at this point in the history
  • Loading branch information
elivlo committed Apr 13, 2023
1 parent f951c6b commit 2dbcad4
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions examples/spoof_and_decoys/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,30 @@ import (
)

func main() {
ifaceScanner, err := nmap.NewScanner(context.Background())
if err != nil {
log.Fatalf("unable to create nmap scanner: %v", err)
}

interfaceList, err := ifaceScanner.GetInterfaceList()
if err != nil {
log.Fatalf("could not get interface list: %v", err)
}

if len(interfaceList.Interfaces) == 0 {
log.Fatal("no interface to scan with")
}

lastInterfaceIndex := len(interfaceList.Interfaces) - 1
interfaceToScan := interfaceList.Interfaces[lastInterfaceIndex].Device

// Equivalent to
// nmap -e eth0 -S 192.168.0.10 \
// nmap -S 192.168.0.10 \
// -D 192.168.0.2,192.168.0.3,192.168.0.4,192.168.0.5,192.168.0.6,ME,192.168.0.8 \
// 192.168.0.72`.
scanner, err := nmap.NewScanner(
context.Background(),
nmap.WithInterface("eth0"),
nmap.WithInterface(interfaceToScan),
nmap.WithTargets("192.168.0.72"),
nmap.WithSpoofIPAddress("192.168.0.10"),
nmap.WithDecoys(
Expand Down

0 comments on commit 2dbcad4

Please sign in to comment.