| skipped 29 lines |
30 | 30 | | |
31 | 31 | | var ( |
32 | 32 | | nmapScan bool |
| 33 | + | script bool |
33 | 34 | | urls bool |
34 | 35 | | noCPEs bool |
35 | 36 | | noTags bool |
| skipped 19 lines |
55 | 56 | | flag.BoolVar(&urls, "url", false, "Show only IP and Port") |
56 | 57 | | flag.IntVar(&concurrency, "c", 5, "Concurrency") |
57 | 58 | | flag.BoolVar(&nmapScan, "nmap", false, "Run Nmap Service Detection") |
| 59 | + | flag.BoolVar(&script, "script", false, "Run Nmap Scripts") |
58 | 60 | | flag.Parse() |
59 | 61 | | |
60 | 62 | | var inputs, targets []string |
| skipped 322 lines |
383 | 385 | | |
384 | 386 | | ports := strings.Trim(strings.Join(strings.Fields(fmt.Sprint(intPorts)), ", "), "[]") |
385 | 387 | | |
386 | | - | scanner, err := nmap.NewScanner( |
| 388 | + | var options = []nmap.Option{ |
387 | 389 | | nmap.WithTargets(target), |
388 | 390 | | nmap.WithPorts(ports), |
389 | 391 | | nmap.WithServiceInfo(), |
390 | 392 | | nmap.WithSkipHostDiscovery(), |
391 | | - | ) |
| 393 | + | } |
| 394 | + | |
| 395 | + | if script { |
| 396 | + | options = append(options, nmap.WithDefaultScript()) |
| 397 | + | } |
| 398 | + | |
| 399 | + | scanner, err := nmap.NewScanner(options...) |
392 | 400 | | if err != nil { |
393 | 401 | | log.Fatalf("unable to create nmap scanner: %v", err) |
394 | 402 | | } |
| skipped 15 lines |
410 | 418 | | } |
411 | 419 | | for _, port := range host.Ports { |
412 | 420 | | fmt.Printf("%s:%d/%s %s %s %s %s %s\n", host.Addresses[0], port.ID, port.Protocol, port.State, port.Service.Name, port.Service.Product, port.Service.ExtraInfo, port.Service.Version) |
| 421 | + | if script { |
| 422 | + | for _, service := range port.Scripts { |
| 423 | + | fmt.Printf(" %s: %s\n", service.ID, service.Output) |
| 424 | + | } |
| 425 | + | fmt.Println() |
| 426 | + | } |
413 | 427 | | } |
414 | 428 | | } |
415 | 429 | | } |