|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Making tests of BForce
|
|
|
|
CURDIR=$(pwd)
|
|
|
|
BFBIN=$(pwd)/../source/bin/bforce
|
|
|
|
|
|
|
|
function prepconfig() {
|
|
|
|
echo "Preparing configs with $1 as protocol..."
|
|
|
|
cp ${CURDIR}/configs/bforceA.conf ${CURDIR}/etc/bforceA.conf
|
|
|
|
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/etc/bforceA.conf
|
|
|
|
sed -i -e "s#%TESTZONE%#${CURDIR}#" ${CURDIR}/etc/bforceA.conf
|
|
|
|
|
|
|
|
cp ${CURDIR}/configs/bforceB.conf ${CURDIR}/etc/bforceB.conf
|
|
|
|
sed -i -e "s/%PROTO%/$1/" ${CURDIR}/etc/bforceB.conf
|
|
|
|
sed -i -e "s#%TESTZONE%#${CURDIR}#" ${CURDIR}/etc/bforceB.conf
|
|
|
|
|
|
|
|
cp ${CURDIR}/configs/00010002.cut ${CURDIR}/outboundA/00010002.cut
|
|
|
|
cp ${CURDIR}/configs/00010001.cut ${CURDIR}/outboundB/00010001.cut
|
|
|
|
}
|
|
|
|
|
|
|
|
function testcomm() {
|
|
|
|
rm -rf ${CURDIR}/inboundA/*
|
|
|
|
rm -rf ${CURDIR}/inboundB/*
|
|
|
|
|
|
|
|
mkfifo ${CURDIR}/bforceAtoB
|
|
|
|
mkfifo ${CURDIR}/bforceBtoA
|
|
|
|
|
|
|
|
BFCFGA=${CURDIR}/etc/bforceA.conf
|
|
|
|
BFCFGB=${CURDIR}/etc/bforceB.conf
|
|
|
|
|
|
|
|
# Works for Linux
|
|
|
|
|
|
|
|
BFCONFIG=${BFCFGA}
|
|
|
|
BFCONFIG=${BFCFGA} ${BFBIN} -o 99:1/2 > ${CURDIR}/bforceAtoB < ${CURDIR}/bforceBtoA &
|
|
|
|
#
|
|
|
|
|
|
|
|
BFCONFIG=${BFCFGB}
|
|
|
|
BFCONFIG=${BFCFGB} ${BFBIN} -S"CONNECT 9600" auto < ${CURDIR}/bforceAtoB > ${CURDIR}/bforceBtoA
|
|
|
|
|
|
|
|
# For [Free]BSD it need to be replaced - pipes are bidirectional:
|
|
|
|
# ./ping <&1 | ./pong >&0
|
|
|
|
|
|
|
|
rm ${CURDIR}/{bforceAtoB,bforceBtoA}
|
|
|
|
|
|
|
|
## WE MUST CHECK THAT INBOUND ARE FULL!!! ##
|
|
|
|
FCNTA=$( find ${CURDIR}/inboundA -name *.pkt | wc -l )
|
|
|
|
FCNTB=$( find ${CURDIR}/inboundB -name *.pkt | wc -l )
|
|
|
|
DIFFA=$( diff ${CURDIR}/inboundA/*.pkt ${CURDIR}/configs/00010001.cut && echo $? )
|
|
|
|
DIFFB=$( diff ${CURDIR}/inboundB/*.pkt ${CURDIR}/configs/00010002.cut && echo $? )
|
|
|
|
|
|
|
|
if [[ "${DIFFA}" -eq "0" ]] && [[ "${FCNTA}" -eq "1" ]]
|
|
|
|
then
|
|
|
|
if [[ "${DIFFB}" -eq "0" ]] && [[ "${FCNTB}" -eq "1" ]]
|
|
|
|
then
|
|
|
|
echo "....Result: OK"
|
|
|
|
else
|
|
|
|
echo "....Failed DiffB"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "....Failed DiffA"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat ${CURDIR}/logsA/bf-debug >> ${CURDIR}/debugA.log
|
|
|
|
cat ${CURDIR}/logsB/bf-debug >> ${CURDIR}/debugB.log
|
|
|
|
}
|
|
|
|
|
|
|
|
if [[ ! -d "${CURDIR}/inboundA" ]]
|
|
|
|
then
|
|
|
|
echo "All clear to begin"
|
|
|
|
else
|
|
|
|
echo "Dir exists!"
|
|
|
|
rm -rf {etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB}
|
|
|
|
fi
|
|
|
|
mkdir -p "${CURDIR}"/{etc,inbound-unsecureA,inbound-unsecureB,inboundA,inboundB,logsA,logsB,outboundA,outboundB}
|
|
|
|
|
|
|
|
if [[ ! -f "${BFBIN}" ]]
|
|
|
|
then
|
|
|
|
# No executable to test!
|
|
|
|
echo "No executable to run! Aborting..."
|
|
|
|
else
|
|
|
|
# All doing here
|
|
|
|
echo "Bforce executable found"
|
|
|
|
|
|
|
|
prepconfig "ZMO"
|
|
|
|
echo -n "--> Running ZMO test..."
|
|
|
|
testcomm
|
|
|
|
|
|
|
|
prepconfig "ZAP"
|
|
|
|
echo -n "--> Running ZAP test..."
|
|
|
|
testcomm
|
|
|
|
|
|
|
|
prepconfig "HYD"
|
|
|
|
echo -n "--> Running Hydra test..."
|
|
|
|
testcomm
|
|
|
|
|
|
|
|
# TODO: make binkd test over netcat possibly
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rm -rf {etc,inboundA,inboundB,inbound-unsecureA,inbound-unsecureB,logsA,logsB,outboundA,outboundB}
|