Skip to content

Instantly share code, notes, and snippets.

@kf4bzt
Created February 7, 2017 16:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kf4bzt/ff0b499821c12722341dbdbde3f57e60 to your computer and use it in GitHub Desktop.
Save kf4bzt/ff0b499821c12722341dbdbde3f57e60 to your computer and use it in GitHub Desktop.
This is a python script that is in work to allow for easy port and vulnerability scanning
#I want to thank Mark Hufe for his video on creating a menu structure inside python.
#This helped me out a lot. https://www.youtube.com/watch?v=kGY9n5H6nr0
#
import subprocess
import sys
subnet_list = '/root/subnet_list'
vulscan_results = 'root/vulscan_results'
scan_results = '/root/scan_results'
#Display simple menu with scanning options and use choice to select option
print ("Welcome to the Network Scanner")
print ()
print ("Here Are Your Options:")
print ()
print ("1) Single Port Scan")
print ("2) Single Vulnerability / Port Scan")
print ("3) Single Subnet Port Scan")
print ("4) Single Subnet Vulnerability / Port Scan")
print ("5) Multiple Subnet Port Scan")
print ("6) Multiple Subnet Vulnerability / Port Scan")
print ("7) Exit")
print ()
#Make a choice using the menu structure and place code under each choice
loop = 1
while loop == 1:
choice = input ("Choose An Option: ")
choice = int (choice)
if choice == 1:
print "Single Port Scan"
print
elif choice == 2:
print "Single Vulnerability / Port Scan"
print
elif choice == 3:
print "Single Subnet Port Scan"
print
elif choice == 4:
print "Single Subnet Vulnerability / Port Scan"
print
elif choice == 5:
print "Multiple Subnet Port Scan"
print
#Open file and read in subnets file producing a space delimited list.
#Format: One host or subnet per line.
with open(subnet_list) as f:
subnets = f.readlines()
subnets = [x.rstrip('\n') for x in subnets]
subnets = ' '.join(map(str, subnets))
subnets = subnets.split()
print subnets
#Open file called scan_results to write scan data during nmap scan process
#Run nmap scan with vulscan vulnerability module against the subnets list
#Send data using stdout to scantest
with open(scan_results, 'w') as f:
subprocess.call(['nmap', '-sT']+ subnets, stdout=f)
elif choice == 6:
print "Multiple Subnet Vulnerability / Port Scan"
print
#Open file and read in subnets file producing a space delimited list.
#Format: One host or subnet per line.
with open(subnet_list) as f:
subnets = f.readlines()
subnets = [x.rstrip('\n') for x in subnets]
subnets = ' '.join(map(str, subnets))
subnets = subnets.split()
print subnets
#Open file called vulscan_results to write scan data during nmap scan process
#Run nmap scan with vulscan vulnerability module against the subnets list
#Send data using stdout to scantest
with open(vulscan_results, 'w') as f:
subprocess.call(['nmap', '-sV', '-script=vulscan/vulscan.nse' ]+ subnets, stdout=f)
elif choice == 7:
loop = 0
else:
print ("Please Enter a Choice From The Menu: ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment