使用方法:command [options] addr
options:
-p 使用指定协议,如:tcp、udp,默认为tcp
-c 使用指定cpu数量,默认为1
-t 使用指定线程数,默认为1(使用多线程扫描,速度会更快)
-d 扫描单个端口超时控制,单位:秒,默认为5秒
package main
import (
"fmt"
"net"
"time"
"sync"
"flag"
"os"
"runtime"
)
type PortScan struct {
timeOut time.Duration
protocol string
cores int
threads int
addr string
availablePort []int
wasteTime int64
rwLocker sync.RWMutex
}
var protocol = flag.String("p", "tcp", "Use the specified protocol")
var cores = flag.Int("c", 1, "Use the specified core number")
var threads = flag.Int("t", 0, "Use the specified thread number")
var timeout = flag.Int("d", 5, "Use the specif

本文介绍如何利用Golang创建一个端口扫描器。通过指定协议(默认TCP)、CPU数量和线程数来定制扫描。同时,文章还讨论了单个端口扫描的超时控制,超时默认设置为5秒,以提高扫描效率。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



