- -bash: nmap: command not found
- #CentOS/RHEL 安裝
- yum install nmap
- #Debian/Ubuntu 安裝
- apt-get install nmap
- #Fedora
- sudo dnf install nmap
- #Arch Linux
- sudo pacman -S nmap
- #OpenSUSE
- zypper install nmap
- #Snap package
- sudo snap install nmap
- nmap [Scan Type...] [Options] {target specification}
- -O:激活操作探測(cè);
- -P0:值進(jìn)行掃描,不ping主機(jī);
- -PT:是同TCP的ping;
- -sV:探測(cè)服務(wù)版本信息;
- -sP:ping掃描,僅發(fā)現(xiàn)目標(biāo)主機(jī)是否存活;
- -ps:發(fā)送同步(SYN)報(bào)文;
- -PU:發(fā)送udp ping;
- -PE:強(qiáng)制執(zhí)行直接的ICMPping;
- -PB:默認(rèn)模式,可以使用ICMPping和TCPping;
- -6:使用IPv6地址;
- -v:得到更多選項(xiàng)信息;
- -d:增加調(diào)試信息地輸出;
- -oN:以人們可閱讀的格式輸出;
- -oX:以xml格式向指定文件輸出信息;
- -oM:以機(jī)器可閱讀的格式輸出;
- -A:使用所有高級(jí)掃描選項(xiàng);
- --resume:繼續(xù)上次執(zhí)行完的掃描;
- -P:指定要掃描的端口,可以是一個(gè)單獨(dú)的端口,用逗號(hào)隔開多個(gè)端口,使用“-”表示端口范圍;
- -e:在多網(wǎng)絡(luò)接口Linux系統(tǒng)中,指定掃描使用的網(wǎng)絡(luò)接口;
- -g:將指定的端口作為源端口進(jìn)行掃描;
- --ttl:指定發(fā)送的掃描報(bào)文的生存期;
- --packet-trace:顯示掃描過程中收發(fā)報(bào)文統(tǒng)計(jì);
- --scanflags:設(shè)置在掃描報(bào)文中的TCP標(biāo)志。
- --send-eth/--send-ip 使用原始以太網(wǎng)發(fā)送/構(gòu)造指定IP發(fā)送
- ip地址:指定待掃描報(bào)文中的TCP地址。
- $ nmap -A -T4 www.hexun.com
- Starting Nmap 6.40 ( http://nmap.org ) at 2020-05-06 12:04 CST
- Nmap scan report for www.hexun.com (119.97.159.10)
- Host is up (0.026s latency).
- Not shown: 983 closed ports
- PORT STATE SERVICE VERSION
- 22tcp filtered ssh
- 23/tcp filtered telnet
- 25/tcp filtered smtp
- 80/tcp open http nginx
- |_http-methods: No Allow or Public header in OPTIONS response (status code 405)
- | http-robots.txt: 1 disallowed entry
- |_/*\xA3\xBF*
- |_http-title: \xBA\xCD\xD1\xB6\xCD\xF8
- 135/tcp filtered msrpc
- 139/tcp filtered netbios-ssn
- 443/tcp open http nginx
- |_http-methods: No Allow or Public header in OPTIONS response (status code 400)
- |_http-title: 400 The plain HTTP request was sent to HTTPS port
- | ssl-cert: Subject: commonName=*.hexun.com/organizationName=Beijing Hexun Online Consulting Co.,Ltd/stateOrProvinceName=Beijing/countryName=CN
- | Not valid before: 2019-06-25T00:00:00+00:00
- |_Not valid after: 2021-09-23T12:00:00+00:00
- |_ssl-date: 2020-05-06T04:04:51+00:00; 0s from local time.
- | tls-nextprotoneg:
- |_ http/1.1
- 445/tcp filtered microsoft-ds
- 1433/tcp filtered ms-sql-s
- 1434/tcp filtered ms-sql-m
- 2000/tcp open tcpwrapped
- 3306/tcp filtered mysql
- 3389/tcp filtered ms-wbt-server
- 4444/tcp filtered krb524
- 5060/tcp open tcpwrapped
- 5800/tcp filtered vnc-http
- 5900/tcp filtered vnc
- Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
- Nmap done: 1 IP address (1 host up) scanned in 13.29 seconds
- $ nmap www.hexun.com
- Starting Nmap 6.40 ( http://nmap.org ) at 2020-05-06 12:08 CST
- Nmap scan report for www.hexun.com (119.97.159.10)
- Host is up (0.025s latency).
- Not shown: 983 closed ports
- PORT STATE SERVICE
- 22/tcp filtered ssh
- 23/tcp filtered telnet
- 25/tcp filtered smtp
- 80/tcp open http
- 135/tcp filtered msrpc
- /tcp filtered netbios-ssn
- 443/tcp open https
- 445/tcp filtered microsoft-ds
- 1433/tcp filtered ms-sql-s
- 1434/tcp filtered ms-sql-m
- 2000/tcp open cisco-sccp
- 3306/tcp filtered mysql
- 3389/tcp filtered ms-wbt-server
- 4444/tcp filtered krb524
- 5060/tcp open sip
- 5800/tcp filtered vnc-http
- 5900/tcp filtered vnc
- Nmap done: 1 IP address (1 host up) scanned in 1.65 seconds
- $ nmap -v www.hexun.com
- Starting Nmap 6.40 ( http://nmap.org ) at 2020-05-06 12:09 CST
- Initiating Ping Scan at 12:09
- Scanning www.hexun.com (119.97.159.10) [2 ports]
- Completed Ping Scan at 12:09, 0.03s elapsed (1 total hosts)
- Initiating Parallel DNS resolution of 1 host. at 12:09
- Completed Parallel DNS resolution of 1 host. at 12:09, 0.00s elapsed
- Initiating Connect Scan at 12:09
- Scanning www.hexun.com (119.97.159.10) [1000 ports]
- Discovered open port 80/tcp on 119.97.159.10
- Discovered open port 443/tcp on 119.97.159.10
- Discovered open port 2000/tcp on 119.97.159.10
- Discovered open port 5060/tcp on 119.97.159.10
- Completed Connect Scan at 12:09, 1.47s elapsed (1000 total ports)
- Nmap scan report for www.hexun.com (119.97.159.10)
- Host is up (0.026s latency).
- Not shown: 983 closed ports
- PORT STATE SERVICE
- 22/tcp filtered ssh
- 23/tcp filtered telnet
- 25/tcp filtered smtp
- 80/tcp open http
- 135/tcp filtered msrpc
- 139/tcp filtered netbios-ssn
- 443/tcp open https
- 445/tcp filtered microsoft-ds
- 1433/tcp filtered ms-sql-s
- 1434/tcp filtered ms-sql-m
- 2000/tcp open cisco-sccp
- 3306/tcp filtered mysql
- 3389/tcp filtered ms-wbt-server
- 4444/tcp filtered krb524
- 5060/tcp open sip
- 5800/tcp filtered vnc-http
- 5900/tcp filtered vnc
- Read data files from: /usr/bin/../share/nmap
- Nmap done: 1 IP address (1 host up) scanned in 1.53 seconds
- nmap -sT ip_address #TCP contect()端口掃描
- nmap -p 1-65535 -T4 -A -v ip #掃描1-65535(基本覆蓋所有端口)
- nmap -sU ip_address #UDP端口掃描
- 輸出命令
- -oN 文件名 #輸出普通文件
- -oX 文件名.xml #輸出xml文件
nmap 命令補(bǔ)充說明:
nmap(Network Mapper - 網(wǎng)絡(luò)映射器)是用于網(wǎng)絡(luò)探索和安全審核的開源工具。盡管它可以掃描單個(gè)主機(jī),但它可以快速掃描大型網(wǎng)絡(luò)。 nmap 以新穎的方式使用原始 IP 數(shù)據(jù)包來確定網(wǎng)絡(luò)上可用的主機(jī),這些主機(jī)提供的服務(wù)(應(yīng)用程序名稱和版本),它們正在運(yùn)行的操作系統(tǒng)(和 OS 版本),包過濾器/防火墻的類型。正在使用中,還有許多其他特性。盡管 nmap 通常用于安全審核,但許多系統(tǒng)和網(wǎng)絡(luò)管理員發(fā)現(xiàn)它對(duì)于常規(guī)任務(wù)(如網(wǎng)絡(luò)清單,管理服務(wù)升級(jí)計(jì)劃以及監(jiān)視主機(jī)或服務(wù)正常運(yùn)行時(shí)間)很有用。
nmap 的輸出是掃描目標(biāo)的列表,每個(gè)目標(biāo)都有補(bǔ)充信息,具體取決于所使用的選項(xiàng)。該信息中的關(guān)鍵是“有趣的端口表”。該表列出了端口號(hào)和協(xié)議,服務(wù)名稱以及狀態(tài)。狀態(tài)為打開,已過濾,已關(guān)閉或未過濾。
打開表示目標(biāo)計(jì)算機(jī)上的應(yīng)用程序正在偵聽該端口上的連接/數(shù)據(jù)包。
篩選表示防火墻,篩選器或其他網(wǎng)絡(luò)障礙物阻止了該端口,從而使 nmap 無法判斷它是打開還是關(guān)閉。
封閉的端口沒有應(yīng)用程序在監(jiān)聽它們,盡管它們可以隨時(shí)打開。端口分類為未過濾。當(dāng)它們對(duì) nmap 的探針有反應(yīng)時(shí),nmap 無法確定它們是打開還是關(guān)閉。當(dāng)無法確定兩個(gè)狀態(tài)中的哪個(gè)描述端口時(shí),nmap 報(bào)告已打開和已關(guān)閉的狀態(tài)組合。當(dāng)請(qǐng)求版本檢測(cè)時(shí),端口表還可以包括軟件版本詳細(xì)信息。當(dāng)請(qǐng)求 IP 協(xié)議掃描(-sO)時(shí),nmap 提供有關(guān)支持的 IP 協(xié)議的信息,而不是偵聽端口。
除了有趣的端口表之外,nmap 還可以提供有關(guān)目標(biāo)的更多信息,包括反向 DNS 名稱,操作系統(tǒng)猜測(cè),設(shè)備類型和 MAC 地址。
典型的 nmap 掃描如下所示。此示例中僅使用的 nmap 參數(shù)是 -A,以啟用操作系統(tǒng)和版本檢測(cè),腳本掃描和 traceroute; -T4 可以更快地執(zhí)行;然后是兩個(gè)目標(biāo)主機(jī)名。
nmap 命令語法:
nmap 命令選項(xiàng):
nmap 命令參數(shù):
nmap 命令實(shí)例
典型的 nmap
掃描
nmap
的其他示例
nmap
基本使用方法小結(jié)
生成報(bào)告: