Skip to content

Instantly share code, notes, and snippets.

@Patrick-Kelley
Created June 30, 2023 12:52
Show Gist options
  • Save Patrick-Kelley/e4ff1d68b0f6d23ee3ac2143f09d8545 to your computer and use it in GitHub Desktop.
Save Patrick-Kelley/e4ff1d68b0f6d23ee3ac2143f09d8545 to your computer and use it in GitHub Desktop.
import subprocess
def run_nmap(cidr_block, output_file):
command = f"nmap -A -oX {output_file} {cidr_block}"
try:
subprocess.check_call(command, shell=True)
print(f"Nmap scan results saved to: {output_file}")
except subprocess.CalledProcessError as e:
print(f"Error executing Nmap command: {e}")
def main():
cidr_blocks = input("Enter CIDR blocks (comma-separated): ").split(",")
output_file = input("Enter the output XML file name: ")
for cidr_block in cidr_blocks:
cidr_block = cidr_block.strip()
run_nmap(cidr_block, output_file)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment