36 lines
588 B
Go
36 lines
588 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"sync"
|
|
"time"
|
|
)
|
|
|
|
func scanPort(host string, port int, wg *sync.WaitGroup) {
|
|
defer wg.Done()
|
|
|
|
address := fmt.Sprintf("%s:%d", host, port)
|
|
conn, err := net.DialTimeout("tcp", address, 500*time.Millisecond)
|
|
if err == nil {
|
|
fmt.Printf("[OPEN] %s\n", address)
|
|
conn.Close()
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
var wg sync.WaitGroup
|
|
|
|
host := "134.185.113.169" // 스캔할 IP 주소
|
|
startPort := 1
|
|
endPort := 1024
|
|
|
|
for port := startPort; port <= endPort; port++ {
|
|
wg.Add(1)
|
|
go scanPort(host, port, &wg)
|
|
}
|
|
|
|
wg.Wait()
|
|
fmt.Println("✅ 스캔 완료.")
|
|
}
|