fscan/clean_exploits.sh
ZacharyZcR 6cf5719e8a refactor: 彻底清理插件系统,消除虚假利用功能
- 删除整个legacy插件系统(7794行代码)
- 完成所有插件向单文件架构迁移
- 移除19个插件的虚假Exploit功能,只保留真实利用:
  * Redis: 文件写入、SSH密钥注入、计划任务
  * SSH: 命令执行
  * MS17010: EternalBlue漏洞利用
- 统一插件接口,简化架构复杂度
- 清理临时文件和备份文件

重构效果:
- 代码行数: -7794行
- 插件文件数: 从3文件架构→单文件架构
- 真实利用插件: 从22个→3个
- 架构复杂度: 大幅简化
2025-08-26 11:43:48 +08:00

53 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 进入services目录
cd plugins/services
# 需要清理exploit的文件列表保留ssh, redis, ms17010的exploit
FILES_TO_CLEAN="elasticsearch.go findnet.go ftp.go kafka.go ldap.go mongodb.go mssql.go neo4j.go netbios.go oracle.go postgresql.go rabbitmq.go rdp.go rsync.go smb.go smb2.go smbghost.go smbinfo.go smtp.go snmp.go telnet.go vnc.go webpoc.go webtitle.go"
for file in $FILES_TO_CLEAN; do
if [ -f "$file" ]; then
echo "Cleaning $file..."
# 备份文件
cp "$file" "${file}.backup"
# 使用awk删除Exploit函数
awk '
BEGIN { skip = 0; brace_count = 0; }
/^\/\/ Exploit.*利用操作/ {
skip = 1;
brace_count = 0;
next;
}
/^func.*Exploit\(/ {
if (!skip) {
skip = 1;
brace_count = 0;
}
next;
}
skip && /\{/ {
brace_count += gsub(/\{/, "");
brace_count -= gsub(/\}/, "");
if (brace_count <= 0 && /\}/) {
skip = 0;
next;
}
}
skip && /\}/ {
brace_count -= gsub(/\}/, "");
brace_count += gsub(/\{/, "");
if (brace_count <= 0) {
skip = 0;
next;
}
}
!skip { print; }
' "${file}.backup" > "$file"
echo "✅ Cleaned $file"
fi
done
echo "✅ All exploit functions cleaned!"