refactor: 优化插件系统设计,消除代码重复

主要改进:
1. 修复Services插件端口数据重复问题
   - 删除插件结构体中的ports字段和GetPorts()方法
   - 系统统一使用注册时的端口信息

2. 引入BasePlugin基础结构体
   - 消除51个插件中重复的name字段和Name()方法
   - 统一插件基础功能,简化代码维护

3. 统一插件接口设计
   - 保持向后兼容,功能完全不变
   - 代码更简洁,符合工程最佳实践

影响范围:
- services插件:29个文件简化
- web插件:2个文件简化
- local插件:21个文件简化
- 总计删除约150行重复代码
This commit is contained in:
ZacharyZcR 2025-09-02 05:36:12 +08:00
parent 8f54702c02
commit 95497da8ca
58 changed files with 174 additions and 695 deletions

View File

@ -1,75 +0,0 @@
#!/usr/bin/env python3
import re
import os
# 需要清理的文件保留ssh.go redis.go ms17010.go
FILES_TO_CLEAN = [
'elasticsearch.go', 'findnet.go', 'ftp.go', 'kafka.go',
'ldap.go', 'netbios.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'
]
def clean_exploit_function(file_path):
"""清理单个文件的Exploit函数"""
with open(file_path, 'r', encoding='utf-8') as f:
content = f.read()
# 使用正则表达式匹配并删除Exploit函数
# 匹配从 "// Exploit" 注释开始到函数结束的整个块
pattern = r'\/\/\s*Exploit.*?利用操作.*?\nfunc\s+\([^)]*\)\s+Exploit\([^{]*\{[^}]*(?:\{[^}]*\}[^}]*)*\}\n'
# 简化方法:按行处理
lines = content.split('\n')
output_lines = []
skip_mode = False
brace_count = 0
i = 0
while i < len(lines):
line = lines[i]
# 检测Exploit函数开始
if ('// Exploit' in line and '利用操作' in line) or ('func ' in line and 'Exploit(' in line):
skip_mode = True
brace_count = 0
if 'func ' in line and '{' in line:
brace_count = line.count('{') - line.count('}')
i += 1
continue
if skip_mode:
# 计算花括号
brace_count += line.count('{')
brace_count -= line.count('}')
# 如果花括号归零,函数结束
if brace_count <= 0:
skip_mode = False
i += 1
continue
output_lines.append(line)
i += 1
# 写回文件
with open(file_path, 'w', encoding='utf-8') as f:
f.write('\n'.join(output_lines))
def main():
os.chdir('plugins/services')
for filename in FILES_TO_CLEAN:
if os.path.exists(filename):
print(f"Cleaning {filename}...")
try:
clean_exploit_function(filename)
print(f"{filename}")
except Exception as e:
print(f"{filename}: {e}")
else:
print(f"⚠️ {filename} not found")
if __name__ == "__main__":
main()

View File

@ -1,53 +0,0 @@
#!/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!"

View File

@ -1,79 +0,0 @@
#!/usr/bin/env python3
import os
import re
# 保留exploit的插件真正有利用价值的
KEEP_EXPLOITS = ['ssh.go', 'redis.go', 'ms17010.go']
# 需要清理exploit的插件目录
PLUGINS_DIR = 'plugins/services'
def remove_exploit_function(content, filename):
"""移除Exploit函数及其相关方法"""
print(f"Processing {filename}")
# 匹配并删除Exploit函数
exploit_pattern = r'// Exploit.*?\nfunc \([^)]+\) Exploit\([^{]*\{(?:[^{}]++|\{(?:[^{}]++|\{[^{}]*\})*\})*\}\n'
content = re.sub(exploit_pattern, '', content, flags=re.MULTILINE | re.DOTALL)
# 简化一点,匹配函数定义到下一个函数定义
lines = content.split('\n')
output_lines = []
skip_lines = False
brace_count = 0
for line in lines:
# 检查是否是Exploit函数的开始
if 'func ' in line and 'Exploit(' in line:
skip_lines = True
brace_count = 0
continue
if skip_lines:
# 计算花括号
brace_count += line.count('{')
brace_count -= line.count('}')
# 如果花括号平衡且不在函数内,停止跳过
if brace_count <= 0 and '}' in line:
skip_lines = False
continue
if not skip_lines:
output_lines.append(line)
return '\n'.join(output_lines)
def main():
if not os.path.exists(PLUGINS_DIR):
print(f"Directory {PLUGINS_DIR} not found")
return
for filename in os.listdir(PLUGINS_DIR):
if not filename.endswith('.go') or filename in KEEP_EXPLOITS or filename == 'init.go':
continue
filepath = os.path.join(PLUGINS_DIR, filename)
try:
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
# 检查是否有Exploit函数
if 'func ' in content and 'Exploit(' in content:
# 移除Exploit函数
new_content = remove_exploit_function(content, filename)
# 写回文件
with open(filepath, 'w', encoding='utf-8') as f:
f.write(new_content)
print(f"✅ Cleaned {filename}")
else:
print(f"⏭️ Skipped {filename} (no Exploit function)")
except Exception as e:
print(f"❌ Error processing {filename}: {e}")
if __name__ == "__main__":
main()

View File

@ -10,7 +10,7 @@ import (
// Plugin 统一插件接口 - 消除过度设计 // Plugin 统一插件接口 - 消除过度设计
// //
// Linus哲学"好代码没有特殊情况" // 统一插件系统设计原则:
// 之前3个不同的接口做同样的事情 // 之前3个不同的接口做同样的事情
// 现在1个接口统治所有插件 // 现在1个接口统治所有插件
type Plugin interface { type Plugin interface {
@ -18,6 +18,23 @@ type Plugin interface {
Scan(ctx context.Context, info *common.HostInfo) *Result Scan(ctx context.Context, info *common.HostInfo) *Result
} }
// BasePlugin 基础插件结构 - 消除插件name字段重复
//
// 所有插件都需要name字段通过基础结构体统一提供
type BasePlugin struct {
name string
}
// NewBasePlugin 创建基础插件
func NewBasePlugin(name string) BasePlugin {
return BasePlugin{name: name}
}
// Name 实现Plugin接口
func (b BasePlugin) Name() string {
return b.name
}
// Result 统一结果结构 - 合并所有类型 // Result 统一结果结构 - 合并所有类型
type Result struct { type Result struct {
Success bool Success bool

View File

@ -10,6 +10,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
//go:embed auto.json //go:embed auto.json
@ -28,14 +29,14 @@ type AVProduct struct {
// - 删除复杂的结果结构体 // - 删除复杂的结果结构体
// - 跨平台支持,运行时适配 // - 跨平台支持,运行时适配
type AVDetectPlugin struct { type AVDetectPlugin struct {
name string plugins.BasePlugin
avProducts map[string]AVProduct avProducts map[string]AVProduct
} }
// NewAVDetectPlugin 创建AV检测插件 // NewAVDetectPlugin 创建AV检测插件
func NewAVDetectPlugin() *AVDetectPlugin { func NewAVDetectPlugin() *AVDetectPlugin {
plugin := &AVDetectPlugin{ plugin := &AVDetectPlugin{
name: "avdetect", BasePlugin: plugins.NewBasePlugin("avdetect"),
avProducts: make(map[string]AVProduct), avProducts: make(map[string]AVProduct),
} }
@ -49,10 +50,6 @@ func NewAVDetectPlugin() *AVDetectPlugin {
return plugin return plugin
} }
// GetName 实现Plugin接口
func (p *AVDetectPlugin) Name() string {
return p.name
}
// Scan 执行AV/EDR检测 - 直接、有效 // Scan 执行AV/EDR检测 - 直接、有效

View File

@ -9,6 +9,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// CleanerPlugin 系统痕迹清理插件 - Linus式简化版本 // CleanerPlugin 系统痕迹清理插件 - Linus式简化版本
@ -18,20 +19,16 @@ import (
// - 直接实现清理功能 // - 直接实现清理功能
// - 消除不必要的统计和报告结构 // - 消除不必要的统计和报告结构
type CleanerPlugin struct { type CleanerPlugin struct {
name string plugins.BasePlugin
} }
// NewCleanerPlugin 创建系统痕迹清理插件 // NewCleanerPlugin 创建系统痕迹清理插件
func NewCleanerPlugin() *CleanerPlugin { func NewCleanerPlugin() *CleanerPlugin {
return &CleanerPlugin{ return &CleanerPlugin{
name: "cleaner", BasePlugin: plugins.NewBasePlugin("cleaner"),
} }
} }
// GetName 实现Plugin接口
func (p *CleanerPlugin) Name() string {
return p.name
}
// Scan 执行系统痕迹清理 - 直接、简单 // Scan 执行系统痕迹清理 - 直接、简单

View File

@ -13,6 +13,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// CronTaskPlugin 计划任务持久化插件 - Linus式简化版本 // CronTaskPlugin 计划任务持久化插件 - Linus式简化版本
@ -22,7 +23,7 @@ import (
// - 直接实现持久化功能 // - 直接实现持久化功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type CronTaskPlugin struct { type CronTaskPlugin struct {
name string plugins.BasePlugin
targetFile string targetFile string
} }
@ -34,15 +35,11 @@ func NewCronTaskPlugin() *CronTaskPlugin {
} }
return &CronTaskPlugin{ return &CronTaskPlugin{
name: "crontask", BasePlugin: plugins.NewBasePlugin("crontask"),
targetFile: targetFile, targetFile: targetFile,
} }
} }
// GetName 实现Plugin接口
func (p *CronTaskPlugin) Name() string {
return p.name
}
// Scan 执行计划任务持久化 - 直接实现 // Scan 执行计划任务持久化 - 直接实现

View File

@ -12,6 +12,7 @@ import (
"github.com/go-ldap/ldap/v3" "github.com/go-ldap/ldap/v3"
"github.com/go-ldap/ldap/v3/gssapi" "github.com/go-ldap/ldap/v3/gssapi"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// DCInfoPlugin 域控信息收集插件 - Linus式简化版本 // DCInfoPlugin 域控信息收集插件 - Linus式简化版本
@ -21,7 +22,7 @@ import (
// - 直接实现域信息收集功能 // - 直接实现域信息收集功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type DCInfoPlugin struct { type DCInfoPlugin struct {
name string plugins.BasePlugin
} }
// DomainInfo 域信息结构 // DomainInfo 域信息结构
@ -34,14 +35,10 @@ type DomainInfo struct {
// NewDCInfoPlugin 创建域控信息收集插件 // NewDCInfoPlugin 创建域控信息收集插件
func NewDCInfoPlugin() *DCInfoPlugin { func NewDCInfoPlugin() *DCInfoPlugin {
return &DCInfoPlugin{ return &DCInfoPlugin{
name: "dcinfo", BasePlugin: plugins.NewBasePlugin("dcinfo"),
} }
} }
// GetName 实现Plugin接口
func (p *DCInfoPlugin) Name() string {
return p.name
}
// Scan 执行域控信息收集 - 直接实现 // Scan 执行域控信息收集 - 直接实现

View File

@ -12,6 +12,7 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// DownloaderPlugin 文件下载插件 - Linus式简化版本 // DownloaderPlugin 文件下载插件 - Linus式简化版本
@ -21,7 +22,7 @@ import (
// - 直接实现文件下载功能 // - 直接实现文件下载功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type DownloaderPlugin struct { type DownloaderPlugin struct {
name string plugins.BasePlugin
downloadURL string downloadURL string
savePath string savePath string
downloadTimeout time.Duration downloadTimeout time.Duration
@ -31,7 +32,7 @@ type DownloaderPlugin struct {
// NewDownloaderPlugin 创建文件下载插件 // NewDownloaderPlugin 创建文件下载插件
func NewDownloaderPlugin() *DownloaderPlugin { func NewDownloaderPlugin() *DownloaderPlugin {
return &DownloaderPlugin{ return &DownloaderPlugin{
name: "downloader", BasePlugin: plugins.NewBasePlugin("downloader"),
downloadURL: common.DownloadURL, downloadURL: common.DownloadURL,
savePath: common.DownloadSavePath, savePath: common.DownloadSavePath,
downloadTimeout: 30 * time.Second, downloadTimeout: 30 * time.Second,
@ -39,10 +40,6 @@ func NewDownloaderPlugin() *DownloaderPlugin {
} }
} }
// GetName 实现Plugin接口
func (p *DownloaderPlugin) Name() string {
return p.name
}
// Scan 执行文件下载任务 - 直接实现 // Scan 执行文件下载任务 - 直接实现

View File

@ -8,6 +8,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// EnvInfoPlugin 环境变量信息收集插件 - Linus式简化版本 // EnvInfoPlugin 环境变量信息收集插件 - Linus式简化版本
@ -17,20 +18,16 @@ import (
// - 过滤敏感信息关键词 // - 过滤敏感信息关键词
// - 简单有效的实现 // - 简单有效的实现
type EnvInfoPlugin struct { type EnvInfoPlugin struct {
name string plugins.BasePlugin
} }
// NewEnvInfoPlugin 创建环境变量信息插件 // NewEnvInfoPlugin 创建环境变量信息插件
func NewEnvInfoPlugin() *EnvInfoPlugin { func NewEnvInfoPlugin() *EnvInfoPlugin {
return &EnvInfoPlugin{ return &EnvInfoPlugin{
name: "envinfo", BasePlugin: plugins.NewBasePlugin("envinfo"),
} }
} }
// GetName 实现Plugin接口
func (p *EnvInfoPlugin) Name() string {
return p.name
}
// Scan 执行环境变量收集 - 直接、有效 // Scan 执行环境变量收集 - 直接、有效

View File

@ -9,6 +9,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// FileInfoPlugin 文件信息收集插件 - Linus式简化版本 // FileInfoPlugin 文件信息收集插件 - Linus式简化版本
@ -19,20 +20,16 @@ import (
// - 没有平台检查(运行时错误更清晰) // - 没有平台检查(运行时错误更清晰)
// - 没有复杂配置(直接硬编码关键路径) // - 没有复杂配置(直接硬编码关键路径)
type FileInfoPlugin struct { type FileInfoPlugin struct {
name string plugins.BasePlugin
} }
// NewFileInfoPlugin 创建文件信息插件 // NewFileInfoPlugin 创建文件信息插件
func NewFileInfoPlugin() *FileInfoPlugin { func NewFileInfoPlugin() *FileInfoPlugin {
return &FileInfoPlugin{ return &FileInfoPlugin{
name: "fileinfo", BasePlugin: plugins.NewBasePlugin("fileinfo"),
} }
} }
// GetName 实现Plugin接口
func (p *FileInfoPlugin) Name() string {
return p.name
}
// Scan 执行本地文件扫描 - 直接、简单、有效 // Scan 执行本地文件扫描 - 直接、简单、有效

View File

@ -12,6 +12,7 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// ForwardShellPlugin 正向Shell插件 - Linus式简化版本 // ForwardShellPlugin 正向Shell插件 - Linus式简化版本
@ -21,7 +22,7 @@ import (
// - 直接实现Shell服务功能 // - 直接实现Shell服务功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type ForwardShellPlugin struct { type ForwardShellPlugin struct {
name string plugins.BasePlugin
port int port int
listener net.Listener listener net.Listener
} }
@ -34,15 +35,11 @@ func NewForwardShellPlugin() *ForwardShellPlugin {
} }
return &ForwardShellPlugin{ return &ForwardShellPlugin{
name: "forwardshell", BasePlugin: plugins.NewBasePlugin("forwardshell"),
port: port, port: port,
} }
} }
// GetName 实现Plugin接口
func (p *ForwardShellPlugin) Name() string {
return p.name
}
// Scan 执行正向Shell服务 - 直接实现 // Scan 执行正向Shell服务 - 直接实现

View File

@ -10,6 +10,7 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// KeyloggerPlugin 键盘记录插件 - Linus式简化版本 // KeyloggerPlugin 键盘记录插件 - Linus式简化版本
@ -19,7 +20,7 @@ import (
// - 直接实现键盘记录功能 // - 直接实现键盘记录功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type KeyloggerPlugin struct { type KeyloggerPlugin struct {
name string plugins.BasePlugin
outputFile string outputFile string
isRunning bool isRunning bool
stopChan chan struct{} stopChan chan struct{}
@ -35,17 +36,13 @@ func NewKeyloggerPlugin() *KeyloggerPlugin {
} }
return &KeyloggerPlugin{ return &KeyloggerPlugin{
name: "keylogger", BasePlugin: plugins.NewBasePlugin("keylogger"),
outputFile: outputFile, outputFile: outputFile,
stopChan: make(chan struct{}), stopChan: make(chan struct{}),
keyBuffer: make([]string, 0), keyBuffer: make([]string, 0),
} }
} }
// GetName 实现Plugin接口
func (p *KeyloggerPlugin) Name() string {
return p.name
}
// Scan 执行键盘记录 - 直接实现 // Scan 执行键盘记录 - 直接实现

View File

@ -12,6 +12,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// LDPreloadPlugin LD_PRELOAD持久化插件 - Linus式简化版本 // LDPreloadPlugin LD_PRELOAD持久化插件 - Linus式简化版本
@ -21,7 +22,7 @@ import (
// - 直接实现持久化功能 // - 直接实现持久化功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type LDPreloadPlugin struct { type LDPreloadPlugin struct {
name string plugins.BasePlugin
targetFile string targetFile string
} }
@ -33,15 +34,11 @@ func NewLDPreloadPlugin() *LDPreloadPlugin {
} }
return &LDPreloadPlugin{ return &LDPreloadPlugin{
name: "ldpreload", BasePlugin: plugins.NewBasePlugin("ldpreload"),
targetFile: targetFile, targetFile: targetFile,
} }
} }
// GetName 实现Plugin接口
func (p *LDPreloadPlugin) Name() string {
return p.name
}
// Scan 执行LD_PRELOAD持久化 - 直接实现 // Scan 执行LD_PRELOAD持久化 - 直接实现

View File

@ -16,6 +16,7 @@ import (
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
const ( const (
@ -61,7 +62,7 @@ type TOKEN_PRIVILEGES struct {
// - 直接实现内存转储功能 // - 直接实现内存转储功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type MiniDumpPlugin struct { type MiniDumpPlugin struct {
name string plugins.BasePlugin
kernel32 *syscall.DLL kernel32 *syscall.DLL
dbghelp *syscall.DLL dbghelp *syscall.DLL
advapi32 *syscall.DLL advapi32 *syscall.DLL
@ -77,14 +78,10 @@ type ProcessManager struct {
// NewMiniDumpPlugin 创建内存转储插件 // NewMiniDumpPlugin 创建内存转储插件
func NewMiniDumpPlugin() *MiniDumpPlugin { func NewMiniDumpPlugin() *MiniDumpPlugin {
return &MiniDumpPlugin{ return &MiniDumpPlugin{
name: "minidump", BasePlugin: plugins.NewBasePlugin("minidump"),
} }
} }
// GetName 实现Plugin接口
func (p *MiniDumpPlugin) Name() string {
return p.name
}
// Scan 执行内存转储 - 直接实现 // Scan 执行内存转储 - 直接实现

View File

@ -13,6 +13,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// ReverseShellPlugin 反弹Shell插件 - Linus式简化版本 // ReverseShellPlugin 反弹Shell插件 - Linus式简化版本
@ -22,7 +23,7 @@ import (
// - 直接实现反弹Shell功能 // - 直接实现反弹Shell功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type ReverseShellPlugin struct { type ReverseShellPlugin struct {
name string plugins.BasePlugin
target string // 目标地址:端口 target string // 目标地址:端口
host string host string
port int port int
@ -48,7 +49,7 @@ func NewReverseShellPlugin() *ReverseShellPlugin {
} }
return &ReverseShellPlugin{ return &ReverseShellPlugin{
name: "reverseshell", BasePlugin: plugins.NewBasePlugin("reverseshell"),
target: target, target: target,
host: host, host: host,
port: port, port: port,
@ -56,9 +57,6 @@ func NewReverseShellPlugin() *ReverseShellPlugin {
} }
// GetName 实现Plugin接口 // GetName 实现Plugin接口
func (p *ReverseShellPlugin) Name() string {
return p.name
}
// Scan 执行反弹Shell - 直接实现 // Scan 执行反弹Shell - 直接实现

View File

@ -12,6 +12,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// ShellEnvPlugin Shell环境变量持久化插件 - Linus式简化版本 // ShellEnvPlugin Shell环境变量持久化插件 - Linus式简化版本
@ -21,7 +22,7 @@ import (
// - 直接实现持久化功能 // - 直接实现持久化功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type ShellEnvPlugin struct { type ShellEnvPlugin struct {
name string plugins.BasePlugin
targetFile string targetFile string
} }
@ -33,15 +34,11 @@ func NewShellEnvPlugin() *ShellEnvPlugin {
} }
return &ShellEnvPlugin{ return &ShellEnvPlugin{
name: "shellenv", BasePlugin: plugins.NewBasePlugin("shellenv"),
targetFile: targetFile, targetFile: targetFile,
} }
} }
// GetName 实现Plugin接口
func (p *ShellEnvPlugin) Name() string {
return p.name
}
// Scan 执行Shell环境变量持久化 - 直接实现 // Scan 执行Shell环境变量持久化 - 直接实现

View File

@ -10,6 +10,7 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// Socks5ProxyPlugin SOCKS5代理插件 - Linus式简化版本 // Socks5ProxyPlugin SOCKS5代理插件 - Linus式简化版本
@ -19,7 +20,7 @@ import (
// - 直接实现SOCKS5代理功能 // - 直接实现SOCKS5代理功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type Socks5ProxyPlugin struct { type Socks5ProxyPlugin struct {
name string plugins.BasePlugin
port int port int
listener net.Listener listener net.Listener
} }
@ -33,15 +34,11 @@ func NewSocks5ProxyPlugin() *Socks5ProxyPlugin {
} }
return &Socks5ProxyPlugin{ return &Socks5ProxyPlugin{
name: "socks5proxy", BasePlugin: plugins.NewBasePlugin("socks5proxy"),
port: port, port: port,
} }
} }
// GetName 实现Plugin接口
func (p *Socks5ProxyPlugin) Name() string {
return p.name
}
// Scan 执行SOCKS5代理扫描 - 直接实现 // Scan 执行SOCKS5代理扫描 - 直接实现

View File

@ -12,6 +12,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// SystemdServicePlugin 系统服务持久化插件 - Linus式简化版本 // SystemdServicePlugin 系统服务持久化插件 - Linus式简化版本
@ -21,7 +22,7 @@ import (
// - 直接实现系统服务持久化功能 // - 直接实现系统服务持久化功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type SystemdServicePlugin struct { type SystemdServicePlugin struct {
name string plugins.BasePlugin
targetFile string targetFile string
} }
@ -33,15 +34,11 @@ func NewSystemdServicePlugin() *SystemdServicePlugin {
} }
return &SystemdServicePlugin{ return &SystemdServicePlugin{
name: "systemdservice", BasePlugin: plugins.NewBasePlugin("systemdservice"),
targetFile: targetFile, targetFile: targetFile,
} }
} }
// GetName 实现Plugin接口
func (p *SystemdServicePlugin) Name() string {
return p.name
}
// Scan 执行系统服务持久化 - 直接实现 // Scan 执行系统服务持久化 - 直接实现

View File

@ -10,6 +10,7 @@ import (
"os/user" "os/user"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// SystemInfoPlugin 系统信息收集插件 - Linus式简化版本 // SystemInfoPlugin 系统信息收集插件 - Linus式简化版本
@ -19,20 +20,16 @@ import (
// - 收集基本系统信息 // - 收集基本系统信息
// - 跨平台支持,运行时适配 // - 跨平台支持,运行时适配
type SystemInfoPlugin struct { type SystemInfoPlugin struct {
name string plugins.BasePlugin
} }
// NewSystemInfoPlugin 创建系统信息插件 // NewSystemInfoPlugin 创建系统信息插件
func NewSystemInfoPlugin() *SystemInfoPlugin { func NewSystemInfoPlugin() *SystemInfoPlugin {
return &SystemInfoPlugin{ return &SystemInfoPlugin{
name: "systeminfo", BasePlugin: plugins.NewBasePlugin("systeminfo"),
} }
} }
// GetName 实现Plugin接口
func (p *SystemInfoPlugin) Name() string {
return p.name
}
// Scan 执行系统信息收集 - 直接、简单、有效 // Scan 执行系统信息收集 - 直接、简单、有效

View File

@ -11,6 +11,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// WinRegistryPlugin Windows注册表持久化插件 - Linus式简化版本 // WinRegistryPlugin Windows注册表持久化插件 - Linus式简化版本
@ -20,7 +21,7 @@ import (
// - 直接实现注册表持久化功能 // - 直接实现注册表持久化功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type WinRegistryPlugin struct { type WinRegistryPlugin struct {
name string plugins.BasePlugin
pePath string pePath string
} }
@ -32,15 +33,11 @@ func NewWinRegistryPlugin() *WinRegistryPlugin {
} }
return &WinRegistryPlugin{ return &WinRegistryPlugin{
name: "winregistry", BasePlugin: plugins.NewBasePlugin("winregistry"),
pePath: pePath, pePath: pePath,
} }
} }
// GetName 实现Plugin接口
func (p *WinRegistryPlugin) Name() string {
return p.name
}
// Scan 执行Windows注册表持久化 - 直接实现 // Scan 执行Windows注册表持久化 - 直接实现

View File

@ -11,6 +11,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// WinSchTaskPlugin Windows计划任务持久化插件 - Linus式简化版本 // WinSchTaskPlugin Windows计划任务持久化插件 - Linus式简化版本
@ -20,7 +21,7 @@ import (
// - 直接实现计划任务持久化功能 // - 直接实现计划任务持久化功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type WinSchTaskPlugin struct { type WinSchTaskPlugin struct {
name string plugins.BasePlugin
pePath string pePath string
} }
@ -32,15 +33,11 @@ func NewWinSchTaskPlugin() *WinSchTaskPlugin {
} }
return &WinSchTaskPlugin{ return &WinSchTaskPlugin{
name: "winschtask", BasePlugin: plugins.NewBasePlugin("winschtask"),
pePath: pePath, pePath: pePath,
} }
} }
// GetName 实现Plugin接口
func (p *WinSchTaskPlugin) Name() string {
return p.name
}
// Scan 执行Windows计划任务持久化 - 直接实现 // Scan 执行Windows计划任务持久化 - 直接实现

View File

@ -11,6 +11,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// WinServicePlugin Windows服务持久化插件 - Linus式简化版本 // WinServicePlugin Windows服务持久化插件 - Linus式简化版本
@ -20,7 +21,7 @@ import (
// - 直接实现服务持久化功能 // - 直接实现服务持久化功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type WinServicePlugin struct { type WinServicePlugin struct {
name string plugins.BasePlugin
pePath string pePath string
} }
@ -32,15 +33,11 @@ func NewWinServicePlugin() *WinServicePlugin {
} }
return &WinServicePlugin{ return &WinServicePlugin{
name: "winservice", BasePlugin: plugins.NewBasePlugin("winservice"),
pePath: pePath, pePath: pePath,
} }
} }
// GetName 实现Plugin接口
func (p *WinServicePlugin) Name() string {
return p.name
}
// Scan 执行Windows服务持久化 - 直接实现 // Scan 执行Windows服务持久化 - 直接实现

View File

@ -11,6 +11,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// WinStartupPlugin Windows启动文件夹持久化插件 - Linus式简化版本 // WinStartupPlugin Windows启动文件夹持久化插件 - Linus式简化版本
@ -20,7 +21,7 @@ import (
// - 直接实现启动文件夹持久化功能 // - 直接实现启动文件夹持久化功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type WinStartupPlugin struct { type WinStartupPlugin struct {
name string plugins.BasePlugin
pePath string pePath string
} }
@ -32,15 +33,11 @@ func NewWinStartupPlugin() *WinStartupPlugin {
} }
return &WinStartupPlugin{ return &WinStartupPlugin{
name: "winstartup", BasePlugin: plugins.NewBasePlugin("winstartup"),
pePath: pePath, pePath: pePath,
} }
} }
// GetName 实现Plugin接口
func (p *WinStartupPlugin) Name() string {
return p.name
}
// Scan 执行Windows启动文件夹持久化 - 直接实现 // Scan 执行Windows启动文件夹持久化 - 直接实现

View File

@ -11,6 +11,7 @@ import (
"strings" "strings"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// WinWMIPlugin Windows WMI事件订阅持久化插件 - Linus式简化版本 // WinWMIPlugin Windows WMI事件订阅持久化插件 - Linus式简化版本
@ -20,7 +21,7 @@ import (
// - 直接实现WMI事件订阅持久化功能 // - 直接实现WMI事件订阅持久化功能
// - 保持原有功能逻辑 // - 保持原有功能逻辑
type WinWMIPlugin struct { type WinWMIPlugin struct {
name string plugins.BasePlugin
pePath string pePath string
} }
@ -32,15 +33,11 @@ func NewWinWMIPlugin() *WinWMIPlugin {
} }
return &WinWMIPlugin{ return &WinWMIPlugin{
name: "winwmi", BasePlugin: plugins.NewBasePlugin("winwmi"),
pePath: pePath, pePath: pePath,
} }
} }
// GetName 实现Plugin接口
func (p *WinWMIPlugin) Name() string {
return p.name
}
// Scan 执行Windows WMI事件订阅持久化 - 直接实现 // Scan 执行Windows WMI事件订阅持久化 - 直接实现

View File

@ -8,27 +8,20 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type ActiveMQPlugin struct { type ActiveMQPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewActiveMQPlugin() *ActiveMQPlugin { func NewActiveMQPlugin() *ActiveMQPlugin {
return &ActiveMQPlugin{ return &ActiveMQPlugin{
name: "activemq", BasePlugin: plugins.NewBasePlugin("activemq"),
ports: []int{61616, 61617, 61618, 8161},
} }
} }
func (p *ActiveMQPlugin) Name() string {
return p.name
}
func (p *ActiveMQPlugin) GetPorts() []int {
return p.ports
}
func (p *ActiveMQPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *ActiveMQPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -9,27 +9,20 @@ import (
"github.com/gocql/gocql" "github.com/gocql/gocql"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type CassandraPlugin struct { type CassandraPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewCassandraPlugin() *CassandraPlugin { func NewCassandraPlugin() *CassandraPlugin {
return &CassandraPlugin{ return &CassandraPlugin{
name: "cassandra", BasePlugin: plugins.NewBasePlugin("cassandra"),
ports: []int{9042, 9160, 7000, 7001},
} }
} }
func (p *CassandraPlugin) Name() string {
return p.name
}
func (p *CassandraPlugin) GetPorts() []int {
return p.ports
}
func (p *CassandraPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *CassandraPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -11,27 +11,20 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type ElasticsearchPlugin struct { type ElasticsearchPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewElasticsearchPlugin() *ElasticsearchPlugin { func NewElasticsearchPlugin() *ElasticsearchPlugin {
return &ElasticsearchPlugin{ return &ElasticsearchPlugin{
name: "elasticsearch", BasePlugin: plugins.NewBasePlugin("elasticsearch"),
ports: []int{9200, 9300},
} }
} }
func (p *ElasticsearchPlugin) Name() string {
return p.name
}
func (p *ElasticsearchPlugin) GetPorts() []int {
return p.ports
}
func (p *ElasticsearchPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *ElasticsearchPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -13,31 +13,23 @@ import (
"unicode" "unicode"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// FindNetPlugin Windows网络发现插件 - 通过RPC端点映射服务收集网络信息 // FindNetPlugin Windows网络发现插件 - 通过RPC端点映射服务收集网络信息
type FindNetPlugin struct { type FindNetPlugin struct {
name string plugins.BasePlugin
ports []int
} }
// NewFindNetPlugin 创建FindNet插件 // NewFindNetPlugin 创建FindNet插件
func NewFindNetPlugin() *FindNetPlugin { func NewFindNetPlugin() *FindNetPlugin {
return &FindNetPlugin{ return &FindNetPlugin{
name: "findnet", BasePlugin: plugins.NewBasePlugin("findnet"),
ports: []int{135}, // RPC端点映射器端口
} }
} }
// GetName 实现Plugin接口
func (p *FindNetPlugin) Name() string {
return p.name
}
// GetPorts 实现Plugin接口 // GetPorts 实现Plugin接口
func (p *FindNetPlugin) GetPorts() []int {
return p.ports
}
// Scan 执行FindNet扫描 - Windows网络信息收集 // Scan 执行FindNet扫描 - Windows网络信息收集
func (p *FindNetPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *FindNetPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {

View File

@ -7,27 +7,20 @@ import (
ftplib "github.com/jlaffaye/ftp" ftplib "github.com/jlaffaye/ftp"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type FTPPlugin struct { type FTPPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewFTPPlugin() *FTPPlugin { func NewFTPPlugin() *FTPPlugin {
return &FTPPlugin{ return &FTPPlugin{
name: "ftp", BasePlugin: plugins.NewBasePlugin("ftp"),
ports: []int{21, 2121, 990},
} }
} }
func (p *FTPPlugin) Name() string {
return p.name
}
func (p *FTPPlugin) GetPorts() []int {
return p.ports
}
func (p *FTPPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *FTPPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -7,27 +7,20 @@ import (
"github.com/IBM/sarama" "github.com/IBM/sarama"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type KafkaPlugin struct { type KafkaPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewKafkaPlugin() *KafkaPlugin { func NewKafkaPlugin() *KafkaPlugin {
return &KafkaPlugin{ return &KafkaPlugin{
name: "kafka", BasePlugin: plugins.NewBasePlugin("kafka"),
ports: []int{9092, 9093, 9094},
} }
} }
func (p *KafkaPlugin) Name() string {
return p.name
}
func (p *KafkaPlugin) GetPorts() []int {
return p.ports
}
func (p *KafkaPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *KafkaPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -6,27 +6,20 @@ import (
ldaplib "github.com/go-ldap/ldap/v3" ldaplib "github.com/go-ldap/ldap/v3"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type LDAPPlugin struct { type LDAPPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewLDAPPlugin() *LDAPPlugin { func NewLDAPPlugin() *LDAPPlugin {
return &LDAPPlugin{ return &LDAPPlugin{
name: "ldap", BasePlugin: plugins.NewBasePlugin("ldap"),
ports: []int{389, 636, 3268, 3269},
} }
} }
func (p *LDAPPlugin) Name() string {
return p.name
}
func (p *LDAPPlugin) GetPorts() []int {
return p.ports
}
func (p *LDAPPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *LDAPPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -8,27 +8,20 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type MemcachedPlugin struct { type MemcachedPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewMemcachedPlugin() *MemcachedPlugin { func NewMemcachedPlugin() *MemcachedPlugin {
return &MemcachedPlugin{ return &MemcachedPlugin{
name: "memcached", BasePlugin: plugins.NewBasePlugin("memcached"),
ports: []int{11211, 11212, 11213},
} }
} }
func (p *MemcachedPlugin) Name() string {
return p.name
}
func (p *MemcachedPlugin) GetPorts() []int {
return p.ports
}
func (p *MemcachedPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *MemcachedPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -8,27 +8,20 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type MongoDBPlugin struct { type MongoDBPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewMongoDBPlugin() *MongoDBPlugin { func NewMongoDBPlugin() *MongoDBPlugin {
return &MongoDBPlugin{ return &MongoDBPlugin{
name: "mongodb", BasePlugin: plugins.NewBasePlugin("mongodb"),
ports: []int{27017, 27018, 27019},
} }
} }
func (p *MongoDBPlugin) Name() string {
return p.name
}
func (p *MongoDBPlugin) GetPorts() []int {
return p.ports
}
func (p *MongoDBPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *MongoDBPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -14,31 +14,23 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// MS17010Plugin MS17-010漏洞检测和利用插件 - 保持完整的原始利用功能 // MS17010Plugin MS17-010漏洞检测和利用插件 - 保持完整的原始利用功能
type MS17010Plugin struct { type MS17010Plugin struct {
name string plugins.BasePlugin
ports []int
} }
// NewMS17010Plugin 创建MS17010插件 // NewMS17010Plugin 创建MS17010插件
func NewMS17010Plugin() *MS17010Plugin { func NewMS17010Plugin() *MS17010Plugin {
return &MS17010Plugin{ return &MS17010Plugin{
name: "ms17010", BasePlugin: plugins.NewBasePlugin("ms17010"),
ports: []int{445}, // SMB端口
} }
} }
// GetName 实现Plugin接口
func (p *MS17010Plugin) Name() string {
return p.name
}
// GetPorts 实现Plugin接口 // GetPorts 实现Plugin接口
func (p *MS17010Plugin) GetPorts() []int {
return p.ports
}
// Scan 执行MS17-010扫描 // Scan 执行MS17-010扫描
func (p *MS17010Plugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *MS17010Plugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {

View File

@ -9,27 +9,20 @@ import (
_ "github.com/denisenkom/go-mssqldb" _ "github.com/denisenkom/go-mssqldb"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type MSSQLPlugin struct { type MSSQLPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewMSSQLPlugin() *MSSQLPlugin { func NewMSSQLPlugin() *MSSQLPlugin {
return &MSSQLPlugin{ return &MSSQLPlugin{
name: "mssql", BasePlugin: plugins.NewBasePlugin("mssql"),
ports: []int{1433, 1434},
} }
} }
func (p *MSSQLPlugin) Name() string {
return p.name
}
func (p *MSSQLPlugin) GetPorts() []int {
return p.ports
}
func (p *MSSQLPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *MSSQLPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -9,27 +9,20 @@ import (
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type MySQLPlugin struct { type MySQLPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewMySQLPlugin() *MySQLPlugin { func NewMySQLPlugin() *MySQLPlugin {
return &MySQLPlugin{ return &MySQLPlugin{
name: "mysql", BasePlugin: plugins.NewBasePlugin("mysql"),
ports: []int{3306, 3307, 33060},
} }
} }
func (p *MySQLPlugin) Name() string {
return p.name
}
func (p *MySQLPlugin) GetPorts() []int {
return p.ports
}
func (p *MySQLPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *MySQLPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -9,27 +9,20 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type Neo4jPlugin struct { type Neo4jPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewNeo4jPlugin() *Neo4jPlugin { func NewNeo4jPlugin() *Neo4jPlugin {
return &Neo4jPlugin{ return &Neo4jPlugin{
name: "neo4j", BasePlugin: plugins.NewBasePlugin("neo4j"),
ports: []int{7474, 7687, 7473},
} }
} }
func (p *Neo4jPlugin) Name() string {
return p.name
}
func (p *Neo4jPlugin) GetPorts() []int {
return p.ports
}
func (p *Neo4jPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *Neo4jPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -9,31 +9,23 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// NetBIOSPlugin NetBIOS名称服务扫描插件 - 收集Windows主机名和域信息 // NetBIOSPlugin NetBIOS名称服务扫描插件 - 收集Windows主机名和域信息
type NetBIOSPlugin struct { type NetBIOSPlugin struct {
name string plugins.BasePlugin
ports []int
} }
// NewNetBIOSPlugin 创建NetBIOS插件 // NewNetBIOSPlugin 创建NetBIOS插件
func NewNetBIOSPlugin() *NetBIOSPlugin { func NewNetBIOSPlugin() *NetBIOSPlugin {
return &NetBIOSPlugin{ return &NetBIOSPlugin{
name: "netbios", BasePlugin: plugins.NewBasePlugin("netbios"),
ports: []int{137, 139}, // NetBIOS名称服务和会话服务端口
} }
} }
// GetName 实现Plugin接口
func (p *NetBIOSPlugin) Name() string {
return p.name
}
// GetPorts 实现Plugin接口 // GetPorts 实现Plugin接口
func (p *NetBIOSPlugin) GetPorts() []int {
return p.ports
}
// Scan 执行NetBIOS扫描 - 收集Windows主机和域信息 // Scan 执行NetBIOS扫描 - 收集Windows主机和域信息
func (p *NetBIOSPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *NetBIOSPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {

View File

@ -5,27 +5,20 @@ import (
"fmt" "fmt"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type OraclePlugin struct { type OraclePlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewOraclePlugin() *OraclePlugin { func NewOraclePlugin() *OraclePlugin {
return &OraclePlugin{ return &OraclePlugin{
name: "oracle", BasePlugin: plugins.NewBasePlugin("oracle"),
ports: []int{1521, 1522, 1525},
} }
} }
func (p *OraclePlugin) Name() string {
return p.name
}
func (p *OraclePlugin) GetPorts() []int {
return p.ports
}
func (p *OraclePlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *OraclePlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
if common.DisableBrute { if common.DisableBrute {

View File

@ -9,27 +9,20 @@ import (
_ "github.com/lib/pq" _ "github.com/lib/pq"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type PostgreSQLPlugin struct { type PostgreSQLPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewPostgreSQLPlugin() *PostgreSQLPlugin { func NewPostgreSQLPlugin() *PostgreSQLPlugin {
return &PostgreSQLPlugin{ return &PostgreSQLPlugin{
name: "postgresql", BasePlugin: plugins.NewBasePlugin("postgresql"),
ports: []int{5432, 5433, 5434},
} }
} }
func (p *PostgreSQLPlugin) Name() string {
return p.name
}
func (p *PostgreSQLPlugin) GetPorts() []int {
return p.ports
}
func (p *PostgreSQLPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *PostgreSQLPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -9,27 +9,20 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type RabbitMQPlugin struct { type RabbitMQPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewRabbitMQPlugin() *RabbitMQPlugin { func NewRabbitMQPlugin() *RabbitMQPlugin {
return &RabbitMQPlugin{ return &RabbitMQPlugin{
name: "rabbitmq", BasePlugin: plugins.NewBasePlugin("rabbitmq"),
ports: []int{5672, 15672, 5671},
} }
} }
func (p *RabbitMQPlugin) Name() string {
return p.name
}
func (p *RabbitMQPlugin) GetPorts() []int {
return p.ports
}
func (p *RabbitMQPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *RabbitMQPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -8,31 +8,23 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// RDPPlugin RDP远程桌面服务扫描插件 - 弱密码检测和服务识别 // RDPPlugin RDP远程桌面服务扫描插件 - 弱密码检测和服务识别
type RDPPlugin struct { type RDPPlugin struct {
name string plugins.BasePlugin
ports []int
} }
// NewRDPPlugin 创建RDP插件 // NewRDPPlugin 创建RDP插件
func NewRDPPlugin() *RDPPlugin { func NewRDPPlugin() *RDPPlugin {
return &RDPPlugin{ return &RDPPlugin{
name: "rdp", BasePlugin: plugins.NewBasePlugin("rdp"),
ports: []int{3389}, // RDP端口
} }
} }
// GetName 实现Plugin接口
func (p *RDPPlugin) Name() string {
return p.name
}
// GetPorts 实现Plugin接口 // GetPorts 实现Plugin接口
func (p *RDPPlugin) GetPorts() []int {
return p.ports
}
// Scan 执行RDP扫描 - 基础服务识别 // Scan 执行RDP扫描 - 基础服务识别
func (p *RDPPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *RDPPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {

View File

@ -10,31 +10,22 @@ import (
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/common/i18n" "github.com/shadow1ng/fscan/common/i18n"
"github.com/shadow1ng/fscan/plugins"
) )
// RedisPlugin Redis数据库扫描和利用插件 - 包含文件写入利用功能 // RedisPlugin Redis数据库扫描和利用插件 - 包含文件写入利用功能
type RedisPlugin struct { type RedisPlugin struct {
name string plugins.BasePlugin
ports []int
} }
// NewRedisPlugin 创建Redis插件 // NewRedisPlugin 创建Redis插件
func NewRedisPlugin() *RedisPlugin { func NewRedisPlugin() *RedisPlugin {
return &RedisPlugin{ return &RedisPlugin{
name: "redis", BasePlugin: plugins.NewBasePlugin("redis"),
ports: []int{6379, 6380, 6381, 16379, 26379},
} }
} }
// GetName 实现Plugin接口
func (p *RedisPlugin) Name() string {
return p.name
}
// GetPorts 实现Plugin接口
func (p *RedisPlugin) GetPorts() []int {
return p.ports
}
// Scan 执行Redis扫描 - 未授权访问检测和弱密码检测 // Scan 执行Redis扫描 - 未授权访问检测和弱密码检测
func (p *RedisPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *RedisPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {

View File

@ -9,27 +9,20 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type RsyncPlugin struct { type RsyncPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewRsyncPlugin() *RsyncPlugin { func NewRsyncPlugin() *RsyncPlugin {
return &RsyncPlugin{ return &RsyncPlugin{
name: "rsync", BasePlugin: plugins.NewBasePlugin("rsync"),
ports: []int{873},
} }
} }
func (p *RsyncPlugin) Name() string {
return p.name
}
func (p *RsyncPlugin) GetPorts() []int {
return p.ports
}
func (p *RsyncPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *RsyncPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -6,32 +6,25 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
"github.com/stacktitan/smb/smb" "github.com/stacktitan/smb/smb"
) )
// SmbPlugin SMB弱密码检测插件 // SmbPlugin SMB弱密码检测插件
type SmbPlugin struct { type SmbPlugin struct {
name string plugins.BasePlugin
ports []int
} }
// NewSmbPlugin 创建SMB插件 // NewSmbPlugin 创建SMB插件
func NewSmbPlugin() *SmbPlugin { func NewSmbPlugin() *SmbPlugin {
return &SmbPlugin{ return &SmbPlugin{
name: "smb", BasePlugin: plugins.NewBasePlugin("smb"),
ports: []int{445},
} }
} }
// GetName 实现Plugin接口 // GetName 实现Plugin接口
func (p *SmbPlugin) Name() string {
return p.name
}
// GetPorts 实现Plugin接口 // GetPorts 实现Plugin接口
func (p *SmbPlugin) GetPorts() []int {
return p.ports
}
// Scan 执行SMB扫描 // Scan 执行SMB扫描
func (p *SmbPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *SmbPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {

View File

@ -7,31 +7,24 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// Smb2Plugin SMB2弱密码检测插件 // Smb2Plugin SMB2弱密码检测插件
type Smb2Plugin struct { type Smb2Plugin struct {
name string plugins.BasePlugin
ports []int
} }
// NewSmb2Plugin 创建SMB2插件 // NewSmb2Plugin 创建SMB2插件
func NewSmb2Plugin() *Smb2Plugin { func NewSmb2Plugin() *Smb2Plugin {
return &Smb2Plugin{ return &Smb2Plugin{
name: "smb2", BasePlugin: plugins.NewBasePlugin("smb2"),
ports: []int{445},
} }
} }
// GetName 实现Plugin接口 // GetName 实现Plugin接口
func (p *Smb2Plugin) Name() string {
return p.name
}
// GetPorts 实现Plugin接口 // GetPorts 实现Plugin接口
func (p *Smb2Plugin) GetPorts() []int {
return p.ports
}
// Scan 执行SMB2扫描 // Scan 执行SMB2扫描
func (p *Smb2Plugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *Smb2Plugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {

View File

@ -8,12 +8,12 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// SmbGhostPlugin CVE-2020-0796 SMB Ghost漏洞检测插件 // SmbGhostPlugin CVE-2020-0796 SMB Ghost漏洞检测插件
type SmbGhostPlugin struct { type SmbGhostPlugin struct {
name string plugins.BasePlugin
ports []int
} }
// SMB Ghost 检测数据包 // SMB Ghost 检测数据包
@ -104,20 +104,12 @@ const smbGhostPacket = "\x00" + // session
// NewSmbGhostPlugin 创建SMB Ghost插件 // NewSmbGhostPlugin 创建SMB Ghost插件
func NewSmbGhostPlugin() *SmbGhostPlugin { func NewSmbGhostPlugin() *SmbGhostPlugin {
return &SmbGhostPlugin{ return &SmbGhostPlugin{
name: "smbghost", BasePlugin: plugins.NewBasePlugin("smbghost"),
ports: []int{445},
} }
} }
// GetName 实现Plugin接口
func (p *SmbGhostPlugin) Name() string {
return p.name
}
// GetPorts 实现Plugin接口 // GetPorts 实现Plugin接口
func (p *SmbGhostPlugin) GetPorts() []int {
return p.ports
}
// Scan 执行SMB Ghost漏洞检测 // Scan 执行SMB Ghost漏洞检测
func (p *SmbGhostPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *SmbGhostPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {

View File

@ -10,31 +10,23 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// SMBInfoPlugin SMB协议信息收集插件 - 收集操作系统和NTLM信息 // SMBInfoPlugin SMB协议信息收集插件 - 收集操作系统和NTLM信息
type SMBInfoPlugin struct { type SMBInfoPlugin struct {
name string plugins.BasePlugin
ports []int
} }
// NewSMBInfoPlugin 创建SMBInfo插件 // NewSMBInfoPlugin 创建SMBInfo插件
func NewSMBInfoPlugin() *SMBInfoPlugin { func NewSMBInfoPlugin() *SMBInfoPlugin {
return &SMBInfoPlugin{ return &SMBInfoPlugin{
name: "smbinfo", BasePlugin: plugins.NewBasePlugin("smbinfo"),
ports: []int{139, 445}, // SMB端口
} }
} }
// GetName 实现Plugin接口
func (p *SMBInfoPlugin) Name() string {
return p.name
}
// GetPorts 实现Plugin接口 // GetPorts 实现Plugin接口
func (p *SMBInfoPlugin) GetPorts() []int {
return p.ports
}
// Scan 执行SMBInfo扫描 - SMB信息收集 // Scan 执行SMBInfo扫描 - SMB信息收集
func (p *SMBInfoPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *SMBInfoPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {

View File

@ -10,27 +10,20 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type SMTPPlugin struct { type SMTPPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewSMTPPlugin() *SMTPPlugin { func NewSMTPPlugin() *SMTPPlugin {
return &SMTPPlugin{ return &SMTPPlugin{
name: "smtp", BasePlugin: plugins.NewBasePlugin("smtp"),
ports: []int{25, 465, 587, 2525},
} }
} }
func (p *SMTPPlugin) Name() string {
return p.name
}
func (p *SMTPPlugin) GetPorts() []int {
return p.ports
}
func (p *SMTPPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *SMTPPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -8,27 +8,20 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type SNMPPlugin struct { type SNMPPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewSNMPPlugin() *SNMPPlugin { func NewSNMPPlugin() *SNMPPlugin {
return &SNMPPlugin{ return &SNMPPlugin{
name: "snmp", BasePlugin: plugins.NewBasePlugin("snmp"),
ports: []int{161, 162},
} }
} }
func (p *SNMPPlugin) Name() string {
return p.name
}
func (p *SNMPPlugin) GetPorts() []int {
return p.ports
}
func (p *SNMPPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *SNMPPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -12,31 +12,22 @@ import (
"golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/common/i18n" "github.com/shadow1ng/fscan/common/i18n"
"github.com/shadow1ng/fscan/plugins"
) )
// SSHPlugin SSH扫描和利用插件 - 单文件实现,包含真正的利用功能 // SSHPlugin SSH扫描和利用插件 - 单文件实现,包含真正的利用功能
type SSHPlugin struct { type SSHPlugin struct {
name string plugins.BasePlugin
ports []int
} }
// NewSSHPlugin 创建SSH插件 // NewSSHPlugin 创建SSH插件
func NewSSHPlugin() *SSHPlugin { func NewSSHPlugin() *SSHPlugin {
return &SSHPlugin{ return &SSHPlugin{
name: "ssh", BasePlugin: plugins.NewBasePlugin("ssh"),
ports: []int{22, 2222, 2200, 22222},
} }
} }
// GetName 实现Plugin接口
func (p *SSHPlugin) Name() string {
return p.name
}
// GetPorts 实现Plugin接口
func (p *SSHPlugin) GetPorts() []int {
return p.ports
}
// Scan 执行SSH扫描 - 支持密码和密钥认证 // Scan 执行SSH扫描 - 支持密码和密钥认证
func (p *SSHPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *SSHPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {

View File

@ -8,27 +8,20 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type TelnetPlugin struct { type TelnetPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewTelnetPlugin() *TelnetPlugin { func NewTelnetPlugin() *TelnetPlugin {
return &TelnetPlugin{ return &TelnetPlugin{
name: "telnet", BasePlugin: plugins.NewBasePlugin("telnet"),
ports: []int{23, 2323},
} }
} }
func (p *TelnetPlugin) Name() string {
return p.name
}
func (p *TelnetPlugin) GetPorts() []int {
return p.ports
}
func (p *TelnetPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *TelnetPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -10,7 +10,6 @@ import (
// 插件接口定义 - 统一命名风格 // 插件接口定义 - 统一命名风格
type Plugin interface { type Plugin interface {
Name() string Name() string
GetPorts() []int
Scan(ctx context.Context, info *common.HostInfo) *ScanResult Scan(ctx context.Context, info *common.HostInfo) *ScanResult
} }

View File

@ -10,27 +10,20 @@ import (
"time" "time"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
type VNCPlugin struct { type VNCPlugin struct {
name string plugins.BasePlugin
ports []int
} }
func NewVNCPlugin() *VNCPlugin { func NewVNCPlugin() *VNCPlugin {
return &VNCPlugin{ return &VNCPlugin{
name: "vnc", BasePlugin: plugins.NewBasePlugin("vnc"),
ports: []int{5900, 5901, 5902, 5903, 5904, 5905, 5906, 5907, 5908, 5909},
} }
} }
func (p *VNCPlugin) Name() string {
return p.name
}
func (p *VNCPlugin) GetPorts() []int {
return p.ports
}
func (p *VNCPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult { func (p *VNCPlugin) Scan(ctx context.Context, info *common.HostInfo) *ScanResult {
target := fmt.Sprintf("%s:%s", info.Host, info.Ports) target := fmt.Sprintf("%s:%s", info.Host, info.Ports)

View File

@ -5,26 +5,22 @@ import (
"fmt" "fmt"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
"github.com/shadow1ng/fscan/webscan" "github.com/shadow1ng/fscan/webscan"
) )
// WebPocPlugin Web漏洞扫描插件 // WebPocPlugin Web漏洞扫描插件
type WebPocPlugin struct { type WebPocPlugin struct {
name string plugins.BasePlugin
} }
// NewWebPocPlugin 创建Web POC插件 // NewWebPocPlugin 创建Web POC插件
func NewWebPocPlugin() *WebPocPlugin { func NewWebPocPlugin() *WebPocPlugin {
return &WebPocPlugin{ return &WebPocPlugin{
name: "webpoc", BasePlugin: plugins.NewBasePlugin("webpoc"),
} }
} }
// GetName 实现Plugin接口
func (p *WebPocPlugin) Name() string {
return p.name
}
// Scan 执行Web POC扫描 // Scan 执行Web POC扫描
func (p *WebPocPlugin) Scan(ctx context.Context, info *common.HostInfo) *WebScanResult { func (p *WebPocPlugin) Scan(ctx context.Context, info *common.HostInfo) *WebScanResult {

View File

@ -12,25 +12,21 @@ import (
"unicode/utf8" "unicode/utf8"
"github.com/shadow1ng/fscan/common" "github.com/shadow1ng/fscan/common"
"github.com/shadow1ng/fscan/plugins"
) )
// WebTitlePlugin Web标题获取插件 // WebTitlePlugin Web标题获取插件
type WebTitlePlugin struct { type WebTitlePlugin struct {
name string plugins.BasePlugin
} }
// NewWebTitlePlugin 创建WebTitle插件 // NewWebTitlePlugin 创建WebTitle插件
func NewWebTitlePlugin() *WebTitlePlugin { func NewWebTitlePlugin() *WebTitlePlugin {
return &WebTitlePlugin{ return &WebTitlePlugin{
name: "webtitle", BasePlugin: plugins.NewBasePlugin("webtitle"),
} }
} }
// GetName 实现Plugin接口
func (p *WebTitlePlugin) Name() string {
return p.name
}
// Scan 执行WebTitle扫描 // Scan 执行WebTitle扫描
func (p *WebTitlePlugin) Scan(ctx context.Context, info *common.HostInfo) *WebScanResult { func (p *WebTitlePlugin) Scan(ctx context.Context, info *common.HostInfo) *WebScanResult {

View File

@ -1,47 +0,0 @@
#!/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!"