mirror of
https://github.com/codingo/Interlace.git
synced 2025-12-18 07:14:20 +01:00
Added in exclusion functionality
This commit is contained in:
@@ -61,9 +61,13 @@ class InputHelper(object):
|
|||||||
commands = set()
|
commands = set()
|
||||||
ranges = set()
|
ranges = set()
|
||||||
targets = set()
|
targets = set()
|
||||||
|
exclusions_ranges = set()
|
||||||
|
exclusions = set()
|
||||||
final_commands = set()
|
final_commands = set()
|
||||||
output = OutputHelper(arguments)
|
output = OutputHelper(arguments)
|
||||||
|
|
||||||
|
print(arguments.exclusions)
|
||||||
|
|
||||||
if "," in arguments.port:
|
if "," in arguments.port:
|
||||||
ports = arguments.port.split(",")
|
ports = arguments.port.split(",")
|
||||||
elif "-" in arguments.port:
|
elif "-" in arguments.port:
|
||||||
@@ -80,6 +84,13 @@ class InputHelper(object):
|
|||||||
for target in arguments.target_list:
|
for target in arguments.target_list:
|
||||||
ranges.add(target.strip())
|
ranges.add(target.strip())
|
||||||
|
|
||||||
|
# process exclusions first
|
||||||
|
if arguments.exclusions:
|
||||||
|
exclusions_ranges.add(arguments.exclusions)
|
||||||
|
else:
|
||||||
|
for exclusion in arguments.exclusions_list:
|
||||||
|
exclusions_ranges.add(target.strip())
|
||||||
|
|
||||||
# removing elements that may have spaces (helpful for easily processing comma notation)
|
# removing elements that may have spaces (helpful for easily processing comma notation)
|
||||||
for target in ranges:
|
for target in ranges:
|
||||||
target = target.replace(" ", "")
|
target = target.replace(" ", "")
|
||||||
@@ -97,6 +108,25 @@ class InputHelper(object):
|
|||||||
else:
|
else:
|
||||||
targets.add(ips)
|
targets.add(ips)
|
||||||
|
|
||||||
|
# removing elements that may have spaces (helpful for easily processing comma notation)
|
||||||
|
for exclusion in exclusions_ranges:
|
||||||
|
exclusion = exclusion.replace(" ", "")
|
||||||
|
|
||||||
|
for ips in exclusion.split(","):
|
||||||
|
# checking for CIDR
|
||||||
|
if not arguments.nocidr and "/" in ips:
|
||||||
|
exclusions.update(InputHelper._get_cidr_to_ips(ips))
|
||||||
|
# checking for IPs in a range
|
||||||
|
elif "-" in ips:
|
||||||
|
exclusions.update(InputHelper._get_ips_from_range(ips))
|
||||||
|
# checking for glob ranges
|
||||||
|
elif "*" in ips:
|
||||||
|
exclusions.update(InputHelper._get_ips_from_glob(ips))
|
||||||
|
else:
|
||||||
|
exclusions.add(ips)
|
||||||
|
|
||||||
|
targets -= exclusions
|
||||||
|
|
||||||
if arguments.command:
|
if arguments.command:
|
||||||
commands.add(arguments.command)
|
commands.add(arguments.command)
|
||||||
else:
|
else:
|
||||||
@@ -140,7 +170,7 @@ class InputParser(object):
|
|||||||
targets.add_argument(
|
targets.add_argument(
|
||||||
'-t', dest='target', required=False,
|
'-t', dest='target', required=False,
|
||||||
help='Specify a target or domain name either in comma format, '
|
help='Specify a target or domain name either in comma format, '
|
||||||
'CIDR notation, or a single target.'
|
'CIDR notation, glob notation, or a single target.'
|
||||||
)
|
)
|
||||||
|
|
||||||
targets.add_argument(
|
targets.add_argument(
|
||||||
@@ -150,6 +180,22 @@ class InputParser(object):
|
|||||||
type=lambda x: InputHelper.readable_file(parser, x)
|
type=lambda x: InputHelper.readable_file(parser, x)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# exclusions group
|
||||||
|
exclusions = parser.add_mutually_exclusive_group()
|
||||||
|
|
||||||
|
exclusions.add_argument(
|
||||||
|
'-e', dest='exclusions', required=False,
|
||||||
|
help='Specify an exclusion either in comma format, '
|
||||||
|
'CIDR notation, or a single target.'
|
||||||
|
)
|
||||||
|
|
||||||
|
exclusions.add_argument(
|
||||||
|
'-eL', dest='exclusions_list', required=False,
|
||||||
|
help='Specify a list of exclusions.',
|
||||||
|
metavar="FILE",
|
||||||
|
type=lambda x: InputHelper.readable_file(parser, x)
|
||||||
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-threads', dest='threads', required=False,
|
'-threads', dest='threads', required=False,
|
||||||
help="Specify the maximum number of threads to run (DEFAULT:5)",
|
help="Specify the maximum number of threads to run (DEFAULT:5)",
|
||||||
|
|||||||
Reference in New Issue
Block a user