Skip to content

Commit

Permalink
scan
Browse files Browse the repository at this point in the history
  • Loading branch information
rasheedmhd committed Aug 25, 2024
1 parent f00d22a commit ae9a347
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions go/bhg/scanner.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package main

import (
"fmt"
"net"
"sync"
)

func main() {
var wg sync.WaitGroup
for i := 1; i <= 65535; i++ {
wg.Add(1)
go func(j int) {
defer wg.Done()
address := fmt.Sprintf("localhost:%d", j)
conn, err := net.Dial("tcp", address)
if err != nil {
return
}
conn.Close()
fmt.Printf("port %d is open\n", j)
}(i)
}
wg.Wait()
}

0 comments on commit ae9a347

Please sign in to comment.