Added simple-port-scanner exercise!
This commit is contained in:
parent
1e08dc4069
commit
cd17d47e0d
|
@ -0,0 +1,3 @@
|
|||
module simple-port-scanner
|
||||
|
||||
go 1.23.2
|
|
@ -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) {
|
||||
|
||||
}
|
Loading…
Reference in New Issue