> For the complete documentation index, see [llms.txt](https://106-sam.gitbook.io/ejptv2-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://106-sam.gitbook.io/ejptv2-notes/the-metasploit-framework-msf/information-gathering-and-enumeration/nmap.md).

# Nmap

### Port Scanning & Enumeration With Nmap

* Nmap is a free and open-source network scanner that can be used to discover hosts on a network as well as scan targets for open ports.
* It can also be used to enumerate the services running on open ports as well as the operating system running on the target system.
* We can output the results of our Nmap scan in to a format that can be imported into MSF for vulnerability detection and exploitation.

**DEMO**

* Default Scan

```
nmap <target IP>
```

* Ping probes

```
nmap -Pn <target IP>
```

* Service Version & OS detection

```
nmap -Pn -sV -O <target IP>
```

* &#x20;Export Nmap output for Metasploit

```
nmap -Pn -sV -O <targetIP> -oX <output_file_name>
```

***

### Importing Nmap Scan Results Into MSF

```
service postgresql start
```

```
msfconsole -q 
> db_status
> workspace 
> workspace -a Win2k12
> workspace
> db_import /root/<NmapOutputFile>
> hosts
> services 
> workspace -a Nmap_MSF
> workspace
> db_nmap -Pn -sV -O <targetIP>
> vulns
```

***
