jablonka.czprosek.czf

wifimon

Subversion Repositories:
[/] [trunk/] [wifimon] - Diff between revs 19 and 20

Show entire file Ignore whitespace

Rev 19 Rev 20
Line 2... Line 2...
# authors : Petr Simandl www.simandl.cz # authors : Petr Simandl www.simandl.cz
# : Fyzik, Covex, Tydyt # : Fyzik, Covex, Tydyt
# release date : 11/09/2005 # release date : 09/09/2005
# name : wifimon # name : wifimon
# description : hostap and madwifi powered card monitoring # description : hostap powered wifi card monitoring
# license : GPL # license : GPL
######################################################################  
   
wl_version="0.5.5" wl_version="0.5.5pre1"
   
######################################################################  
#custom settings  
   
PATH=$PATH:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:usr/local/bin:/usr/local/sbin PATH=$PATH:$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:usr/local/bin:/usr/local/sbin
   
wl_iwccmd=`which iwconfig` wl_iwccmd=`which iwconfig`
wl_iwlcmd=`which iwlist`  
wl_ifccmd=`which ifconfig` wl_ifccmd=`which ifconfig`
wl_hnmcmd=`which hostname` wl_hnmcmd=`which hostname`
wl_awkcmd=`which awk` wl_awkcmd=`which awk`
   
wl_tptcmde="" wl_tptcmde=""
Line 30... Line 25...
wl_dhcpcnf="/etc/dhcpd.conf" wl_dhcpcnf="/etc/dhcpd.conf"
wl_dhcplss="/var/lib/dhcp/dhcpd.leases" wl_dhcplss="/var/lib/dhcp/dhcpd.leases"
# wl_dhcpcnf="/etc/dhcp3/dhcpd.conf" # wl_dhcpcnf="/etc/dhcp3/dhcpd.conf"
# wl_dhcplss="/var/lib/dhcp3/dhcpd.leases" # wl_dhcplss="/var/lib/dhcp3/dhcpd.leases"
   
wl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"15\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>" #testing all settings
wl_header="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"  
wl_footer="</pre></body></html>"  
   
wlm_no_managed_or_master=" neni ani Master ani Managed..."  
wlm_number_of_clients="Pocet asociovanych klientu : "  
wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : "  
#wlm_no_managed_or_master=" is not Master or Managed..."  
#wlm_number_of_clients="Number of associated clients : "  
   
wlch_signal="="  
wlch_noise="*"  
   
######################################################################  
#testing basic setings  
   
if [ "$wl_iwccmd x" = " x" ] if [ "$wl_iwccmd x" = " x" ]
then then
echo "iwconfig not found" echo "iwconfig not found"
exit 1  
fi  
   
if [ "$wl_iwlcmd x" = " x" ]  
then  
echo "iwlist not found"  
exit 1 exit 1
fi fi
   
if [ "$wl_ifccmd x" = " x" ] if [ "$wl_ifccmd x" = " x" ]
then then
Line 73... Line 48...
fi fi
   
if [ "$wl_awkcmd x" = " x" ] if [ "$wl_awkcmd x" = " x" ]
then then
echo "awk not found" echo "awk not found"
  exit 1
  fi
   
  if [ -d $wl_hostap ]
  then
  wl_nop=1
  else
  echo "hostap not found"
exit 1 exit 1
fi fi
   
if [ -e $wl_wireless ] if [ -e $wl_wireless ]
then then
Line 107... Line 90...
wl_nop=1 wl_nop=1
else else
echo "$wl_dhcplss not found" echo "$wl_dhcplss not found"
wl_dhcplss="/dev/null" wl_dhcplss="/dev/null"
fi fi
######################################################################  
   
if [ -d ${wl_hostap}wlan0 ] wl_header_refresh="<html><head><meta HTTP-EQUIV=\"Refresh\" CONTENT=\"15\"><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
then wl_header="<html><head><title>Wifimon @ `$wl_hnmcmd`</title></head><body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\"><pre>"
wlf_hostap=1 wl_footer="</pre></body></html>"
else  
# echo "${wl_hostap}wlan0 not found"  
wlf_hostap=0  
fi  
   
if [ -d ${wl_sysdev}ath0 ] wlm_no_managed_or_master=" neni ani Master ani Managed..."
then wlm_number_of_clients="Pocet asociovanych klientu : "
wlf_madwifi=1 wlm_unknown="Nezname parametry nebo neplatne jmeno rozhrani : "
else #wlm_no_managed_or_master=" is not Master or Managed..."
# echo "${wl_sysdev}ath0 not found" #wlm_number_of_clients="Number of associated clients : "
wlf_madwifi=0  
fi  
   
if [ "$wlf_hostap" -eq 0 ] && [ "$wlf_madwifi" -eq 0 ] wlch_signal="="
then wlch_noise="*"
echo "${wl_hostap}wlan0 not found"  
echo "${wl_sysdev}ath0 not found"  
exit 1  
fi  
   
######################################################################  
# procedures  
###################################################################### ######################################################################
w_col() w_col()
{ {
wlc_red=`tput setaf 1` # ruda (Red) wlc_red=`tput setaf 1` # ruda (Red)
wlc_green=`tput setaf 2` # zelena (Lime) wlc_green=`tput setaf 2` # zelena (Lime)
Line 316... Line 286...
} # w_managed } # w_managed
   
###################################################################### ######################################################################
w_master() w_master()
{ if [ $wcm_oneline -eq 0 ] { if [ $wcm_oneline -eq 0 ]
then then
echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}' echo $wl_iwctxt | $wl_awkcmd '{print $1,$3,$4,$5" "}'
if [ $wcm_macoff -eq 1 ] if [ $wcm_macoff -eq 1 ]
then  
echo $wl_iwctxt | $wl_awkcmd '{print $6,$11" "}'  
else  
echo $wl_iwctxt | $wl_awkcmd '{print $6,$9,$11" "}'  
fi  
else  
echo $wl_iwctxt | $wl_awkcmd '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g'  
fi  
   
if [ -d $wl_hostap$wl_iface ]  
then then
wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00` echo $wl_iwctxt | $wl_awkcmd '{print $6,$11" "}'
wl_macs=`ls $wl_hostap$wl_iface | grep 00` else
  echo $wl_iwctxt | $wl_awkcmd '{print $6,$9,$11" "}'
  fi
  else
  echo $wl_iwctxt | $wl_awkcmd '{print $1,$4,$5,$6,$11" "}' | sed 's/ [^": ]*:/ /g'
fi fi
  wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
if [ -d $wl_sysdev$wl_iface ]  
then  
wl_numcl=`$wl_iwlcmd $wl_iface peers | grep -c 00`  
wl_macs=`iwlist $wl_iface peers | grep 00 | awk '{print $1}'`  
fi  
   
echo $wlm_number_of_clients $wl_numcl echo $wlm_number_of_clients $wl_numcl
   
wl_numcllast=$(($wl_numcllast + $wl_numcl)) wl_numcllast=$(($wl_numcllast + $wl_numcl))
   
for wl_mac in $wl_macs for wl_mac in `ls $wl_hostap$wl_iface | grep 00 `
do do
if [ -d $wl_hostap$wl_iface ] wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'`
then wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $6}' | sed 's/signal=//g'`
wl_macparam=`cat $wl_hostap$wl_iface/$wl_mac | grep -E 'last_rx|last_tx' | sed 's/last_//g'` wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence=//g'`
wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $6}' | sed 's/signal=//g'`  
wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $4}' | sed 's/silence=//g'`  
fi  
   
if [ -d $wl_sysdev$wl_iface ]  
then  
wl_macparam=`$wl_iwlcmd $wl_iface peers | grep $wl_mac`  
wl_signal=`echo $wl_macparam | $wl_awkcmd '{print $5}' | sed 's/level://g'`  
wl_silence=`echo $wl_macparam | $wl_awkcmd '{print $8}' | sed 's/level://g'`  
fi  
   
wl_cnt=$(($wl_signal - $wl_silence)) wl_cnt=$(($wl_signal - $wl_silence))
wl_ipc=`cat $wl_arp | grep -i $wl_mac | $wl_awkcmd '{print $1}'` # IP adresa peeru z arp tabulky wl_ipc=`cat $wl_arp | grep -i $wl_mac | $wl_awkcmd '{print $1}'` # IP adresa peeru z arp tabulky
   
wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | $wl_awkcmd '{print $2}'` wl_name=`cat $wl_dhcpcnf | grep -i $wl_mac | $wl_awkcmd '{print $2}'`
if [ "$wl_name" = "ethernet" ] || [ "$wl_name" = "" ] if [ "$wl_name" = "ethernet" ] || [ "$wl_name" = "" ]
Line 373... Line 320...
then then
wl_name=`cat $wl_dhcplss | grep -i $wl_mac -A 2 | grep -i client-hostname | $wl_awkcmd '{print$2}'` wl_name=`cat $wl_dhcplss | grep -i $wl_mac -A 2 | grep -i client-hostname | $wl_awkcmd '{print$2}'`
wl_name=`echo $wl_name | $wl_awkcmd '{print$1}' ` wl_name=`echo $wl_name | $wl_awkcmd '{print$1}' `
fi fi
fi fi
if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ] && [ -d $wl_hostap$wl_iface ] if [ $wcm_ppkts -eq 1 ] || [ $wcm_pkts -eq 1 ]
then then
w_pkts w_pkts
fi fi
   
if [ $wcm_oneline -eq 0 ] if [ $wcm_oneline -eq 0 ]
Line 396... Line 343...
echo -n "Signal ${wlc_sig}$wl_cnt${wlc_std} " echo -n "Signal ${wlc_sig}$wl_cnt${wlc_std} "
if [ $wcm_rxtx -eq 0 ] if [ $wcm_rxtx -eq 0 ]
then then
echo "" echo ""
else else
if [ -d $wl_hostap$wl_iface ] echo $wl_macparam | $wl_awkcmd '{print $1,$2" "}'
then  
echo $wl_macparam | $wl_awkcmd '{print $1,$2" "}'  
else  
echo ""  
fi  
fi fi
w_bar w_bar
else else
if [ $wcm_macoff -eq 0 ] if [ $wcm_macoff -eq 0 ]
then then
Line 446... Line 388...
exit 0 exit 0
} }
###################################################################### ######################################################################
w_help() w_help()
{ {
echo Monitorovani wifi karet pouzivajicich hostap nebo madwifi ovladace  
echo Pouziti: wifimon [param] echo Pouziti: wifimon [param]
echo param: echo param:
echo -v vypise verzi echo -v vypise verzi
echo -html generovani html stranky echo -html generovani html stranky
echo -col barevny vypis na obrazovku echo -col barevny vypis na obrazovku
echo -once vypsani jen jednoho vypisu a pak program skonci echo -once vypsani jen jednoho vypisu a pak program skonci
echo -oneline vypsani klientu na jednu linku echo -oneline vypsani klientu na jednu linku
echo -threeline vypsani klienta na trech radcich echo -threeline vypsani klienta na trech radcich
echo -macoff vypnuti zobrazeni MAC adres  
echo -wlan0 -ath0 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi  
echo nasledujici parametry ovlivnuji jen karty s hostap:  
echo -rxtxoff vypnuti zobrazeni objemu prenesenych dat klienta echo -rxtxoff vypnuti zobrazeni objemu prenesenych dat klienta
  echo -macoff vypnuti zobrazeni MAC adres
echo -ppkts vypsani procentniho pomeru 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty echo -ppkts vypsani procentniho pomeru 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
echo -pkts vypsani poctu 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty echo -pkts vypsani poctu 1M, 2M, 5.5M a 11M paketu pro jednotlive klienty
  echo -wlan0 -wlan1 -wlan2 vypise jen uvedene karty a to v danem poctu a poradi
echo bez parametru cyklicky vypis na obrazovku echo bez parametru cyklicky vypis na obrazovku
exit 0 exit 0
} }
###################################################################### ######################################################################
###################################################################### ######################################################################
Line 530... Line 470...
shift shift
;; ;;
*) *)
wl_flg=0 wl_flg=0
#wlan check #wlan check
if [ $wlf_hostap -eq 1 ] for wl_iface in `ls $wl_hostap`
  do
  if [ "a-$wl_iface" = "a$1" ]
then then
for wl_iface in `ls $wl_hostap` wcm_ifc="$wcm_ifc $wl_iface"
do wl_flg=1
if [ "a-$wl_iface" = "a$1" ] fi
then done
wcm_ifc="$wcm_ifc $wl_iface"  
wl_flg=1  
fi  
done  
fi  
# ath check # ath check
if [ $wlf_madwifi -eq 1 ] for wl_iface in `ls $wl_sysdev | grep "ath[0..9]"`
  do
  if [ "a-$wl_iface" = "a$1" ]
then then
for wl_iface in `ls $wl_sysdev | grep "ath[0-9]"` wcm_ifc="$wcm_ifc $wl_iface"
do wl_flg=1
if [ "a-$wl_iface" = "a$1" ] fi
then done
wcm_ifc="$wcm_ifc $wl_iface"  
wl_flg=1  
fi  
done  
fi  
if [ $wl_flg -eq 0 ] if [ $wl_flg -eq 0 ]
then then
wl_unknown="$wl_unknown$1 " wl_unknown="$wl_unknown$1 "
fi fi
shift shift
esac esac
done done
   
Line 567... Line 501...
if [ "a$wl_unknown" != "a" ] if [ "a$wl_unknown" != "a" ]
then then
echo "$wlm_unknown $wl_unknown" echo "$wlm_unknown $wl_unknown"
w_help w_help
fi fi
   
# if no interface is selected then all available are choosen # if no interface is selected then all available are choosen
if [ "a$wcm_ifc" = "a" ] if [ "a$wcm_ifc" = "a" ]
then then
if [ $wlf_hostap -eq 1 ] wcm_ifc=`ls $wl_hostap ; ls $wl_sysdev | grep "ath[0..9]"`
then  
wcm_ifc=`ls $wl_hostap `  
fi  
if [ $wlf_madwifi -eq 1 ]  
then  
wcm_ifc=`echo $wcm_ifc ; ls $wl_sysdev | grep "ath[0-9]"`  
fi  
fi fi
   
# setting for old and last same value to avoid double clear after start # setting for old and last same value to avoid double clear after start
wl_numcllast=0 wl_numcllast=0
wl_numclold=0 wl_numclold=0
for wl_iface in $wcm_ifc for wl_iface in $wcm_ifc
do do
if [ -d $wl_hostap$wl_iface ] wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`
then wl_numcllast=$(($wl_numcllast + $wl_numcl))
wl_numcl=`ls $wl_hostap$wl_iface | grep -c 00`  
wl_numcllast=$(($wl_numcllast + $wl_numcl))  
fi  
if [ -d $wl_sysdev$wl_iface ]  
then  
wl_mode=`$wl_iwccmd $wl_iface | grep Mode | $wl_awkcmd '{print $1}' | sed 's/Mode://g'`  
if [ "a$wl_mode" = "aMaster" ]  
then  
wl_numcl=`$wl_iwlcmd $wl_iface peers | grep -c 00`  
wl_numcllast=$(($wl_numcllast + $wl_numcl))  
fi  
fi  
done done
wl_numclold=$wl_numcllast wl_numclold=$wl_numcllast
   
if [ $wcm_col -eq 0 ] if [ $wcm_col -eq 0 ]
then then

Powered by WebSVN 2.2.1