https://github.com/zhuima/whoamifuck
用于Linux应急响应,快速排查异常用户登录情况和入侵信息排查,准确定位溯源时间线,高效辅助还原攻击链。
https://github.com/zhuima/whoamifuck
Last synced: 11 months ago
JSON representation
用于Linux应急响应,快速排查异常用户登录情况和入侵信息排查,准确定位溯源时间线,高效辅助还原攻击链。
- Host: GitHub
- URL: https://github.com/zhuima/whoamifuck
- Owner: zhuima
- License: mit
- Created: 2024-10-22T12:04:41.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-11-01T06:56:39.000Z (over 1 year ago)
- Last Synced: 2025-04-14T19:11:31.718Z (about 1 year ago)
- Language: Rust
- Size: 266 KB
- Stars: 21
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Whoamifuck
Whoamifuck 是 zhuima 的第一个 `Rust` 命令行开源工具。这是一个最初由 Shell 编写的用于检测入侵者的工具,本人使用Rust复刻了 Shell 版的完整的功能。
本仓库是`Rust`版本,Shell 版请参考[原版](https://github.com/enomothem/Whoamifuck)

## 功能特点
- 快速命令用于基本操作
- 特殊命令用于高级操作
- 风险评估命令
- 杂项命令用于各种任务
- 输出命令用于生成报告
## 安装
首先,确保您的系统上安装了 Rust。如果没有,请访问 [Rust 官网](https://www.rust-lang.org/) 进行安装。
然后,克隆此仓库并编译项目:
```bash
git clone https://github.com/zhuima/Whoamifuck.git
cd Whoamifuck
make all
```
## 程序流程图
以下是 Whoamifuck 主要程序流程的时序图:
```mermaid
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
```
## 自动补全
#### 生成 Bash 补全脚本:
```bash
yum install -y bash-completion # 或 apt-get install bash-completion
source <(whoamifuck complete bash)
echo 'source <(whoamifuck complete bash)' >> ~/.bashrc
```
#### 生成 Zsh 补全脚本:
```bash
source <(whoamifuck complete zsh)
echo 'source <(whoamifuck complete zsh)' >> ~/.zshrc
```
## 使用指南
Whoamifuck 使用 Clap 库来构建命令行界面。以下是主要命令的使用方法:
### 快速命令 (quick)
用于基本操作:
```bash
./whoamifuck quick --user-device <设备名> --login <登录名> [--nomal] [--all]
```
- `--user-device`:用户设备名称
- `--login`:用户登录名(默认值:`/var/log/secure;/var/log/auth.log`)
- `--nomal`:基本输出
- `--all`:完整输出
### 特殊命令 (special)
用于高级操作:
```bash
./whoamifuck special --user-device <设备名> --login <登录名> [--nomal] [--all]
```
- `--proc-serv`:检查用户进程和服务状态
- `--port`:检查用户端口开放状态
- `--os-status`:检查系统状态信息
### 风险评估命令 (risk)
```bash
./whoamifuck risk --user-device <设备名> --login <登录名> [--nomal] [--all]
```
- `--baseline`:安全基线检查
- `--risk`:检查系统漏洞信息
- `--rootkitcheck`:检查系统 rootkit 信息
- `--webshell`:检查 Web shell 信息(默认值:`/var/www/;/www/wwwroot/..`)
### 杂项命令 (misc)
```bash
./whoamifuck misc --user-device <设备名> --login <登录名> [--nomal] [--all]
```
- `--code`:检查页面存活状态
- `--sqletlog`:检查用户信息
- `--auto-run`:设置 crontab 信息
- `--ext`:自定义命令定义测试(默认值:`~/.whok/chief-inspector.conf`)
### 输出命令 (output)
```bash
./whoamifuck output
```
- `--output`:输出到文件
- `--html`:输出到终端(HTML 格式)
## 示例
进行安全基线检查并生成 HTML 报告:
```bash
./whoamifuck output --html
```
## 贡献
欢迎提交 Pull Requests 来改进这个工具。在提交之前,请确保您的代码符合项目的编码规范并通过所有测试。
## 许可证
[MIT](./LICENSE)