Skip to content

Commit d1dc43d

Browse files
authored
Merge pull request #18 from codingo/bug-fix-for
Bug fix for Ports, Exclusions, and Domain Names
2 parents 6a0b1d8 + 6b2ebcf commit d1dc43d

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

Interlace/lib/core/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = '1.1'
1+
__version__ = '1.1.1'
22

Interlace/lib/core/input.py

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from netaddr import IPNetwork, IPRange, IPGlob
33
from Interlace.lib.core.output import OutputHelper, Level
44
import os.path
5+
from re import compile
56

67

78
class InputHelper(object):
@@ -66,13 +67,14 @@ def process_commands(arguments):
6667
final_commands = set()
6768
output = OutputHelper(arguments)
6869

69-
if "," in arguments.port:
70-
ports = arguments.port.split(",")
71-
elif "-" in arguments.port:
72-
tmp_ports = arguments.port.split("-")
73-
ports = list(range(int(tmp_ports[0]), int(tmp_ports[1]) + 1))
74-
else:
75-
ports = [arguments.port]
70+
if arguments.port:
71+
if "," in arguments.port:
72+
ports = arguments.port.split(",")
73+
elif "-" in arguments.port:
74+
tmp_ports = arguments.port.split("-")
75+
ports = list(range(int(tmp_ports[0]), int(tmp_ports[1]) + 1))
76+
else:
77+
ports = [arguments.port]
7678

7779

7880
# process targets first
@@ -86,14 +88,19 @@ def process_commands(arguments):
8688
if arguments.exclusions:
8789
exclusions_ranges.add(arguments.exclusions)
8890
else:
89-
for exclusion in arguments.exclusions_list:
90-
exclusions_ranges.add(target.strip())
91+
if arguments.exclusions_list:
92+
for exclusion in arguments.exclusions_list:
93+
exclusions_ranges.add(target.strip())
9194

9295
# removing elements that may have spaces (helpful for easily processing comma notation)
9396
for target in ranges:
9497
target = target.replace(" ", "")
9598

9699
for ips in target.split(","):
100+
# check if it is a domain name
101+
if ips.split(".")[-1][0].isalpha():
102+
targets.add(ips)
103+
continue
97104
# checking for CIDR
98105
if not arguments.nocidr and "/" in ips:
99106
targets.update(InputHelper._get_cidr_to_ips(ips))
@@ -111,6 +118,10 @@ def process_commands(arguments):
111118
exclusion = exclusion.replace(" ", "")
112119

113120
for ips in exclusion.split(","):
121+
# check if it is a domain name
122+
if ips.split(".")[-1][0].isalpha():
123+
targets.add(ips)
124+
continue
114125
# checking for CIDR
115126
if not arguments.nocidr and "/" in ips:
116127
exclusions.update(InputHelper._get_cidr_to_ips(ips))
@@ -136,16 +147,24 @@ def process_commands(arguments):
136147
# replace flags
137148
for command in commands:
138149
tmp_command = command
139-
for port in ports:
150+
if arguments.port:
151+
for port in ports:
152+
command = tmp_command
153+
command = str(command).replace("_target_", target)
154+
command = str(command).replace("_host_", target)
155+
if arguments.output:
156+
command = str(command).replace("_output_", arguments.output)
157+
command = str(command).replace("_port_", str(port))
158+
if arguments.realport:
159+
command = str(command).replace("_realport_", arguments.realport)
160+
final_commands.add(command)
161+
output.terminal(Level.VERBOSE, command, "Added after processing")
162+
else:
140163
command = tmp_command
141164
command = str(command).replace("_target_", target)
142165
command = str(command).replace("_host_", target)
143166
if arguments.output:
144167
command = str(command).replace("_output_", arguments.output)
145-
if arguments.port:
146-
command = str(command).replace("_port_", str(port))
147-
if arguments.realport:
148-
command = str(command).replace("_realport_", arguments.realport)
149168
final_commands.add(command)
150169
output.terminal(Level.VERBOSE, command, "Added after processing")
151170

0 commit comments

Comments
 (0)