golang-exercises/simple-port-scanner/main.go

36 lines
517 B
Go
Raw Permalink Normal View History

2024-10-13 21:12:58 +02:00
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) {
}