Open wrharding opened 2 years ago
With guidance I was able to find the segfault was caused by a rule being triggered in Sagan. Note, Sagan v2.0.2 was being utilized with the CURRENT rule set and a protocol.map file from December 2021. After recompiling with the current most up to date version of Sagan a new error occurs on a smaller set of sample data (local auth.log file):
[*]
[*] Successfully opened uncompressed file /auth.log.... processing events.....
[*] Waiting on 49/50 threads....
Thread 47 "SaganProcessor" received signal SIGSEGV, Segmentation fault.
[Switching to LWP 844]
0x0000561583319baa in Format_JSON_Alert_EVE (Event=Event@entry=0x7f07d6b0c040, str=str@entry=0x7f07111db650 "", size=size@entry=32768) at json-handler.c:55
55 {
(gdb) bt
#0 0x0000561583319baa in Format_JSON_Alert_EVE (Event=Event@entry=0x7f07d6b0c040, str=str@entry=0x7f07111db650 "", size=size@entry=32768) at json-handler.c:55
#1 0x0000561583306e22 in Output (Event=0x7f07d6b0c040) at output.c:81
#2 0x0000561583309006 in Send_Alert (SaganProcSyslog_LOCAL=0x7f072a925720, rule_position=544, tp=..., bluedot_json=0x7f0729db0180 "", bluedot_results=<optimized out>, GeoIP_SRC=0x0, GeoIP_DEST=0x0)
at send-alert.c:104
#3 0x000056158331fc36 in Sagan_Engine (SaganProcSyslog_LOCAL=0x7f072a925720, JSON_LOCAL=0x7f07222de8c0, dynamic_rule_flag=false) at processors/engine.c:1364
#4 0x000056158330727e in Processor () at processor.c:224
#5 0x00007f07d7cb61f5 in ?? () from /lib/ld-musl-x86_64.so.1
#6 0x0000000000000000 in ?? ()
Example data:
127.0.0.1|user|debug|debug|localhost|2022-09-09T05:01:00Z|2022-09-09T01:01:00|sudo|root : TTY=pts/1 ; PWD=/ ; USER=root ; COMMAND=list
127.0.0.1|user|debug|debug|localhost|2022-09-09T05:01:00Z|2022-09-09T01:01:00|sudo|sudo: wharding : TTY=pts/5 ; PWD=/home/wharding/Projects/sagan-docker ; USER=root ; COMMAND=/bin/bash
I was able to ingest upwards of 10 million lines of logs from a ~75 million log file for a segfault occurred. Note, the example data above does not contain the prerequisite space needed by Sagan. New example data should be like so:
127.0.0.1|user|debug|debug|localhost|2022-09-09T05:01:00Z|2022-09-09T01:01:00|sudo| root : TTY=pts/1 ; PWD=/ ; USER=root ; COMMAND=list
127.0.0.1|user|debug|debug|localhost|2022-09-09T05:01:00Z|2022-09-09T01:01:00|sudo| sudo: wharding : TTY=pts/5 ; PWD=/home/wharding/Projects/sagan-docker ; USER=root ; COMMAND=/bin/bash
When attempting to read in the BTV's Project Obsidian logs the syslog headers will need to be included in the JSON. See the following Sagan docs for details on what needs to be included.
Attempting to load in fake data from Blue Team Village's Project Obsideian from DC30 results in a core dump:
Segmentation fault (core dumped)
The container is run with the following parameters:
sudo docker run -dit --name sagan-docker -v /home/wharding/Downloads/DC30/Obsidian/filebeat/:/mnt/filebeat/ sagan-docker:0.3.0
Sagan is run with the following parameters:
/var/log/sagan # sagan -u root -F /mnt/filebeat/hmail-2022.02.12.log -d engine,syslog
The last few lines before segfault(note, I can't see the segfault thanks to a lack of dmesg utility):