Skip to content

Commit

Permalink
timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberRoute committed Jan 12, 2024
1 parent 4000b68 commit de4240f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion scanme/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"net"
"time"

"github.com/CyberRoute/scanme/utils"
"github.com/google/gopacket"
Expand Down Expand Up @@ -244,6 +245,8 @@ func (s *scanner) Synscan() (map[layers.TCPPort]string, error) {
return nil, err
}

start := time.Now()

for {
// Send one packet per loop iteration until we've sent packets
// to all of ports [1, 65535].
Expand All @@ -254,9 +257,13 @@ func (s *scanner) Synscan() (map[layers.TCPPort]string, error) {
log.Printf("error sending to port %v: %v", tcp.DstPort, err)
}
} else if tcp.DstPort == 65535 {
log.Printf("last port scanned for %v dst port %s assuming we've seen all we can", s.dst, tcp.DstPort)
log.Printf("last port scanned for %v dst port %s", s.dst, tcp.DstPort)
return openPorts, nil
}
if time.Since(start) > time.Second*5 {
log.Printf("timed out for %v aborting scan", s.dst)
return nil, nil
}

eth := &layers.Ethernet{}
ip4 := &layers.IPv4{}
Expand Down

0 comments on commit de4240f

Please sign in to comment.