Skip to content

Commit 341abb0

Browse files
authored
Merge pull request #15 from codingo/exclusions
Exclusions
2 parents 28bb9be + 6bd597c commit 341abb0

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

Interlace/lib/core/input.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ def process_commands(arguments):
6161
commands = set()
6262
ranges = set()
6363
targets = set()
64+
exclusions_ranges = set()
65+
exclusions = set()
6466
final_commands = set()
6567
output = OutputHelper(arguments)
6668

@@ -80,6 +82,13 @@ def process_commands(arguments):
8082
for target in arguments.target_list:
8183
ranges.add(target.strip())
8284

85+
# process exclusions first
86+
if arguments.exclusions:
87+
exclusions_ranges.add(arguments.exclusions)
88+
else:
89+
for exclusion in arguments.exclusions_list:
90+
exclusions_ranges.add(target.strip())
91+
8392
# removing elements that may have spaces (helpful for easily processing comma notation)
8493
for target in ranges:
8594
target = target.replace(" ", "")
@@ -97,6 +106,25 @@ def process_commands(arguments):
97106
else:
98107
targets.add(ips)
99108

109+
# removing elements that may have spaces (helpful for easily processing comma notation)
110+
for exclusion in exclusions_ranges:
111+
exclusion = exclusion.replace(" ", "")
112+
113+
for ips in exclusion.split(","):
114+
# checking for CIDR
115+
if not arguments.nocidr and "/" in ips:
116+
exclusions.update(InputHelper._get_cidr_to_ips(ips))
117+
# checking for IPs in a range
118+
elif "-" in ips:
119+
exclusions.update(InputHelper._get_ips_from_range(ips))
120+
# checking for glob ranges
121+
elif "*" in ips:
122+
exclusions.update(InputHelper._get_ips_from_glob(ips))
123+
else:
124+
exclusions.add(ips)
125+
126+
targets -= exclusions
127+
100128
if arguments.command:
101129
commands.add(arguments.command)
102130
else:
@@ -140,7 +168,7 @@ def setup_parser():
140168
targets.add_argument(
141169
'-t', dest='target', required=False,
142170
help='Specify a target or domain name either in comma format, '
143-
'CIDR notation, or a single target.'
171+
'CIDR notation, glob notation, or a single target.'
144172
)
145173

146174
targets.add_argument(
@@ -150,6 +178,22 @@ def setup_parser():
150178
type=lambda x: InputHelper.readable_file(parser, x)
151179
)
152180

181+
# exclusions group
182+
exclusions = parser.add_mutually_exclusive_group()
183+
184+
exclusions.add_argument(
185+
'-e', dest='exclusions', required=False,
186+
help='Specify an exclusion either in comma format, '
187+
'CIDR notation, or a single target.'
188+
)
189+
190+
exclusions.add_argument(
191+
'-eL', dest='exclusions_list', required=False,
192+
help='Specify a list of exclusions.',
193+
metavar="FILE",
194+
type=lambda x: InputHelper.readable_file(parser, x)
195+
)
196+
153197
parser.add_argument(
154198
'-threads', dest='threads', required=False,
155199
help="Specify the maximum number of threads to run (DEFAULT:5)",

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Dependencies will then be installed and Interlace will be added to your path as
1717
|------------|--------------------------------------------------------------------------------------------------------------|
1818
| -t | Specify a target or domain name either in comma-delimited format, CIDR notation, or as an individual host |
1919
| -tL | Specify a list of targets or domain names |
20+
| -e | Specify an exclusion either in comma-delimited format, CIDR notation, or as an individual host |
21+
| -eL | Specify a list of exclusions |
2022
| -threads | Specify the maximum number of threads to run at any one time (DEFAULT:5) |
2123
| -timeout | Specify a timeout value in seconds for any single thread (DEFAULT:600) |
2224
| -c | Specify a single command to execute over each target or domain |
@@ -118,6 +120,16 @@ interlace -t 192.168.12.* -c "vhostscan _target_ -oN _output_/_target_-vhosts.tx
118120
```
119121
Yet again, VHostScan does not have any inbuilt glob range format support.
120122

123+
## Dash (-) notation with an application that doesn't support it
124+
Interlace automatically expands dash ranges when starting threads. This allows you to pass glob ranges to a variety of applications:
125+
126+
To run a virtual host scan against every target within `192.168.12.1-15` using a direct command you could use:
127+
```bash
128+
interlace -t 192.168.12.1-15 -c "vhostscan _target_ -oN _output_/_target_-vhosts.txt" -o ~/scans/ -threads 50
129+
```
130+
Yet again, VHostScan does not have any inbuilt dash range format support.
131+
132+
121133
## Threading Support for an application that doesn't support it
122134
Run a [virtual host scan](https://github.com/codingo/VHostScan) against each host in a file (`target-lst.txt`), whilst also limiting scans at any one time to 50 maximum threads.
123135

@@ -136,6 +148,16 @@ vhostscan -t $target -oN _output_/_target_-vhosts.txt
136148
```
137149
This would output a file for each target in the specified output folder. You could also run multiple commands simply by adding them into the command file.
138150

151+
## Exclusions
152+
Interlace automatically excludes any hosts provided when specified via the `-e` or `-eL` arguments. These arguments are also compatible with the above-mentinoed range notations (CIDR, Glob, and dash)
153+
154+
To run a virtual host scan against every target within `192.168.12.0/24` despire targets within `192.168.12.0/26` using a direct command you could use:
155+
```bash
156+
interlace -t 192.168.12.0/24 -e 192.168.12.0/26 -c "vhostscan _target_ -oN _output_/_target_-vhosts.txt" -o ~/scans/ -threads 50
157+
```
158+
159+
160+
139161
# Authors and Thanks
140162
Originally written by Michael Skelton ([codingo](https://twitter.com/codingo_)) and Sajeeb Lohani ([sml555](https://twitter.com/sml555_)) with help from Charelle Collett ([@Charcol0x89](https://twitter.com/Charcol0x89)) for threading refactoring and overall approach, and Luke Stephens ([hakluke](https://twitter.com/hakluke)) for testing and approach.
141163

0 commit comments

Comments
 (0)