detect unauthorized connections (cisco-led)

Discussion in 'Cisco/Linksys Wireless Routers' started by Pioneer, Sep 9, 2006.

  1. Pioneer

    Pioneer LI Guru Member

    hey guys!

    today i wrote a script for my wrt54gl that indicates with the amber-coloured cisco-led that there is a unauthorized access to my network.
    When there are only known mac-adresses connected, the cisco-led is white.
    i've to mention, that i've only 2 computers connected over w-lan otherwise the code would be much longer (for every mac-adress a new if-query ^^)

    here's the script:

    Code:
    #!/bin/sh
    I=`nvram get wl0_ifname`
    while sleep 1; do
    
    if [ "`wl assoclist`" == "" ]; then
       LED="am of wh of"
    
    else
    
       if [ "`wl assoclist`" == "assoclist [COLOR="Red"]XX:XX:XX:XX:XX:XX[/COLOR]" ]; then
          LED="am of wh on"
       else
          if [ "`wl assoclist`" == "assoclist [COLOR="Red"]YY:YY:YY:YY:YY:YY[/COLOR]" ]; then
             LED="am of wh on"
          else
             if [ "`wl assoclist`" == "assoclist [COLOR="Red"]XX:XX:XX:XX:XX:XX[/COLOR]
    assoclist [COLOR="Red"]YY:YY:YY:YY:YY:YY[/COLOR]" ]; then
                LED="am of wh on"
             else
                if [ "`wl assoclist`" == "assoclist [COLOR="Red"]YY:YY:YY:YY:YY:YY[/COLOR]
    assoclist [COLOR="Red"]XX:XX:XX:XX:XX:XX[/COLOR]" ]; then
                   LED="am of wh on"
                else
                   LED="am on wh of"
                fi
             fi
          fi
       fi
    fi
    
    if [ "$LED" != "$PLED" ]; then
    led $LED
    PLED=$LED
    fi
    done

    now my question is, is there a possibility to make the code more compact?
    does anyone have a suggestion for improvement?

    i hope you can help me!

    thanx
    pioneer


    ps.: english isn't my first language so please excuse the mistakes, if existing ;)
     
  2. crawdaddy

    crawdaddy Network Guru Member

    Im not strong in coding, but I'm sure there's some way that you could take the MAC adresses and put them in a text file and then refrence the query to that, making the authorized mac addy line into 1 line for all mac adresses.
     
  3. Guyfromhe

    Guyfromhe Network Guru Member

    Why not turn on mac filtering and forget about the light?
     
  4. Pioneer

    Pioneer LI Guru Member

    @ crawdaddy: I'm a noob in coding too, so I've absolutely no idea how to realize that with the text-file :hmm:
    I would not even know how to upload the txt-file to the router ^^

    @ Guyfromhe: Yes that would be a possibility, but I got into my head, to realize it that way.
    You also have to know, that in my neighbourhood there aren't so much people who are able to crack a w-lan, but if there are some, I'll catch them :p
     
  5. RonWessels

    RonWessels Network Guru Member

    How about the following as the checking code?
    Code:
    LED='am of wh of'
    
    for entry in `wl assoclist`
    do
        case $entry in
        assoclist) ;;
        xx:xx:xx:xx:xx:xx) ;;
        yy:yy:yy:yy:yy:yy) ;;
        *) LED='am of wh on' ;;
        esac
    done
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice