mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 11:37:01 -07:00
Changed order of adding default ports to add host correctly
This commit is contained in:
parent
3d6daa757a
commit
4cc3f7f7ac
2 changed files with 10 additions and 9 deletions
17
cmd/scan.go
17
cmd/scan.go
|
|
@ -63,6 +63,14 @@ var scanCmd = &cobra.Command{
|
|||
// assumes subnet without CIDR has a subnet-mask of 255.255.0.0
|
||||
" magellan scan --subnet 10.0.0.0/24 --subnet 172.16.0.0 --subnet-mask 255.255.0.0 --cache ./assets.db",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// add default ports for hosts if none are specified with flag
|
||||
if len(ports) == 0 {
|
||||
if debug {
|
||||
log.Debug().Msg("adding default ports")
|
||||
}
|
||||
ports = magellan.GetDefaultPorts()
|
||||
}
|
||||
|
||||
// format and combine flag and positional args
|
||||
targetHosts = append(targetHosts, util.FormatHostUrls(args, ports, scheme, verbose)...)
|
||||
targetHosts = append(targetHosts, util.FormatHostUrls(hosts, ports, scheme, verbose)...)
|
||||
|
|
@ -93,14 +101,6 @@ var scanCmd = &cobra.Command{
|
|||
}
|
||||
}
|
||||
|
||||
// add default ports for hosts if none are specified with flag
|
||||
if len(ports) == 0 {
|
||||
if debug {
|
||||
log.Debug().Msg("adding default ports")
|
||||
}
|
||||
ports = magellan.GetDefaultPorts()
|
||||
}
|
||||
|
||||
// show the parameters going into the scan
|
||||
if debug {
|
||||
combinedTargetHosts := []string{}
|
||||
|
|
@ -133,6 +133,7 @@ var scanCmd = &cobra.Command{
|
|||
}
|
||||
|
||||
// scan and store scanned data in cache
|
||||
fmt.Printf("targets: %v\n", targetHosts)
|
||||
foundAssets := magellan.ScanForAssets(&magellan.ScanParams{
|
||||
TargetHosts: targetHosts,
|
||||
Scheme: scheme,
|
||||
|
|
|
|||
|
|
@ -155,8 +155,8 @@ func FormatIPUrls(ips []string, ports []int, scheme string, verbose bool) [][]st
|
|||
}
|
||||
|
||||
// tidy up slashes and update arg with new value
|
||||
uri.Path = strings.TrimSuffix(uri.Path, "/")
|
||||
uri.Path = strings.ReplaceAll(uri.Path, "//", "/")
|
||||
uri.Path = strings.TrimSuffix(uri.Path, "/")
|
||||
|
||||
// for hosts with unspecified ports, add ports to scan from flag
|
||||
if uri.Port() == "" {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue