前言
Nmap是一款强大的开源扫描工具。同时Nmap提供了强大的脚本引擎(Nmap Scripting Engine),支持通过Lua脚本语言来扩展Nmap的功能,在Nmap的发行版中已经包含了数百个扩展脚本,除了辅助完成Nmap的主机发现、端口扫描、服务侦测、操作系统侦测四个基本功能,还补充了其他扫描能力:如执行HTTP服务详细的探测、暴力破解简单密码、检查漏洞信息等等。
脚本分类及使用
分类
Nmap脚本主要分为以下几类,引用自: Nmap脚本使用总结 :
auth: 负责处理鉴权证书(绕开鉴权)的脚本 broadcast: 在局域网内探查更多服务开启状况,如dhcp/dns/sqlserver等服务 brute: 提供暴力破解方式,针对常见的应用如http/snmp等 default: 使用-sC或-A选项扫描时候默认的脚本,提供基本脚本扫描能力 discovery: 对网络进行更多的信息,如SMB枚举、SNMP查询等 dos: 用于进行拒绝服务攻击 exploit: 利用已知的漏洞入侵系统 external: 利用第三方的数据库或资源,例如进行whois解析 malware: 探测目标机是否感染了病毒、开启了后门等信息 safe: 此类与intrusive相反,属于安全性脚本 version: 负责增强服务与版本扫描(Version Detection)功能的脚本 vuln: 负责检查目标机是否有常见的漏洞(Vulnerability),如是否有MS08_067 |
命令行选项
Nmap提供的一些命令如下:
-sC/--script=default:使用默认的脚本进行扫描。 --script=<Lua scripts>:使用某个脚本进行扫描 --script-args=x=x,y=y: 为脚本提供参数 --script-args-file=filename: 使用文件来为脚本提供参数 --script-trace: 显示脚本执行过程中发送与接收的数据 --script-updatedb: 更新脚本数据库 --script-help=<Lua scripts>: 显示脚本的帮助信息 |
脚本
针对性脚本
收集了Github上的一些较有针对性Nmap脚本:
MS15-034、LFI、Nikto、ShellShock、tenda
https://github.com/s4n7h0/NSE
枚举ICS程序和设备
https://github.com/digitalbond/Redpoint
一些NSE脚本合集
https://github.com/cldrn/nmap-nse-scripts
路由器信息收集:
https://github.com/DaniLabs/scripts-nse
暴力破解
https://github.com/lelybar/hydra.nse
Cassandra、WebSphere
https://github.com/kost/nmap-nse
Scada
https://github.com/drainware/nmap-scada
NSE开发工具
https://github.com/s4n7h0/Halcyon
Hadoop、Flume
https://github.com/b4ldr/nse-scripts
WordPress
https://github.com/peter-hackertarget/nmap-nse-scripts
VNC
https://github.com/nosteve/vnc-auth
PhantomJS检查Http Header信息
https://github.com/aerissecure/nse
WebServices检测
https://github.com/c-x/nmap-webshot
SSL心脏滴血
https://github.com/takeshixx/ssl-heartbleed.nse
OpenStack
https://github.com/sicarie/nse
Apache、Rails-xml
https://github.com/michenriksen/nmap-scripts
网关、DNS
https://github.com/ernw/nmap-scripts
MacOS
https://github.com/ulissescastro/ya-nse-screenshooter
目录扫描、WhatCMS、漏洞检测
https://github.com/Cunzhang/NseScripting
Redis
https://github.com/axtl/nse-scripts
华为设备检测
https://github.com/vicendominguez/http-enum-vodafone-hua253s
Axis
https://github.com/bikashdash/Axis_Vuln_Webcam
内网渗透
来自影牛milsec公众号的推荐
Nmap提供了许多有效的脚本,无需依赖其他第三方的工具对内网机器进行渗透测试:
smb-enum-domains.nse
域控制器信息收集,主机信息、用户、密码策略等
smb-enum-users.nse
域控制器扫描
smb-enum-shares.nse
遍历远程主机的共享目录
smb-enum-processes.nse
通过SMB对主机的系统进程进行遍历
smb-enum-sessions.nse
通过SMB获取域内主机的用户登录session,查看当前用户登录情况
smb-os-discovery.nse
通过SMB协议来收集目标主机的操作系统、计算机名、域名、全称域名、域林名称、NetBIOS机器名、NetBIOS域名、工作组、系统时间等
smb-ls.nse
列举共享目录内的文件,配合smb-enum-share使用
smb-psexec.nse
获取到SMB用户密码时可以通过smb-psexec在远程主机来执行命令
smb-system-info.nse
通过SMB协议获取目标主机的操作系统信息、环境变量、硬件信息以及浏览器版本等
ms-sql-brute.nse
收集组合字典后对域内的MSSQL机器进行破解
ms-sql-xp-cmdshell.nse
获得MSSQL的SA权限用户名密码时可以通过Nmap脚本来执行指定命令,可以通过SMB协议或者MSSQL来执行
redis.nse
爆破Redis的用户密码,可以结合写入SSH key获取服务器权限
oracle-sid-brute.nse
挂载字典爆破oracle的sid
oracle-enum-users
通过挂载字典遍历Oracle的可用用户
oracle-brute.nse
获取sid之后可以爆破Oracle的用户密码
pgsql-brute.nse
PostgreSql用户密码猜解脚本,对pgsql进行密码爆破,适当的权限下可以读写文件、执行命令,从而进一步获取服务器控制权限。
svn-brute.nse
对SVN服务器进行爆破,通过这些svn服务器上的内容,我们可以下载源代码,寻找一些有用的信息
工具
Nmap NSE脚本搜索引擎
https://github.com/JKO/nsearch
================================================
_ _ _____ _____ _
| \ | |/ ___|| ___| | |
| \| |\ `--. | |__ __ _ _ __ ___ | |__
| . ` | `--. \| __| / _` || '__| / __|| '_ |
| |\ |/\__/ /| |___ | (_| || | | (__ | | | |
\_| \_/\____/ \____/ \__,_||_| \___||_| |_|
================================================
Version 0.4b http://goo.gl/8mFHE5 @jjtibaquira
Email: jko@dragonjar.org | www.dragonjar.org
================================================
nsearch> search name:http author:calderon category:vuln
*** Name Author
[+] http-vuln-cve2012-1823.nse Paulino Calderon, Paul AMAR
[+] http-phpself-xss.nse Paulino Calderon
[+] http-wordpress-enum.nse Paulino Calderon
[+] http-adobe-coldfusion-apsa1301.nse Paulino Calderon
[+] http-vuln-cve2013-0156.nse Paulino Calderon
[+] http-awstatstotals-exec.nse Paulino Calderon
[+] http-axis2-dir-traversal.nse Paulino Calderon
[+] http-huawei-hg5xx-vuln.nse Paulino Calderon
[+] http-tplink-dir-traversal.nse Paulino Calderon
[+] http-trace.nse Paulino Calderon
[+] http-litespeed-sourcecode-download.nse Paulino Calderon
[+] http-majordomo2-dir-traversal.nse Paulino Calderon
[+] http-method-tamper.nse Paulino Calderon
总结
扫描经常会触发IDS或者其他的安全设备,所以在用的时候应根据实际的环境,来选择合适的脚本。