> For the complete documentation index, see [llms.txt](https://notes.cavementech.com/pentesting-quick-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://notes.cavementech.com/pentesting-quick-reference/metasploit-and-meterpreter/importing-nmap-scan-results-into-msf.md).

# Importing Nmap Scan Results Into MSF

### Save Nmap Scan results in XML format

```
┌──(root㉿INE)-[~]
└─# nmap -sV -Pn -oX myscan.xml demo.ine.local
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-11-13 21:08 IST
Nmap scan report for demo.ine.local (10.5.31.165)
Host is up (0.0019s latency).
Not shown: 993 filtered tcp ports (no-response)
PORT      STATE SERVICE            VERSION
80/tcp    open  http               HttpFileServer httpd 2.3
135/tcp   open  msrpc              Microsoft Windows RPC
139/tcp   open  netbios-ssn        Microsoft Windows netbios-ssn
445/tcp   open  microsoft-ds       Microsoft Windows Server 2008 R2 - 2012 microsoft-ds
3389/tcp  open  ssl/ms-wbt-server?
49154/tcp open  msrpc              Microsoft Windows RPC
49155/tcp open  msrpc              Microsoft Windows RPC
Service Info: OSs: Windows, Windows Server 2008 R2 - 2012; CPE: cpe:/o:microsoft:windows

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 71.28 seconds
```

### Start postgresql database service

```
service postgresql start
```

### Importing results

Check the db status

```
msf6 > db_status
[*] Connected to msf. Connection type: postgresql.
```

You can now import the Nmap scan result

```
msf6 > db_import myscan.xml
[*] Importing 'Nmap XML' data
[*] Import: Parsing with 'Nokogiri v1.13.10'
[*] Importing host 10.5.31.165
[*] Successfully imported /root/myscan.xml
```

We can now view the results by running the following commands:

```
msf6 > hosts

Hosts
=====

address      mac  name            os_name  os_flavor  os_sp  purpose  info  comments
-------      ---  ----            -------  ---------  -----  -------  ----  --------
10.5.31.165       demo.ine.local  Unknown                    device

```

```
msf6 > services
Services
========

host         port   proto  name               state  info
----         ----   -----  ----               -----  ----
10.5.31.165  80     tcp    http               open   HttpFileServer httpd 2.3
10.5.31.165  135    tcp    msrpc              open   Microsoft Windows RPC
10.5.31.165  139    tcp    netbios-ssn        open   Microsoft Windows netbios-ssn
10.5.31.165  445    tcp    microsoft-ds       open   Microsoft Windows Server 2008 R2 - 2012 microsoft-ds
10.5.31.165  3389   tcp    ssl/ms-wbt-server  open
10.5.31.165  49154  tcp    msrpc              open   Microsoft Windows RPC
10.5.31.165  49155  tcp    msrpc              open   Microsoft Windows RPC
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://notes.cavementech.com/pentesting-quick-reference/metasploit-and-meterpreter/importing-nmap-scan-results-into-msf.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
