Skip to content

Commit

Permalink
check that close handle work. 7
Browse files Browse the repository at this point in the history
  • Loading branch information
adedayo committed Feb 9, 2019
1 parent 01ce76c commit 8019c9e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions portscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func ScanCIDR(config ScanConfig, cidrAddresses ...string) <-chan PortACK {
go func(ips []string, ports []int) { // run the scans in parallel
println("SCanCIDR INNER goroutine")

writeHandle := getHandle(filter, config)
writeHandle := getNonFilteredHandle(config)
defer func() {
println("Closing writehandle")
writeHandle.Close()
Expand All @@ -151,7 +151,6 @@ func ScanCIDR(config ScanConfig, cidrAddresses ...string) <-chan PortACK {
sourcePort := 50000
for _, dstPort := range ports {
for _, dstIP := range ips {
fmt.Printf("Processing %s:%d\n", dstIP, dstPort)
dst := net.ParseIP(dstIP)
// Send a specified number of SYN packets
for i := 0; i < count; i++ {
Expand Down Expand Up @@ -658,3 +657,11 @@ func getHandle(bpfFilter string, config ScanConfig) *pcap.Handle {
handle.SetBPFFilter(bpfFilter)
return handle
}

func getNonFilteredHandle(config ScanConfig) *pcap.Handle {
dev, _, err := getPreferredDevice(config)
bailout(err)
handle, err := pcap.OpenLive(dev.Name, 65535, false, pcap.BlockForever)
bailout(err)
return handle
}

0 comments on commit 8019c9e

Please sign in to comment.