赞
踩
Nmap(Network Mapper)是一个开源的网络探测和安全审核工具。它被广泛用于网络发现和安全扫描。Nmap使用原始IP数据包来确定网络上的哪些主机可用、这些主机提供哪些服务(应用程序名和版本)、这些主机运行的操作系统(包括版本信息和可能的硬件类型)、这些主机使用的包过滤器/防火墙类型以及各种其他特性。
参数 | 解释 | 示例 |
---|---|---|
-p [port(s)] | 扫描指定的端口或端口范围 | nmap -p 80,443 [target] |
-F | 快速扫描,只检查常用端口 | nmap -F [target] |
-O | 启用操作系统检测 | nmap -O [target] |
-sV | 探测服务版本信息 | nmap -sV [target] |
-n | 禁止DNS解析 | nmap -n [target] |
-sS | 使用TCP SYN扫描,不完全建立TCP连接 | nmap -sS [target] |
-sT | 使用TCP Connect扫描,完全建立TCP连接 | nmap -sT [target] |
--script | 使用指定的Nmap脚本进行扫描 | nmap --script=[script-name] [target] |
-A | 综合扫描,包括操作系统检测、版本检测、脚本扫描和traceroute | nmap -A [target] |
-T[0-5] | 设置扫描速度,0是最慢,5是最快 | nmap -T4 [target] |
-v | 增加输出的详细程度 | nmap -v [target] |
-Pn | 跳过主机发现,直接扫描端口 | nmap -Pn [target] |
例子: 扫描端口: nmap 192.168.75.225 扫描特定端口: nmap -p 22,80,443 192.168.75.225 快速扫描: nmap -F 192.168.75.225
┌──(newrain㉿kali)-[~/Desktop] └─$ sudo nmap 192.168.75.225 [sudo] newrain 的密码: Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-14 14:21 CST Nmap scan report for 192.168.75.225 Host is up (0.000031s latency). Not shown: 997 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 3306/tcp open mysql MAC Address: 00:0C:29:A4:C1:3C (VMware) Nmap done: 1 IP address (1 host up) scanned in 2.26 seconds
扫描多个目标:nmap 192.168.75.225 192.168.75.226 192.168.75.227 扫描整个子网:nmap 192.168.75.0/24
# 多地址扫描 ┌──(newrain㉿kali)-[~/Desktop] └─$ sudo nmap 192.168.75.225 192.168.75.226 192.168.75.227 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-14 14:24 CST Nmap scan report for 192.168.75.225 Host is up (0.00026s latency). Not shown: 997 closed tcp ports (conn-refused) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 3306/tcp open mysql Nmap done: 3 IP addresses (1 host up) scanned in 3.34 seconds # 扫描整个网段 ┌──(newrain㉿kali)-[~/Desktop] └─$ sudo nmap 192.168.75.0/24 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-14 14:25 CST Nmap scan report for 192.168.75.1 Host is up (0.00013s latency). Not shown: 993 closed tcp ports (conn-refused) PORT STATE SERVICE 135/tcp open msrpc 139/tcp open netbios-ssn 443/tcp open https 445/tcp open microsoft-ds 902/tcp open iss-realsecure 912/tcp open apex-mesh 7000/tcp open afs3-fileserver Nmap scan report for 192.168.75.2 Host is up (0.00024s latency). Not shown: 999 closed tcp ports (conn-refused) PORT STATE SERVICE 53/tcp open domain Nmap scan report for 192.168.75.225 Host is up (0.00052s latency). Not shown: 997 closed tcp ports (conn-refused) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 3306/tcp open mysql Nmap scan report for 192.168.75.231 Host is up (0.000091s latency). All 1000 scanned ports on 192.168.75.231 are in ignored states. Not shown: 1000 closed tcp ports (conn-refused) Nmap done: 256 IP addresses (4 hosts up) scanned in 7.19 seconds
操作系统检测:nmap -O 192.168.75.225 服务版本检测:nmap -sV 192.168.75.225
# 检测操作系统 ┌──(newrain㉿kali)-[~/Desktop] └─$ sudo nmap -O 192.168.75.225 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-14 14:27 CST Nmap scan report for 192.168.75.225 Host is up (0.00044s latency). Not shown: 997 closed tcp ports (reset) PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 3306/tcp open mysql MAC Address: 00:0C:29:A4:C1:3C (VMware) Device type: general purpose Running: Linux 3.X|4.X OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4 OS details: Linux 3.2 - 4.9 Network Distance: 1 hop OS detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 3.65 seconds # 检查版本 ┌──(newrain㉿kali)-[~/Desktop] └─$ sudo nmap -sV 192.168.75.225 Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-01-14 14:29 CST Nmap scan report for 192.168.75.225 Host is up (0.000070s latency). Not shown: 997 closed tcp ports (reset) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 7.4 (protocol 2.0) 80/tcp open http nginx 1.20.1 3306/tcp open mysql MySQL 5.7.44 MAC Address: 00:0C:29:A4:C1:3C (VMware) Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 8.94 seconds
nmap --script=default 192.168.106.134 执行默认的脚本集,这通常包括针对最常见的漏洞和问题的检测。 nmap --script=auth 192.168.106.214 运行与认证相关的脚本,通常用于发现目标上的认证漏洞。 nmap --script=brute 192.168.106.134 执行暴力破解攻击的脚本,用于尝试破解目标上的各种服务(如FTP、SSH等)的密码。 nmap --script=vuln 192.168.106.134 运行检测已知漏洞的脚本,用于识别目标上可能存在的漏洞。 nmap --script=broadcast 192.168.106.134 使用广播脚本,这通常用于发现局域网内的主机和服务。 nmap --script=smb-brute.nse 192.168.106.134 执行针对SMB服务的暴力破解脚本,尝试猜测SMB协议上的用户名和密码。 nmap --script=smb-check-vulns.nse --script-args=unsafe=1 192.168.106.134 运行SMB漏洞检查脚本,unsafe=1参数允许脚本执行可能会对目标系统造成影响的检测。 nmap --script=smb-vuln-conficker.nse --script-args=unsafe=1 192.168.106.134 执行检测Conficker蠕虫的脚本,这是一种在Windows系统上广泛传播的恶意软件。 nmap -p3306 --script=mysql-empty-password.nse 192.168.106.134 在端口3306(MySQL的默认端口)上运行检查空密码的MySQL账户的脚本。
执行对目标服务器的基本扫描,只需输入以下命令:
nikto -h [目标主机] 例如:nikto -h http://www.example.com
┌──(newrain㉿kali)-[~] └─$ nikto -h http://192.168.75.225 - Nikto v2.5.0 --------------------------------------------------------------------------- + Target IP: 192.168.75.225 + Target Hostname: 192.168.75.225 + Target Port: 80 + Start Time: 2024-01-14 16:07:36 (GMT8) --------------------------------------------------------------------------- + Server: nginx/1.20.1 + /: Retrieved x-powered-by header: PHP/8.0.30. + /: The anti-clickjacking X-Frame-Options header is not present. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options + /: Drupal Link header found with value: <http://192.168.75.225/index.php?rest_route=/>; rel="https://api.w.org/". See: https://www.drupal.org/ + /: The X-Content-Type-Options header is not set. This could allow the user agent to render the content of the site in a different fashion to the MIME type. See: https://www.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/ + /index.php?: Uncommon header 'x-redirect-by' found, with contents: WordPress. + No CGI Directories found (use '-C all' to force check all possible dirs) + /wp-content/plugins/akismet/readme.txt: The WordPress Akismet plugin 'Tested up to' version usually matches the WordPress version. + /wp-links-opml.php: This WordPress script reveals the installed version. + /license.txt: License file found may identify site software. + /: A Wordpress installation was found. + /wp-login.php?action=register: Cookie wordpress_test_cookie created without the httponly flag. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies + 8102 requests: 0 error(s) and 10 item(s) reported on remote host + End Time: 2024-01-14 16:08:27 (GMT8) (51 seconds) --------------------------------------------------------------------------- + 1 host(s) tested
报告内容: 针对IP地址192.168.75.225上运行的Web服务器(端口80)的一些关键发现。这台服务器运行着nginx/1.20.1,并且部署了WordPress和Drupal。以下是一些重要的安全隐患和信息泄露点:
PHP版本公开:
扫描发现了x-powered-by头部,显示PHP版本为8.0.30。公开版本信息可能增加被攻击的风险。
缺少X-Frame-Options头:
没有X-Frame-Options头可能使网站容易受到点击劫持攻击。更多信息可参考:X-Frame-Options。
Drupal API链接:
发现了Drupal的API链接,这可能是信息泄露。
缺少X-Content-Type-Options头:
缺少这个头部可能允许浏览器基于内容推断MIME类型,可能导致安全漏洞。详情见:[Missing Content-Type Header](https://www
.netsparker.com/web-vulnerability-scanner/vulnerabilities/missing-content-type-header/).
WordPress的非常见头部 'x-redirect-by':
发现了指向WordPress的非常见头部,这可能是信息泄露。
未找到CGI目录:
未发现CGI目录,但可以使用-C all参数强制检查所有可能的目录。
WordPress Akismet插件信息:
通过/wp-content/plugins/akismet/readme.txt文件,泄露了WordPress Akismet插件的版本信息。
WordPress版本泄露:
/wp-links-opml.php脚本泄露了WordPress的安装版本。
可能泄露的许可证文件:
通过/license.txt文件可能泄露了站点软件的信息。
WordPress安装确认:
确认了站点上安装了WordPress。
Cookie缺少HttpOnly标志:
在/wp-login.php?action=register发现了未设置HttpOnly标志的wordpress_test_cookie。这可能使cookie容易受到跨站脚本攻击。
解决建议:
更新和打补丁:确保所有服务(如PHP, WordPress, Drupal, nginx)都是最新版本,并应用了所有安全补丁。
隐藏版本信息:配置Web服务器和应用,以避免泄露版本信息。
设置安全头部:添加X-Frame-Options、X-Content-Type-Options等安全头部,以增强浏览器安全性。
安全配置WordPress:确保WordPress配置正确,不泄露不必要的信息。
检查插件版本:确保所有WordPress插件是最新的,避免使用过时的插件。
配置Cookie安全:对所有敏感Cookie设置HttpOnly标志。
参数 | 解释 | 示例 |
---|---|---|
-h [host] | 指定要扫描的主机或IP地址 | nikto -h www.example.com |
-p [port] | 指定要扫描的端口 | nikto -h www.example.com -p 8080 |
-ssl | 使用SSL连接到主机 | nikto -h www.example.com -ssl |
-id [id:pass] | 使用HTTP认证 | nikto -h www.example.com -id user:pass |
-o [file] | 将扫描结果保存到指定文件 | nikto -h www.example.com -o result.txt |
-nolookup | 不进行DNS或WHOIS查找 | nikto -h 192.168.1.1 -nolookup |
-C [dir] | 强制检查指定目录 | nikto -h www.example.com -C all |
-T [test] | 选择特定测试类型执行 | nikto -h www.example.com -T xss |
-useproxy [host] | 通过指定的HTTP/HTTPS代理进行扫描 | nikto -h www.example.com -useproxy http://localhost:8080 |
-timeout [time] | 设置请求超时时间(秒) | nikto -h www.example.com -timeout 30 |
-evasion [num] | 使用指定的逃避技术 | nikto -h www.example.com -evasion 1 |
-useragent [ua] | 设置自定义的User-Agent字符串 | nikto -h www.example.com -useragent "MyUserAgent" |
-update | 更新Nikto插件和数据库 | nikto -update |
-list-plugins | 列出所有可用的Nikto插件 | nikto -list-plugins |
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。