belated wip

This commit is contained in:
~d6 2024-06-10 22:44:40 -04:00
parent d95af32a41
commit 4779ca7a7c
3 changed files with 227 additions and 37 deletions

254
munin.tal
View File

@ -1,3 +1,46 @@
( expect to see: )
( )
( header is everything before ">" )
( header includes "Selected interface 'wlp170s0'\r\n" )
( )
( "OK\r\n" in response to command )
( )
( "<id>" starts an unpromtped message about network `id` e.g. 3 )
( )
( > scan )
( <3>CTRL-EVENT-SCAN-STARTED )
( )
( <3>CTRL-EVENT-SCAN-RESULTS )
( > scan_results )
( )
( <3>WPA: Group rekeying completed with 70:73:cb:b8:ce:b7 [GTK=CCMP] )
( )
( <3>CTRL-EVENT-DISCONNECTED bssid=70:73:cb:b8:ce:b7 reason=3 locally_generated=1 )
( <3>CTRL-EVENT-DSCP-POLICY clear_all )
( <3>CTRL-EVENT-NETWORK-REMOVED 0 )
( <3>CTRL-EVENT-SCAN-STARTED )
( <3>CTRL-EVENT-REGDOM-CHANGE init=DRIVER type=WORLD )
( )
( <3>CTRL-REQ-PASSWORD-1:Password needed for SSID foobar )
( > password 3 mysecretpassword )
( )
( > status )
( bssid=e8:9f:80:d8:f4:04 )
( freq=5180 )
( ssid=_VelopSetup402 )
( id=0 )
( mode=station )
( wifi_generation=5 )
( pairwise_cipher=CCMP )
( group_cipher=CCMP )
( key_mgmt=WPA2-PSK )
( wpa_state=COMPLETED )
( ip_address=192.168.1.25 )
( p2p_device_address=74:3a:f4:33:fc:7f )
( address=74:3a:f4:33:fc:7f )
( uuid=75819ed3-c224-5b27-92bf-d167dc1ebc85 )
( ieee80211ac=1 )
|00 @System [ |00 @System [
&vect $2 &expansion $2 &title $2 &metadata $2 &vect $2 &expansion $2 &title $2 &metadata $2
&r $2 &g $2 &b $2 ] &r $2 &g $2 &b $2 ]
@ -25,9 +68,20 @@
( &vect $2 &ok $2 &stat $2 &del $1 &append $1 ) ( &vect $2 &ok $2 &stat $2 &del $1 &append $1 )
( &name $2 &len $2 &r $2 &w $2 ] ) ( &name $2 &len $2 &r $2 &w $2 ] )
|c0 @DateTime [
&year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1
&doty $2 &isdst $1 &pad $5 ]
|0000 |0000
@cur-x $2 @ready $1 ( wpa_cli is ready to start )
@cur-y $2 @cur-x $2 ( mouse: current x position )
@cur-y $2 ( mouse: current y position )
@scan-year $2 ( last scan time: year )
@scan-month $1 ( last scan time: month )
@scan-day $1 ( last scan time: day of month )
@scan-hour $1 ( last scan time: hour )
@scan-minute $1 ( last scan time: minute )
@cur-ap $2 ( address of current wireless AP )
|0100 |0100
#17ef .System/r DEO2 #17ef .System/r DEO2
@ -35,12 +89,52 @@
#406e .System/b DEO2 #406e .System/b DEO2
;on-screen .Screen/vect DEO2 ;on-screen .Screen/vect DEO2
;on-console .Console/vect DEO2
;on-mouse .Mouse/vect DEO2 ;on-mouse .Mouse/vect DEO2
;on-controller .Controller/vect DEO2 ;on-controller .Controller/vect DEO2
#0140 .Screen/w DEO2 #0100 .Screen/h DEO2 draw-ui #0140 .Screen/w DEO2 #0100 .Screen/h DEO2 draw-ui
BRK BRK
@on-console ( -> BRK )
.Console/type DEI #01 EQU ?on-stdin BRK ( from literal stdin )
.Console/type DEI #20 EQU ?on-stdin BRK ( from child 0 )
BRK
@on-stdin ( -> BRK )
.Console/stdin DEI #0a EQU ?on-newline
.Console/stdin DEI ;buffer/ptr LDA2 STA
;buffer/ptr LDA2k INC2 SWP2 STA2 BRK
@on-newline ( -> BRK )
( TODO: do something )
reset-buffer BRK
@reset-buffer ( -> )
;buffer ;buffer/ptr STA2 JMP2r
( formula: )
( )
( if signal >= -40 then percentage = 100 )
( if signal <= -100 then percentage = 0 )
( else percentage = 166 + 5/3 * signal )
@parse-scan JMP2r
@parse-scan-line ( -> )
( bssid - first 17 bytes: "1a:85:f9:85:1f:5e" )
( skip one tab: "\t" )
( frequency: 1+ digits: "2412" )
( skip 1+ spaces: " " )
( signal: 1+ signed digit: "-76" )
( skip 1+ spaces: " " )
( read 1+ non-space bytes: "[WPA2-PSK-CCMP][WPS][ESS]" )
( skip 1+ spaces: " " )
( read until CRLF: "NZTW802" )
JMP2r
@draw-space ( -> )
;tiles/space #81 !draw-tile
@draw-cursor ( tile* -> ) @draw-cursor ( tile* -> )
.Screen/addr DEO2 .Screen/addr DEO2
.cur-x LDZ2 .Screen/x DEO2 .cur-x LDZ2 .Screen/x DEO2
@ -54,41 +148,85 @@
STHkr .Screen/sprite DEO INC2 !&loop STHkr .Screen/sprite DEO INC2 !&loop
@draw-ui ( -> ) @draw-ui ( -> )
draw-frame
#01 .Screen/auto DEO draw-ap
#0000 #0000 goto draw-listings
;tiles/nw load #81 .Screen/sprite DEO draw-scrollbar
;tiles/horiz load #0020 #81 draw-n
;tiles/ne load #81 .Screen/sprite DEO
#02 .Screen/auto DEO
;tiles/vert .Screen/addr DEO2
#0108 #0008 goto #0018 #81 draw-n
#0000 #0008 goto #0018 #81 draw-n
#01 .Screen/auto DEO
;tiles/sw load #81 .Screen/sprite DEO
;tiles/horiz load #0020 #81 draw-n
;tiles/se load #81 .Screen/sprite DEO
#01 .Screen/auto DEO
#0008 #0008 goto ;tiles/str2 ;tiles/lit-lock ;demo/RadioX draw-listing
#0008 #0008 goto ;tiles/str2 ;tiles/lit-lock ;demo/RadioX draw-listing
#0008 #0010 goto ;tiles/str2 ;tiles/lit-lock ;demo/interzone draw-listing
#0008 #0018 goto ;tiles/str1 ;tiles/dark-lock ;demo/bee_happy_ draw-listing
#0008 #0020 goto ;tiles/str1 ;tiles/lit-lock ;demo/DuckHunt draw-listing
#0008 #0028 goto ;tiles/str1 ;tiles/lit-lock ;demo/LINKSYS6672 draw-listing
#0008 #0030 goto ;tiles/str0 ;tiles/space ;demo/Public draw-listing
#0008 #0038 goto ;tiles/str0 ;tiles/space ;demo/Q-bert draw-listing
#0008 #0040 goto ;tiles/str0 ;tiles/dark-lock ;demo/xyzzy draw-listing
JMP2r JMP2r
@draw-frame ( -> )
#0000 #0000 goto
;tiles/nw ;tiles/ne draw-horiz
#0008 #0002 draw-vert
;tiles/nes ;tiles/nsw draw-horiz
#0020 #0008 draw-vert
;tiles/nes ;tiles/nsw draw-horiz
#0068 #0001 draw-vert
;tiles/sw ;tiles/se draw-horiz
JMP2r
( draw h tiles of vertical side bars, starting at y )
@draw-vert ( y* h* -> )
STH2 ( y* [h*] )
#02 .Screen/auto DEO
;tiles/vert load
#0108 OVR2 goto STH2kr #81 draw-n
#0000 SWP2 goto STH2r #81 draw-n
JMP2r
( draw horizontal bar, tile w on left, e on right )
@draw-horiz ( w* e* -> )
STH2
#01 .Screen/auto DEO
load #81 .Screen/sprite DEO
;tiles/horiz load #0020 #81 draw-n
STH2r load #81 .Screen/sprite DEO
( draw currently connected ap, if any )
@draw-ap ( -> )
#0008 #0008 goto ;tiles/str3 ;tiles/lit-lock ;demo/Paradiso draw-listing
#00e8 #0008 goto ;demo/percentage #82 draw-str
#0008 #0010 goto ;demo/bssid #81 draw-str
#00d8 #0010 goto ;demo/signal #81 draw-str
JMP2r
( draw scan results, if any )
@draw-listings ( -> )
#01 .Screen/auto DEO
#0008 #0020 goto ;tiles/str2 ;tiles/lit-lock ;demo/RadioX draw-listing
#0008 #0028 goto ;tiles/str2 ;tiles/lit-lock ;demo/interzone draw-listing
#0008 #0030 goto ;tiles/str1 ;tiles/dark-lock ;demo/bee_happy_ draw-listing
#0008 #0038 goto ;tiles/str1 ;tiles/lit-lock ;demo/DuckHunt draw-listing
#0008 #0040 goto ;tiles/str1 ;tiles/lit-lock ;demo/LINKSYS6672 draw-listing
#0008 #0048 goto ;tiles/str0 ;tiles/space ;demo/Public draw-listing
#0008 #0050 goto ;tiles/str0 ;tiles/space ;demo/Q-bert draw-listing
#0008 #0058 goto ;tiles/str0 ;tiles/dark-lock ;demo/xyzzy draw-listing
JMP2r
( draw individual scan listing )
@draw-listing ( str* lock* name* -> ) @draw-listing ( str* lock* name* -> )
( #01 .Screen/auto DEO ) STH2 STH2 STH2 STH2 #81 draw-tile STH2r #81 draw-tile STH2r #82 !draw-str
#81 draw-tile STH2r #81 draw-tile STH2r #82 !draw-str
( draw scrollbar, if necessary )
@draw-scrollbar ( -> )
#02 .Screen/auto DEO
#0100 #0020 goto
;tiles/bar-top load #81 .Screen/sprite DEO
;tiles/bar-fg load #0004 #81 draw-n
;tiles/bar-bg load #0002 #81 draw-n
;tiles/bar-bot load #81 .Screen/sprite DEO
JMP2r
@constants
&connected-to "Connected 20 "To: 00
&interactive-mode "Interactive 20 "mode 00
@demo @demo
&bssid "70:73:cb:b8:ce:b7 00
&frequency "2437 20 "Mhz 00
&signal "-53 20 "dB 00
&percentage 20 "86% 00
&Paradiso "Paradiso 00
&RadioX "RadioX 00 &RadioX "RadioX 00
&interzone "interzone 00 &interzone "interzone 00
&bee_happy_ "bee_happy_ 00 &bee_happy_ "bee_happy_ 00
@ -107,15 +245,18 @@
@draw-tile ( tile* attr^ -> ) @draw-tile ( tile* attr^ -> )
STH .Screen/addr DEO2 STHr .Screen/sprite DEO JMP2r STH .Screen/addr DEO2 STHr .Screen/sprite DEO JMP2r
( TODO: redraw parts of the screen )
@on-screen ( -> BRK ) @on-screen ( -> BRK )
BRK BRK
( TODO: supports clicks and interaction )
@on-mouse ( -> BRK ) @on-mouse ( -> BRK )
;tiles/space draw-cursor ;tiles/space draw-cursor
.Mouse/x DEI2 .cur-x STZ2 .Mouse/x DEI2 .cur-x STZ2
.Mouse/y DEI2 .cur-y STZ2 .Mouse/y DEI2 .cur-y STZ2
;tiles/cursor draw-cursor BRK ;tiles/cursor draw-cursor BRK
( TODO: keyboard input )
@on-controller ( -> BRK ) @on-controller ( -> BRK )
BRK BRK
@ -124,4 +265,53 @@
&loop STHkr .Screen/sprite DEO INC2 ORAk ?&loop &loop STHkr .Screen/sprite DEO INC2 ORAk ?&loop
POPr POP2 JMP2r POPr POP2 JMP2r
@str-eq ( s* t* -> ok^ )
STH2 &l LDAk ?{ &d LDA LDAr STHr EQU JMP2r }
LDAk LDAkr STHr NEQ ?&d INC2 INC2r !&l
@read-bssid ( addr* -> addr+18* )
;buffer LIT2r =networks/ptr LDA2r ( buf* [dst*] )
&do LDA2k hexdigit #40 SFT SWP hexdigit ORA ( buf* byte^ [dst*] )
STH2kr STA INC2 INC2 INC2r ( buf+2* [dst+1*] ; dst<-byte )
LDAk #20 EQU ?{ INC2 !&do } POP2 STH2r JMP2r ( buf+k* [dst+1*] )
@hexdigit ( c^ -> h^ )
LIT "0 SUB DUP #0a LTH ?{ #27 SUB } JMP2r
( > scan_results )
( bssid / frequency / signal level / flags / ssid )
( 70:73:cb:b8:ce:b7 2437 -60 [WPA2-PSK-CCMP][ESS] timecrimes )
( dBm to percentage mapping )
( see https://www.intuitibits.com/2016/03/23/dbm-to-percent-conversion/ )
@table
64 64 64 64 64 64 64 64 64 64 ( -1 to -10 dBm: 100% )
64 64 64 64 64 64 64 64 64 64 ( -11 to -20 dBm: 100% )
63 63 63 62 62 62 61 61 60 60 ( -21 to -30 dBm: 99 to 96% )
5f 5f 5e 5d 5d 5c 5b 5a 5a 59 ( -31 to -40 dBm: 95 to 89% )
58 57 56 55 54 53 52 51 50 4f ( -41 to -50 dBm: 88 to 79% )
4e 4c 4b 4a 49 47 46 45 43 42 ( -51 to -60 dBm: 78 to 66% )
40 3f 3d 3c 3a 38 37 35 33 32 ( -61 to -70 dBm: 64 to 50% )
30 2e 2c 2a 28 26 24 22 20 1e ( -71 to -80 dBm: 48 to 30% )
1c 1a 18 16 14 11 0f 0d 0a 08 ( -81 to -90 dBm: 28 to 8% )
06 03 01 01 01 01 01 01 01 01 ( -91 to -100 dBm: 6 to 1% )
@tiles ~tiles.tal @tiles ~tiles.tal
( scan-line [43 bytes]: )
( - bssid, 6 bytes )
( - frequency, 2 bytes )
( - signal, 1 signed byte )
( - flags, 1 byte )
( + 0x00 no encryption )
( + 0x01 weaker: wep, wpa )
( + 0x02 stronger: wpa2 )
( + 0x03 other )
( - ssid, 33 bytes )
( buffer one line of input, until "\n"; up to 512 bytes )
@buffer [ $200 &ptr :buffer ]
( store results, 33 bytes per entry; 8448 bytes means 256 entries )
@networks [ $2100 &ptr :networks ]

View File

@ -146,10 +146,10 @@
( 91 ) &se 00 00 00 08 18 f0 e0 00 18 18 38 f0 e0 00 00 00 ( 91 ) &se 00 00 00 08 18 f0 e0 00 18 18 38 f0 e0 00 00 00
( 92 ) &nw 00 00 00 00 00 03 07 04 00 00 00 07 0f 1c 18 18 ( 92 ) &nw 00 00 00 00 00 03 07 04 00 00 00 07 0f 1c 18 18
( 93 ) &ne 00 00 00 00 00 c0 e0 20 00 00 00 e0 f0 38 18 18 ( 93 ) &ne 00 00 00 00 00 c0 e0 20 00 00 00 e0 f0 38 18 18
( 94 ) 00 00 00 00 00 c0 e0 20 18 18 38 f8 f8 38 18 18 ( 94 ) &nsw 00 00 00 00 00 c0 e0 20 18 18 38 f8 f8 38 18 18
( 95 ) 00 00 00 00 00 03 07 04 18 18 1c 1f 1f 1c 18 18 ( 95 ) &nes 00 00 00 00 00 03 07 04 18 18 1c 1f 1f 1c 18 18
( 96 ) 00 00 00 00 00 c3 e7 24 00 00 00 ff ff 3c 18 18 ( 96 ) &esw 00 00 00 00 00 c3 e7 24 00 00 00 ff ff 3c 18 18
( 97 ) 00 00 00 00 00 ff ff 00 18 18 3c ff ff 00 00 00 ( 97 ) &new 00 00 00 00 00 ff ff 00 18 18 3c ff ff 00 00 00
( 98 ) &vert 00 00 00 00 00 00 00 00 18 18 18 18 18 18 18 18 ( 98 ) &vert 00 00 00 00 00 00 00 00 18 18 18 18 18 18 18 18
( 99 ) &horiz 00 00 00 00 00 ff ff 00 00 00 00 ff ff 00 00 00 ( 99 ) &horiz 00 00 00 00 00 ff ff 00 00 00 00 ff ff 00 00 00
( 9a ) &nesw 00 00 00 00 00 c3 e7 24 18 18 3c ff ff 3c 18 18 ( 9a ) &nesw 00 00 00 00 00 c3 e7 24 18 18 3c ff ff 3c 18 18
@ -157,7 +157,7 @@
( 9c ) &bar-top 00 7f 77 77 63 63 41 41 00 00 08 08 1c 1c 3e 3e ( 9c ) &bar-top 00 7f 77 77 63 63 41 41 00 00 08 08 1c 1c 3e 3e
( 9d ) &bar-bot 41 41 63 63 77 77 7f 00 3e 3e 1c 1c 08 08 00 00 ( 9d ) &bar-bot 41 41 63 63 77 77 7f 00 3e 3e 1c 1c 08 08 00 00
( 9e ) &bar-bg 6b 55 6b 55 6b 55 6b 55 00 00 00 00 00 00 00 00 ( 9e ) &bar-bg 6b 55 6b 55 6b 55 6b 55 00 00 00 00 00 00 00 00
( 9f ) &bar-fg 00 00 00 00 00 00 00 00 00 7e 7e 7e 7e 7e 7e 00 ( 9f ) &bar-fg 00 00 00 00 00 00 00 00 7f 7f 7f 7f 7f 7f 7f 7f
( a0 ) &cursor 80 c0 e0 f0 f8 e0 10 00 00 00 00 00 00 00 00 00 ( a0 ) &cursor 80 c0 e0 f0 f8 e0 10 00 00 00 00 00 00 00 00 00
( a1 ) &pointer 20 20 20 b8 7c 7c 38 38 00 00 00 00 00 00 00 00 ( a1 ) &pointer 20 20 20 b8 7c 7c 38 38 00 00 00 00 00 00 00 00
( a2 ) &lightning 0e 1c 38 7e 0c 18 10 20 00 00 00 00 00 00 00 00 ( a2 ) &lightning 0e 1c 38 7e 0c 18 10 20 00 00 00 00 00 00 00 00

BIN
wifi2.chr

Binary file not shown.