diff --git a/README.md b/README.md index c604e3b..cb5034a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ # go-study - +git add test \ No newline at end of file diff --git a/helloworld b/helloworld new file mode 100755 index 0000000..f0a32b6 Binary files /dev/null and b/helloworld differ diff --git a/helloworld.go b/helloworld.go new file mode 100644 index 0000000..87595e3 --- /dev/null +++ b/helloworld.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("hello world") +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..1734462 --- /dev/null +++ b/main.go @@ -0,0 +1,35 @@ +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("✅ 스캔 완료.") +}