您好,欢迎访问一九零五行业门户网

Nmap如何快速上手

1.安装https://nmap.org/,不做过多赘述
2.靶机搭建本文使用靶机为owasp broken web applications project
https://sourceforge.net/projects/owaspbwa/
靶机地址1:192.168.154.128
靶机地址2:192.168.3.7
3.命令行c:\users\torjan>nmap --helpnmap 7.80 ( https://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: input from list of hosts/networks,从文件中导入目标主机或目标网段-ir: choose random targets,随机选择目标主机--exclude: exclude hosts/networks,后面跟的主机或网段将不在扫描范围内--excludefile: exclude list from file,后面跟的文件中的主机或网段将不在扫描范围内host discovery:[主机发现]-sl:list scan,list scan(列表扫描),仅列举指定目标的ip,不进行主机发现-sn: ping scan - disable port scan,ping 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,使用 tcp syn/ack或sctp init/echo方式来发现。-pe/pp/pm: icmp echo, timestamp, and netmask request discovery probes,使用 icmp echo、 timestamp、 netmask请求包发现主机-po[protocol list]: ip protocol ping,使用ip协议包探测对方主机是否开启。-n/-r: never do dns resolution/always resolve [default: sometimes],-n表示不进行dns解析;-r表示总是进行dns解析。--dns-servers: specify custom dns servers,指定dns服务器。--system-dns: use os s dns resolver,指定使用系统的dns服务器。--traceroute: trace hop path to each host,追踪每个路由节点。scan techniques:[扫描参数]-ss/st/sa/sw/sm: tcp syn/connect()/ack/window/maimon scans,指定使用 tcp syn/connect()/ack/window/maimon scans的方式对目标主机进行扫描。-su: udp scan,指定使用udp扫描的方式确定目标主机的udp端口状况。-sn/sf/sx: tcp null, fin, and xmas scans,指定使用 tcp null/fin/xmas scans秘密扫描的方式协助探测对方的tcp端口状态。--scanflags: customize tcp scan flags,定制tcp包的flags-si: idle scan,指定使用 idle scan的方式扫描目标主机(前提是需要找到合适的僵尸主机zombie host)。-sy/sz: sctp init/cookie-echo scans,使用 sctp init/cookie-echo扫描sctp协议端口的开放情况-so: ip protocol scan,使用 ip protocol扫描确定目标机支持的协议类型。-b: ftp bounce scan,使用 ftp bounce scan扫描方式。port specification and scan order:[端口扫描参数和顺序]-p: only scan specified ports,:扫描指定的端口ex(例如): -p22; -p1-65535; -p u:53,111,137,t:21-25,80,139,8080,s:9--exclude-ports: exclude the specified ports from scanning,不扫描的端口-f: fast mode - scan fewer ports than the default scan,(快速模式),仅扫描top100的端口-r: scan ports consecutively - dont randomize,不进行端口随机打乱的操作(如无该参数,nmap会将要扫描的端口以随机顺序的方式进行扫描,让nmap的扫描不易被对方防火墙检测到),即顺序扫描。--top-ports: scanmost common ports,扫描开放概率最高的 number个端口(nmap的作者曾做过大规模的互联网扫描,以此统计网络上各种端口可能开放的概率,并排列出最有可能开放端口的列表,具体可以参见nmap- -services文件。默认情况下,nmap会扫描最有可能的1000个tcp端口)。--port-ratio: scan ports more common than,扫描指定频率以上的端口。与上述top-ports类似,这里以概率作为参数,概率大于port--ratio的端口才被扫描。显然参数必须在0~1之间,想了解具体的概率范围可以查看nmap- -services文件。service/version detection:[版本探测]-sv: probe open ports to determine service/version info,指定让nmap进行版本侦测。--version-intensity: set from 0 (light) to 9 (try all probes),指定版本侦测的强度(0~9),默认为7。数值越高,探测出的服务越准确,但是运行时间会比较长。--version-light: limit to most likely probes (intensity 2),指使用轻量级侦测方式(intensity2)--version-all: try every single probe (intensity 9),尝试使用所有的 probes进行侦测( intensity9)。--version-trace: show detailed version scan activity (for debugging),显示出详细的版本侦测过程信息。script scan:[扫描脚本]-sc/--script=default: 使用默认的脚本进行扫描。--script=:is a comma separated list of,使用某个脚本进行扫描。directories, script-files or script-categories--script-args=: provide arguments to scripts,该参数用于传递脚本里的参数key是参数名,该参数对应valuel这个值。如有更多的参数,使用逗号连接。--script-args-file=filename: provide nse script args in a file,使用文件为脚本提供参数。--script-trace: show all data sent and received,如设置该参数,则显示脚本执行过程中发送与接收的数据。--script-updatedb: update the script database.在nmap 的scripts目录里有一个db文件,该文件保存了当前nmap可用的脚本,类似于一个小型数据库,如果我们开启nmap并调用了此参数,则nmap会自行扫描scripts扫描目录中的扩展脚本,进行数据库更新--script-help=: show help about scripts.查看扫描脚本帮助文档is a comma-separated list of script-files orscript-categoriesos detection:[系统探测]-o: enable os detection,系统探测--osscan-limit: limit os detection to promising targets,只对满足“同时具备状态为open和closed的端口”的主机进行操作系统探测--osscan-guess: guess os more aggressively,猜测最有可能的系统版本timing and performance:[时间与性能]options which takeare 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: parallel host scan group sizes,指定并行扫描的主机数量,每次最大或者最小扫描多少个主机--min-parallelism/max-parallelism: probe parallelization--min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout: specifiesprobe round trip time.--max-retries: caps number of port scan probe retransmissions.最大的探测次数--host-timeout: give up on target after this long,超时时间--scan-delay/--max-scan-delay: adjust delay between probes,扫描探测的延时时间/间隔时间--min-rate: send packets no slower thanper second,每秒发包不少于number--max-rate: send packets no faster thanper second,每秒发包不多于numberfirewall/ids evasion and spoofing:[防火墙/ids绕过和欺骗]-f; --mtu: fragment packets (optionally w/given mtu),分片-d: cloak a scan with decoys,伪造源地址,但并不是正真的源地址,而是增加一些噪声源,用以迷惑目标ip,增加对方的分析难度。-s: spoof source address,源地址伪造-e: use specified interface,使用特殊接口-g/--source-port: use given port number,使用指定源端口--proxies: relay connections through http/socks4 proxies,代理--data: append a custom payload to sent packets,添加自定义数据字段,但字段必须是16进制--data-string: append a custom ascii string to sent packets,添加ascii码发送数据--data-length: append random data to sent packets,数据长度--ip-options: send packets with specified ip options,特殊ip选项--ttl: set ip time-to-live field,设置ip存活时间--spoof-mac: spoof your mac address,mac欺骗--badsum: send packets with a bogus tcp/udp/sctp checksumoutput:,差错校验-on/-ox/-os/-og: output scan in normal, xml, s| 4.初级快速使用靶机1ip:192.168.154.128
靶机2ip:192.168.3.7
4.1扫描单个目标 nmap 192.168.154.128
4.2扫描多个目标nmap 192.168.154.128 192.168.3.7
nmap 192.168.3.1-10 192.168.154.100-130
4.3扫描除某个目标之外的目标targets.txt:
192.168.3.1
192.168.3.5
192.168.3.7
192.168.154.128
使用方法:
nmap 192.168.3.1/28 -exclude 192.168.3.7
nmap 192.168.154.128 -excludefile targets.txt
4.4扫描指定文件内的目标由于要读取文件,可能根据文件存放路径不同需要管理员权限
nmap -il targets.txt
4.5扫描指定端口nmap 192.168.154.128 -p 21,22,23,80,443,3306
4.6扫描端口开放与服务版本情况nmap -sv 192.168.154.128
4.7路由跟踪nmap --traceroute 192.168.154.128
4.8主机存活情况nmap -sp 192.168.3.0/24 192.168.154.0/24 -t5
4.9os版本探测nmap -o 192.168.154.128
4.10防火墙状态nmap -sf -t5 192.168.154.128
状态识别
状态
含义
open
端口处于开放状态,表示应用程序正在监听该端口的连接,外部可以访问
filtered
被过滤,表示端口被防火墙或其他安全设备阻止,不能访问
closed
关闭,表示目标主机未开放该端口
unfiltered
未被过滤的,表示nmap无法确认该端口所处状态,需进一步探测
open/filtered
开放的或被过滤的,nmap不能识别
closed/filtered
关闭的或被过滤的,nmap不能识别
5.进阶使用nmap脚本默认存放在/xx/nmap/scripts
5.1nmap脚本分类auth: 负责处理鉴权证书(绕开鉴权)的脚本 broadcast: 在局域网内探查更多服务开启状况,如dhcp/dns/sqlserver等服务   brute: 提供暴力破解方式,针对常见的应用如http/snmp等 default: 使用-sc或-a选项扫描时候默认的脚本,提供基本脚本扫描能力 discovery: 对网络进行更多的信息,如smb枚举、snmp查询等 dos: 用于进行拒绝服务攻击 exploit: 利用已知的漏洞入侵系统 external: 利用第三方的数据库或资源,例如进行whois解析 fuzzer: 模糊测试的脚本,发送异常的包到目标机,探测出潜在漏 intrusive:入侵性的脚本,此类脚本可能引发对方的ids/ips的记录或屏蔽 malware: 探测目标机是否感染了病毒、开启了后门等信息 safe: 此类与intrusive相反,属于安全性脚本 version: 负责增强服务与版本扫描(version detection)功能的脚本 vuln: 负责检查目标机是否有常见的漏洞(vulnerability),如是否有ms08_067
常用脚本使用语法:
script scan:[扫描脚本]  -sc/--script=default: 使用默认的脚本进行扫描。  --script=:is a comma separated list of,使用某个脚本进行扫描。           directories, script-files or script-categories  --script-args=: provide arguments to scripts,该参数用于传递脚本里的参数key是参数名,该参数对应valuel这个值。如有更多的参数,使用逗号连接。  --script-args-file=filename: provide nse script args in a file,使用文件为脚本提供参数。  --script-trace: show all data sent and received,如设置该参数,则显示脚本执行过程中发送与接收的数据。  --script-updatedb: update the script database.在nmap 的scripts目录里有一个db文件,该文件保存了当前nmap可用的脚本,类似于一个小型数据库,如果我们开启nmap并调用了此参数,则nmap会自行扫描scripts扫描目录中的扩展脚本,进行数据库更新  --script-help=: show help about scripts.查看扫描脚本帮助文档           is a comma-separated list of script-files or           script-categories.
更多关于脚本使用参见本文命令行部分。
5.2鉴权扫描nmap --script=auth 192.168.154.128
5.3暴力破解nmap --script=brute 192.168.154.128
5.4漏洞扫描一般进行默认扫描配置就行。
nmap --script=vuln 192.168.154.128
5.4.1漏洞来源
 nmap-vulners:https://github.com/vulnerscom/nmap-vulners[默认已有]1.更改为nmap脚本目录:
cd /usr/share/nmap/scripts/
2.直接下载nmap-vulners脚本内容复制到scripts路径下
3.更新漏洞数据库:
nmap --script-updatedb
4.进行扫描
nmap --script nmap-vulners -sv -p 80 192.168.154.128
注:该-sv是绝对必要的。使用-sv,告诉nmap探测版本信息的目标地址。没有版本信息由nmap生成,nmap-vulners便无法获取任何数据来查询vulners数据库。使用这些nse脚本时始终使用-sv。
vulscan:https://github.com/scipag/vulscan.git
1.将github存储库克隆到nmap脚本目录中:git clone
https://github.com/scipag/vulscan.git
vulscan支持许多优秀的漏洞利用数据库:
 scipvuldb.csv cve.csv osvdb.csv securityfocus.csv securitytracker.csv xforce.csv expliotdb.csv openvas.csv
2.更新漏洞库:
3.使用vulscan进行扫描
nmap -sv --script=vulscan/vulscan.nse www.example.com
4.vulscan漏洞库更新[linux]
为确保数据库完全是最新的,可使用vulscan / utilities / updater /目录中的updatefiles.sh脚本进行更新。
(1)通过在终端中键入命令,切换到updater目录:
cd vulscan/utilities/updater/
(2)chmod命令确保该文件具有执行的适当权限:chmod +x updatefiles.sh
(3)终端中输入命令来执行和运行脚本:./updatefiles.sh
(4)完成更新
5.vulscan漏洞库更新[windows]
(1)下载漏洞库文件
•https://www.computec.ch/projekte/vulscan/download/cve.csv•https://www.computec.ch/projekte/vulscan/download/exploitdb.csv•https://www.computec.ch/projekte/vulscan/download/openvas.csv•https://www.computec.ch/projekte/vulscan/download/osvdb.csv•https://www.computec.ch/projekte/vulscan/download/scipvuldb.csv•https://www.computec.ch/projekte/vulscan/download/securityfocus.csv•https://www.computec.ch/projekte/vulscan/download/securitytracker.csv•https://www.computec.ch/projekte/vulscan/download/xforce.csv
(2)复制到scripts路径下
/scripts/
(3)使用时调用漏洞库
--script-args vulscandb=your_own_database
5.5应用服务扫描不是很好用
nmap --script=realvnc-auth-bypass 192.168.154.128
5.6局域网服务探测用于探测网卡和开放服务
nmap -n -p 443 --script=broadcast 192.168.154.128
5.7whois解析利用第三方数据库进行whois解析,并不是完全准确
nmap -script external baidu.com
以上就是nmap如何快速上手的详细内容。
其它类似信息

推荐信息