LilithSec/Lilith

GitHub: LilithSec/Lilith

将 Suricata 和 Sagan 的 EVE 日志存入 PostgreSQL 并提供多维度搜索查询的轻量级安全事件聚合工具。

Stars: 1 | Forks: 1

# Lilith Lilith 读取来自 Suricata 和 Sagan 的 EVE 文件并存入 PostgreSQL。 随后可以搜索这些数据并获取特定事件的信息。 ## 安装 ### Debian ``` apt-get install zlib1g-dev cpanminus libjson-perl libtoml-perl \ libdbi-perl libfile-readbackwards-perl libdigest-sha-perl libpoe-perl \ libfile-slurp-perl libdbd-pg-perl cpanm Lilith ``` ### FreeBSD ``` pkg install p5-App-cpanminus p5-JSON p5-TOML p5-DBI \ p5-File-ReadBackwards p5-Digest-SHA p5-POE \ p5-MIME-Base64 p5-Gzip-Faster p5-DBD-Pg p5-File-Slurp cpanm Lilith ``` ### 源码 ``` perl Makefile.PL make make test make install ``` ## 设置 首先你需要设置你的 PostgreSQL 服务器。 ``` createuser -D -l -P -R -S lilith createdb -E UTF8 -O lilith lilith ``` 设置 `/usr/local/etc/lilith.toml` ``` dsn="dbi:Pg:dbname=lilith;host=192.168.1.2" pass="WhateverYouSetAsApassword" user="lilith" # 用于 extend 时方便忽略的一个选项,因为它会产生大量信息 class_ignore=["Generic Protocol Command Decode"] # 添加一个 suricata 实例进行监控 [suricata-eve] instance="foo-pie" type="suricata" eve="/var/log/suricata/alert.json" # 添加第二个 suricata 实例进行监控 [another-eve] instance="foo2-pie" type="suricata" eve="/var/log/suricata/alert2.json" # 添加一个 sagan eve 进行监控 # 实例名称为 'foo-lae',因为实例没有值 [foo-lae] type="sagan" eve="/var/log/sagan/alert.json" ``` 现在我们只需要设置表。 ``` lilith -a create_tables ``` 如果使用 snmpd。 ``` extend lilith /usr/local/bin/lilith -a extend ``` ### 配置文件 默认配置文件是 `/usr/local/etc/lilith.toml`。 | 变量 | 描述 | |--------------|------------------------------------------------------------------------------------------------------------------------| | dsn | [DBI][https://metacpan.org/pod/DBI] 使用的 DSN 连接字符串。[DBD::Pg][https://metacpan.org/pod/DBD::Pg] | | pass | 用于连接的密码。 | | user | 用于连接的用户。 | | class_ignore | 要忽略的类数组。 | 子哈希随后被视为一个实例。以下值可用于该实例。 | 变量 | 必需 | 描述 | |----------|------|----------------------------------------------------| | eve | 是 | 要跟踪的 EVE 文件。 | | type | 是 | `sagan` 或 `suricata`,取决于它是哪种。 | | instance | 否 | 实例的名称。如果未指定,则使用哈希名称。 | ## 选项 ### 概要 lilith \[-c \\] -a run lilith -a class_map lilith \[-c \\] -a create_tables lilith \[-c \\] -a dump_self lilith \[-c \\] -a event \[-t \\] --id \ \[--raw\] \[\[--virani \\] \[--pcap \\] \[--buffer \\]\] lilith \[-c \\] -a event \[-t \\] --event \ \[--raw\] \[\[--virani \\] \[--pcap \\] \[--buffer \\]\] lilith \[-c \\] -a extend \[-Z\] \[-m \\] lilith -a generate_baphomet_yamls --dir \ lilith \[-c \\] -a get_short_class_snmp_list lilith \[-c \\] -a search \[--output \\] \[-t \\] \[-m \\] \[--order \\] \[--limit \\] \[--offset \\] \[--orderdir \\] \[--si \\] \[--di \\] \[--ip \\] \[--sp \\] \[--dp \\] \[--port \\] \[--host \\] \[--hostl\] \[--hosN\] \[--ih \\] \[--ihl\] \[--ihN\] \[-i \\] \[-il\] \[-iN\] \[-c \\] \[--cl\] \[--cN\] \[-s \\] \[--sl\] \[--sN\] \[--if \\] \[--ifl\] \[--ifN\] \[--ap \\] \[--apl\] \[--apN\] \[--gid \\] \[--sid \\] \[--rev \\] ### 通用开关 #### -a 要执行的动作。 ``` - Default :: search ``` #### -c 要使用的配置文件。 ``` - Default :: /usr/local/etc/lilith.toml ``` #### -t 要操作的表。 ``` - Default :: suricata ``` ### 动作 #### 运行 开始处理 EVE 日志并守护进程化。 #### class_map 打印从长名称到搜索结果显示中使用的短名称的类映射表。 #### create_tables 在数据库中创建表。 #### dump_self 初始化 Lilith 然后通过 Data::Dumper 将其转储。 #### 事件 获取事件。可以通过 -t 指定要使用的表。 ##### --id 通过行 ID 获取事件。 ##### --event 通过事件 ID 获取事件。 ##### --raw 不解码 EVE JSON。 ##### --pcap 通过 Virani 获取远程 PCAP 并将其写入文件。仅适用于 Suricata 表。 默认值 :: undef ##### --virani 传递给 -r 的 Virani 设置。 默认值 :: 告警中的实例名称 ##### --buffer 在开始和结束时间上填充多少秒。 默认值 :: 60 #### extend 打印 LibreNMS 风格的扩展。 ##### -Z 启用 Gzip+Base64 LibreNMS 风格的扩展压缩。 ##### -m 搜索多长时间之前的数据。对于 extend 动作,默认为 5 分钟。 #### generate_baphomet_yamls 为 Baphomet 生成 YAML。 ##### -d 输出到的目录。 #### get_short_class_snmp_list 打印用于 SNMP 的短类名列表。 #### 搜索 搜索数据库。可以通过 -t 指定表。 常见的搜索选项类型如下。 ``` - Integer :: A comma seperated list of integers to check for. Any number prefixed with a ! will be negated. - String :: A string to check for. May be matched using like or negated via the proper options. - Complex :: A item to match. ``` ##### 通用搜索选项 ###### --output 输出类型。 ``` - Values :: table,json - Default :: table ``` ###### -m 回溯多少分钟。 ``` - Default :: 1440 - Default, extend :: 5 ``` ###### --order 用于排序的列。 ``` - Default :: timestamp ``` ###### --orderdir 排序方向。 ``` - Values :: ASC,DSC - Default :: ASC ``` ##### IP 选项 ###### --si 源 IP。 ``` - Default :: undef - Type :: string ``` ###### --di 目标 IP。 ``` - Default :: undef - Type :: string ``` ###### --ip IP,目标或源。 ``` - Default :: undef - Type :: complex ``` ##### 端口选项 ###### --sp 源端口。 ``` - Default :: undef - Type :: integer ``` ###### --dp 目标端口。 ``` - Default :: undef - Type :: integer ``` ###### -p 端口,目标或源。 ``` - Default :: undef - Type :: complex ``` ##### 主机选项 ``` Sagan :: Host is the sending system and instance host is the host the instance is running on. Suricata :: Host is the system the instance is running on. There is no instance host. ``` ###### --host 主机。 ``` - Default :: undef - Type :: string ``` ###### --hostl 使用 like 匹配主机。 ``` - Default :: undef ``` ###### --hostN 反转主机匹配。 ``` - Default :: undef ``` ##### 实例选项 ###### --ih 实例主机。 ``` - Default :: undef - Type :: string ``` ###### --ihl 使用 like 匹配实例主机。 ``` - Default :: undef ``` ###### --ihN 反转实例主机匹配。 ``` - Default :: undef ``` ##### 实例选项 =head4 -i 实例。 ``` - Default :: undef - Type :: string ``` ###### --il 使用 like 匹配实例。 ``` - Default :: undef ``` ###### --iN 反转实例匹配。 ``` - Default :: undef ``` ##### 类选项 ###### -c 分类。 ``` - Default :: undef - Type :: string ``` ###### --cl 使用 like 匹配分类。 ``` - Default :: undef ``` ###### --cN 反转分类匹配。 ``` - Default :: undef ``` ##### 签名选项 ###### -s 签名。 ``` - Default :: undef - Type :: string ``` ###### --sl 使用 like 匹配签名。 ``` - Default :: undef ``` ###### --sN 反转签名匹配。 ``` - Default :: undef ``` ##### 入接口选项 ###### --if 接口。 ``` - Default :: undef - Type :: string ``` ###### --ifl 使用 like 匹配接口。 ``` - Default :: undef ``` ###### --ifN 反转接口匹配。 ``` - Default :: undef ``` ##### 应用协议选项 ###### --ap 应用协议。 ``` - Default :: undef - Type :: string ``` ###### --apl 使用 like 匹配应用协议。 ``` - Default :: undef ``` ###### --apN 反转应用协议匹配。 ``` - Default :: undef ``` ##### 规则选项 ###### --gid GID。 ``` - Default :: undef - Type :: integer ``` ###### --sid SID。 ``` - Default :: undef - Type :: integer ``` ###### --rev Rev。 ``` - Default :: undef - Type :: integer ``` ## 环境变量 ### Lilith_table_color 要使用的 L 表颜色。 ``` - Default :: Text::ANSITable::Standard::NoGradation ``` ### Lilith_table_border 要使用的 L 边框类型。 ``` - Default :: ASCII::None ``` ### Lilith_IP_color Perl 布尔值,用于判断 IP 是否应着色。 ``` - Default :: 1 ``` ### Lilith_IP_private_color 用于私有 IP 的 ANSI 颜色。 ``` - Default :: bright_green ``` ### Lilith_IP_remote_color 用于远程 IP 的 ANSI 颜色。 ``` - Default :: bright_yellow ``` ### Lilith_IP_local_color 用于本地 IP 的 ANSI 颜色。 ``` - Default :: bright_red ``` ### Lilith_timesamp_drop_micro Perl 布尔值,用于判断是否应去掉微秒。 ``` - Default :: 1 ``` ### Lilith_instance_color Lilith 实例列信息是否应着色。 ``` - Default :: 1 ``` ### Lilith_instance_type_color 实例名称的颜色。 ``` - Default :: bright_blue ``` ### Lilith_instance_slug_color 实例 slug 的颜色。 ``` - Default :: bright_magenta ``` ### Lilith_instance_loc_color 实例 loc 的颜色。 ``` - Default :: bright_cyan. ```
标签:AMSI绕过, CPAN, DBI, EVE JSON, Metaprompt, OISF, Perl, PostgreSQL, Python安全, Sagan, SecOps, SIEM工具, Suricata, 云安全架构, 威胁检测, 安全运营, 扫描框架, 数据库存储, 数据摄取, 日志搜索, 日志管理, 日志解析, 测试用例, 现代安全运营, 网络安全, 证书伪造, 隐私保护