Skip to content

Commit 313844f

Browse files
authored
Merge pull request #49 from evcsec/master
Update file_helper to split host ranges provided as arguments
2 parents 4981705 + be406b8 commit 313844f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

reconnoitre/file_helper.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,25 @@ def check_directory(output_directory):
1313
def load_targets(target_hosts, output_directory, quiet):
1414
if(os.path.isdir(target_hosts) or os.path.isfile(target_hosts)):
1515
return target_hosts
16+
elif "-" in target_hosts:
17+
expand_targets(target_hosts, output_directory)
18+
return output_directory + "/targets.txt"
1619
else:
1720
return output_directory + "/targets.txt"
1821

22+
23+
def expand_targets(target_hosts, output_directory):
24+
parts = target_hosts.split(".")
25+
target_list= []
26+
for part in parts:
27+
if "-" in part:
28+
iprange = part.split("-")
29+
for i in range(int(iprange[0]), int(iprange[1])):
30+
target_list.append(parts[0]+"."+parts[1]+"."+parts[2]+"."+str(i))
31+
with open(output_directory + "/targets.txt", "w") as targets:
32+
for target in target_list:
33+
targets.write("%s\n" % target)
34+
1935

2036
def create_dir_structure(ip_address, output_directory):
2137
print("[+] Creating directory structure for " + ip_address)

0 commit comments

Comments
 (0)