一、namp簡介
Nmap(Network Mapper)是一款網絡探測和安全審核的自由軟件。雖然它也能掃描單一的主機,但當初設計它的目的是為了快速掃描很大范圍的網絡。Nmap采用新的方法分析原始的IP包,能確定網絡上有哪些可用的主機、主機提供哪些服務(應用程序名和版本號)、運行的操作系統(及其版本號)、使用的包過濾器和防火墻,以及其他一系列功能。Nmap可以在絕大多數計算機上運行,除了有命令行版本之外,還有帶GUI的版本。Nmap是一款自由軟件,只要遵守GNU 通用公共許可證(GPL),就可以使用完整的源代碼。
Nmap被開發用于允許系統管理員察看一個大的網絡系統有哪些主機以及其上運行何種服務。它支持多種協議的掃描如UDP,TCP connect(),TCP SYN (half open), ftp proxy (bounce attack),Reverse-ident,ICMP (ping sweep), FIN, ACK sweep,Xmas Tree, SYN sweep, 和Null掃描。你可以從SCAN TYPES一節中察看相關細節。Nmap還提供一些實用功能如通過tcp/ip來甄別操作系統類型、秘密掃描、動態延遲和重發、平行掃描、通過并行的PING偵測下屬的主機、欺騙掃描、端口過濾探測、直接的RPC掃描、分布掃描、靈活的目標選擇以及端口的描述。
對非ROOT的用戶來說,Nmap的正式版可以做很多重要的東西了。不幸的是部份關鍵的核心功能(比如rawsockets)需要root權限。所以盡量以root的身份運行Nmap。
運行Nmap后通常會得到一個關 于你掃描的機器的一個實用的端口列表。Nmap總是顯示該服務的服務名稱,端口號,狀態以及協議。狀態有’open’,'filtered’和’unfiltered’三種。’open’指的是目標機器將會在該端口接受你的連接請求?!痜iltered’指的是有防火墻、過濾裝置或者其它的網絡障礙物在這個端口阻擋了Nmap 進一步查明端口是否開放的動作。至于’unfiltered’則只有在大多數的掃描端口都處在’filtered’狀態下才會出現的。
根據選項的使用,Nmap還可以報告遠程主機下面的特性:使用的操作系統、TCP連續性、在各端口上綁定的應用程序用戶的用戶名、DNS名、主機是否是個smurf地址以及一些其它功能。
二、namp使用
中文:
用法: nmap 掃描類型(多個) [選項] {目標}1、目標指定: 可以通過主機名,IP地址,網絡等。 例如:scanme.nmap.org,microsoft.com/24 192.168.0.1;10.0.0-255.1-254
-iL : 輸入從主機/網絡列表
-iR : 選擇隨機指標
–exclude : 排除主機/網絡
–excludefile : 從列表文件中排除
2、主機發現:
-sL: 列表掃描 – 簡單掃描列表目標
-sn: Ping掃描 – 禁用端口掃描
-Pn: 檢測所有在線主機 — 跳過主機發現
-PS/PA/PU/PY[端口列表]: TCP SYN/ACK, UDP 或 SCTP 發現指定的端口
-PE/PP/PM: ICMP echo, timestamp, 和netmask request發現
-PO[協議列表]:IP協議ping
-n/-R: 從不DNS解析/始終解析 [默認: 有時]
–dns-servers : 指定自定義DNS服務器
–system-dns: 使用操作系統的DNS解析器
–traceroute: 每個主機跟蹤一跳路徑
3、掃描技術:
-sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon 掃描
-sU: UDP掃描
-sN/sF/sX: TCP Null, FIN, 和 Xmas 掃描
–scanflags : 自定義TCP掃描標志-sI : 閑置掃描
-sY/sZ: SCTP INIT/COOKIE-ECHO 掃描
-sO: IP協議掃描
-b : 使用FTP bounce掃描
端口說明和掃描順序:
-p < 端口范圍>: 只掃描指定的端口
例: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
-F: 快速模式 – 掃描比默認的掃描的端口少
-r: 連續掃描端口 – 不隨機
–top-ports < 數量>: 掃描< 數量>個最常見的端口
–port-ratio < 比率>:掃描端口,較常見的 < 比率>
服務/版本檢測:
-sV: 探索開放的端口,以確定服務/版本信息
–version-intensity < 級別>: 設置從0(淺)到9(嘗試所有探測)
–version-light: 更快地識別最有可能的探測 (強度 2)
–version-all: 嘗試每一個探測 (強度 9)
–version-trace: 顯示詳細的版本掃描活動 (用于調試)
腳本掃描:
-sC: 相當于–script=default
–script=: 是用逗號分隔的目錄列表,腳本文件或腳本類別
–script-args=: 腳本提供參數
–script-args-file=文件名:在一個NSE文件中提供腳本參數
–script-trace: 顯示所有的數據發送和接收
–script-updatedb: 更新腳本數據庫
–script-help=: 顯示有關腳本的幫助。
是用逗號分隔的目錄列表,腳本文件或腳本類別 操作系統檢測:
-O: 開啟操作系統檢測
–osscan-limit: 限定操作系統檢測到有希望的目標
–osscan-guess: 猜測操作系統更快速
時序和性能:
使用選項是在幾秒鐘內或追加’MS’(毫秒)“S”(秒),“M”(分鐘),或’h’(小時)的值(如30m)。
-T<0-5>: 設置計時模板(越高速度越快)
–min-hostgroup/max-hostgroup < 大小>: 并行主機掃描大小
–min-parallelism/max-parallelism < 探測數量>: 探測并行
–min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <
時間>:指定探測往返時間。
–max-retries < 嘗試>: 端口掃描探測重發的上限數量。
–host-timeout < 時間>: 掃描間隔
–scan-delay/–max-scan-delay < 時間>: 調節延遲之間的探測
–min-rate < 數量>: 發送數據包不超過每秒< 數量>個
–max-rate < 數量>: 數據包發送速度超過每秒< 數量>個
防火墻/入侵檢測系統 躲避和欺騙:
-f; –mtu : 分片包(可選 w/given MTU)
-D < 誘餌1,誘餌2[,自己],…>: 掩蔽與誘餌掃描
-S : 欺騙源地址
-e < 接口>: 使用指定的接口
-g/–source-port < 端口號>: 使用給定的端口號
–data-length < 大小>: 附加隨機數據發送的數據包
–ip-options < 選項>: 發送指定IP選項的包
–ttl : 設置IP生存時間
–spoof-mac : 欺騙你的MAC地址
–badsum: 發送一個偽造的TCP/UDP/SCTP的校驗數據包
輸出:
-oN/-oX/-oS/-oG < 文件>: 輸出標準掃描, XML, s| -oA : 輸出三種格式
-v: 提高詳細級別 (使用-vv或更多更好的效果)
-d: 提高調試級別 (使用-dd或更多更好的效果)
–reason: 顯示端口的原因是在一個特定的狀態
–open: 只顯示打開(或可能打開) 端口
–packet-trace: 顯示所有的數據包發送和接收
–iflist: 顯示主機接口和路由(用于調試)
–log-errors: 正常格式輸出文件 記錄錯誤/警告
–append-output:追加,而不是更改已經指定輸出文件
–resume < 文件名>: 恢復中止掃描
–stylesheet < 路徑/URL>: XSL樣式表轉換XML輸出為HTML
–webxml: 從Nmap.Org獲得更便攜的XML參考樣式
–no-stylesheet:防止關聯的XSL樣式表W / XML輸出
雜項:
-6: 開啟IPv6掃描
-A: 啟用操作系統檢測,檢測版本,腳本掃描,路由跟蹤
–datadir < 目錄名>: 指定自定義的Nmap數據文件的位置
–send-eth/–send-ip: 使用原始的以太網幀或IP數據包發送
–privileged: 假設用戶是完全權限
–unprivileged: 假設用戶缺乏原始套接字權限
-V: 打印的版本號
-h: 打印此幫助摘要頁面。
例如:
nmap -v -A scanme.nmap.org
nmap -v -sn 192.168.0.0/16 10.0.0.0/8
nmap -v -iR 10000 -Pn -p 80
更多的選擇和例子,請參閱手冊頁(http://nmap.org/book/man.html)
英文:
Nmap 5.51 ( http://nmap.org )
Usage: nmap [Scan Type(s)] [Options] {target specification}
TARGET SPECIFICATION:
Can pass hostnames, IP addresses, networks, etc.
Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
-iL <inputfilename>: Input from list of hosts/networks
-iR <num hosts>: Choose random targets
–exclude <host1[,host2][,host3],…>: Exclude hosts/networks
–excludefile <exclude_file>: Exclude list from file
HOST DISCOVERY:
-sL: List Scan – simply list targets to scan
-sn: Ping Scan – disable port scan
-Pn: Treat all hosts as online — skip host discovery
-PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
-PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
-PO[protocol list]: IP Protocol Ping
-n/-R: Never do DNS resolution/Always resolve [default: sometimes]
–dns-servers <serv1[,serv2],…>: Specify custom DNS servers
–system-dns: Use OS’s DNS resolver
–traceroute: Trace hop path to each host
SCAN TECHNIQUES:
-sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
-sU: UDP Scan
-sN/sF/sX: TCP Null, FIN, and Xmas scans
–scanflags <flags>: Customize TCP scan flags
-sI <zombie host[:probeport]>: Idle scan
-sY/sZ: SCTP INIT/COOKIE-ECHO scans
-sO: IP protocol scan
-b <FTP relay host>: FTP bounce scan
PORT SPECIFICATION AND SCAN ORDER:
-p <port ranges>: Only scan specified ports
Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
-F: Fast mode – Scan fewer ports than the default scan
-r: Scan ports consecutively – don’t randomize
–top-ports <number>: Scan <number> most common ports
–port-ratio <ratio>: Scan ports more common than <ratio>
SERVICE/VERSION DETECTION:
-sV: Probe open ports to determine service/version info
–version-intensity <level>: Set from 0 (light) to 9 (try all probes)
–version-light: Limit to most likely probes (intensity 2)
–version-all: Try every single probe (intensity 9)
–version-trace: Show detailed version scan activity (for debugging)
SCRIPT SCAN:
-sC: equivalent to –script=default
–script=<Lua scripts>: <Lua scripts> is a comma separated list of
directories, script-files or script-categories
–script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
–script-trace: Show all data sent and received
–script-updatedb: Update the script database.
OS DETECTION:
-O: Enable OS detection
–osscan-limit: Limit OS detection to promising targets
–osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE:
Options which take <time> are in seconds, or append ‘ms’ (milliseconds),
‘s’ (seconds), ‘m’ (minutes), or ‘h’ (hours) to the value (e.g. 30m).
-T<0-5>: Set timing template (higher is faster)
–min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
–min-parallelism/max-parallelism <numprobes>: Probe parallelization
–min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
probe round trip time.
–max-retries <tries>: Caps number of port scan probe retransmissions.
–host-timeout <time>: Give up on target after this long
–scan-delay/–max-scan-delay <time>: Adjust delay between probes
–min-rate <number>: Send packets no slower than <number> per second
–max-rate <number>: Send packets no faster than <number> per second
FIREWALL/IDS EVASION AND SPOOFING:
-f; –mtu <val>: fragment packets (optionally w/given MTU)
-D <decoy1,decoy2[,ME],…>: Cloak a scan with decoys
-S <IP_Address>: Spoof source address
-e <iface>: Use specified interface
-g/–source-port <portnum>: Use given port number
–data-length <num>: Append random data to sent packets
–ip-options <options>: Send packets with specified ip options
–ttl <val>: Set IP time-to-live field
–spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
–badsum: Send packets with a bogus TCP/UDP/SCTP checksum
OUTPUT:
-oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
and Grepable format, respectively, to the given filename.
-oA <basename>: Output in the three major formats at once
-v: Increase verbosity level (use -vv or more for greater effect)
-d: Increase debugging level (use -dd or more for greater effect)
–reason: Display the reason a port is in a particular state
–open: Only show open (or possibly open) ports
–packet-trace: Show all packets sent and received
–iflist: Print host interfaces and routes (for debugging)
–log-errors: Log errors/warnings to the normal-format output file
–append-output: Append to rather than clobber specified output files
–resume <filename>: Resume an aborted scan
–stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
–webxml: Reference stylesheet from Nmap.Org for more portable XML
–no-stylesheet: Prevent associating of XSL stylesheet w/XML output
MISC:
-6: Enable IPv6 scanning
-A: Enable OS detection, version detection, script scanning, and traceroute
–datadir <dirname>: Specify custom Nmap data file location
–send-eth/–send-ip: Send using raw ethernet frames or IP packets
–privileged: Assume that the user is fully privileged
–unprivileged: Assume the user lacks raw socket privileges
-V: Print version number
-h: Print this help summary page.
EXAMPLES:
nmap -v -A scanme.nmap.org
nmap -v -sn 192.168.0.0/16 10.0.0.0/8
nmap -v -iR 10000 -Pn -p 80
SEE THE MAN PAGE (http://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES