Skip to content

Commit 6040b36

Browse files
committed
Update file_helper to split host ranges provided as arguments
1 parent f6e7466 commit 6040b36

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

reconnoitre/file_helper.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,27 @@ 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 "targets.txt"
1619
else:
1720
return output_directory + "/targets.txt"
1821

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

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

0 commit comments

Comments
 (0)