Mac OSX nmap nse script search
OK,
I was tired of listing the directory manually everytime I wanted to use a nmap nse scrip on my mac. Therefore, I wrote this simple script to either display all nmap nse script or search for a string and list the relevant scripts. Call me lazy but I am all about saving time and increasing efficiency. I also love the challenge =)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #!/usr/bin/python """ Nmap Script search, this script displays all nmap scripts, or searches for a string within the title of the nmap script""" import sys,subprocess,os # to see if nmap is installed and the script directory is in default directories usage = """ nmap nse search script coded by bostonlink @ pentest-labs.org example1: ./nse_search.py -l example2: ./nse_search.py -s smb""" help = """ Nmap nse search script options -l = lists all nmap nse scripts within the /nmap/scripts directory -s [search string] = searches all nse scripts and prints ones that matches the search string\n""" if len(sys.argv) <= 1: print usage print help sys.exit(0) cwd = os.getcwd() script_path = '/usr/local/share/nmap/scripts/' def chg_dir(): if cwd != script_path: os.chdir('/usr/local/share/nmap/scripts/') print '\nChanged CWD to default nmap script directory\n' def list_all(): cmd1 = subprocess.Popen(["ls","-l"], stdout=subprocess.PIPE) lista = cmd1.stdout.read() cmd1.wait() print lista def list_search(): if len(sys.argv) <= 2: print usage print help sys.exit(0) else: search_string = sys.argv[2] cmd1 = subprocess.Popen(["ls"], stdout=subprocess.PIPE) lista = cmd1.stdout.read() cmd1.wait() lista1 = lista.strip().split() for i in lista1: if search_string in i: print i if sys.argv[1] == '-l': chg_dir() list_all() if sys.argv[1] == '-s': chg_dir() list_search() |
Note: same path in a Ubuntu Linux environment
you can use wget to download the script http://pentest-labs.org/downloads/nse_search.py





