Author
Message
ruddles DD-WRT User Joined: 30 Nov 2008 Posts: 206 Location: Wherever the wind blows.
Posted: Sat Dec 06, 2008 6:43 Post subject: Wireless Network Scanner script (Kuthulu) Help please ?
Hello all
I found what looks like a great solution to running something similar to Netstumbler on DD-WRT, I have a need to scan for various ap's as we move around.
I found this script modded by Kuthulu.
It works sort of on my WRT54G with newd 10999.
The display (A screenshot is enclosed) seems to at first think there is a problem, then appears to be out of alignment. It looks as if it is supposed to have various colour highlights too.
Forgive my ignorance of scripting, it is something I WILL look into for the enourmous flexibility.
The script is at - http://www.dd-wrt.com/wiki/index.php/Useful_Scripts#Wireless_Network_Scanner_.28working_on_DD-WRT_v24.29
A screenshot of what I get is attached. (There IS only the one site here at the mo - Marina 3)
Thanks, hope Kuthulu or somebody can advise.
To use this as the basis of a netstumbler type of add on looks fantastic. Maybe even being able to pipe the ouput to a small windows program ? - Nirvana for me.
Rudds
Description:
Filesize:
35.92 KB
Viewed:
9031 Time(s)
Back to top
Sponsor
ruddles DD-WRT User Joined: 30 Nov 2008 Posts: 206 Location: Wherever the wind blows.
Posted: Sat Dec 06, 2008 6:45 Post subject: here is the script
I thought it would be easier for folks to view if I also pasted the script, here it is.
#!/bin/sh
awk -F"[][]" '
BEGIN{
IGNORECASE = 1;
command = "site_survey 2>&1";
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 ($22 == "") continue;
bssid=$6;
name[bssid] = $4;
rssi[bssid] = $10;
noise[bssid]= $12;
channel[bssid] = $8;
caps[bssid] = $22;
age[bssid] = 1;
}
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 " 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] = "-100 xxxx";
ln++;
}
if (ln ==0)
print red "No Results - Do you have survey capability? \nThis program depends on site_survey to run. Hit ctrl-c to stop.";
print erase2end;
}
}
'
Back to top
ruddles DD-WRT User Joined: 30 Nov 2008 Posts: 206 Location: Wherever the wind blows.
Posted: Sat Dec 06, 2008 6:52 Post subject:
editsed - posted script again doh
Rudds
Back to top
BloodDrench DD-WRT Novice Joined: 15 Jan 2009 Posts: 2
Posted: Thu Jan 15, 2009 8:44 Post subject:
I'm new to using dd-wrt, ive had it for about 2 weeks so im quite comfortable with the settings and everything. ive made a bi-quad wifi antenna for it and so far have gotten a 27% quality link from 2 blocks away. So I have been trying to get this scanner to work so i can fine tune. i got v24 sp1. I have telnet. I log in and copy paste the script into it. I dunno, Maybe im retarded. Any pointers?
Back to top
techo91 DD-WRT Novice Joined: 30 Dec 2008 Posts: 8
Posted: Sun Feb 03, 2013 14:17 Post subject:
WRT54GL, Firmware: DD-WRT v24-sp2 build 131064
I tried that as well but no result. Made a script and uploaded it to mmc, but when i run it nothing happens. Is it suppose to work on this firmware?
Back to top
mwchang DD-WRT Guru Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Tue Feb 27, 2024 9:44 Post subject:
ruddles wrote: editsed - posted script again doh
Rudds
I fixed the "wink" part of the posted script, and attached it as site_survey.awk.txt ! Unfortunately, the script's use of ANSI terminal codes is a bit buggy. There are other bugs, but I am not familiar with Awk. Well...
ANSI Codes and Colorized Terminals | Linux.org
https://www.linux.org/threads/ansi-codes-and-colorized-terminals.11706/
And you can set an alias in ~/.profile to run site_survey in a shell:
Code: wlscan='site_survey 2>&1 | cut -d \] -f 2,4 | sed -e "s/SSID\[//" -e "s/\] channel\[/ /"'
Or you can use Admin->Command to run the command inside the single quotes directly.
Code: site_survey 2>&1 | cut -d \] -f 2,4 | sed -e "s/SSID\[//" -e "s/\] channel\[/ /"
Update:
I think kuthulu did NOT quite know what he/she was programming, or the Awk script he/she posted was either deliberately messed up or it's incomplete, casual work. I ASSUMED that the output format of site_survey command never changed, but I might be wrong.
As a reuslt, the codes in the Wiki (http://www.dd-wrt.com/wiki/index.php/Useful_Scripts#Wireless_Network_Scanner_.28working_on_DD-WRT_v24.29 ) will NOT work!!
Right now, I wish ChatGPT would NOT deep-learn/borrow/steal then generate kuthulu 's codes as results.
Related:
DD-WRT :: View topic - Wireless scanner for linux
https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=34924&highlight=scanner
Description:
Using Awk to call site_survey with coloring
Download
Filename:
site_survey.awk.txt
Filesize:
1.74 KB
Downloaded:
44 Time(s)
Last edited by mwchang on Wed Feb 28, 2024 12:46; edited 10 times in total
Back to top
mwchang DD-WRT Guru Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Tue Feb 27, 2024 16:57 Post subject:
This is the corrected script, but without colors and a few columns missing:
Updated: 28 Feb 2024
Code: #!/bin/sh
#
# DD-WRT :: View topic - Wireless scanner for linux
# https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=34924&highlight=scanner
#
# DD-WRT :: View topic - Wireless Network Scanner script (Kuthulu) Help please ?
# https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=43598&highlight=sitesurvey+script
#
# The various escape codes you can use to color output to StdOut from Node JS · GitHub
# https://gist.github.com/abritinthebay/d80eb99b2726c83feb0d97eab95206c4
#
# talyian.github.io/ansicolors/
# https://talyian.github.io/ansicolors/
#
# Created by: kuthulu
# https://forum.dd-wrt.com/phpBB2/profile_sec.php?mode=viewprofile&u=14849
#
# DD-WRT :: View topic - Wireless scanner for linux
# https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=34924
# DD-WRT Wiki
# http://www.dd-wrt.com/wiki/index.php/Useful_Scripts#Wireless_Network_Scanner_.28working_on_DD-WRT_v24.29
#
# Reposted by: ruddles
# https://forum.dd-wrt.com/phpBB2/profile_sec.php?mode=viewprofile&u=49001
#
awk -F[][] '
BEGIN{
IGNORECASE = 1;
command = "site_survey 2>&1";
reset = "\x1b[0m";
bright = "\x1b[1m";
dim = "\x1b[2m";
underscore = "\x1b[4m";
blink = "\x1b[5m";
reverse = "\x1b[7m";
hidden = "\x1b[8m";
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";
underscore = "\x1b[4m"; clear = "\e[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;
for(;;)
{
while (command|getline)
{
# skip line 1
if ($22 == "") continue;
# use first column as array index
# bssid=$2;
bssid=$6;
# age[bssid] = $6;
name[bssid] = $4;
channel[bssid] = $8;
rssi[bssid] = $14;
noise[bssid]= $16;
caps[bssid] = $20;
row[bssid]=$2;
# 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;
}
close(command);
gsub(/[^\11\12\15\40-\176]/,"");
# asort(name);
print clear home;
print bright white;
print "Row Name Channel RSSI Noise BSSID";
print reset white;
ln=0;
for (x in name)
{
# printf $4 ":6:" $6 ":9:" $9 ":14:" $14 ":16:" $16 ":20:" $20 "!\n";
# fmt = "%s%-15s %s%0"sigstrength"d "reset erase2end "\n %s %s%-4d %s%-4d %s%-4d %s%2s " 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];
print row[x] " " name[x] " " channel[x] " " rssi[x] " " noise[x] " " x;
ln++;
}
print bright white;
print "Rows: " ln yellow " Hit Ctrl-C to stop!";
if (ln == 0)
print red "No Results - Do you have survey capability?"
}
}
'
Description:
Using Awk to parse site_survey with coloring (corrected 28 Feb 2024)
Download
Filename:
ruddles-site_survey.awk-20240228.sh.txt
Filesize:
2.61 KB
Downloaded:
48 Time(s)
Last edited by mwchang on Wed Feb 28, 2024 13:08; edited 3 times in total
Back to top
mwchang DD-WRT Guru Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Wed Feb 28, 2024 7:41 Post subject:
Because the site_survey command of DD-WRT uses "[" and "]" as field separators, the following SSID names will confuse this program when using them as Awk field separators:
1. "[LG_StickVacuum]xxxx"
The simplest solution is for site_survey to use characters other than "[]" as field separators via maybe a command-line option, thus not affecting the WEBUI. The hard solution is to add an Awk function() to reformat "[]" to "{}", so that "[[LG_StickVacuum]xxxx]" becomes "{[LG_StickVacuum]xxxx}" for example. The function() might be a lot of work. Um...
Code: # site_survey 2>&1
....
[ 2] SSID[[LG_StickVacuum]xxxx] BSSID[82:5B:xx:xx:xx:xx] channel[99] frequency[2234] ....
...
Related:
SSID Naming Conventions (for Cisco equipments)
https://www.cisco.com/assets/sol/sb/WAP321_Emulators/WAP321_Emulator_v1.0.0.3/help/Wireless05.html
Code: The SSID (Service Set Identifier) can be any alphanumeric, case-sensitive entry from 2 to 32 characters. The printable characters plus the space (ASCII 0x20) are allowed, but these six characters are not: ?, ", $, [, \, ], and +.
Service set (802.11 network) - Wikipedia
https://en.wikipedia.org/wiki/Service_set_(802.11_network)
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
Back to top
mwchang DD-WRT Guru Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Posted: Thu Feb 29, 2024 21:43 Post subject:
A simple script to convert "[]" to "{}":
Code: #!/bin/sh
#
# shell script - awk print apostrophe/single quote - Unix & Linux Stack Exchange
# https://unix.stackexchange.com/questions/593212/awk-print-apostrophe-single-quote
#
# shell - How can I output null-terminated strings in Awk? - Stack Overflow
# https://stackoverflow.com/questions/9133315/how-can-i-output-null-terminated-strings-in-awk
#
awk '
BEGIN {
cmd="site_survey 2>&1 | \
sed -e '\''s/^./{/'\'' \
-e '\''s/\\] SSID\\[/\} SSID\{/'\'' \
-e '\''s/\\] BSSID\\[/} BSSID{/'\'' \
-e '\''s/\\] channel\\[/} channel{/'\'' \
-e '\''s/\\] frequency\\[/} frequency{/'\'' \
-e '\''s/\\] numsta\\[/} numsta{/'\'' \
-e '\''s/\\] rssi\\[/} rssi{/'\'' \
-e '\''s/\\] noise\\[/} noise{/'\'' \
-e '\''s/\\] beacon\\[/} beacon{/'\'' \
-e '\''s/\\] cap\\[/} cap{/'\'' \
-e '\''s/\\] dtim\\[/} dtim{/'\'' \
-e '\''s/\\] rate\\[/} rate{/'\'' \
-e '\''s/\\] enc\\[/} enc{/'\'' \
-e '\''s/.$/\}/'\'' ";
print cmd;
while (cmd|getline)
{
print $0;
}
}
'
_________________ Router: Asus RT-N18U (rev. A1)
Drink, Blink, Stretch! Live long and prosper! May the Force and farces be with you!
Facebook: https://www.facebook.com/changmanwai
Website: https://sites.google.com/site/changmw
SETI@Home profile: http://setiathome.berkeley.edu/view_profile.php?userid=211832
GitHub: https://github.com/changmw/changmw
Back to top
mwchang DD-WRT Guru Joined: 26 Mar 2013 Posts: 1858 Location: Hung Hom, Hong Kong
Back to top