Nmap port scanning with targeted NSE script execution
Many of the Nmap Scripting Engine (NSE) scripts are only applicable if there is a service running on a given port. Consider the usage of the smb-check-vulns.nse
script. This script will evaluate SMB services running on TCP port 445
for common service vulnerabilities. If this script were executed across an entire network, it would have to reaccomplish the task of determining whether port 445
is open and if the SMB service is accessible on each target system. This is a task that has probably already been accomplished during the scanning phase of the assessment. Bash scripting can be used to leverage existing Nmap greppable output files to run service-specific NSE scripts only against systems that are running those services. In this recipe, we will demonstrate how a script can be used to determine hosts that are running a service on TCP 445
from previous scan results and then run the smb-check-vulns.nse
script against only those systems...