c0m4r/paranoya
GitHub: c0m4r/paranoya
一款专为 Linux 设计的 IOC 和 YARA 扫描器,支持守护进程模式和进程扫描,适用于主机入侵检测和应急响应场景。
Stars: 12 | Forks: 0

## paranoya:简单的 Linux® IOC 和 YARA 扫描器

[](https://www.gnu.org/licenses/gpl-3.0)
[](https://github.com/c0m4r/paranoya/actions)
[](https://www.codefactor.io/repository/github/c0m4r/paranoya)



[](https://hub.docker.com/r/c0m4r/paranoya)
[](https://github.com/c0m4r/paranoya?tab=readme-ov-file#flatpak)
[](https://github.com/c0m4r/paranoya/wiki/paranoya-on-Android)
这是 [Loki - Simple IOC and YARA Scanner](https://github.com/Neo23x0/Loki) 的一个分支,为 Linux 重写并修改以支持单文件扫描,
以及一种 daemon 模式,用于以客户端/服务器方式接受扫描。它还包含一些[其他改进](#New-features)。
## 依赖项
#### Python 模块
[colorama](https://pypi.org/project/colorama/)
| [progressbar2](https://pypi.org/project/progressbar2/)
| [psutil](https://pypi.org/project/psutil/)
| [requests](https://pypi.org/project/requests/)
| [yara-python](https://pypi.org/project/yara-python/)
#### 基础 YARA 规则
[Neo23x0/signature-base](https://github.com/Neo23x0/signature-base)
| [reversinglabs-yara-rules](https://github.com/reversinglabs/reversinglabs-yara-rules)
#### 自定义 YARA 规则
[elastic/protections-artifacts](https://github.com/elastic/protections-artifacts)
| [PhishingKit-Yara-Rules](https://github.com/t4d/PhishingKit-Yara-Rules)
| [malpedia/signator-rules](https://github.com/malpedia/signator-rules)
| [YARAHQ/yara-forge](https://github.com/YARAHQ/yara-forge)
#### Alpine Linux
```
apk add bash gcc git linux-headers musl-dev openssl-dev python3 python3-dev py3-pip
```
#### Arch Linux
```
pacman -S bash gcc git python3 python-devtools python-pip
```
#### Debian / Ubuntu / Linux Mint / Kali Linux
```
apt -y install gcc git libssl-dev python3 python3-dev python3-venv
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
```
#### Rocky Linux / AlmaLinux
```
dnf -y install bash gcc git openssl-devel python3 python3-devel python3-pip
```
#### Void Linux
```
xbps-install -Sy bash gcc git openssl-devel python3 python3-devel
```
## 安装
#### 手动安装
```
git clone https://github.com/c0m4r/paranoya.git
cd paranoya
./deploy.sh
./paranoya.py --nolog --intense -p ./test
```
#### Docker
现已在 [Docker Hub](https://hub.docker.com/r/c0m4r/paranoya)
和 [Github Packages](https://github.com/c0m4r/paranoya/pkgs/container/paranoya) 上可用。
```
docker run --name paranoya -v /tmp:/tmp -p 127.0.0.1:1337:1337 -d c0m4r/paranoya
```
你也可以自己构建镜像。本仓库预置了 Docker 文件。
默认的那个基于 [官方 Python 镜像](https://hub.docker.com/_/python),
所以运行它应该很简单:
```
git clone https://github.com/c0m4r/paranoya.git
cd paranoya/addons/docker/default
docker compose up -d
```
然而,为了能够扫描 Docker 外部的任何内容,
你必须挂载一个指向特定目录的卷。
请相应地修改 docker-compose.yml。
还有其他基于不同 Linux 发行版的 [Dockerfiles](/addons/docker) 可用。
#### Flatpak
DIY flatpak-builder 文件可在[此处](/addons/flatpak)获取。
```
git clone https://github.com/c0m4r/paranoya.git
cd paranoya/addons/flatpak
./build.sh
```
一旦准备好,你就可以运行 paranoya,并传递所需的参数。
```
flatpak run org.flatpak.paranoya --intense -p ./test
```
请记住,即使设置了 `--filesystem=host`,
某些目录在 Flatpak 沙箱下是[黑名单](https://docs.flatpak.org/en/latest/sandbox-permissions.html#filesystem-access),
这会阻止 paranoya 扫描它们。
为了扫描其中之一,请使用覆盖(override)。以 /tmp 目录为例:
```
flatpak override --user --filesystem=/tmp org.flatpak.paranoya
```
#### 编译版
关于 paranoya 及其工具的二进制版本,请使用 `./build.sh` 脚本。
然而,在可能的情况下,你应该在 venv 下使用原生 Python,
因为这允许你获取最新版本的 Python 模块并保持更新,
以及查看和验证源代码。
#### Chroot
参见:[paranoya in chroot](https://github.com/c0m4r/paranoya/wiki/paranoya-in-chroot)
#### Android
参见:[paranoya on Android](https://github.com/c0m4r/paranoya/wiki/paranoya-on-Android)
#### FreeBSD
参见:[paranoya on FreeBSD](https://github.com/c0m4r/paranoya/wiki/paranoya-on-FreeBSD)
## 守护进程用法
#### 服务器
作为 daemon 启动并绑定到默认的 localhost:1337
```
./paranoya.py -d -s 20000 --noindicator --csv --nolog --intense
```
你也可以使用 `--listen-host`
和 `--listen-port` 参数更改默认绑定地址/端口。详情请查看 `--help`。
查看示例 [init 文件](/addons/etc) 以了解 OpenRC 和 systemd 集成。
#### 客户端
```
./client.py -p /path/to/scan
```
目前,服务器接受一个纯路径和一个可选的空格分隔认证密钥。
```
echo "./test" | nc localhost 1337 ; echo
echo "./test authkey" | nc localhost 1337 ; echo
```
可能的响应:
| 答复 | 级别 | 分数 |
| ------------------------------------ | ------- | ------ |
| RESULT: Indicators detected! | ALERT | >= 100 |
| RESULT: Suspicious objects detected! | WARNING | >= 60 |
| RESULT: SYSTEM SEEMS TO BE CLEAN. | NOTICE | >= 40 |
在 `--auth` 模式下,如果未发送 authkey,它将响应 `authorization required`;如果 authkey 无效,则响应 `unauthorized`。
## 新功能
* 为 Linux 重写
* 如果给定路径是文件,则进行单文件扫描
* Daemon 模式 `-d`,带有监听套接字 `--listen-host 127.0.0.1` `--listen-port 1337`
接受从 client.py 请求的扫描
* 如果在 daemon 模式下运行,会在程序目录中创建 PID 文件 `paranoya.pid`,
你可以使用 `--pidfile /path/to/pidfile` 更改其路径
* Daemon 模式下的可选认证密钥 `--auth somethingRandomHere`
(只是一个简单的字符串授权,可能会被拦截并从进程列表中读取)
* 你可以禁用一个或多个 yara 文件,例如 `--disable-yara-files apt_vpnfilter.yar,yara_mixed_ext_vars.yar`
* 按哈希排除文件,正如 [rafaelarcanjo](https://github.com/rafaelarcanjo)
在 [Neo23x0/Loki/pull/204](https://github.com/Neo23x0/Loki/pull/204) 中提议的那样。参见:[excludes.cfg](/config/excludes.cfg)
* Linux 下进程扫描的初步实现 (scan_processes_linux()):
* 文件名检查:使用 signature-base/iocs/filename-iocs.txt(注意:默认缺少 linux iocs)
* 进程连接:目前,它只显示每个进程检测到的连接
* 进程伪装检测:报告在其 cmdlines 中使用方括号的进程的非空 /proc/PID/maps
* 进度条(实验性)可以通过 --progress 启用
* 使用 --followlinks 强制 paranoya 跟随符号链接(注意:可能导致 RAM 溢出)
* 自定义 yara 规则来源
* 添加了一些额外的 YARA 规则来源,你也可以选择自己的
* 自定义 yara 规则集目录可以用 --custom signature-custom/yara/name 设置
* 为了避免规则之间的冲突,建议一次只使用一个来源
## 用法
使用 --help 运行程序以查看用法信息。
参见:[Usage](https://github.com/c0m4r/paranoya/wiki/Usage)
## 自定义签名
除了 signature-base 之外,还有一些示例
自定义签名规则集会被更新脚本拉取。
自定义签名可以作为补充独立使用,
但你应该避免混合规则来源,因为这可能导致规则之间的冲突。
使用 `--custom` 将扫描器指向存储规则的不同目录。
它将处理存储在该目录中的所有 .yar 和 .yara 文件;不要指向文件,因为那样不行。
自定义规则集的使用示例:
```
./paranoya.py --intense --progress -p ./sample/webshell/ --custom signature-custom/yara/protections-artifacts-main/
```
这些额外的自定义 YARA 规则已被证明可与 paranoya 一起工作*:
* [SupportIntelligence/Icewater](https://github.com/SupportIntelligence/Icewater)
* [intezer/yara-rules](https://github.com/intezer/yara-rules)
* [jeFF0Falltrades/YARA-Signatures](https://github.com/jeFF0Falltrades/YARA-Signatures)
* [evthehermit/YaraRules](https://github.com/kevthehermit/YaraRules)
* [MalGamy/YARA_Rules](https://github.com/MalGamy/YARA_Rules)
* [advanced-threat-research/Yara-Rules](https://github.com/advanced-threat-research/Yara-Rules)
* [securitymagic/yara](https://github.com/securitymagic/yara)
* [telekom-security/malware_analysis](https://github.com/telekom-security/malware_analysis)
* [tenable/yara-rules](https://github.com/tenable/yara-rules)
\* 这并不意味着它们实际上会检测到什么;只是说它们被 yara-python 正确处理了
## 许可证
```
paranoya: Simple IOC and YARA Scanner for Linux®
Copyright (c) 2015-2023 Florian Roth
Copyright (c) 2023-2026 c0m4r
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see 标签:Android 兼容, Client/Server 架构, Daemon 模式, Docker, Flatpak, HTTP工具, IOC 扫描器, Linux 安全工具, LOKI, Python, Triage, Webshell 检测, YARA, 云资产可视化, 后门检测, 威胁情报, 安全防御评估, 库, 应急响应, 开发者工具, 数字取证, 数据集, 文件完整性检测, 无后门, 服务器, 端点防护, 系统加固, 网络安全, 网络安全审计, 自动化脚本, 请求拦截, 逆向工具, 隐私保护