57

绕过 CDN 寻找真实 IP 地址的各种姿势

 4 years ago
source link: https://www.tuicool.com/articles/IBfiMj3
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

本文作者: Patrilic (信安之路红蓝对抗小组成员 & 首次投稿)

成员招募: 信安之路红蓝对抗小组招募志同道合的朋友

加入任意兴趣小组,成员文章由组长审核通过之后即可发布到信安之路公众号,获得相应的奖励(知识星球等)

个人觉得,绕过 CDN 去寻找主机的真实 ip,更容易能寻找到企业网络的薄弱地带,所以 Bypass CDN 也就变成了至关重要的一点。

0x01 常见 Bypass 方法

域名搜集

由于成本问题,可能某些厂商并不会将所有的子域名都部署 CDN,所以如果我们能尽量的搜集子域名,或许可以找到一些没有部署 CDN 的子域名,拿到某些服务器的真实 ip/ 段

然后关于子域名搜集的方式很多,就不一一介绍了,我平时主要是从这几个方面搜集子域名:

1、SSL 证书

2、爆破

3、Google Hacking

4、同邮箱注册人

4、DNS 域传送

5、页面 JS 搜集

6、网络空间引擎

工具也有很多厉害的,平时我一般使用 OneForALL + ESD + JSfinder 来进行搜集,(ESD 可以加载 layer 的字典,很好用)

查询 DNS 历史解析记录

常常服务器在解析到 CDN 服务前,会解析真实 ip,如果历史未删除,就可能找到

Af2uUrV.jpg!web

常用网站:

http://viewdns.info/
https://x.threatbook.cn/
http://www.17ce.com/
https://dnsdb.io/zh-cn/
https://securitytrails.com/
http://www.ip138.com/
https://github.com/vincentcox/bypass-firewalls-by-DNS-history

MX 记录(邮件探测)

这个很简单,如果目标系统有发件功能,通常在注册用户/找回密码等地方

6FnYvyf.jpg!web

SSL 证书探测

我们可以利用空间引擎进行 SSL 证书探测

443.https.tls.certificate.parsed.extensions.subject_alt_name.dns_names:www.baidu.com

M3ENVvy.jpg!web

再放一个搜集证书的网站:

https://crt.sh

一个小脚本,可以快速搜集证书

# -*- coding: utf-8 -*-

# @Time : 2019-10-08 22:51

# @Author : Patrilic

# @FileName: SSL_subdomain.py

# @Software: PyCharm


import requests

import re


TIME_OUT = 60

def get_SSL(domain):

domains = []

url = 'https://crt.sh/?q=%25.{}'.format(domain)

response = requests.get(url,timeout=TIME_OUT)

# print(response.text)

ssl = re.findall("<TD>(.*?).{}</TD>".format(domain),response.text)

for i in ssl:

i += '.' + domain

domains.append(i)

print(domains)


if __name__ == '__main__':

get_SSL("baidu.com")

还有一种方式,就是搜集 SSL 证书 Hash,然后遍历 ip 去查询证书 hash,如果匹配到相同的,证明这个 ip 就是那个 域名同根证书的服务器真实 ip

简单来说,就是遍历 0.0.0.0/0:443,通过 ip 连接 https 时,会显示证书

当然,也可以用 censys 等引擎

yUrEzmb.jpg!web

偏远地区服务器访问

在偏远地区的服务器访问时,可能不会访问到 CDN 节点,而是直接访问服务器真实 ip

所以我们可以搞一个偏远地区的代理池,来访问目标域名,有概率就可以拿到真实 ip

也就是平常说的多地 Ping

vi2UNbu.jpg!web

favicon_hash 匹配

利用 shodan 的  http.favicon.hash  语法,来匹配 icon 的 hash 值, 直接推:

https://github.com/Ridter/get_ip_by_ico/blob/master/get_ip_by_ico.py

CloudFlare Bypass

免费版的 cf,我们可以通过 DDOS 来消耗对方的流量,只需要把流量打光,就会回滚到原始 ip

还有利用 cloudflare 的改 host 返回示例:

https://blog.detectify.com/2019/07/31/bypassing-cloudflare-waf-with-the-origin-server-ip-address/

里面给了详细的介绍,我们可以通过 HOST 来判断是否是真实 ip, 具体看文章即可

奇特的 ping

比如可能有些地方,使用的 CDN 都是以  www.xxx.edu.cn ,例如  www.cuit.edu.cn,www.jwc.cuit.edu.cn

可能去掉前缀的 www,就可能绕过 CDN 了,猜测应该是类似于 Apache VirtualHost, 可参考

https://httpd.apache.org/docs/2.4/en/vhosts/examples.html

例如:

ZBJzi2J.jpg!web

我这里其实是 ping 了  www.xxx.xxx.cn  和 xxx.xxx.cn

这样就可以绕过 CDN 的检测

利用老域名

在换新域名时,常常将 CDN 部署到新的域名上,而老域名由于没过期,可能未使用 CDN,然后就可以直接获取服务器真实 ip。

例如 patrilic.top > patrilic.com

域名更新时,可能老域名同时解析到真实服务器,但是没有部署 CDN

这个可以通过搜集域名备案的邮箱去反查,可能会有意外收获

暴力匹配

找到目标服务器 IP 段后,可以直接进行暴力匹配 ,使用 masscan 扫描 HTTP banner,然后匹配到目标域名的相同 banner

最后是 DDos/ 社工 CDN 平台等

0x02 其他方法

phpinfo

I7ZZzeA.jpg!web

ssrf,文件上传等漏洞

略..

0x03 参考链接

https://github.com/shmilylty/OneForAll
https://github.com/FeeiCN/ESD
https://github.com/Threezh1/JSFinder
https://github.com/AI0TSec/blog/issues/8
https://www.4hou.com/tools/8251.html
https://www.freebuf.com/sectool/112583.html

iMr6bi7.jpg!web


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK