#!/bin/bash # # audiodata_sense v0.1 - detects incoming audio data from the 'Net # Written by Robert Pectol # rob@pectol.com # http://rob.pectol.com/irlp/ # # This script returns a, "1" if there is audio data coming in from the # 'Net when it is executed, else it returns a , "0". # # * NOTE * # This script requires that your /etc/sudoers file contains the following # line: # # repeater ALL= NOPASSWD: /sbin/iptables # # This MUST be accomplished by editing /etc/sudoers with the, 'visudo' # command as user, root. # ############################################################################## # establish packet marking for incoming audio data only if ! ( sudo /sbin/iptables -t mangle --list -nv | grep '0x2' > /dev/null 2>&1 ); then sudo /sbin/iptables -t mangle -A INPUT -p udp --dport 2074:2093 -m length --length 128:640 -j MARK --set-mark 2 fi # reset the packet counters and inspect the number of marked packets between intervals and see if they are different sudo /sbin/iptables -t mangle --zero pass=0 firstvalue=0 secondvalue=0 while [[ "$pass" -lt "3" && "$secondvalue" == "$firstvalue" ]]; do let firstvalue=`sudo /sbin/iptables -t mangle --list -nv | grep '0x2' | awk '{$1=$1;print}' | cut -d ' ' -f1` usleep 80000 let secondvalue=`sudo /sbin/iptables -t mangle --list -nv | grep '0x2' | awk '{$1=$1;print}' | cut -d ' ' -f1` pass=$(($pass + 1)) done # set the activity flag based upon the inspected packet counts if [ "$secondvalue" -gt "$firstvalue" ]; then data_in=1 else data_in=0 fi # return the flag value echo $data_in exit 0