Created
February 20, 2023 10:25
-
-
Save yosignals/c426aeabbf3727140b9d88f567b38eb4 to your computer and use it in GitHub Desktop.
Subslplit.py | some (excellent) pen testing tools have a hard time outside of /24 and smaller networks, this little script tries to address that by fragmenting large networks into palatable lists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ipaddress | |
import os | |
# Get the IP address range from the user | |
ip_range = input("Enter IP address range (CIDR notation): ") | |
# Convert the IP address range to an object of type ipaddress.IPv4Network | |
ip_net = ipaddress.IPv4Network(ip_range) | |
# Get the number of target files from the user | |
num_files = int(input("Enter the number of target files: ")) | |
# Calculate the number of IP addresses per file | |
num_ips = ip_net.num_addresses // num_files | |
# Create a list of all the IP addresses in the range | |
ips = [str(ip) for ip in ip_net] | |
# Create the target files and write the IP addresses to them | |
for i in range(num_files): | |
filename = f"targets_{chr(97+i)}" | |
with open(filename, "w") as f: | |
start_index = i * num_ips | |
end_index = (i + 1) * num_ips if i < num_files - 1 else len(ips) | |
f.write("\n".join(ips[start_index:end_index])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment