Skip to content

Instantly share code, notes, and snippets.

@darren
Last active November 30, 2023 05:04
Show Gist options
  • Select an option

  • Save darren/ca7e8bfa44ddd27d472f to your computer and use it in GitHub Desktop.

Select an option

Save darren/ca7e8bfa44ddd27d472f to your computer and use it in GitHub Desktop.

Revisions

  1. darren revised this gist May 5, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion nlc.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/usr/bin/env bash

    USERNAME= #改成你的读者卡号
    PASSWORD= #改成你的读者卡号密码
    PASSWORD= #改成你的读者卡密码

    LOGINURL="http://192.168.180.11:8080/nlcwlan/QueryGuest"

  2. darren renamed this gist May 5, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. darren created this gist May 5, 2014.
    47 changes: 47 additions & 0 deletions gistfile1.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    #!/usr/bin/env bash

    USERNAME= #改成你的读者卡号
    PASSWORD= #改成你的读者卡号密码

    LOGINURL="http://192.168.180.11:8080/nlcwlan/QueryGuest"

    PASSWORD=$(echo $PASSWORD|base64)
    UA="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"

    function test_conn {
    server=$1
    ping -c 3 -t 5 $server >/dev/null 2>&1
    res=$?
    if [[ $res == 0 ]] ;then
    return $res
    else
    return -1
    fi
    }

    function try_conn {
    res=$(curl -d "id_userPwd=$PASSWORD&id_userName=$USERNAME" "$LOGINURL" --user-agent "$UA" 2>/dev/null)
    if [[ $res =~ "success" ]]; then
    printf "\x1b[1;33mo\x1b[m" # o
    else
    printf "\x1b[3;31m!\x1b[m" # !
    fi
    }
    let i=0

    while :; do
    let 'o=i%16, i=i+1'
    if test_conn 60.247.28.1; then
    [ $o -eq 0 ] && printf "\x1b[32m.\x1b[m" # .
    elif test_conn 192.168.180.11; then
    # Login server is OK
    # echo "No Connection, try Connect"
    try_conn
    else
    #echo "No Connection and login Server not available"
    [ $o -eq 0 ] && printf "\x1b[1;31mx\x1b[m" # x
    fi
    sleep 1
    done

    exit 0;