This is a simple OpenBSD daemon, based on spamlogd(8), that monitors a
pflog(4) interface for packets and inserts their details into a database
table.
This daemon is used by echoCTF to log connections to targets and award points to users, but it can easily be adapted to perform other tasks.
The setup is quite simple
- Configure a pflog(4) interface
- Add required PF rules
- Create the database table to log your packets
- Compile, install and start the service
- Profit
echo "up">/etc/hostname.pflog1
match log (to pflog1) inet proto tcp to <web_servers> port 22
mysql mydatabase<findingsd.sql
git clone https://github.com/echoctf/findingsd.git
cd findingsd
make
install -o root -g wheel -m 0555 findingsd /usr/local/sbin/findingsd
install -o root -g wheel -m 0555 findingsd.rc /etc/rc.d/findingsd
rcctl set findingsd status on
rcctl set findingsd flags -l pflog1 -n DATABASE -u USER
Run by hand and send a packet to based on your PF rules.
findingsd -D -l pflog1 -n DATABASE_NAME -u DATABASE_USER
The daemon will start printing out packets similar to the following
[Tue Jan 7 14:11:43 2020] SRC: 10.10.0.10 => DST: => 10.0.100.34:22, PROTO: tcp
Check the database table to confirm that the packets gets logged successfully.
- name: Clone findingsd repo
git:
repo: "https://github.com/echoCTF/findingsd.git"
dest: /usr/src/findingsd
clone: yes
force: yes
depth: 1
- name: Build findingsd
shell: "{{item}}"
args:
chdir: /usr/src/findingsd
with_items:
- "LDFLAGS='-lssl -lm' make"
- "install -c -s -o root -g bin -m 555 findingsd /usr/local/sbin/findingsd"
- "install -c -o root -g wheel -m 555 findingsd.rc /etc/rc.d/findingsd"
- "rcctl set findingsd status on"
- "rcctl set findingsd flags -l pflog1 -n echoCTF -u openvpn -p openvpn -h 127.0.0.1 -U _memcached"