Skip to content

Commit

Permalink
refactor: ipscan
Browse files Browse the repository at this point in the history
  • Loading branch information
niudaii committed Mar 21, 2023
1 parent c7c6105 commit cf50f02
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
24 changes: 5 additions & 19 deletions cmd/ipscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
}
// 获取地理位置
Expand Down Expand Up @@ -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),
Expand Down
14 changes: 14 additions & 0 deletions pkg/ipscan/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("开始端口扫描")
Expand Down

0 comments on commit cf50f02

Please sign in to comment.