Whoamifuck 是 zhuima 的第一个 Rust 命令行开源工具。这是一个最初由 Shell 编写的用于检测入侵者的工具,本人使用Rust复刻了 Shell 版的完整的功能。
本仓库是Rust版本,Shell 版请参考原版
- 快速命令用于基本操作
- 特殊命令用于高级操作
- 风险评估命令
- 杂项命令用于各种任务
- 输出命令用于生成报告
首先,确保您的系统上安装了 Rust。如果没有,请访问 Rust 官网 进行安装。
然后,克隆此仓库并编译项目:
git clone https://github.com/zhuima/Whoamifuck.git
cd Whoamifuck
make all以下是 Whoamifuck 主要程序流程的时序图:
sequenceDiagram
actor User
participant Main
participant Cli
participant Commands
participant Special
participant System
User->>Main: Run program
activate Main
Main->>Cli: parse()
activate Cli
Cli-->>Main: Parsed CLI
deactivate Cli
Main->>Commands: match command
activate Commands
alt Quick command
Commands->>Main: Print "QUICK: {quick:?}"
else Special command
Commands->>Special: run()
activate Special
Special->>System: new_all()
activate System
System-->>Special: system
Special->>System: refresh_all()
alt proc_serv flag set
Special->>Special: fk_procserv(&system)
Special->>System: processes()
System-->>Special: process list
end
alt port flag set
Special->>Special: fk_portstatus(&system)
Special->>System: networks()
System-->>Special: network data
end
alt os_status flag set
Special->>Special: check_system_status(&system)
Special->>System: various system info calls
System-->>Special: system information
end
Special-->>Commands: Result
deactivate Special
deactivate System
alt Error occurred
Commands->>Main: Print error and exit(1)
end
else Risk command
Commands->>Main: Print "RISK: {risk:?}"
else Misc command
Commands->>Main: Print "MISC: {misc:?}"
else Output command
Commands->>Main: Print "OUTPUT: {output:?}"
else No command (None)
Commands->>Cli: parse_from(["Whoamifuck", "--help"])
Cli-->>Commands: Help information
Commands->>Main: Print help and exit(0)
end
deactivate Commands
Main-->>User: Program output
deactivate Main
yum install -y bash-completion # 或 apt-get install bash-completion
source <(whoamifuck complete bash)
echo 'source <(whoamifuck complete bash)' >> ~/.bashrcsource <(whoamifuck complete zsh)
echo 'source <(whoamifuck complete zsh)' >> ~/.zshrcWhoamifuck 使用 Clap 库来构建命令行界面。以下是主要命令的使用方法:
用于基本操作:
./whoamifuck quick --user-device <设备名> --login <登录名> [--nomal] [--all]--user-device:用户设备名称--login:用户登录名(默认值:/var/log/secure;/var/log/auth.log)--nomal:基本输出--all:完整输出
用于高级操作:
./whoamifuck special --user-device <设备名> --login <登录名> [--nomal] [--all]--proc-serv:检查用户进程和服务状态--port:检查用户端口开放状态--os-status:检查系统状态信息
./whoamifuck risk --user-device <设备名> --login <登录名> [--nomal] [--all]--baseline:安全基线检查--risk:检查系统漏洞信息--rootkitcheck:检查系统 rootkit 信息--webshell:检查 Web shell 信息(默认值:/var/www/;/www/wwwroot/..)
./whoamifuck misc --user-device <设备名> --login <登录名> [--nomal] [--all]--code:检查页面存活状态--sqletlog:检查用户信息--auto-run:设置 crontab 信息--ext:自定义命令定义测试(默认值:~/.whok/chief-inspector.conf)
./whoamifuck output --output:输出到文件--html:输出到终端(HTML 格式)
进行安全基线检查并生成 HTML 报告:
./whoamifuck output --html欢迎提交 Pull Requests 来改进这个工具。在提交之前,请确保您的代码符合项目的编码规范并通过所有测试。
