bonsaiviking / nmap-completion

Bash-completion script for Nmap
68 stars 7 forks source link

nmap-completion

https://github.com/bonsaiviking/nmap-completion

A bash-completion script for Nmap (http://www.nmap.org). Currently supporting version 6.40 of Nmap and Zenmap.

FEATURES

PREFERRED ARGUMENTS

For options that require arguments (see the pref_opts variable), nmap-completion will look in ~/.nmap/prefs for a line that starts with that option and will generate completions from the arguments that follow it. The lines should follow basic shell quoting syntax, e.g. argument1 "argument 2 w/spaces" 'argument "3"'. See the included "prefs" file for examples.

INSTALLING

This script will work in any location that is "sourced" by Bash on startup. Distributions (like Ubuntu) that package bash-completion separately may have a directory for these scripts. On Ubuntu, the directory is /etc/bash_completion.d/. In this case, just copy the file for the command you want to complete (nmap, ncat, nping, ndiff) into that directory and restart Bash.

If you have problems, check that /etc/bash_completion is sourced from your ~/.bashrc or /etc/bash.bashrc. On Backtrack, for instance, the code for this is commented out.

For other distributions, or as a safe fallback, copy the contents of each file into your ~/.bashrc file. Some features (like -e interface name completion) may not work with this method.

AUTHOR

Daniel Miller bonsaiviking@gmail.com

KNOWN ISSUES

o Don't let anyone edit your ~/.nmap/prefs file. Contents of the file are directly eval'd, which could be considered a security issue. For example, change your prefs file to contain this line: -g ); cat /etc/passwd # Now whenever you hit tab after -g, you'll see the contents of your /etc/passwd file. Keep it safe, and pay attention to what you put in there.

o Completion for -e uses bash-completion's _available_interfaces function, which uses POSIX named character classes in an awk script. GNU awk (gawk) handles this just fine, but other awks may not. Specifically, Ubuntu Linux uses mawk to provide awk, which causes this to fail. Bug report for bash-completion under Ubuntu filed at https://bugs.launchpad.net/ubuntu/+source/bash-completion/+bug/778679

o --spoof-mac adds single quotes ('') to complete vendor names, which may be confusing, and break in some cases (if the vendor name contains a single quote, for instance). Also, this interacts poorly with the sudo completion script, rendering it useless (since root privilege is needed to spoof your MAC address). Note that the list of vendor names is quite long. Use with caution.

o The --datadir option changes NMAPDIR for Nmap, but the completion script isn't smart enough to know about it. Don't expect it to tab-complete script names in odd directories. However, if you export the $NMAPDIR environment variable, both Nmap and nmap-completion will use it properly.