Nmap备忘单:从探索到漏洞利用 第三章 NSE脚本的使用

众所周知NMAP是经常用来进行端口发现、端口识别。除此之外我们还可以通过NMAP的NSE脚本做很多事情,比如邮件指纹识别,检索WHOIS记录,使用UDP服务等

众所周知NMAP是经常用来进行端口发现、端口识别。除此之外我们还可以通过NMAP的NSE脚本做很多事情,比如邮件指纹识别,检索WHOIS记录,使用UDP服务等。

发现地理位置

Gorjan Petrovski提交了个NMAP的NSE脚本,帮助我们定位远程IP的地理位置:ip-geolocation-maxmind,ip-geolocation-ipinfodb,和ipgeolocation-geobytes。

这将告诉我们如何设置并使用附带的NMAP NSE的地理位置脚本。

 ip-geolocation-maxmind

为了能调用该脚本,需要先下载MaxMind的城市数据库http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz。解压到本地的NMAP数据文件夹($Nmap_DATA/nselib/data/)。

命令:

Nmap  --script ip-geolocation-* ip

 提交新的地理位置提供商

有时地理位置可能是错误的,因为地理位置取决于的MaxMind数据库。因此我们必须给NMAP提供一个新的数据库。

 获得WHOIS记录信息

WHOIS记录通常包含如注册人的姓名和联系方式的重要数据。虽然这里有很多工具可以查询WHOIS协议,但NMAP的证明了自身的优秀,因为它能够批量处理IP范围和主机列表。

命令:Nmap --script whois 目标

图片1.png-600

 --script WHOIS查询参数告诉NMAP的,以获得给定目标的记录。此脚本使用IANA分配的数据来选择RIR,它的结果在本地缓存。另外,我们可以覆盖此行为,并选择服务提供商的说法whodb使用的顺序:

参数--script whois告诉NMAP去查询区域互联网注册管理机构WHOIS数据库来获得给定目标的whois记录。这个脚本使用IANA分配的数据选择RIR并在本地缓存结果。或者我们可以覆盖这一行为,指定whois数据库的提供商并依次查询。

命令:

Nmap --script whois --script-args whois.whodb=arin+ripe+afrinic <目标>

图片2.png-600

该脚本将会按顺序在WHOIS提供商中查询记录或者推荐记录,要忽略推荐记录请指定参数值nofollow。

命令:Nmap --script whois --script-args whois.whodb=nofollow <目标>

要批量查询的主机名列表(-iL <文件名>)的WHOIS记录而不启用端口扫描(-sn)。命令:Nmap -sn –script whois -v -iL hosts.txt (hosts.txt包含主机或者ip的列表)

禁用缓存

有时候whois查询返回的是缓存的结果而不是最新的,可以指定参数禁止查询缓存。

命令:

Nmap -sn --script whois -script-args whois.whodb=nocache scanme. Nmap.org

图片3.png-600 

检查主机是否有恶意行为

NMAP通过调用谷歌安全浏览服务API来检查主机是否进行恶意软件分发或者网络钓鱼攻击的行为。

使用脚本http-google-malware之前,先获取谷歌安全浏览服务API的密钥:

https://developers.google.com/safe-browsing/key_signup?csw=1

命令:

Nmap -p80 -script http-google-malware -script-args http-google-malware.api= <目标>

如果不使用API,也可以进行查询。

命令:Nmap -p80 --script http-google-malware -v scanme.Nmap.org

图片4.png-600 

收集有效的邮箱

收集邮箱对渗透测试非常有用,我们可以对这些邮箱进行钓鱼工具或者暴力破解攻击。NMAP可以进行邮箱的收集,但是脚本http-google-email不在NMAP的官方资料库中,我们需要手动下载http://seclists.org/Nmap-dev/2011/q3/att-401/http-google-email.nse,并把它复制到本地脚本目录。正如你所看到的,下面的截图有电子邮件收集脚本的详细信息:

图片5.png-600 

但作为一名安全研究人员必须要了解脚本,因为脚本可能包含恶意的东西。所以下面介绍关于脚本的详细信息。下面就是下载的脚本内容,这样你就不必再下载,可以直接使用该脚本。

找到所有的NSE脚本的最简单方法是使用find命令如下所示。

description = [[ http-google-email queries the Google web search engine and Google Groups for e-mails pertaining to a specific domain. ]] --- -- @usage -- Nmap -p80 --script http-google-email  -- -- @output -- PORT   STATE SERVICE -- 80/tcp open  http -- | http-google-email: -- | Nmap-dev () insecure org -- | Nmap-svn () insecure org -- |_fyodor () insecure org -- -- @args http-google-email.domain Domain to search for. -- @args http-google-email.pages The number of results pages to be requested from Google Web search and Google Group search respectively. Default is 5. --- author = "Shinnok" license = "Same as Nmap--See http://Nmap.org/book/man-legal.html" categories = {"discovery", "safe", "external"} require "http" require "shortport" portrule = shortport.http --Builds Google Web Search query --@param domain --@param page --@return Url local function google_search_query(domain, page) return string.format("http://www.google.com/search?q=%%40%s&hl=en&lr=&ie=UTF-8&start=%s&sa=N", domain, page) end --Builds Google Groups Search query --@param domain --@param page --@return Url local function google_groups_query(domain, page) return string.format("http://groups.google.com/groups?q=%s&hl=en&lr=&ie=UTF-8&start=%s&sa=N", domain, page) end --- --MAIN --- action = function(host, port) local pages = 50 local target local emails = {} if(stdnse.get_script_args("http-google-email.pages")) then pages = stdnse.get_script_args("http-google-email.pages")*10 end -- Check if we have the domain argument passed if(stdnse.get_script_args("http-google-email.domain")) then target = stdnse.get_script_args("http-google-email.domain") else -- Ver

以上就是Nmap备忘单:从探索到漏洞利用 第三章 NSE脚本的使用的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 工具使用