@@ -61,9 +61,13 @@ def process_commands(arguments):
61
61
commands = set ()
62
62
ranges = set ()
63
63
targets = set ()
64
+ exclusions_ranges = set ()
65
+ exclusions = set ()
64
66
final_commands = set ()
65
67
output = OutputHelper (arguments )
66
68
69
+ print (arguments .exclusions )
70
+
67
71
if "," in arguments .port :
68
72
ports = arguments .port .split ("," )
69
73
elif "-" in arguments .port :
@@ -80,6 +84,13 @@ def process_commands(arguments):
80
84
for target in arguments .target_list :
81
85
ranges .add (target .strip ())
82
86
87
+ # process exclusions first
88
+ if arguments .exclusions :
89
+ exclusions_ranges .add (arguments .exclusions )
90
+ else :
91
+ for exclusion in arguments .exclusions_list :
92
+ exclusions_ranges .add (target .strip ())
93
+
83
94
# removing elements that may have spaces (helpful for easily processing comma notation)
84
95
for target in ranges :
85
96
target = target .replace (" " , "" )
@@ -97,6 +108,25 @@ def process_commands(arguments):
97
108
else :
98
109
targets .add (ips )
99
110
111
+ # removing elements that may have spaces (helpful for easily processing comma notation)
112
+ for exclusion in exclusions_ranges :
113
+ exclusion = exclusion .replace (" " , "" )
114
+
115
+ for ips in exclusion .split ("," ):
116
+ # checking for CIDR
117
+ if not arguments .nocidr and "/" in ips :
118
+ exclusions .update (InputHelper ._get_cidr_to_ips (ips ))
119
+ # checking for IPs in a range
120
+ elif "-" in ips :
121
+ exclusions .update (InputHelper ._get_ips_from_range (ips ))
122
+ # checking for glob ranges
123
+ elif "*" in ips :
124
+ exclusions .update (InputHelper ._get_ips_from_glob (ips ))
125
+ else :
126
+ exclusions .add (ips )
127
+
128
+ targets -= exclusions
129
+
100
130
if arguments .command :
101
131
commands .add (arguments .command )
102
132
else :
@@ -140,7 +170,7 @@ def setup_parser():
140
170
targets .add_argument (
141
171
'-t' , dest = 'target' , required = False ,
142
172
help = 'Specify a target or domain name either in comma format, '
143
- 'CIDR notation, or a single target.'
173
+ 'CIDR notation, glob notation, or a single target.'
144
174
)
145
175
146
176
targets .add_argument (
@@ -150,6 +180,22 @@ def setup_parser():
150
180
type = lambda x : InputHelper .readable_file (parser , x )
151
181
)
152
182
183
+ # exclusions group
184
+ exclusions = parser .add_mutually_exclusive_group ()
185
+
186
+ exclusions .add_argument (
187
+ '-e' , dest = 'exclusions' , required = False ,
188
+ help = 'Specify an exclusion either in comma format, '
189
+ 'CIDR notation, or a single target.'
190
+ )
191
+
192
+ exclusions .add_argument (
193
+ '-eL' , dest = 'exclusions_list' , required = False ,
194
+ help = 'Specify a list of exclusions.' ,
195
+ metavar = "FILE" ,
196
+ type = lambda x : InputHelper .readable_file (parser , x )
197
+ )
198
+
153
199
parser .add_argument (
154
200
'-threads' , dest = 'threads' , required = False ,
155
201
help = "Specify the maximum number of threads to run (DEFAULT:5)" ,
0 commit comments