diff --git a/simple-port-scanner/go.mod b/simple-port-scanner/go.mod new file mode 100644 index 0000000..1a871c6 --- /dev/null +++ b/simple-port-scanner/go.mod @@ -0,0 +1,3 @@ +module simple-port-scanner + +go 1.23.2 diff --git a/simple-port-scanner/main.go b/simple-port-scanner/main.go new file mode 100644 index 0000000..c4b4876 --- /dev/null +++ b/simple-port-scanner/main.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + "log" + "net" + "os" +) + +var ( + IP string + Port string + ScanType = "tcp" +) + +func main() { + if len(os.Args) != 3 { + fmt.Printf("Insufficient arguments:\n./simple-port-scanner $IP $PORT") + os.Exit(0) + } + IP = os.Args[1] + Port = os.Args[2] + fmt.Printf("Scanning %v:%v...\n", IP, Port) + + conn, err := net.Dial(ScanType, IP+":"+Port) + if err != nil { + log.Fatalf("Fatal error occurred while scanning port: %v\n", err) + } + defer conn.Close() + +} + +func handleConn(conn net.Conn) { + +}