问答
发起
提问
文章
攻防
活动
Toggle navigation
首页
(current)
问答
商城
实战攻防技术
漏洞分析与复现
NEW
活动
摸鱼办
搜索
登录
注册
【由浅入深_打牢基础】HOST头攻击
渗透测试
【由浅入深_打牢基础】HOST头攻击
0x00 前言 ------- 前几天一直准备别的事情,然后用了2/3天时间去挖了补天某厂的SRC,还是太菜了,最后提交了一个低危(还没出结果,还有点敏感信息泄露,感觉略鸡肋也没交),不过偶然发现之前提的一个公益SRC被收了(当时快半个月都没人处理)不过没money,等过几天有时间再看吧,还是得虚心学技术,慢慢的进步。 0x01 HOST头的作用 ============= 1.1 文字原理讲解 ---------- 首先我们需要了解一个概念叫`虚拟主机`,也就是一台服务器上存在多个网站。你会想这还不简单,每个站点分一个端口即可,但是我说的是一个端口。 既然如此,那么我们不管它是怎么实现的,我们要关注的是为什么如此,为什么我们访问这些网站均是正常的呢?这就是HOST头的作用了,当我们去访问一个url的时候,这个域名只会被DNS解析为IP,但是因为这些虚拟主机的IP是同一个,所以会看我们的HOST头,它的值是谁,那么服务器就去交给那个站去响应。(如下图)  1.2 实际演示 -------- 我这里用`小皮面板`再来演示一下它的奇妙之处,首先我先创建两个站点,分别是pikachu和dvwa,配置如下图。   可以看到,这时候我给它们不同的域名,而且端口均为本机的80,好,接下来我去访问。   两个站点没有任何问题,紧接着我重新访问dvwa并抓包  再来看一下页面  OK相信到这里就了解了,HOST头的作用了,接下来,围绕着Burp Suite官方实验室,演示下会发生的安全问题 - - - - - - 0x02 漏洞利用 ========= 2.1 基本密码重置中毒 ------------ **要求如下:**  我们需要登录到Carlos才可以完成,登录时点击忘记密码  可以看到是根据我们的账户名或邮箱地址,发一封重置密码的邮件给我们  我们先用自己的账户,也就是wiener来试试,ok,点击后去漏洞利用服务器试试  往下翻有个Email client,点进去查看刚刚的邮件内容  看到有个修改密码连接,ok,我们打开它,并随便修改成123   接下来我们去Burp看下刚刚的数据包,如下,可以看到里面存在一个`temp-forgot-password-token`值,所以我们现在需要搞到它。 POST /forgot-password?temp-forgot-password-token=F7vqHnRQVDFVZwEfG8CjqPOx4gwgMGr2 HTTP/1.1 Host: ac3d1fxxxxxx060.web-security-academy.net Cookie: \_lab=46%7cMasdCwCFAiRGPkiVdxxxNhS8mYDOMvkk3CWJakAhR0wUzpasdGqNbbKzMESDTwqnN4%2bmfnDv415Yp1OeYCQWOHaYTqDhOeWLYsbDczuZvkT8kfY2yqQxeqN9CdAsyGMC7FUxTGUuUMjnXEJlyJaZ1ArCyi5xbmznovOWg2psOzMjkzQnGNekasdzgthyY%3d; session=jcqZVUOp3gtGaRpFeBD7r577ERV38AkV7 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:101.0) Gecko/20100101 Firefox/101.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,\*/\*;q=0.8 Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2 Accept-Encoding: gzip, deflate Content-Type: application/x-www-form-urlencoded Content-Length: 135 Upgrade-Insecure-Requests: 1 Sec-Fetch-Dest: document Sec-Fetch-Mode: navigate Sec-Fetch-Site: same-origin Sec-Fetch-User: ?1 Te: trailers Connection: close csrf=KmpFXtDQMQuzxEkE0t8LRYxfT698ibN1&temp-forgot-password-token=F7vqHnRQVDFVZwEfG8CjqPOx4gwgMGr2&new-password-1=123&new-password-2=123 接下来我的猜想就来了,既然我们知道漏洞肯定跟HOST头注入有关,那么我猜我们刚刚点击忘记密码,发包的时候肯定是抓不到这个token的,而是网站后端服务器发送到我们的邮箱,但是这个时候如果我们将HOST头改成我们自己利用服务器,那么流量会不会就会到我们这里,然后根据这个token值构造重置密码链接,ok,说干就干。  紧接着去我们漏洞利用服务器查一下token  构造重置密码链接,直接将我们重置密码的包里面的`csrf` (值在上上个图中)和`temp-forgot-password-token`值改成对应的,然后成功了  - - - - - - 2.2 主机标头身份验证绕过 -------------- **要求如下:**  既然要进入管理面板,那么首先我们应该找到路径,随手加一个admin,演示仅对本地用户可用  一般我们搭建靶场用的最多的就是localhost,同理这里将HOST头改为localhost  直接删除,同样还得抓包改HOST  - - - - - - 2.3 通过模糊请求导致 Web 缓存中毒 --------------------- **要求如下:**  **利用过程:** 这个我盲猜可能就就是web缓存投毒并且非缓存建是HOST,相信看到我之前那篇文章的兄弟一下就懂了,就是web缓存投毒,投到HOST键上 首先刷新一下观察历史包,发现加载了两个js  存在缓存机制  那我现在漏洞利用服务器构造一下js文件  ok,改一下HOST,投毒吧  改了发现不可以,那么也就不能在原来基础上修改,那就尝试在原来基础上增加,双写HOST  可以看到加载我们利用服务器的js了,这个时候正常如何访问就会中毒了  - - - - - - 2.4 基于路由的 SSRF -------------- **要求如下:**  **利用过程:** 首先这里提示了,必须使用`Burp Collaborator`来进行测试,如果不知道它是什么,可以百度,我暂时没找到好文章,后续打算就其使用写个帖子,这里先简单理解成dnslog就好了,数据由Burp->靶机,靶机响应到`Burp Collaborator`再到Burp,也就是说它的内网靶机不会出网,除非是Burp自带`Burp Collaborator`地址,所以我们需要配置一下 点击`Burp`->`Burp Collaborator client`出现下图界面,点击`Copy to clipboard`来获取一个随机地址  然后可以在`Project options`里面查看一下,我们这里使用默认的Collaborator的server就好  尝试SSRF漏洞,将访问实验室主页的包的HOST头改成我们的`Collaborator server`地址,然后发包,然后就可以看到`Collaborator server`存在流量,然后就可以关掉Collaborator了  证明存在SSRF漏洞,可通过HOST值访问内部敏感系统,但是不知道IP,所以直接爆破,如下图设置  别忘了关掉自动更新Header功能  Payload设置如下  这里因为没特殊字符,所以paylaod Encoding勾不勾没关系,直接爆破,130被爆破成功  然后我们访问主页并抓包将HOST改成192.168.0.130然后放出去,同样的删除用户的这个POST包也需要将HOST改为192.168.0.130  成功了  - - - - - - 2.5 SSRF 通过有缺陷的请求解析 ------------------- **要求:**  **利用过程:** 这题拿到手很懵圈,感觉跟上一个一样,于是按照上一个的做法将HOST先改成`Collaborator Server`的地址,发现返回403,并且`Collaborator Server`无解析  既然如此,再看一下要求,`基于路由的`这几个大字出现在眼前的时候,就应该意识到是路由地址的问题,于是尝试将GET / 改成绝对的  非常nice,然后就跟上边一样了,爆破,251  删除用户,像下边这样改包(请求admin目录的和删除用户的都类似)  成功
发表于 2022-06-23 10:06:34
阅读 ( 6356 )
分类:
漏洞分析
2 推荐
收藏
0 条评论
请先
登录
后评论
小惜渗透
7 篇文章
×
发送私信
请先
登录
后发送私信
×
举报此文章
垃圾广告信息:
广告、推广、测试等内容
违规内容:
色情、暴力、血腥、敏感信息等内容
不友善内容:
人身攻击、挑衅辱骂、恶意行为
其他原因:
请补充说明
举报原因:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!