refactor: 规范本地插件编译标签和注册架构

- 为所有平台特定插件添加正确的编译标签
  - Linux插件添加 //go:build linux 标签
  - Windows插件添加 //go:build windows 标签
- 重构本地插件注册方式
  - 从main.go移至core包统一管理
  - 创建平台特定的注册文件实现条件编译
- 修正参数文档中minidump平台支持描述
- 优化插件注册架构,提升代码组织性
This commit is contained in:
ZacharyZcR 2025-08-11 21:36:14 +08:00
parent 7ca20cbebe
commit b89bf4b0da
14 changed files with 54 additions and 30 deletions

View File

@ -42,6 +42,17 @@ import (
// 导入Web插件适配器
_ "github.com/shadow1ng/fscan/plugins/legacy/webtitle"
_ "github.com/shadow1ng/fscan/plugins/legacy/webpoc"
// 导入跨平台本地插件
_ "github.com/shadow1ng/fscan/plugins/local/fileinfo" // 文件信息收集
_ "github.com/shadow1ng/fscan/plugins/local/dcinfo" // 域控信息收集
_ "github.com/shadow1ng/fscan/plugins/local/reverseshell" // 反弹Shell
_ "github.com/shadow1ng/fscan/plugins/local/socks5proxy" // SOCKS5代理
_ "github.com/shadow1ng/fscan/plugins/local/avdetect" // 杀毒软件检测
_ "github.com/shadow1ng/fscan/plugins/local/forwardshell" // 正向Shell
_ "github.com/shadow1ng/fscan/plugins/local/keylogger" // 跨平台键盘记录
_ "github.com/shadow1ng/fscan/plugins/local/downloader" // 跨平台文件下载
_ "github.com/shadow1ng/fscan/plugins/local/cleaner" // 跨平台系统痕迹清理
)
// =============================================================================

11
Core/registry_linux.go Normal file
View File

@ -0,0 +1,11 @@
//go:build linux
package core
import (
// Linux持久化插件
_ "github.com/shadow1ng/fscan/plugins/local/ldpreload" // Linux LD_PRELOAD持久化
_ "github.com/shadow1ng/fscan/plugins/local/shellenv" // Linux Shell环境变量持久化
_ "github.com/shadow1ng/fscan/plugins/local/crontask" // Linux Cron计划任务持久化
_ "github.com/shadow1ng/fscan/plugins/local/systemdservice" // Linux Systemd服务持久化
)

13
Core/registry_windows.go Normal file
View File

@ -0,0 +1,13 @@
//go:build windows
package core
import (
// Windows持久化插件
_ "github.com/shadow1ng/fscan/plugins/local/winregistry" // Windows 注册表持久化
_ "github.com/shadow1ng/fscan/plugins/local/winstartup" // Windows 启动文件夹持久化
_ "github.com/shadow1ng/fscan/plugins/local/winschtask" // Windows 计划任务持久化
_ "github.com/shadow1ng/fscan/plugins/local/winservice" // Windows 服务持久化
_ "github.com/shadow1ng/fscan/plugins/local/winwmi" // Windows WMI事件订阅持久化
_ "github.com/shadow1ng/fscan/plugins/local/minidump" // Windows 内存转储
)

View File

@ -108,7 +108,7 @@
| `avdetect` | 杀毒软件检测 | Windows/Linux/macOS |
| `fileinfo` | 文件信息收集 | Windows/Linux/macOS |
| `dcinfo` | 域控信息收集 | Windows/Linux/macOS |
| `minidump` | 内存转储 | Windows/Linux |
| `minidump` | 内存转储 | Windows |
| `reverseshell` | 反弹Shell | Windows/Linux/macOS |
| `socks5proxy` | SOCKS5代理 | Windows/Linux/macOS |
| `forwardshell` | 正向Shell | Windows/Linux/macOS |

View File

@ -1,3 +1,5 @@
//go:build linux
package crontask
import (

View File

@ -1,3 +1,5 @@
//go:build linux
package ldpreload
import (

View File

@ -1,3 +1,5 @@
//go:build linux
package shellenv
import (

View File

@ -1,3 +1,5 @@
//go:build linux
package systemdservice
import (

View File

@ -1,3 +1,5 @@
//go:build windows
package winregistry
import (

View File

@ -1,3 +1,5 @@
//go:build windows
package winschtask
import (

View File

@ -1,3 +1,5 @@
//go:build windows
package winservice
import (

View File

@ -1,3 +1,5 @@
//go:build windows
package winstartup
import (

View File

@ -1,3 +1,5 @@
//go:build windows
package winwmi
import (

29
main.go
View File

@ -8,35 +8,6 @@ import (
"github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/core"
"github.com/shadow1ng/fscan/plugins/base"
// 引入本地插件以触发注册
_ "github.com/shadow1ng/fscan/plugins/local/fileinfo" // 已重构,可用
_ "github.com/shadow1ng/fscan/plugins/local/dcinfo" // 已重构,可用
_ "github.com/shadow1ng/fscan/plugins/local/minidump" // 已重构,可用
_ "github.com/shadow1ng/fscan/plugins/local/reverseshell" // 已重构,可用
_ "github.com/shadow1ng/fscan/plugins/local/socks5proxy" // 已重构,可用
_ "github.com/shadow1ng/fscan/plugins/local/avdetect" // 已重构,可用
_ "github.com/shadow1ng/fscan/plugins/local/forwardshell" // 新增,可用
// Linux持久化插件
_ "github.com/shadow1ng/fscan/plugins/local/ldpreload" // Linux LD_PRELOAD持久化
_ "github.com/shadow1ng/fscan/plugins/local/shellenv" // Linux Shell环境变量持久化
_ "github.com/shadow1ng/fscan/plugins/local/crontask" // Linux Cron计划任务持久化
_ "github.com/shadow1ng/fscan/plugins/local/systemdservice" // Linux Systemd服务持久化
// Windows持久化插件
_ "github.com/shadow1ng/fscan/plugins/local/winregistry" // Windows 注册表持久化
_ "github.com/shadow1ng/fscan/plugins/local/winstartup" // Windows 启动文件夹持久化
_ "github.com/shadow1ng/fscan/plugins/local/winschtask" // Windows 计划任务持久化
_ "github.com/shadow1ng/fscan/plugins/local/winservice" // Windows 服务持久化
_ "github.com/shadow1ng/fscan/plugins/local/winwmi" // Windows WMI事件订阅持久化
// 监控插件
_ "github.com/shadow1ng/fscan/plugins/local/keylogger" // 跨平台键盘记录
// 实用工具插件
_ "github.com/shadow1ng/fscan/plugins/local/downloader" // 跨平台文件下载
_ "github.com/shadow1ng/fscan/plugins/local/cleaner" // 跨平台系统痕迹清理
)
// initLocalPlugins 初始化本地插件列表