From cf50f02dc9e92fe84e569ca90b7a6e0314bb9657 Mon Sep 17 00:00:00 2001 From: niudaii <243536998@qq.com> Date: Tue, 21 Mar 2023 13:47:49 +0800 Subject: [PATCH] refactor: ipscan --- cmd/ipscan.go | 24 +++++------------------- pkg/ipscan/runner.go | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/cmd/ipscan.go b/cmd/ipscan.go index 58cbf15..daa295e 100644 --- a/cmd/ipscan.go +++ b/cmd/ipscan.go @@ -120,24 +120,10 @@ func initNmapProbe() error { if err = config.Worker.Ipscan.NmapProbe.Init(nmapData); err != nil { return err } - gologger.Info().Msgf("nmap指纹数量: %v个探针,%v条正则", len(config.Worker.Ipscan.NmapProbe.Probes), config.Worker.Ipscan.NmapProbe.Count()) + gologger.Info().Msgf("nmap指纹: %v个探针,%v条正则", len(config.Worker.Ipscan.NmapProbe.Probes), config.Worker.Ipscan.NmapProbe.Count()) return nil } -type Ip struct { - Ip string - Ports string - Country string - Area string - OS string -} - -type Service struct { - Address string - Protocol string - Version string -} - func (o *IpscanOptions) run() { var hosts []string for _, target := range targets { @@ -163,10 +149,10 @@ func (o *IpscanOptions) run() { gologger.Error().Msgf("ipscan.NewRunner() err, %v", err) return } - var ipResults []*Ip - var servResults []*Service + var ipResults []*ipscan.Ip + var servResults []*ipscan.Service for _, ip := range hosts { - ipResult := &Ip{ + ipResult := &ipscan.Ip{ Ip: ip, } // 获取地理位置 @@ -225,7 +211,7 @@ func (o *IpscanOptions) run() { } else if portscanResult.ServiceName == "unknown" { webTargets = append(webTargets, ip+":"+port) } else { - servResults = append(servResults, &Service{ + servResults = append(servResults, &ipscan.Service{ Address: portscanResult.Addr, Protocol: portscanResult.ServiceName, Version: fmt.Sprintf("%v %v", portscanResult.VendorProduct, portscanResult.Version), diff --git a/pkg/ipscan/runner.go b/pkg/ipscan/runner.go index 97a934c..72b1233 100644 --- a/pkg/ipscan/runner.go +++ b/pkg/ipscan/runner.go @@ -44,6 +44,20 @@ func NewRunner(options *Options) (*Runner, error) { }, nil } +type Ip struct { + Ip string + Ports string + Country string + Area string + OS string +} + +type Service struct { + Address string + Protocol string + Version string +} + func (r *Runner) Run() (results []*portfinger.Result) { start := time.Now() gologger.Info().Msgf("开始端口扫描")