WikiDevi.Wi-Cat.RU:DD-WRT/Wireless Network Scanner (awk -f scanner)
Jump to navigation
Jump to search
#####################
cat - > scanner
# Show scanresults in consistent order with graphical bars.
# To be run via telnet to WRT54g running modified firmware.
# Do the following. Use your own router address instead of 192.168.1.1 on the following lines
# Login via telnet:
# telnet 192.168.1.1
# a simple test to make sure you can run this script, type:
# wl scan; wl scanresults
# and make sure you can run those commands. If not this program will not work.
# If you succeeded with the scanresults then
# copy and paste this entire text into the terminal window
# (the cat - > scanner line will copy the rest of the file into a file named 'scanner')
# and then hit return and then ctrl-c to close the file.
# then just run script by typing the following line:
# awk -f scanner
#
# I hereby release this into the public domain. Justin Jones, 2005
#
# Jan. '07 corrected bug from '06 improvement.
BEGIN{
IGNORECASE = 1;
command = "wl scan 2> /dev/null ; wl scanresults 2> /dev/null";
red = "\x1b[31m"; green = "\x1b[32m";
greenback="\x1b[42m"; yellow = "\x1b[33m";
cyan = "\x1b[36m"; blue = "\x1b[34m";
blueback = "\x1b[44m"; white = "\x1b[37m";
whiteback = "\x1b[47m"; reset = "\x1b[0m";
underscore = "\x1b[4m"; clear = "\x1b[2J";
home = "\x1b[0;0H"; erase2end = "\x1b[K";
cName = white; cSignal = green;
cNoise = red; cCaps = green;
cStrengthLow = blue blueback; cChannel = green;
cStrengthMed = white whiteback;
cStrengthHi = green greenback;
cStrengthAged = red;
print clear;
for(;;)
{
while (command|getline)
{
if(/^SSID/) { name = $2; rssi = $6;noise= $9; rssi=""; noise="";channel="";bssid="";caps=""}
if(/^Mode/) {rssi = $4;noise= $7; channel = $10 }
if(/^BSSID/) {bssid = $2; caps = $4" "$5" "$6" "$7" "$8" "$9" "$10 }
if(/^Supported/)
{
name[bssid] = name
rssi[bssid] = rssi
noise[bssid]= noise
channel[bssid] = channel
caps[bssid] = caps
}
}
close(command)
printf home;
ln = 0;
print white " Name BSSID Signal Noise Channel Type";
for (x in name)
{
{
#arbitrary strength calc through trial and error... modify as you wish:
sigstrength = ((rssi[x] - noise[x])*1.5) + ((rssi[x] +90)*1.5);
if (sigstrength <1) sigstrength=0;
cStrength = cStrengthLow;
if(sigstrength>4) cStrength = cStrengthMed;
if(sigstrength>7) cStrength = cStrengthHi;
if(age[x]=0) cStrength = cStrengthAged;
fmt = "%s%-15s %s%0"sigstrength"d "reset erase2end "\n %s %s%-4d %s%-4d %s%-4d %s%2s %s%10s " reset erase2end "\n" erase2end "\n";
printf fmt, cName,name[x],cStrength,0,x,cSignal,rssi[x],cNoise,noise[x],cChannel, channel[x],cCaps,caps[x];
rssi[x] = "-1000 xxxx";
ln++;
}
}
if (ln ==0) print red "No Results - Do you have wl scan capability? \nThis program depends on 'wl scan; wl scanresults' to run. Hit ctrl-c to stop."
print erase2end;
}
}