35 lines
556 B
Go
35 lines
556 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"strconv"
|
|
"sync"
|
|
)
|
|
|
|
func main() {
|
|
remoteIpPtr := flag.String("remote", "", "Remote Server")
|
|
|
|
flag.Parse()
|
|
ports := flag.Args()
|
|
remoteIp := *remoteIpPtr
|
|
fmt.Println(remoteIp)
|
|
var hostWG sync.WaitGroup
|
|
|
|
ports = portsSetup(ports)
|
|
go scanIp(ports, remoteIp, &hostWG)
|
|
hostWG.Add(1)
|
|
|
|
hostWG.Wait()
|
|
fmt.Println("Process complete.")
|
|
}
|
|
|
|
func portsSetup(ports []string) []string {
|
|
if len(ports) == 0 {
|
|
for i := 1; i < 65535; i++ {
|
|
ports = append(ports, strconv.FormatInt(int64(i), 10))
|
|
}
|
|
}
|
|
return ports
|
|
}
|