2
2
from netaddr import IPNetwork , IPRange , IPGlob
3
3
from Interlace .lib .core .output import OutputHelper , Level
4
4
import os .path
5
+ from re import compile
5
6
6
7
7
8
class InputHelper (object ):
@@ -66,13 +67,14 @@ def process_commands(arguments):
66
67
final_commands = set ()
67
68
output = OutputHelper (arguments )
68
69
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 ]
76
78
77
79
78
80
# process targets first
@@ -86,14 +88,19 @@ def process_commands(arguments):
86
88
if arguments .exclusions :
87
89
exclusions_ranges .add (arguments .exclusions )
88
90
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 ())
91
94
92
95
# removing elements that may have spaces (helpful for easily processing comma notation)
93
96
for target in ranges :
94
97
target = target .replace (" " , "" )
95
98
96
99
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
97
104
# checking for CIDR
98
105
if not arguments .nocidr and "/" in ips :
99
106
targets .update (InputHelper ._get_cidr_to_ips (ips ))
@@ -111,6 +118,10 @@ def process_commands(arguments):
111
118
exclusion = exclusion .replace (" " , "" )
112
119
113
120
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
114
125
# checking for CIDR
115
126
if not arguments .nocidr and "/" in ips :
116
127
exclusions .update (InputHelper ._get_cidr_to_ips (ips ))
@@ -136,16 +147,24 @@ def process_commands(arguments):
136
147
# replace flags
137
148
for command in commands :
138
149
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 :
140
163
command = tmp_command
141
164
command = str (command ).replace ("_target_" , target )
142
165
command = str (command ).replace ("_host_" , target )
143
166
if arguments .output :
144
167
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 )
149
168
final_commands .add (command )
150
169
output .terminal (Level .VERBOSE , command , "Added after processing" )
151
170
0 commit comments