/usr/sbin/fiaif-scan is in fiaif 1.23.1-4.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | #!/bin/bash
#
# FIAIF is an Intelligent firewall
#
# description: Convert syslog entries logged by FIAIF to human readable form.
#
# Script Author:	Anders Fugmann <afu at fugmann dot net>
# 
# FIAIF is an Intelligent firewall
# Copyright (C) 2002-2011 Anders Peter Fugmann
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
shopt -s extglob
source /usr/share/fiaif/constants.sh
source /etc/fiaif/fiaif.conf 
source /usr/share/fiaif/iptables.sh
source /usr/share/fiaif/functions.sh
source /usr/share/fiaif/zones.sh
function scan ()
{
    local LINE="$@"
    local REASON DATE DEV_IN DEV_OUT MAC SRC DST PROTO SPT DPT TYPE TCP_FLAGS
    declare -a TMP_ARRAY=( $@ )
    DATE="${TMP_ARRAY[0]} ${TMP_ARRAY[1]} ${TMP_ARRAY[2]}"
    REASON=${TMP_ARRAY[5]%:*}
    DEV_IN=${TMP_ARRAY[5]#*=}
    DEV_OUT=${TMP_ARRAY[6]#*=}
    local I
    TCP_FLAGS=""
    for (( I=8;I<${#TMP_ARRAY[*]};I++ )); do
	# Dont process ICMP packets
	if [[ -z "${TMP_ARRAY[I]%[*}" ]]; then
	    break
	fi
	if [[ "${TMP_ARRAY[I]%=*}" != "${TMP_ARRAY[I]#*=}" ]]; then
	    declare "${TMP_ARRAY[I]%=*}"="${TMP_ARRAY[I]#*=}" 
	else
	    if [[ "${TMP_ARRAY[I]}" != "DF" ]]; then 
		TCP_FLAGS="${TCP_FLAGS}${TMP_ARRAY[I]} "
	    fi
	fi
    done
    echo -ne "$DATE: ${REASON} queue="
    #Convert device to zones.
    get_zone_name ${DEV_IN} ${SRC}
    ZONE_IN=${RESULT}
    get_zone_name ${DEV_OUT} ${DST}
    ZONE_OUT=${RESULT}
    local CHAIN 
    if [[ -n "${DEV_IN}" ]]; then 
	if [[ -n "${DEV_OUT}" ]]; then
	    CHAIN="FORWARD"
	    echo -n "FORWARD(${ZONE_IN}->${ZONE_OUT})" 
	else 
	    echo -n "INPUT(${ZONE_IN})" 
	    CHAIN="INPUT"
	fi	
    elif [[ -n "${DEV_OUT}" ]]; then
	CHAIN="OUTPUT"
        echo -n "OUTPUT(${ZONE_OUT})" 
    fi
    if [[ -n "${PROTO}" ]]; then
	echo -n " protocol=${PROTO}"
    fi
    if (( RESOLVE == 1 )); then
    	get_host_name ${SRC}
    	SRC=${RESULT}
    	get_host_name ${DST}
    	DST=${RESULT}
    fi
    if (( SERVICE == 1 )) && [[ "${PROTO}" == "TCP" || "${PROTO}" == "UDP" ]]; then
	    get_service_name ${PROTO} ${SPT} 
	    SPT=${RESULT}	
	    get_service_name ${PROTO} ${DPT} 
	    DPT=${RESULT}
    fi
    
    if [[ -n "${SRC}" ]]; then
	echo -n " source=${SRC}"
	if [[ -n "${SPT}" ]]; then
	    echo -n ":${SPT}"
	fi
    fi
    if [[ -n "${DST}" ]]; then
	echo -n " destination=${DST}"
	if [[ -n "${DPT}" ]]; then
	    echo -n ":${DPT}"
	fi
    fi
        
    if [[ "${PROTO}" == "TCP" ]]; then
        echo -n " flags='${TCP_FLAGS}'"
    fi
    if [[ "${PROTO}" == "ICMP" ]]; then
	echo -n " type=${TYPE}"
    fi
    if (( PRINT_MAC == 1 )); then 
	echo -n " mac: ${MAC}"
    fi
    
    echo
}
# Damn bash. We really needed this to be in a function, but declare 
# only declares locally to functions.
for ZONE in ${ZONES}; do
    read_zone ${ZONE}
    if (( $? != 0 )); then
	continue
    fi
    declare ${ZONE}_DEV="${DEV}"
    declare ${ZONE}_IP="${IP}"
    declare ${ZONE}_DYNAMIC="${DYNAMIC}"
    declare ${ZONE}_BCAST="${BCAST}"
    declare ${ZONE}_NETS="${NET} ${NET_EXTRA}"	
done
RESOLVE=1
SERVICE=0
PRINT_MAC=0
for OPTION in $@; do
    case ${OPTION} in
	-n)
	    RESOLVE=0
	    SERVICE=0
	    ;;
	-m)
	    PRINT_MAC=1
	    ;;
	-s)
	    SERVICE=1
	    RESOLVE=0
	    ;;
    esac
done
# Main loop.
grep -e "[A-Z_]*: *IN=" | while read line; do
    scan $line
done
 |