问题

想要查看某个服务器apache或nginx版本

解决

首先安装nmap
官网地址
修改下安装磁盘之后全next就ok。
我安装的7.94版本默认会配置环境变量,所以不需要另行配置。windows环境下直接打开cmd运行命令即可。
一般情况nginx或者apache会在默认端口上

1
nmap -sV -p 80,443 ip

如果服务器没有特殊配置即可查看到版本。

以下转载于:https://blog.csdn.net/weixin_73562787/article/details/131793001

主机发现

全面扫描/综合扫描

1
nmap -A 192.168.1.103

Ping 扫描

1
nmap -sP 192.168.1.1/24

免 Ping 扫描,穿透防火墙,避免被防火墙发现

1
nmap -P0 192.168.1.103

TCP SYN Ping 扫描

1
2
nmap -PS -v 192.168.1.103
nmap -PS80,10-100 -v 192.168.1.103 (针对防火墙丢弃 RST 包)

TCP ACK Ping 扫描

1
nmap -PA -v 192.168.1.103

UDP Ping 扫描

1
nmap -PU -v 192.168.1.103

ICMP Ping Types 扫描

1
2
3
nmap -PU -v 192.168.1.103 (ICMP ECHO)
nmap -PP -v 192.168.1.103 (ICMP 时间戳)
nmap -PM -v 192.168.1.103 (ICMP 地址掩码)

ARP Ping 扫描

1
nmap -PR -v 192.168.1.103

列表 扫描

1
nmap -sL -v 192.168.1.103

禁止方向域名解析

1
nmap -n -sL -v 192.168.1.103

方向域名解析

1
nmap -R -sL -v 192.168.1.103

使用系统域名解析系统

1
nmap --system-dns 192.168.1.2 192.168.1.103

扫描 IPV6 地址

1
nmap -6 IPv6

路由跟踪

1
nmap --traceroute -v www.sunbridgegroup.com

SCTP INIT Ping 扫描

1
nmap -PY -v 192.168.1.103

端口扫描

时序扫描

1
nmap -T(0-5) 192.168.1.103

常用扫描方式

1
2
3
4
5
nmap -p 80 192.168.1.103
nmap -p 80-100 192.168.1.103
nmap -p T:80,U:445 192.168.1.103
nmap -F 192.168.1.1.103 (快速扫描)
nmap --top-ports 100 192.168.1.103 (扫描最有用的前 100 个端口)

TCP SYN 扫描 (高效的扫描方式)

1
nmap -sS -v 192.168.1.103

TCP 连接扫描

1
nmap -sT -v 192.168.1.103

UDP 连接扫描

1
nmap -sU -p 80-100 192.168.1.103

隐蔽扫描

1
2
3
nmap -sN 61.241.194.153(NULL 扫描)
nmap -sF 61.241.194.153(FIN 扫描)
nmap -sX 61.241.194.153(Xmas 扫描)

TCP ACK 扫描

1
nmap -sA 192.168.1.103

TCP 窗口扫描

1
nmap -sW -v -F 192.168.1.103

TCP Maimon 扫描

1
nmap -sM -T4 192.168.1.103

自定义 扫描

1
nmap -sT --scanflags SYNURG 192.168.1.103

空闲 扫描( 隐藏 IP )

1
nmap -sI www.0day.co:80 192.168.1.103

IP 协议 扫描

1
nmap -sO -T4 192.168.1.103

FTP Bounce 扫描
(已经不被支持)

指纹识别与探测

版本探测

1
2
nmap -sV 192.168.1.103
nmap -sV -A 192.168.1.103

全端口版本探测

1
nmap -sV --allports 192.168.1.103

设置扫描强度

1
nmap -sV --version-intensity (0-9) 192.168.1.103

轻量级扫描

1
nmap -sV --version-light 2 192.168.1.103

重量级扫描

1
nmap -sV --version-all 192.168.1.103

获取详细版本信息

1
nmap -sV --version-trace 192.168.1.103

RPC 扫描

1
nmap -sS -sR 192.168.1.103

对指定的目标进行操作系统监测

1
nmap -O --osscan-limit 192.168.1.103

推测系统并识别

1
nmap -O --osscan-guess 192.168.1.103

伺机而动

调整并行扫描组的大小

1
2
nmap --min-hostgroup 30 192.168.1.110/24
nmap --max-hostgroup 30 902 192.168.1.104

调整探测报文的并行度

1
2
nmap --min-parallelism 100 192.168.1.104
nmap --max-parallelism 100 192.168.1.104

调整探测报文超时

1
2
3
nmap --initial-rtt-timeout 100ms 192.168.1.104
nmap --max-rtt-timeout 100ms 192.168.1.104
nmap --min-rtt-timeout 100ms 192.168.1.104

放弃缓慢的目标主机

1
nmap --host-timeout 1800000ms 192.168.1.104

调整报文适合时间间隔

1
2
nmap --scan-delay 1s 192.168.1.104
nmap --max-scan-delay 1s 192.168.1.104

防火墙/IDS 逃逸

报文分段

1
nmap -f -v 61.241.194.153

指定偏移大小

1
nmap --mtu 16 192.168.1.104

IP 欺骗

1
2
nmap -D RND:11 192.168.1.104
nmap -D 192.168.1.104,192.168.1.103,192.168.1.101 192.168.1.104

源地址欺骗

1
nmap -sI www.0day.cn:80 192.168.1.104

源端口欺骗

1
nmap --source-port 902 192.168.1.104

指定发包长度

1
nmap --data-length 30 192.168.1.104

目标主机随机排序

1
nmap --randomize-hosts 192.168.1.104

MAX 地址欺骗

1
nmap -sT -Pn --spoof-mac 0 192.168.1.104

信息收集

IP 信息收集

1
nmap --script ip-geolocation-* www.pcos.cn

WHOIS 查询

1
2
3
4
nmap --script whois-domain www.pcos.cn
nmap --script whois-domain --script-args whois.whodb=nofollow
www.ithome.com
nmap -sn --script whois-domain -v -iL host.txt

搜索邮件信息(新版可能没有这个模块)

1
nmap --script http-email-harvest www.pcos.cn

IP 反查

1
nmap -sn --script hostmap-ip2hosts www.pcos.cn

DNS 信息收集

1
2
3
4
nmap --script dns-brute www.pcos.cn
nmap --script dns-brute dns-brute.threads=10 www.pcos.cn
nmap --script dns-brute dns-brute.threads=10,dns-brute.hostlis
www.pcos.cn

检索系统信息

1
nmap -p 445 445 192.168.1.104 --script membase-http-info

后台打印机服务漏洞

1
nmap --script smb-security-mode.nse -p 445 119.29.155.45

系统漏洞扫描

1
nmap --script smb-check-vulns.nse -p 445 119.29.155.45

扫描 Web 漏洞

1
2
nmap -p80 --script http-stored-xss.nse/http-sql-injection.nse
119.29.155.45

通过 Snmp 列举 Windows 服务/账户

1
2
nmap -sU -p 161 --script=snmp-win32-services 192.168.1.104
nmap -sU -f -p 161 --script=snmp-win32-users 192.168.1.110

枚举 DNS 服务器的主机名

1
nmap --script dns-brute --script-args dns-brute.domain=baidu.com

HTTP 信息收集

1
2
3
4
nmap -sV -p 80 www.0day.com (HTTP 版本探测)
nmap -p 80 --script=http-headers www.pcos.cn (HTTP 信息头探测)
nmap -p 80 --script=http-sitemap-generator www.pcos.cn (爬行 Web 目
录结构)

枚举 SSL 密钥

1
nmap -p 443 --script=ssl-enum-ciphers www.baidu.com

SSH 服务密钥信息探测

1
map -p 22 --script ssh-hostkey --script-args ssh_hostkey=full 127.0.0.1

数据库渗透测试

Mysql 列举数据库

1
2
nmap -p3306 --script=mysql-databases --script-args
mysqluser=root,mysqlpass 192.168.1.101

列举 MySQL 变量

1
2
nmap -p3306 --script=mysql-variables 192.168.1.3
nmap -sV --script=mysql-variables 192.168.1.3 (无法确定端口的情况下)

检查 MySQL 密码

1
2
nmap -p3306 --script=mysql-empty-password 192.168.1.3
nmap -sV -F -T4 --script=mysql-empty-password 192.168.1.3

审计 MySQL 密码

1
2
3
nmap --script=mysql-brute 192.168.1.101
nmap -p3306 --script=mysql-brute userdb=/root/passdb.txt
passdb=/root/pass.txt 192.168.1.101 (指定字典)

审计 MySQL 安全配置

1
2
3
nmap -p3306 --script mysql-audit --script-args
"mysql-audit.username='root',mysql-audit.password='123',mysql-audit.fi
lename='nselib/data/mysql-cis.audit'" 192.168.1.104

审计 Oracle 密码

1
2
3
4
5
nmap --script=oracle-brute -p 1521 --script-args oracle-brute.sid=test
192.168.1.121
nmap --script=oracle-brute -p 1521 --script-args oracle-brute.sid=test
--script-args userdb=/tmp/usernames.txt,passdb=/tmp/password.txt
192.168.1.105

审计 msSQL 密码

1
2
nmap -p 1433 --script ms-sql-brute --script-args
userdb=name.txt,passdb=pass.txt 192.168.1.104

检查 msSQL 空密码

1
nmap -p 1433 --script ms-sql-empty-password 192.168.1.104

读取 msSQL 数据

1
2
nmap -p 1433 --script ms-sql-tables --script-args
mssql.username=sa,mssql.Password=sa 192.168.1.101

读取 msSQL 执行系统命令

1
2
3
nmap -p 1433 --script ms-sql-xp-cmdshell --script-args
mssql.username=sa,mssql.password=sa,ms-sql-xp-cmdshell.cmd="ipconf
ig" 192.168.1.101

审计 PgSQL 密码

1
nmap -p 5432 --script pgsql-brute 192.168.1.101

渗透测试

审计 HTTP 身份验证

1
nmap --script=http-brute -p 80 www.pcos.cn

审计 FTP 服务器

1
2
3
4
nmap --script ftp-brute -p 21 192.168.1.101
nmap --script ftp-brute --script-args userdb=user.txt,passdb=pass.txt -p
21 192.168.1.101
nmap --script=ftp-anon 192.168.1.101

审计 Wordpress 程序

1
2
3
4
5
nmap -p80 --script http-wordpress-brute 192.168.1.110
nmap -p80 --script http-wordpress-brute --script-args
userdb=user.txt,passdb=passwd.txt 192.168.1.110
nmap -p80 --script http-wordpress-brute --script-args
http-wordpress-brute.threads=10 192.168.1.110

审计 Joomla 程序

1
2
3
4
5
6
nmap -p80 --script http-joomla-brute 192.168.1.110
nmap -p80 --script http-joomla-brute --script-args
uesrdb=user.txt,passdb=passwd.txt 192.168.1.110
nmap -p80 --script http-joomla-brute --script-args
uesrdb=user.txt,passdb=passwd.txt,http-joomla-brute.threads=5
192.168.1.110

审计 邮件服务器

1
nmap -p110 --script=pop3-brute 192.168.1.110

审计 SMB 口令

1
2
3
nmap --script smb-brute.nse -p 445 192.168.1.110
nmap --script smb-brute.nse --script-args passdb=pass.txt -p 445
192.168.1.110

审计 VNC 服务

1
nmap --script vnc-brute -p 5900 192.168.1.110

审计 SMTP 服务器

1
2
3
nmap -p 25 --script smtp-brute 192.168.1.110
nmap -p 25 --script=smtp-enum-users.nse smith.jack.com (枚举远程系
统所有用户)

检测 Stuxnet 蠕虫

1
nmap --script stuxnet-detect -p 445 192.168.1.110

SNMP 服务安全审计

1
2
3
4
5
6
7
nmap -sU -p 161 --script=snmp-netstat 192.168.1.101 (获取目标主机网
络连接状态)
nmap -sU -p 161 --script=snmp-processes 192.168.1.110 (枚举目标主机
的系统进程)
nmap -sU -p 161 --script=snmp-win32-services 192.168.1.110 ( 获 得
windows 服务器的服务)
nmap -sU -p 161 --script snmp-brute 192.168.1.110

Zenmap

Intense scan (详细扫描)

1
nmap -T4 -A -v 192.168.1.101

Intense scan plus UDP (UDP 扫描经典使用)

1
nmap -sS -sU -T4 -A -v 192.168.1.101

Intense scan, all TCP ports (TCP 扫描)

1
nmap -p 1-65535 -T4 -A -v 192.168.1.101

Intense scan, no ping (无 Ping 扫描)

1
nmap -T4 -A -v -Pn 192.168.1.101

Ping scan (Ping 扫描)

1
nmap -sn 192.168.1.101/24

Quick scan

1
nmap -T4 -F 192.168.1.101/24

Quick scan plus

1
nmap -sV -T4 -O -F --version-light 192.168.1.101/24

Quick traceroute

1
nmap -sn --traceroute 192.168.1.101

Regular scan

1
nmap 192.168.1.101

Slow comprehensive scan

1
2
nmap -sS -sU -T4 -A -v -PE -PP -PS80,443 -PA3389 -PU40125 -PY -g 53
--script "default or (discovery and safe)" 192.168.1.101

Nmap 技巧

发送以太网数据包

1
nmap --send-eth 192.168.1.111

网络层发送

1
nmap --send-ip 192.168.1.111

假定拥有所有权

1
nmap --privileged 192.168.1.111

在交互模式中启动

1
nmap --interactive

查看 Nmap 版本号

1
nmap -V

设置调试级别

1
nmap -d (1-9) 192.168.1.111

跟踪发送接收的报文

1
nmap --packet-trace -p 20-30 192.168.1.111

列举接口和路由

1
nmap --iflist www.iteye.com

指定网络接口

1
nmap -e eth0 192.168.1.111

继续中断扫描

1
2
nmap -oG 1.txt -v 192.168.126.1/24
nmap --resume 1.txt (继续扫描)

Dnmap

1
2
dnmap_server -f test (指定命令脚本)
dnmap_client -s 192.168.1.107 -a test

编写 Nse 脚本

(1) – The scanning module –

1
2
3
4
5
6
7
8
9
author = "Wing"
categories = {"version"}
portrule = function(host,port)
return port.protocol == "tcp" and port.number == 80 and
port.state == "open"
end
action = function(host,port)
return "Found!!!"
end

(2) – The scanning module –

1
2
3
4
5
6
7
8
9
10
11
12
13
author = "Wing"
categories = {"version"}
local comm=require "comm"
require "shortport"
local http=require "http"
portrule = function(host,port)
return (port.number == 80) and (port.start=="open")
end
action = function(host,port)
local uri = "/admin.php"
local response = http.get(host,port,uri)
return "Found!!!"
end

探测防火墙

1
nmap --script=firewalk --traceroute 192.168.1.111

VMware 认证破解

1
nmap -p 902 --script vmauthd-brute 192.168.1.107

Nmap 的保存和输出

标准保存

1
nmap -F -oN d:/test1.txt 192.168.1.111

XML 保存

1
nmap -F -oX d:/test1.xml 192.168.1.111

133t 保存

1
nmap -F -oS d:/test2.txt 192.168.1.111

Grep 保存

1
nmap -F -oG d:/test2.txt 192.168.1.111

保存到所有格式

1
nmap -F -oA d:/test2 192.168.1.111

补充保存文件

1
nmap -F -append-output -oN d:/test2.txt 192.168.1.111

转换 XML 保存

1
2
nmap -F -oX testB.xml --stylesheet
Nmap Scan Report - Scanned at 192.168.1.111

忽略 XML 声明的 XSL 样式表

1
nmap -oX d:/testC.xml --no-stylesheet 192.168.1.111