mirror of
https://github.com/shadow1ng/fscan.git
synced 2025-09-14 14:06:44 +08:00

- 删除整个legacy插件系统(7794行代码) - 完成所有插件向单文件架构迁移 - 移除19个插件的虚假Exploit功能,只保留真实利用: * Redis: 文件写入、SSH密钥注入、计划任务 * SSH: 命令执行 * MS17010: EternalBlue漏洞利用 - 统一插件接口,简化架构复杂度 - 清理临时文件和备份文件 重构效果: - 代码行数: -7794行 - 插件文件数: 从3文件架构→单文件架构 - 真实利用插件: 从22个→3个 - 架构复杂度: 大幅简化
47 lines
965 B
Bash
47 lines
965 B
Bash
#!/bin/bash
|
|
cd plugins/services
|
|
|
|
# 使用awk清理Exploit函数的通用方法
|
|
clean_exploit() {
|
|
local file=$1
|
|
echo "Cleaning $file..."
|
|
|
|
awk '
|
|
BEGIN {
|
|
skip = 0
|
|
brace_count = 0
|
|
}
|
|
|
|
# 检测Exploit函数开始
|
|
/^func.*Exploit\(/ {
|
|
skip = 1
|
|
brace_count = 0
|
|
next
|
|
}
|
|
|
|
# 在跳过模式下计算花括号
|
|
skip {
|
|
brace_count += gsub(/\{/, "&")
|
|
brace_count -= gsub(/\}/, "&")
|
|
|
|
if (brace_count <= 0 && /\}/) {
|
|
skip = 0
|
|
next
|
|
}
|
|
}
|
|
|
|
# 输出非跳过的行
|
|
!skip { print }
|
|
' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
|
|
|
|
echo "✓ $file cleaned"
|
|
}
|
|
|
|
# 清理简单的服务插件
|
|
for file in ftp.go kafka.go ldap.go rabbitmq.go netbios.go rdp.go smtp.go snmp.go telnet.go vnc.go; do
|
|
if [ -f "$file" ]; then
|
|
clean_exploit "$file"
|
|
fi
|
|
done
|
|
|
|
echo "Batch cleaning completed!" |