diff options
| author | David M. Syzdek <syzdek@bindlebinaries.com> | 2019-03-13 12:19:14 -0800 |
|---|---|---|
| committer | David M. Syzdek <syzdek@bindlebinaries.com> | 2019-03-13 12:19:14 -0800 |
| commit | bdfe99510e0b70e53fa5468dc617cbd8aa190d45 (patch) | |
| tree | f7de7fa141b2e79dfca741dc281df5827d037765 | |
| parent | a750ebf17498cb93bf0199f0cb12693c1fc805bc (diff) | |
| download | bbfw-bdfe99510e0b70e53fa5468dc617cbd8aa190d45.tar.gz bbfw-bdfe99510e0b70e53fa5468dc617cbd8aa190d45.tar.bz2 bbfw-bdfe99510e0b70e53fa5468dc617cbd8aa190d45.tar.xz bbfw-bdfe99510e0b70e53fa5468dc617cbd8aa190d45.zip | |
bbfw-log: adding utility
| -rw-r--r-- | Makefile.am | 6 | ||||
| -rwxr-xr-x | src/bbfw-log.in | 131 |
2 files changed, 136 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am index 09b45a8..2935dc7 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -75,7 +75,7 @@ noinst_PROGRAMS = | |||
| 75 | bin_PROGRAMS = | 75 | bin_PROGRAMS = |
| 76 | bin_SCRIPTS = | 76 | bin_SCRIPTS = |
| 77 | pkgdata_DATA = | 77 | pkgdata_DATA = |
| 78 | sbin_SCRIPTS = src/bbfw | 78 | sbin_SCRIPTS = src/bbfw src/bbfw-log |
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | # lists | 81 | # lists |
| @@ -90,6 +90,7 @@ EXTRA_DIST = \ | |||
| 90 | README.md \ | 90 | README.md \ |
| 91 | doc/slack-desc \ | 91 | doc/slack-desc \ |
| 92 | src/bbfw.in \ | 92 | src/bbfw.in \ |
| 93 | src/bbfw-log.in \ | ||
| 93 | src/firewall.d/global.d/rules-example \ | 94 | src/firewall.d/global.d/rules-example \ |
| 94 | src/firewall.d/global.d/rules4-example \ | 95 | src/firewall.d/global.d/rules4-example \ |
| 95 | src/firewall.d/global.d/rules6-example \ | 96 | src/firewall.d/global.d/rules6-example \ |
| @@ -159,6 +160,9 @@ include $(srcdir)/@bindletools_srcdir@/build-aux/makefile-version.am | |||
| 159 | src/bbfw: Makefile src/bbfw.in | 160 | src/bbfw: Makefile src/bbfw.in |
| 160 | @$(do_subst_fn) | 161 | @$(do_subst_fn) |
| 161 | 162 | ||
| 163 | src/bbfw-log: Makefile src/bbfw-log.in | ||
| 164 | @$(do_subst_fn) | ||
| 165 | |||
| 162 | src/rc.firewall: Makefile src/rc.firewall.in | 166 | src/rc.firewall: Makefile src/rc.firewall.in |
| 163 | @$(do_subst_fn) | 167 | @$(do_subst_fn) |
| 164 | 168 | ||
diff --git a/src/bbfw-log.in b/src/bbfw-log.in new file mode 100755 index 0000000..26acb43 --- /dev/null +++ b/src/bbfw-log.in | |||
| @@ -0,0 +1,131 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # Bindle Binaries Linux Firewall | ||
| 4 | # Copyright (c) 2019 David M. Syzdek <david@syzdek.net>. | ||
| 5 | # | ||
| 6 | # Redistribution and use in source and binary forms, with or without | ||
| 7 | # modification, are permitted provided that the following conditions are | ||
| 8 | # met: | ||
| 9 | # | ||
| 10 | # * Redistributions of source code must retain the above copyright | ||
| 11 | # notice, this list of conditions and the following disclaimer. | ||
| 12 | # * Redistributions in binary form must reproduce the above copyright | ||
| 13 | # notice, this list of conditions and the following disclaimer in the | ||
| 14 | # documentation and/or other materials provided with the distribution. | ||
| 15 | # * Neither the name of David M. Syzdek nor the | ||
| 16 | # names of its contributors may be used to endorse or promote products | ||
| 17 | # derived from this software without specific prior written permission. | ||
| 18 | # | ||
| 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS | ||
| 20 | # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| 21 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
| 22 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID M. SYZDEK BE LIABLE FOR | ||
| 23 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 24 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| 25 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
| 26 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
| 27 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
| 28 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 29 | # SUCH DAMAGE. | ||
| 30 | # | ||
| 31 | |||
| 32 | |||
| 33 | ############### | ||
| 34 | # ENVIRONMENT # | ||
| 35 | ############### | ||
| 36 | |||
| 37 | PATH=/usr/bin:/bin:/usr/sbin:/sbin | ||
| 38 | export PATH | ||
| 39 | |||
| 40 | |||
| 41 | # sets script/package information | ||
| 42 | PROG_NAME="$(basename "${0}")" | ||
| 43 | PACKAGE_NAME="$(echo '@PACKAGE_NAME@' |sed -e 's/[@].*[@]/ /g')" | ||
| 44 | PACKAGE_VERSION="$(echo '@PACKAGE_VERSION@' |sed -e 's/[@].*[@]/ /g')" | ||
| 45 | PACKAGE_BUGREPORT="$(echo '@PACKAGE_BUGREPORT@' |sed -e 's/[@].*[@]/ /g')" | ||
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | ############# | ||
| 50 | # FUNCTIONS # | ||
| 51 | ############# | ||
| 52 | |||
| 53 | usage() | ||
| 54 | { | ||
| 55 | printf "Usage: ${PROG_NAME} [OPTIONS]\n" | ||
| 56 | printf "OPTIONS:\n" | ||
| 57 | printf " -h, --help print this help and exit\n" | ||
| 58 | printf " -k, --kerneltime print kernel timestamp\n" | ||
| 59 | printf " -n, --notime do not print timestamp\n" | ||
| 60 | printf " -t, --timestamp print human readable timestamp\n" | ||
| 61 | printf " -v, --version print version and exit\n" | ||
| 62 | printf " -w, --follow wait for new messages\n" | ||
| 63 | printf "\n" | ||
| 64 | printf "Please send bug reports to ${PACKAGE_BUGREPORT}.\n" | ||
| 65 | } | ||
| 66 | |||
| 67 | |||
| 68 | version() | ||
| 69 | { | ||
| 70 | printf "${PROG_NAME} (${PACKAGE_NAME}) ${PACKAGE_VERSION}\n" | ||
| 71 | printf "\n" | ||
| 72 | printf "Please send bug reports to ${PACKAGE_BUGREPORT}.\n" | ||
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | ############ | ||
| 77 | ### MAIN ### | ||
| 78 | ############ | ||
| 79 | |||
| 80 | DMESG_TIME="-T" | ||
| 81 | DMESG_FOLLOW="" | ||
| 82 | DMESG_PATTERN=" IN=[-.:/a-zA-Z0-9]{0,} OUT=[-.:/a-zA-Z0-9]{0,} MAC=[:a-fA-F0-9]{0,} SRC=[:.0-9a-fA-F]{0,} DST=[:.0-9a-fA-F]{0,} " | ||
| 83 | |||
| 84 | while true; do | ||
| 85 | case "$@" in | ||
| 86 | -h|--help) usage; exit 0;; | ||
| 87 | -k|--kerneltime) DMESG_TIME=""; shift ;; | ||
| 88 | -n|--notime) DMESG_TIME="-t"; shift ;; | ||
| 89 | -t|--timestamp) DMESG_TIME="-T"; shift ;; | ||
| 90 | -v|--version) version; exit 0;; | ||
| 91 | -w|--follow) DMESG_FOLLOW="-w"; shift ;; | ||
| 92 | "") break ;; | ||
| 93 | --) shift; break ;; | ||
| 94 | *) usage; exit 1 ;; | ||
| 95 | esac | ||
| 96 | done | ||
| 97 | |||
| 98 | |||
| 99 | /bin/dmesg ${DMESG_TIME} ${DMESG_FOLLOW} \ | ||
| 100 | |egrep "${DMESG_PATTERN}" \ | ||
| 101 | |sed \ | ||
| 102 | -e 's/[^[:graph:]]/ /g' \ | ||
| 103 | -e 's/ip6tables drop: /,in,/g' \ | ||
| 104 | -e 's/ip6tables input: /,in,/g' \ | ||
| 105 | -e 's/ip6tables forward: /,fwd,/g' \ | ||
| 106 | -e 's/ip6tables output: /,out,/g' \ | ||
| 107 | -e 's/ip6tables blackhole: /,blkhol,/g' \ | ||
| 108 | -e 's/ip6tables \([-_a-z0-9:;,]\{1,\}\): /,\1,/gi' \ | ||
| 109 | -e 's/[[:space:][:cntrl:]]\{1,\}/ /g' \ | ||
| 110 | -e 's/ [[:upper:]]\{1,\} / /g' \ | ||
| 111 | -e 's/ MAC=[:[:xdigit:]]\{1,\} / /g' \ | ||
| 112 | -e 's/ ID=[[:digit:]]\{1,\} / /g' \ | ||
| 113 | -e 's/ TTL=[[:digit:]]\{1,\} / /g' \ | ||
| 114 | -e 's/ LEN=[[:digit:]]\{1,\} / /g' \ | ||
| 115 | -e 's/ URGP=[[:digit:]]\{1,\} / /g' \ | ||
| 116 | -e 's/ WINDOW=[[:digit:]]\{1,\} / /g' \ | ||
| 117 | -e 's/ PREC=0x[[:xdigit:]]\{1,\} / /g' \ | ||
| 118 | -e 's/ RES=0x[[:xdigit:]]\{1,\} / /g' \ | ||
| 119 | -e 's/ TOS=0x[[:xdigit:]]\{1,\} / /g' \ | ||
| 120 | -e 's/ ACK / /g' \ | ||
| 121 | -e 's/ CWR / /g' \ | ||
| 122 | -e 's/ DF / /g' \ | ||
| 123 | -e 's/ ECE / /g' \ | ||
| 124 | -e 's/ RST / /g' \ | ||
| 125 | -e 's/ SYN / /g' \ | ||
| 126 | -e 's/ PSH / /g' \ | ||
| 127 | -e 's/ \([A-Z]\{1,\}=\)/,\1/g' \ | ||
| 128 | |column -t -s ',' | ||
| 129 | |||
| 130 | |||
| 131 | # End of scripts | ||
