Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 9.45 KB | None | 0 0
  1. /*
  2. mSASL Version 1.0 Beta [sans DLL] designed by Kyle Travaglini
  3. * To use this script you must have the proper DLL
  4. * All I ask is you leave the credit line within the main dialog
  5. * PLEASE read the SASLreadme.txt file before asking questions!
  6.  
  7.  
  8. [sans DLL changes]
  9. - $dll call removed and replaced with scripted version [$SASL(username,password).plain]
  10. - $decode call removed and replaced with plain text [mIRC disables $decode by default]
  11. * a few other edits to fix bugs and add a bit more function
  12.  
  13. * only plain is supported for AuthType [blank defaults to plain]
  14. * auth timeout support added [blank defaults to 30 seconds]
  15.  
  16. * break up authenticate lines over 400 characters
  17. * fixed edit network dialog error
  18. - noticed I set the hash tables to binary, removed binary flag [you might lose your settings]
  19. * added checks for required network configuration information
  20. * in network configuration [if left empty]:
  21. *   Domain defaults to 0
  22. *   Real Name defaults to $fullname, if not empty, then *
  23. *   Timeout defaults to 30 seconds [as above]
  24. *   AuthType defaults to PLAIN [as above]
  25. *   Network must be filled in
  26. *   Username must be filled in
  27. *   NS Password must be filled in
  28. */
  29.  
  30. alias f2 { dialog -m SASL.main SASL.main }
  31. menu menubar,status {
  32.   -
  33.   $mSASL.version: f2
  34.   -
  35. }
  36. alias mSASL.ver { return 1.0 }
  37. alias mSASL.version { return mSASL $+(v,$mSASL.ver) Beta [sans DLL] }
  38. alias mSASL {
  39.   var %cid = $1, %network = $2
  40.   if (%network isin $SASL(%network).nlist) {
  41.     if ($prop == timer) { return $+(.timer,mSASL.TimeOut.,%cid,.,%network) }
  42.     elseif ($prop == timeout) {
  43.       if ($SASL(%network).status == Authenticating) { scid %cid .quote CAP END }
  44.     }
  45.   }
  46. }
  47.  
  48. alias shname { return SASL }
  49. alias shfile { return $+(",$scriptdir,SASL.hsh,") }
  50. alias SASL {
  51.   if ($isid) {
  52.     if ($prop == nlist) { return $hget($shname,NLIST) }
  53.     if ($prop == timeout) { return $hget($shname,$+($1,:TIMEOUT)) }
  54.     if ($prop == user) { return $hget($shname,$+($1,:USER)) }
  55.     if ($prop == passwd) { return $hget($shname,$+($1,:PASSWD)) }
  56.     if ($prop == domain) { return $hget($shname,$+($1,:DOMAIN)) }
  57.     if ($prop == realname) { return $hget($shname,$+($1,:REALNAME)) }
  58.     if ($prop == status) { return $hget($shname,$+($1,:STATUS)) }
  59.     if ($prop == authtype) { return $hget($shname,$+($1,:AUTHTYPE)) }
  60.     if ($prop == plain) {
  61.       bset -t &auth 1 $1
  62.       bset -t &auth $calc( $bvar(&auth,0) + 2 ) $1
  63.       bset -t &auth $calc( $bvar(&auth,0) + 2 ) $2
  64.       var %len = $encode(&auth,mb)
  65.       return $bvar(&auth,1,%len).text
  66.     }
  67.   }
  68. }
  69. alias sd { hadd -m $shname $+($1,:,$2) $3- }
  70.  
  71. on *:START:{
  72.   if (!$hget($shname)) { hmake $shname 50 }
  73.   if ($exists($shfile)) { hload $shname $shfile }
  74. }
  75. on *:EXIT:{
  76.   if (($hget($shname)) && ($hget($shname,0).item > 0)) { hsave $shname $shfile }
  77. }
  78.  
  79. on ^*:LOGON:*:{
  80.   if ($network isin $SASL($network).nlist) {
  81.     .quote CAP LS
  82.     .quote NICK $nick
  83.     .quote USER $SASL($network).user $SASL($network).domain $server : $+ $SASL($network).realname
  84.     sd $network STATUS Connecting
  85.     haltdef
  86.   }
  87. }
  88. on *:CONNECT:{
  89.   if ($network isin $SASL($network).nlist) { sd $network STATUS Connected }
  90. }
  91. on *:DISCONNECT:{
  92.   if ($network isin $SASL($network).nlist) { sd $network STATUS Disconnected }
  93. }
  94.  
  95. raw CAP:*LS*:{
  96.   if ($network isin $SASL($network).nlist) {
  97.     .quote CAP REQ :multi-prefix sasl
  98.     var %t = $mSASL($cid,$network).timer
  99.     %t 1 $SASL($network).timeout noop $mSASL($cid,$network).timeout
  100.   }
  101. }
  102. raw CAP:*ACK*:{
  103.   if ($network isin $SASL($network).nlist) {
  104.     .quote AUTHENTICATE $SASL($network).authtype
  105.     sd $network STATUS Authenticating
  106.   }
  107. }
  108. raw AUTHENTICATE:+:{
  109.   if ($network isin $SASL($network).nlist) {
  110.     if ($lower($SASL($network).authtype) == plain) {
  111.       var %p = $SASL($SASL($network).user, $SASL($network).passwd).plain, %e
  112.       while ($len(%p) >= 400) {
  113.         var %e = $left(%p,400), %p = $mid(%p,401,0)
  114.         .quote AUTHENTICATE %e
  115.       }
  116.       if ($len(%p)) { .quote AUTHENTICATE %p }
  117.       else { .quote AUTHENTICATE + }
  118.     }
  119.     else { .quote CAP END }
  120.     haltdef
  121.   }
  122. }
  123. raw *:*:{
  124.   if ($network isin $SASL($network).nlist) {
  125.     if ($numeric isnum 903) {
  126.       .quote CAP END
  127.       sd $network STATUS Authenticated
  128.       var %t = $mSASL($cid,$network).timer
  129.       %t off
  130.     }
  131.     elseif ($numeric isnum 904-907) { .quote CAP END }
  132.   }
  133. }
  134.  
  135. dialog SASL.main {
  136.   title "SASL Manager"
  137.   size -1 -1 150 145
  138.   option dbu
  139.   box "Server List" 1, 5 3 140 113
  140.   text "Created by Kyle Travaglini" 3, 40 135 65 12
  141.   list 4, 10 13 80 104, vsbar, edit
  142.   button "Add" 5, 96 13 43 12
  143.   button "Edit" 6, 96 30 43 12
  144.   button "Delete" 7, 96 47 43 12
  145.   button "Save" 10, 96 64 43 12
  146.   button "Load" 11, 96 81 43 12
  147.   button "OK" 8, 27 120 43 12, ok
  148.   button "Update SASL" 9, 77 120 43 12
  149. }
  150.  
  151. dialog SASL.edit {
  152.   title "Network Configuration"
  153.   size -1 -1 150 120
  154.   option dbu
  155.   box "Network Settings" 1, 5 3 140 97
  156.   text "Network:" 2, 10 13 36 10, right
  157.   edit "" 3, 48 12 92 10
  158.   text "Username:" 4, 10 25 36 10, right
  159.   edit "" 5, 48 24 92 10
  160.   text "NS Password:" 6, 10 37 36 10, right
  161.   edit "" 7, 48 36 92 10
  162.   text "Domain:" 8, 10 49 36 10, right
  163.   edit "" 9, 48 48 92 10
  164.   text "Real Name:" 10, 10 61 36 10, right
  165.   edit "" 11, 48 60 92 10
  166.   text "Timeout:" 12, 10 73 36 10, right
  167.   edit "" 13, 48 72 92 10
  168.   text "AuthType:" 14, 10 85 36 10, right
  169.   edit "" 15, 48 84 92 10
  170.   button "OK" 16, 27 105 43 12, ok
  171.   button "Cancel" 17, 77 105 43 12, cancel
  172. }
  173.  
  174. dialog SASL.deletewarn {
  175.   title "SASL"
  176.   size -1 -1 120 40
  177.   option dbu
  178.   text "You must specify a network to delete." 1, 13 5 100 10
  179.   button "OK" 2, 40 20 43 12, ok
  180. }
  181.  
  182. dialog SASL.editwarn {
  183.   title "SASL"
  184.   size -1 -1 120 40
  185.   option dbu
  186.   text "You must specify a network to edit." 1, 13 5 100 10
  187.   button "OK" 2, 40 20 43 12, ok
  188. }
  189.  
  190. on *:DIALOG:SASL.*:*:*:{
  191.   if ($dname == SASL.main) {
  192.     if ($devent == init) {
  193.       did -r $dname 3
  194.       did -a $dname 3 Created by Kyle Travaglini
  195.       var %net_iter = 1
  196.       while (%net_iter <= $numtok($SASL().nlist,44)) {
  197.         did -a $dname 4 $gettok($SASL().nlist,%net_iter,44)
  198.         inc %net_iter 1      
  199.       }
  200.       ;// disable 'Update SASL' button
  201.       did -b $dname 9
  202.     }
  203.     if ($devent == sclick) {
  204.       if ($did == 5) { dialog -m SASL.edit SASL.edit }
  205.       elseif ($did == 6) {
  206.         if ($did($dname,4).seltext) {
  207.           hadd -m $shname EDIT True
  208.           dialog -m SASL.edit SASL.edit
  209.         }
  210.         else { dialog -m SASL.editwarn SASL.editwarn }
  211.       }
  212.       elseif ($did == 7) {
  213.         if ($did($dname,4).sel) {
  214.           if ($?!="Are you certain you wish to delete $did($dname,4).seltext $+ ?") {
  215.             hdel -w $shname $+($did($dname,4).seltext,:*)
  216.             hadd -m $shname NLIST $remtok($SASL().nlist,$did($dname,4).seltext,1,44)
  217.             did -d $dname 4 $did($dname,4).sel
  218.           }
  219.         }
  220.         else { dialog -m SASL.deletewarn SASL.deletewarn }
  221.       }
  222.       elseif ($did == 9) { usasl }
  223.       elseif ($did == 10) { hsave $shname $shfile }
  224.       elseif ($did == 11) {
  225.         hload $shname $shfile
  226.         did -r $dname 4
  227.         var %net_iter = 1
  228.         while (%net_iter <= $numtok($SASL().nlist,44)) {
  229.           did -a $dname 4 $gettok($SASL().nlist,%net_iter,44)
  230.           inc %net_iter 1      
  231.         }
  232.       }
  233.     }
  234.   }
  235.   elseif ($dname == SASL.edit) {
  236.     if ($devent == init) {
  237.       if ($hget($shname,EDIT) == True) {
  238.         var %network = $did(SASL.main,4).seltext
  239.         did -a $dname 3 %network
  240.         did -a $dname 5 $SASL(%network).user
  241.         did -a $dname 7 $SASL(%network).passwd
  242.         did -a $dname 9 $SASL(%network).domain
  243.         did -a $dname 11 $SASL(%network).realname
  244.         did -a $dname 13 $SASL(%network).timeout
  245.         did -a $dname 15 $SASL(%network).authtype
  246.       }
  247.     }
  248.     if ($devent == sclick) {
  249.       if ($did == 16) {
  250.         var %network = $did($dname,3), %user = $did($dname,5), %passwd = $did($dname,7)
  251.         if ((!%network) || (%network == network name needed)) {
  252.           if (!%network) { did -a $dname 3 network name needed }
  253.           halt
  254.         }
  255.         if ((!%user) || (%user == username name needed)) {
  256.           if (!%user) { did -a $dname 5 username name needed }
  257.           halt
  258.         }
  259.         if ((!%passwd) || (%passwd == password name needed)) {
  260.           if (!%passwd) { did -a $dname 7 password name needed }
  261.           halt
  262.         }
  263.         if ($hget($shname,EDIT) == True) { hadd -m $shname NLIST $remtok($SASL().nlist,%network,1,44) }
  264.         else {
  265.           if ($findtok($SASL().nlist,%network,1,44)) {
  266.             if ($?!=" $+ %network already exists; overwrite?") {
  267.               hadd -m $shname NLIST $remtok($SASL().nlist,%network,1,44)
  268.             }
  269.             else { halt }
  270.           }
  271.         }
  272.         hdel $shname EDIT
  273.         hadd -m $shname NLIST $+($SASL().nlist,$chr(44),%network)
  274.         sd %network USER $did($dname,5)
  275.         sd %network PASSWD $did($dname,7)
  276.         sd %network DOMAIN $iif($did($dname,9),$v1,0)
  277.         sd %network REALNAME $iif($did($dname,11),$v1,$iif($fullname,$v1,*))
  278.         sd %network TIMEOUT $iif($did($dname,13),$v1,30)
  279.         sd %network AUTHTYPE $iif($did($dname,15),$upper($v1),PLAIN)
  280.         var %net_iter = 1
  281.         did -r SASL.main 4
  282.         while (%net_iter <= $numtok($SASL().nlist,44)) {
  283.           did -a SASL.main 4 $gettok($SASL().nlist,%net_iter,44)
  284.           inc %net_iter 1      
  285.         }
  286.       }
  287.     }
  288.   }
  289. }
  290. ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement