Skip to content

Instantly share code, notes, and snippets.

@libcrack
Created May 12, 2024 14:24
Show Gist options
  • Save libcrack/c67f0e3bffc5b0a3ff032e199d212600 to your computer and use it in GitHub Desktop.
Save libcrack/c67f0e3bffc5b0a3ff032e199d212600 to your computer and use it in GitHub Desktop.
Script to extract allow and deny lists from pfblockerng in pfSense boxes
#!/bin/sh
# devnull@libcrack.so
# Mon Sep 9 21:30:51 CEST 2019
denylist=/root/dnsbl.deny
allowlist=/root/dnsbl.allow
allowtmp=/tmp/dnsbl_tmp.sup
logfile=/var/log/pfblockerng/dnsbl.log
if [ ! -f "${logfile}" ]; then
echo "ERROR: Cannot access ${logfile}"
exit 1
fi
if [ ! -f "${allowtmp}" ]; then
echo "ERROR: Cannot access ${allowtmp}"
exit 2
fi
/bin/cat "${logfile}" | /usr/bin/cut -f3 -d, | /usr/bin/sort -u > "${denylist}"
/bin/cat "${allowtmp}" | /usr/bin/cut -f2 -d\" | /usr/bin/cut -f1 -d' ' | /usr/bin/sort -u > "${allowlist}"
/usr/bin/wc -l "${denylist}"
/usr/bin/wc -l "${allowlist}"
exit ${?}
#EOF#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment