mirror of
https://github.com/ghndrx/nmap.git
synced 2026-02-10 06:55:03 +00:00
Update nmap.py
This commit is contained in:
152
nmap.py
152
nmap.py
@@ -1,111 +1,55 @@
|
||||
#!/usr/bin/python
|
||||
import os # i used os throughout to navigate and call cmds.
|
||||
import os
|
||||
|
||||
# Global Elite(variables)
|
||||
addOaValid = "0"
|
||||
oaAdder = ""
|
||||
|
||||
#Global Elite(variables)
|
||||
add_oa_valid="0"
|
||||
oa_adder="" # empty string if not changed later it won't add to the cmd
|
||||
# Functions
|
||||
def fping_txt():
|
||||
#print "Set fping range for scan: (192.168.1.0/24 or 192.168.1.0-254)"
|
||||
fping_target = raw_input("Set fping range for scan: (192.168.1.0-254)")
|
||||
os.system("cd")#Make sure we are in root directory.
|
||||
os.system("rm ~/fping.txt") #It will only append to fping.txt this will make it have a fresh file to append to.
|
||||
print "%s has been selected" % fping_target # this isn't neccessary just there for me, but tells user what we swept.
|
||||
print "fping is running, kickback and chill"
|
||||
print "when finished fping will spit out ~/fping.txt"
|
||||
os.system("fping -a -g %s >> fping.txt" % (fping_target))
|
||||
print "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" # profit, hopefully above worked.
|
||||
print "fping should be finished now!"
|
||||
print "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$"
|
||||
def fpingTxt():
|
||||
fpingTarget = input("Set fping range for scan: (192.168.1.0-254)")
|
||||
os.system("cd && rm ~/fping.txt") # Combine multiple commands into one line
|
||||
os.system(f"fping -a -g {fpingTarget} >> fping.txt")
|
||||
print("fping should be finished now!")
|
||||
|
||||
def menu():# its just text for user to read a menu
|
||||
print "#############################"
|
||||
print "# #"
|
||||
print "# CHOOSE ARGUMENTS #"
|
||||
print "# FOR NMAP #"
|
||||
print "# #"
|
||||
print "#############################\n"
|
||||
print "This is a list of precompiled slightly modular cmds"
|
||||
print "By defualt all NMAP cmds are set to -T4"
|
||||
print "-T4 sends packets at an aggressive rate or 1.25p/s\n"
|
||||
print "#############################"
|
||||
print "0. HOST DISCOVERER - USES NMAP TO CHECK IF TARGET(s) ARE ALIVE"
|
||||
print "1. FULL SCAN - ALL PORTS (0-65,535)"
|
||||
print "2. TCP CONNECT, OS, DETAILED SERVICE SCAN FOR OPEN PORTS"
|
||||
print "3. VIOLATE TCP CONNECTION WITH XMAS"
|
||||
print "4. MASSCAN PORT 80 OF TARGET(s)"
|
||||
print "Anything else to exit."
|
||||
print "#############################\n"
|
||||
def menu():
|
||||
print("""
|
||||
#############################
|
||||
# #
|
||||
# CHOOSE ARGUMENTS #
|
||||
# FOR NMAP #
|
||||
# #
|
||||
#############################
|
||||
|
||||
def menu_selector(): # return users menu_choice and prints the choices.
|
||||
menu_choice = raw_input("Choose from above")
|
||||
if menu_choice == "0": print "0.Selected Host Discoverer..."
|
||||
elif menu_choice == "1": print "1.Selected Full Scan..."
|
||||
elif menu_choice == "2": print "2.Selected TCP Connect..."
|
||||
elif menu_choice == "3": print "3.Selected TCP Violation..."
|
||||
elif menu_choice == "4": print "4.Selected Masscan..."
|
||||
else: print "Exiting..."
|
||||
return menu_choice
|
||||
This is a list of precompiled slightly modular cmds
|
||||
By default all NMAP cmds are set to -T4
|
||||
-T4 sends packets at an aggressive rate or 1.25p/s
|
||||
|
||||
def cmd_list(oa_adder): #for this function i added a print in front of os.system, this was so it just echos the cmd that was ran on the terminal.
|
||||
menu_choice = menu_selector()
|
||||
#############################
|
||||
0. HOST DISCOVERER - USES NMAP TO CHECK IF TARGET(s) ARE ALIVE
|
||||
1. FULL SCAN - ALL PORTS (0-65,535)
|
||||
2. TCP CONNECT, OS, DETAILED SERVICE SCAN FOR OPEN PORTS
|
||||
3. VIOLATE TCP CONNECTION WITH XMAS
|
||||
4. MASSCAN PORT 80 OF TARGET(s)
|
||||
Anything else to exit.
|
||||
#############################
|
||||
""")
|
||||
|
||||
def menuSelector():
|
||||
menuChoice = input("Choose from above")
|
||||
if menuChoice == "0": print("0.Selected Host Discoverer...")
|
||||
elif menuChoice == "1": print("1.Selected Full Scan...")
|
||||
elif menuChoice == "2": print("2.Selected TCP Connect...")
|
||||
elif menuChoice == "3": print("3.Selected TCP Violation...")
|
||||
elif menuChoice == "4": print("4.Selected Masscan...")
|
||||
else: print("Exiting...")
|
||||
return menuChoice
|
||||
|
||||
def cmdList():
|
||||
menuChoice = menuSelector()
|
||||
os.system("cd")
|
||||
if menu_choice == "0": print "nmap -T4 -sn -iL ~/fping.txt %s" % oa_adder;os.system("nmap -T4 -sn -iL ~/fping.txt %s" % oa_adder)
|
||||
elif menu_choice == "1": print "nmap -T4 -p- -iL ~/fping.txt %s" % oa_adder; os.system("nmap -T4 -p- -iL ~/fping.txt %s" % oa_adder)
|
||||
elif menu_choice == "2": print "nmap -T4 -O -sT -sV -iL ~/fping.txt %s" % oa_adder;os.system("nmap -T4 -O -sT -sV -iL ~/fping.txt %s" % oa_adder)
|
||||
elif menu_choice == "3": print "nmap -T4 -sX -iL ~/fping.txt %s" % oa_adder;os.system("nmap -T4 -sX -iL ~/fping.txt %s" % oa_adder)
|
||||
elif menu_choice == "4": print "masscan -p80 -iL ~/fping.txt";os.system("masscan -p80 -iL ~/fping.txt")
|
||||
else: print ""
|
||||
###
|
||||
#
|
||||
#Main body of script
|
||||
#
|
||||
###
|
||||
|
||||
print "Start of script..."
|
||||
|
||||
|
||||
#print "Generate a target list with fping? [y/n]"
|
||||
|
||||
valid_choice="0"
|
||||
while valid_choice=="0":
|
||||
fping_creator = raw_input("Generate a target list with fping?[y/n]").lower()
|
||||
if fping_creator=="y" or fping_creator=="yes":
|
||||
print "Starting fping"
|
||||
fping_txt() #calls fping_txt function.
|
||||
valid_choice="1"
|
||||
elif fping_creator=="n" or fping_creator=="no":
|
||||
print "We will not be generating a target list with fping"
|
||||
valid_choice="1"
|
||||
else: print "Enter a valid choice ('yes','y', 'n', 'no')"
|
||||
|
||||
valid_open="0"
|
||||
while valid_open=="0":
|
||||
open_fping = raw_input("Would you like to edit ~/fping.txt?[y/n]").lower()
|
||||
if open_fping == "y" or open_fping=="yes":
|
||||
raw_input("Opening Vim\nPress [ENTER]") #lets user know we about to open vim
|
||||
os.system("vim ~/fping.txt")
|
||||
valid_open="1"
|
||||
elif open_fping == "n" or open_fping=="no":
|
||||
print "We won't edit ~/fping.txt"
|
||||
valid_open="1"
|
||||
else: print "Enter valid choice ('yes', 'y', 'n', 'no')"
|
||||
|
||||
valid_oa="0"
|
||||
while valid_oa=="0":
|
||||
add_oa = raw_input("Do you want to add NMAP output file?[y/n]").lower() #.lower() takes input converts it to lower case
|
||||
|
||||
if add_oa == "y" or add_oa=="yes":
|
||||
name_oa = raw_input("What do you want to name the output file?")
|
||||
valid_oa="1"
|
||||
add_oa_valid="1" #checks later if we should actually add this to cmd
|
||||
oa_adder="-oA " + name_oa#concatenates strings for usage in cmd
|
||||
elif add_oa == "n" or add_oa=="no":
|
||||
print "There will be no output file for NMAP"#tells user we ain't doin it
|
||||
valid_oa="1"#validates and breaks while
|
||||
else: print "Enter a valid choice ('yes', 'y', 'n', 'no')" #verify and give choices
|
||||
|
||||
menu() # print menu
|
||||
cmd_list(oa_adder) # call function pass oa_adder
|
||||
|
||||
print "End of script..."
|
||||
if menuChoice == "0": os.system("nmap -T4 -sn -iL ~/fping.txt %s" % oaAdder)
|
||||
elif menuChoice == "1": os.system("nmap -T4 -p- -iL ~/fping.txt %s" % oaAdder)
|
||||
elif menuChoice == "2": os.system("nmap -T4 -O -sT -sV -iL ~/fping.txt %s" % oaAdder)
|
||||
elif menuChoice == "3": os.system("nmap -T4 -sX -iL ~/fping.txt %s" % oaAdder)
|
||||
elif menuChoice == "4": os.system("masscan -p80 -iL ~/fping.txt %s" % oaAdder)
|
||||
|
||||
Reference in New Issue
Block a user