This commit is contained in:
2025-10-23 23:09:57 +09:00
parent 1dbeff9087
commit 41a23fdb84
4 changed files with 43 additions and 1 deletions

View File

@ -1,2 +1,2 @@
# go-study
git add test

BIN
helloworld Executable file

Binary file not shown.

7
helloworld.go Normal file
View File

@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Println("hello world")
}

35
main.go Normal file
View File

@ -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("✅ 스캔 완료.")
}