Application Discovery (OWASP-IG-005) 应用发现
作为安全专业人员,有时给你一个集合的IP地址也可能只有一个IP地址来进行测试。常常有这样的情况,系统通过未关联DNS来隐藏一些web应用。因此,目标比你最开始看到的往往要更丰富。这样的情况大型组织比较常见。
Web 应用发现就是为了发现这些信息。
无论是经典类型的渗透测试还是针对应用的评估,应用发现都应该在评估执行之前进行。
除非是只针对 URL 的测试,否则,应该去找出所有的应用。下面描述一些能够完成这个目标的技术。
以下一些技术适用于面向 Internet 的 Web 服务器。
对一个给定的 DNS 域名会关联多少应用取决于下面三个因素:
1 、不同的 URL
比如一个 URL 为: www.example.com 。实际上可能有三个 URL 提供服务: http://www.example.com/url1 http://www.example.com/url2 http://www.example.com/url3 。然而,这样的 3 个 URL 都被隐藏起来了。
2 、不标准的端口
Web 应用一般使用 80 和 443 端口。事实上, web 应可能关联任意 TCP 端口,或者特定的某个端口,如端口 20000
3 、虚拟主机
DNS 允许多对一的映射。基于这种 1- 到 -N 的关系,使用虚拟主机以提供不同的服务。
我们往往不知道其他主机,如 helpdesk.example.com 和 webmail.example.com 的存在,往往只知道明显的主机 www.example.com 的存在。
解决第一点的方法
一般来说,难以完全确定非标准的 URL ,但是如果有服务器未能正确配置并基于此获得浏览目录的权限时,那就有可能获得这些非标准 URL 应用的信息。 Vulnerability scanners 扫描器能够帮助我们实现。此外,可以利用搜索引擎获得隐藏的 URL 信息。如果我们怀疑 www.example.com 这个站点有隐藏的 URL ,那么我们使用 site 命令。在返回的结果中可能有不明显的应用。再有:通过猜测。比如 https://www.example.com/webmail , https://webmail.example.com/ , 或者 https://mail.example.com/ 这样的 URL 就可能有被隐藏的非标准 URL.
解决第二点的方法:
检查非标准端口上的应用比较简单,用 nmap 就可以了。 Nmap –sV 就可以完成。
下面的例子是用 nmap 发现一个目标 192.168.1.100 上的服务。
Interesting ports on 192.168.1.100:
(The 65527 ports scanned but not shown below are in state: closed)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 3.5p1 (protocol 1.99)
80/tcp open http Apache httpd 2.0.40 ((Red Hat Linux))
443/tcp open ssl OpenSSL
901/tcp open http Samba SWAT administration server
1241/tcp open ssl Nessus security scanner
3690/tcp open unknown
8000/tcp open http-alt?
8080/tcp open http Apache Tomcat/Coyote JSP engine 1.1
- There is an Apache http server running on port 80.
- 我们可以看到一个 apache 服务器在 80 端口上
- It looks like there is an https server on port 443 (but this needs to be confirmed, for example, by visiting https://192.168.1.100 with a browser).
- 看起来有一个 https 的服务器在端口 443 上,需要进一步确认
- On port 901 there is a Samba SWAT web interface.
- 这里有一个网络硬盘的接口在 901 端口上
- The service on port 1241 is not https, but is the SSL-wrapped Nessus daemon.
- 1241 不是 https 服务,但是是 NESSUS 的守护进程
- Port 3690 features an unspecified service (nmap gives back its fingerprint - here omitted for clarity - together with instructions to submit it for incorporation in the nmap fingerprint database, provided you know which service it represents).
- 端口 3690 不知道是什么服务。 Nmap 给出了指纹,可以进一步确认。
其他未确定的服务在端口 8000 上,这个可能是 http ,我们进一步确认。
$ telnet 192.168.10.100 8000
Trying 192.168.1.100...
Connected to 192.168.1.100.
Escape character is '^]'.
GET / HTTP/1.0
HTTP/1.0 200 OK
pragma: no-cache
Content-Type: text/html
Server: MX4J-HTTPD/1.0
expires: now
Cache-Control: no-cache
<html>
...
这样就可以确认该端口上使用的是 http 服务。我们能够用 ie 访问这个 URL ,或者使用 GET 等命令。有的服务器可以使用 HEAD 命令,有的不能,比如 apache tomcat ,它运行在 8080 端口上。
使用扫描器也可以完成上述功能。不过首先要检查你的扫描器的选项是可以确定在非标准端口上的 https 、 https 。 Nessus 能够确定在任意端口上的服务,同时能够测试一些 web 服务器上的脆弱点,还有 https 服务上的 SSL 配置。
Nessus 同样能够不被注意的发现流行的应用程序 / 网络接口,比如一个 tomcat 管理接口。
解决第三点的办法:
有很多技术可以用于确定 DNS 域名和其关联的 IP 地址。
DNS 区域传输
如果一个 IP 地址能够同域名联系起来,那么它的域名服务器能够通过工具获知。如 Nslookup 。
如果不能,你需要进一步分析。
The following example shows how to identify the name servers for www.owasp.org by using the host command:
下面的示例演示如何通过使用 host 命令确定 www.owasp.org 的域名服务器
$ host -t ns www.owasp.org
www.owasp.org is an alias for owasp.org.
owasp.org name server ns1.secure.net.
owasp.org name server ns2.secure.net.
$ host -l www.owasp.org ns1.secure.net
Using domain server:
Name: ns1.secure.net
Address: 192.220.124.10#53
Aliases:
Host www.owasp.org not found: 5(REFUSED)
; Transfer failed.
DNS inverse queries DNS 反向询问
这个过程同前面相类似。但是依赖反向 DNS 记录。
Web-based DNS searches 基于 web 的 DNS 搜索
This kind of search is akin to DNS zone transfer, but relies on web-based services that enable name-based searches on DNS.
这个方法和 DNS 区域传输类似,但是依赖基于 web 的服务,这种服务允许基于域名的搜索。
这个链接提供域名查询服务。你可以询问一些域名,然后能查看你查询的域名是不是你期望的目标。
反向 IP 服务类似于 DNS 反向查询,不同之处在于你查询了一个基于 Web 的应用程序而不是一个名称服务器。 Web 上有很多这样的服务提供。由于他们往往返回部分结果,最好使用多个服务,以获得更全面的分析。
Domain tools reverse IP : http://www.domaintools.com/reverse-ip/ (requires free membership)
MSN search : http://search.msn.com syntax: "ip:x.x.x.x" (without the quotes)
Webhosting info : http://whois.webhosting.info/ syntax: http://whois.webhosting.info/x.x.x.x
DNSstuff : http://www.dnsstuff.com/ (multiple services available)
http://net-square.com/msnpawn/index.shtml (multiple queries on domains and IP addresses, requires installation)
tomDNS : http://www.tomdns.net/ (some services are still private at the time of writing)
SEOlogs.com : http://www.seologs.com/ip-domains.html (reverse-IP/domain lookup)
你可以使用搜索引擎, google 或其他来获得你发现的关于一些域名更多的信息。这个内容在 IG-001 中有提到。
工具:
- DNS lookup tools such as nslookup , dig or similar.
- Port scanners (such as nmap, http://www.insecure.org ) and vulnerability scanners (such as Nessus: http://www.nessus.org ; wikto: http://www.sensepost.com/research/wikto/ ).
- Search engines (Google, and other major engines).
- Specialized DNS-related web-based search service: see text.
- nmap - http://www.insecure.org
- Nessus Vulnerability Scanner - http://www.nessus.org