-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.4.3 扫描速度比 1.4.2 慢很多 #31
Comments
对速度影响的还有一个提交,自适应速率,如果发包速率超过了网卡发包的能力就会降速,3e96b21 你添加个 -debug 参数看看输出,作为lib使用的时候对应参数是port.ScannerOption{
Debug: true,
}
…---原始邮件---
发件人: ***@***.***>
发送时间: 2024年12月30日(周一) 晚上6:23
收件人: ***@***.***>;
抄送: ***@***.***>;
主题: [XinRoom/go-portScan] 1.4.3 扫描速度比 1.4.2 慢很多 (Issue #31)
1.4.3版本,除了加了ipv6支持外,是不是还改了一下扫描配速的配置,我用1.4.3扫机器开放的端口的时候,发现同时扫五个IP的1-65535端口,二十多分钟才能扫完,1.4.2大概一分钟搞定。代码如下,调用的时候会多协程调用OpenPorts,传入单个ip地址:
func OpenPorts(ip string, portList []int) []int { b, err := json.Marshal(portList) if err != nil { logger.Error("Marshal portList get error:", err) return portList } pNum := len(portList) portStr := string(b) portStr = portStr[1 : len(portStr)-1] single := make(chan struct{}) retChan := make(chan port.OpenIpPort, pNum) ports, err := port.ShuffleParseAndMergeTopPorts(portStr) if err != nil || len(ports) < 1 { logger.Error("Parse portList get error:", err) return portList } retPortList := []int{} go func() { for ret := range retChan { retPortList = append(retPortList, int(ret.Port)) } single <- struct{}{} }() // parse ip addrType, err := common.JudgeHostType(ip) if addrType == common.INVALID { logger.Error("invalid ip:", ip) return portList } if addrType == common.DOMAIN { ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) defer cancel() r := net.Resolver{} ips, err := r.LookupIP(ctx, "ip", ip) if err != nil { logger.Error("LookupIP get error:", err, " ip:", ip) return portList } if len(ips) > 0 { ip = ips[0].String() } } it, startIp, _ := iprange.NewIter(ip) ss, err := syn.NewSynScanner(startIp, retChan, syn.DefaultSynOption) if err != nil { logger.Error("NewSynScanner get error:", err, " ip:", ip) return portList } portScan := func(ip net.IP) { for _, _port := range ports { ss.WaitLimiter() ss.Scan(ip, _port, port.IpOption{}) } } var wgPing sync.WaitGroup poolPing, _ := ants.NewPoolWithFunc(50, func(ip interface{}) { _ip := ip.(net.IP) portScan(_ip) wgPing.Done() }) defer poolPing.Release() for i := uint64(0); i < it.TotalNum(); i++ { ip := make(net.IP, len(it.GetIpByIndex(0))) copy(ip, it.GetIpByIndex(i)) wgPing.Add(1) poolPing.Invoke(ip) } wgPing.Wait() ss.Wait() ss.Close() <-single return retPortList }
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
好嘞,我试试 |
@XinRoom 配置里加了个debug以外,别的和syn.DefaultSynOption的配置一样,limiter是1500。感觉单独跑一个IP和同时跑多个IP,debug打印出来的限速差不多。我可以自己排查下是不是网速的问题吗? 单独跑一个IP是这样:
同时跑6个IP是这样:
|
@XinRoom 大哥我知道了,中午跑得慢应该是我网速的问题,现在到晚上了就很快了 |
|
如果同一网络环境下,1.4.3 与 1.4.2版本扫描速度在网卡最大发包数(比如调试信息显示该网卡最大1000左右)的限制下有很大差距的话,可以再提下问题。 |
@XinRoom 不用改成option,你那个策略是对的,自动按照网卡限速来调整比较好 |
1.4.3版本,除了加了ipv6支持外,是不是还改了一下扫描配速的配置,我用1.4.3扫机器开放的端口的时候,发现同时扫五个IP的1-65535端口,二十多分钟才能扫完,1.4.2大概一分钟搞定。代码如下,调用的时候会多协程调用OpenPorts,传入单个ip地址:
The text was updated successfully, but these errors were encountered: