Adding network support in ip_list_file
nrukavkov opened this issue · 0 comments
nrukavkov commented
Adding network support in ip_list_file
def process_ip_list(ip_list_file):
ips = []
try:
with open(ip_list_file, 'r') as file:
for target in file:
if '/' in target:
try:
network = ipaddress.ip_network(target.strip(), strict=False)
ips.extend([str(ip) for ip in network.hosts()])
except ValueError as e:
print(f"❌ [-] Invalid CIDR notation {target} {e}")
else:
ips.append(target)
except IOError:
print(f"❌ [-] Could not read file: {ip_list_file}")
return [ip.strip() for ip in ips]