@@ -5,7 +5,6 @@ package cli
5
5
import (
6
6
"fmt"
7
7
"os"
8
- "strings"
9
8
"time"
10
9
11
10
"github.com/jedib0t/go-pretty/table"
@@ -102,7 +101,7 @@ func Root(
102
101
) (* cobra.Command , error ) {
103
102
var printJson bool
104
103
var noProgress bool
105
- var ports string
104
+ var ports [] string
106
105
var timing string
107
106
var idleTimeoutSeconds int
108
107
var listenPort uint16
@@ -119,8 +118,6 @@ func Root(
119
118
RunE : func (cmd * cobra.Command , args []string ) error {
120
119
log := logger .New ()
121
120
122
- portList := strings .Split (ports , "," )
123
-
124
121
if ifaceName != userNet .Interface ().Name {
125
122
uNet , err := network .NewNetworkFromInterfaceName (ifaceName )
126
123
@@ -147,7 +144,7 @@ func Root(
147
144
coreScanner = scanner .NewFullScanner (
148
145
userNet ,
149
146
targets ,
150
- portList ,
147
+ ports ,
151
148
listenPort ,
152
149
scanner .WithIdleTimeout (time .Second * time .Duration (idleTimeoutSeconds )),
153
150
)
@@ -166,7 +163,7 @@ func Root(
166
163
167
164
coreScanner .SetTiming (timingDuration )
168
165
169
- portLen := util .PortTotal (portList )
166
+ portLen := util .PortTotal (ports )
170
167
171
168
targetLen := util .TotalTargets (targets )
172
169
@@ -189,7 +186,7 @@ func Root(
189
186
coreScanner ,
190
187
targets ,
191
188
userNet .Cidr (),
192
- portList ,
189
+ ports ,
193
190
userNet .Interface ().Name ,
194
191
listenPort ,
195
192
timing ,
@@ -209,7 +206,7 @@ func Root(
209
206
cmd .Flags ().BoolVar (& printJson , "json" , false , "output json instead of table text" )
210
207
cmd .Flags ().BoolVar (& arpOnly , "arp-only" , false , "only perform arp scanning (skip syn scanning)" )
211
208
cmd .Flags ().BoolVar (& noProgress , "no-progress" , false , "disable all output except for final results" )
212
- cmd .Flags ().StringVarP (& ports , "ports" , "p" , "1-65535" , "target ports" )
209
+ cmd .Flags ().StringSliceVarP (& ports , "ports" , "p" , [] string { "1-65535" } , "target ports" )
213
210
cmd .Flags ().IntVar (& idleTimeoutSeconds , "idle-timeout" , 5 , "timeout when no expected packets are received for this duration" )
214
211
cmd .Flags ().Uint16Var (& listenPort , "listen-port" , 54321 , "set the port on which the scanner will listen for packets" )
215
212
cmd .Flags ().StringVarP (& ifaceName , "interface" , "i" , userNet .Interface ().Name , "set the interface for scanning" )
0 commit comments