Aryma-f4/worldshellfinder

GitHub: Aryma-f4/worldshellfinder

WorldShellFinder 是一个基于 Go 的 Web Shell 检测工具,利用关键词、规则与启发式评分快速发现可疑文件并降低误报。

Stars: 34 | Forks: 5

# World Shell Finder World Shell Finder 是一个用于检测 Web 根目录或其他源目录中可疑 Web Shell 和后门的 Go 命令行工具。它结合了关键词匹配、正则规则和启发式评分,以提高检测质量并减少嘈杂的单一命中匹配。 ![shellfind](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/c2ee2ebcbd032712.png)

Go version Latest release Issues Discussions Repository size

## 免责声明 本项目仅用于教育、事件响应和防御性安全用途。它不能替代完整的恶意软件分析过程。仍然可能存在误报和漏报。 ## 亮点 - 重构为 **Clean Architecture**,以确保模块化、可维护性和可扩展性。 - 基于 `pterm` 的美观、直观的 **交互式 UI**。 - 集成 **VirusTotal API** 作为恶意软件参考数据库,以改进检测规则并确认可疑文件。 - 通过 Goroutines 和 Worker Pool 实现闪电般的 **多线程支持**,用于大规模目录扫描。 - **动态输出流**,在扫描完成前立即将潜在威胁报告到终端。 - 检测可疑的 **二进制后门 / C2 植入程序**,通过网络和恶意软件行为指示器。 - 基于评分的引擎检测可疑文件。 - 结合关键词匹配、正则签名和启发式指示器。 - 支持在嵌入式默认词表之上使用自定义词表。 - 生成更清晰的输出,包含可疑评分和证据摘要。 - 包含用于清理工作流程的字符串移除模式。 - 附带 GitHub Actions CI/CD,并在每次推送到主分支时自动创建预发布版本。 - 包含深度扫描模式,用于可疑流量检测和更全面的 Rootkit 检查。 ## 检测方式 扫描器使用多种信号评估文件: - 基于文本的 Webshell 模式(关键词 + 正则规则 + 启发式评分)。 - **类似 YARA 的高级启发式(纯 Go):** - **香农熵分析:** 通过计算连续字符串的数学信息密度,检测高度混淆的有效载荷(如隐藏的 Base64 或十六进制块)。 - **内存高效的二进制流解析:** 解析可执行和二进制格式文件以查找 C2/后门指示器,而无需将大型文件加载到内存中。 - **核心文件完整性验证:** 自动检测框架安装并验证核心/供应商文件。未修改的文件将被安全忽略(零误报),而修改的核心文件会立即被标记!支持的框架: - **WordPress**(通过官方 API 进行完整的 MD5 校验和验证) - **Laravel**(通过 `artisan` 根检测进行供应商路径验证) - **CodeIgniter 4**(通过 `spark` 根检测进行系统与供应商路径验证) - **Yii2**(通过 `yii` 根检测进行供应商路径验证) - 二进制后门 / C2 指示器(针对可执行或二进制格式文件)。 - 硬编码的 URL、IP:PORT、许多类似域名的字符串。 - 与网络相关的字符串(WinHTTP/WinINet/Winsock、`socket/connect/send/recv`、libcurl、HTTP 头部)。 - 类似恶意软件的行为字符串(持久化标记、注入标记、打包器标记)。 - 可选的 VirusTotal 信誉检查(仅针对高度可疑的命中,得分 >= 8)。 - 使用本地内存缓存。 - 强制执行免费层速率限制(每分钟 4 次查询),并在收到 HTTP 429 时自动禁用。 当文件的可疑评分达到配置的阈值时,会报告该文件。 ### 工作原理(架构与流程) ``` graph TD A[Start Scan] --> B{Operation Mode} B -->|Detect / Deep| C[Load Config & Wordlists] B -->|Remove| D[Load String to Remove] C --> E["Initialize Worker Pool (-workers)"] D --> ER["Initialize Worker Pool (-workers)"] subgraph Multi-Threaded Scanning E --> F[Walk Directories] F --> G[Push Files to Channel] G --> H1[Worker 1] G --> H2[Worker 2] G --> H3[Worker N] end subgraph Multi-Threaded Removal ER --> FR[Walk Directories] FR --> GR[Push Files to Channel] GR --> RH[Workers Remove String] end H1 --> I{Core File Integrity} I -->|Match Known Framework Vendor/Core| L[Safe / Skip File] I -->|Modified Checksum (WP)| J1[Add +20 Score] I -->|Not a Core File| J2{File Type Check} J1 --> J2 J2 -->|Suspicious Extension| J[Analyze as Text] J2 -->|Unknown Extension| K{Looks Like Text?} K -->|Yes| J K -->|No| K2{Executable or Known Binary Format?} K2 -->|Yes| JB["Analyze as Binary (strings)"] K2 -->|No| L[Skip File] J --> M[Match Keywords & Rules] M --> N[Apply Heuristics] N --> O{Score >= 8 & VT API Key set?} JB --> NB[Score Binary Indicators] NB --> O O -->|Yes| P[Calculate SHA256 Hash] P --> Q{Check Local Cache} Q -->|Found| R[Apply Cached VT Result] Q -->|Not Found| S["Rate Limited Request to VirusTotal API (auto-disable on 429)"] S --> R R --> T{Is Malicious?} T -->|Yes| U[Add +10 Score] T -->|No| V[Keep Current Score] O -->|No| V U --> W V --> W{Score >= Min Threshold?} W -->|Yes| X["Print Alert Immediately (stream)"] W -->|No| L X --> Y[Store in Results] Y --> Z RH --> Z L --> Z Z[Wait All Workers to Finish] --> AA{Is Deep Scan?} AA -->|Yes| AB[Run Traffic, Log, Rootkit Scans] AB --> AC AA -->|No| AC[Print Final Summary & Save Report] AC --> AD[End] ``` ## 安装 ### 从源码构建 ``` git clone https://github.com/Aryma-f4/worldshellfinder.git cd worldshellfinder go build -o worldshellfinder ./cmd/worldshellfinder ``` ### 使用 Go 安装 ``` go install github.com/Aryma-f4/worldshellfinder/cmd/worldshellfinder@latest ``` 如果你的 Go 二进制文件路径未包含在 `PATH` 中,请先添加它: ``` export PATH="$PATH:$HOME/go/bin" ``` ## 使用方法 ### 交互模式 运行程序而不带任何标志,以使用基于菜单的交互模式: ``` ./worldshellfinder ``` ### 检测模式 基础检测: ``` ./worldshellfinder -mode detect -dir /var/www/html ``` 通过目录列表进行检测(递归): ``` ./worldshellfinder -mode detect -dir-list /tmp/list_of_dirs.txt ``` 详细检测: ``` ./worldshellfinder -mode detect -dir /var/www/html -v ``` 使用自定义词表进行检测: ``` ./worldshellfinder -mode detect -dir /var/www/html -wordlist ./wordlists/zeus.txt ``` 使用更严格的阈值进行检测: ``` ./worldshellfinder -mode detect -dir /var/www/html -min-score 6 -max-evidence 8 ``` 将结果保存到文件: ``` ./worldshellfinder -mode detect -dir /var/www/html -out result.txt ``` ### 深度扫描模式 深度扫描结合了: - 基于文件的 Shell 检测, - 可疑流量检查, - 在常见认证、Nginx 和 Apache 日志中进行威胁搜寻, - 使用 `rkhunter`、`chkrootkit`、`unhide` 以及内置启发式检查的 Rootkit 检查。 示例: ``` ./worldshellfinder -mode deep -dir /var/www/html -out deep-report.txt -v ``` ### 移除字符串模式 ``` ./worldshellfinder -mode remove -dir /var/www/html -remove-string "malicious_snippet" ``` ### 帮助 ``` ./worldshellfinder -h ``` ## CLI 选项 ``` -h, --help Show help information -v Enable verbose output -mode string Operation mode: detect, deep, or remove -dir string Directory to scan -out string Output file path -wordlist string Additional custom wordlist file -min-score int Minimum score before a file is reported -max-evidence int Maximum evidence entries shown per file -remove-string string String to remove when mode=remove -dir-list string File containing a list of directories to scan (one per line) -vt-api-key string VirusTotal API key for checking suspicious files against the malware database -workers int Number of concurrent workers for scanning files (default: number of CPUs) --update Update to the latest release ``` ## 词表 词表格式允许定义自定义权重: - 每行一个关键词或签名。 - 使用 `::` 为关键词分配特定分数(例如 `keyword::score`)。 - 如果未提供分数,关键词默认权重为 4。 - 忽略空行和以 `#` 开头的行。 - 自定义条目会与嵌入式默认词表合并。 示例自定义 `custom.txt`: ``` # 给特定后门特征码打高分 c99shell::6 # 给系统枚举打低分以避免误报 systeminfo::1 whoami::1 ``` 参见: - [`wordlists/default.txt`](wordlists/default.txt) - [`wordlists/zeus.txt`](wordlists/zeus.txt) ## 已知覆盖范围 该仓库还记录了项目已覆盖的许多 Shell 家族和样本: - [已知 Shell 列表](list_find_already_shell.md) ## CI/CD GitHub Actions 现在提供: - 在拉取请求和推送时执行测试。 - 多平台构建工件(Linux、Windows 和 macOS)。 - 每次推送到 `main` 或 `master` 时自动创建预发布版本。 - 在每个生成的发布中包含附加的归档文件和校验和文件。 ## Rootkit 检测 深度扫描不依赖单一工具。它可以使用: - `rkhunter` - `chkrootkit` - `unhide` - 内置的启发式检查,用于检测预加载滥用、可疑模块、隐藏可执行文件、临时权限提升二进制文件和持久化点。 ## 日志威胁搜寻 深度扫描还会检查常见日志位置,例如: - `/var/log/auth.log` - `/var/log/secure` - `/var/log/nginx/access.log` - `/var/log/apache2/access.log` 它会查找以下迹象: - `cmd=`、`exec=`、`shell=` 或编码的有效载荷探测 - 可疑的上传和后门模式 - 重复的身份验证失败和无效用户 - `sudo`、`curl`、`wget`、`nc` 或权限提升活动在认证日志中 如果该进程没有权限检查受保护的路径,工具将打印: ``` not enough permission to do this, gotta root ``` ## 兼容性 - Linux - Windows - macOS [![Go Workflow](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/397b13514b032713.svg)](https://github.com/Aryma-f4/worldshellfinder/actions/workflows/go.yml) ## 贡献 欢迎贡献。欢迎提出问题或提交 Pull Request,内容包括: - 新的 Shell 签名, - 检测改进, - 性能修复, - 文档更新。
标签:Clean Architecture, EVTX分析, Goroutine, Go 安全工具, LangChain, pterm, SEO: golang security tool, SEO: incident response, SEO: malware scanner, SEO: web shell detection, SEO: webshell finder, VirusTotal API, Web Shell 检测, Worker Pool, 交互式 UI, 关键词匹配, 后门检测, 启发式评分, 恶意软件扫描, 日志审计, 正则规则, 轻量级