Nmap is a free and open source tool for network discovery and security auditing. Nmap is able to determine what hosts are available on the network, what operating systems and services are running on target hosts, identify the type of the firewalls that are in use, and dozens of other capabilities.
It is very helpful to scan your target with nmap and import the results into Metasploit. All you have to do is scan your target using the -oX option to generate an XML file that will contain the results. To do this, execute the following nmap command, assuming that your target machine has the IP address 192.168.1.5,
nmap -Pn -sS -A -oX scan.xml 192.168.1.5
Launch the msfconsole, if you haven’t done it already, and import the results with the command,
To verify that the import was succesfull, use the hosts command to list all targeted hosts.
Run Nmap from msfconsole
You can also run nmap from within msfconsole and have the results automatically stored into database. To achieve this, run
db_nmap -Pn -sS -A 192.168.1.5
assuming that your target machine’s IP address is 192.168.1.5.
To verify that the results from the scan has been stored in database, run hosts or services.