7:27:06 am - Wednesday September 26th, 2018
Search:     Cat:   
Downloads
Support
Portal
Stats
  • Total Hits: 127,744
  • Today's Hits: 226
  • Most Hits: 7/6/2018
  • Dynamic Hits: 3,394
  • Total Downloads: 552
  • Today's Downloads: 4
  • Newest: Korona
  • Members Online: 3/41
  • Guests Online: 7
Affiliates








Snippets

Invalid Server Commands Blocker v0.90

Block invalid commands sent to server which either risk you booted for flooding, or leak private info meant for local alias.
uses RAW 421 to put invalid commands on blacklist, and ON PARSELINE to block them again
If you enable the option to block non-whitelist commands and you experience server problems, check the graylist for commands that belong on the whitelist. It should be obvious where in the script to add new commands to the basic whitelist.
If you're not an OPER at a network, don't add the OPER commands list, so it won't need to search a longer whitelist.

Uploaded By: maroon
Author: maroon
Added: 4/4/2018
Last Updated: Never
mIRC Version: v7.52 possibly 7.42
Hits: 180
Size: 11.44KB
Downloads: 4
Review By: entropy


  
  1    0


Source Code:
  1. ; Server Commands Blocker by maroon. Lessens chances of being flooded off server due to
  2. ; invalid commands, or broadcasting private info meant for a local alias. If your script
  3. ; uses a command that isn't an internal command or identifier, and isn't a scripted alias,
  4. ; mIRC sends it to the server as a server command, assuming it's an unknown server command.
  5. ; This script lets you block commands placed on the blacklist manually or in reply to
  6. ; 421 "Unknown command", or you can set the script to block ALL commands not on the whitelist.
  7. ; If not blocking all non-whitelist, each invalid command happens at LEAST once per network.
  8. ; White/Black/Gray lists are separate by $network because some recognize different commands.
  9. ; Rightclick menu -> Status Window
  10. ;
  11. ; WhiteList = allowed -> server (optional extra commands only needed by IRCOP's)
  12. ; Blacklist = -> server is blocked
  13. ; GrayList = command going to server that's not on either list. Not blocked unless configured.
  14. ; It's a good idea to browse GrayList for possible commands that should move to WhiteList
  15. ; If 421 "Unknown command" received from server, command moved -> blacklist even if whitelisted
  16. ; Due to Server Lag, while-loop, or multi commands within alias, there might be several/many
  17. ; invalid commands before receiving the 421 event
  18. ;
  19. ; Once you fix script errors, consider removing those bad commands from blacklist or clearing blacklist completely
  20. ; length of each *LIST limited to mIRC line length approx 4150
  21. ; uses ON PARSELINE added v7.42, $unsafe added v7.44
  22.  
  23. alias -l block_msg {
  24. if (whitelist isin $1-) var %c -sgt $+($chr(3),0,$chr(44), 4)
  25. elseif (blacklist isin $1-) var %c -sgt $+($chr(3),0,$chr(44), 1)
  26. elseif ( graylist isin $1-) var %c -sgt $+($chr(3),0,$chr(44),14)
  27. else var %c -sgtc ctcp | echo %c $1- $chr(3)
  28. }
  29.  
  30. on *:PARSELINE:out:*:{
  31. if (!$hget(server_cmds,$network)) return
  32. var %cmd $remove($gettok($parseline,1,32),$lf)
  33. if ($istok($hget(server_cmds,$listfmt(whitelist)),%cmd,32)) return
  34. if ($istok($hget(server_cmds,$listfmt(blacklist)),%cmd,32)) { block_msg Blocking blacklisted command->server: $parseline | .parseline -ot | halt }
  35. if ($hget(server_cmds,$listfmt(blockgrays))) { Add2list graylist %cmd | block_msg If this is a valid server command, move it graylist->whitelist!! Blocking graylisted command->server: $parseline | .parseline -ot | halt }
  36. block_msg Unknown outgoing command->server added to graylist: %cmd
  37. Add2list graylist %cmd
  38. }
  39.  
  40. raw 421:*:{ if (!$hget(server_cmds,$network)) return | Block_msg Raw 421 'Unknown command' moved->blacklist: $2 | Add2List blacklist $2 }
  41.  
  42. alias -l listfmt { return $iif(*.* iswm $1,$1,$+($1,.,$network)) }
  43.  
  44. alias -l listitem {
  45. if (($1 isnum 1-) && ($gettok($hget(server_cmds,$listfmt($2)),$1,32))) return $chr(160) $unsafe($gettok($replace($hget(server_cmds,$listfmt($2)),:,$chr(42889)) ,$1,32)) : MoveList $unsafe($gettok($hget(server_cmds,$listfmt($2)),$1,32)) $2 $3
  46. if ($1 == begin) return -
  47. if ($1 == end) return -
  48. }
  49.  
  50. alias -l listnetwork {
  51. if ($1 isnum 1-) { var %a $scid($scon($1)).network | if (%a) return $iif(%a == $network,$style(2)) %a :clonefromnetwork $scid($scon($1)).network $network $2 $3 }
  52. if ($1 == begin) return -
  53. if ($1 == end) return -
  54. }
  55.  
  56. ; itemname fromlist tolist|delete
  57. alias -l movelist { if ($3 isin blacklist whitelist graylist) farmout Add2List $3 $1 | elseif ($3 == delete) farmout DelFromList $2 $eval($1,1) }
  58.  
  59. ; determines whether action is for active $network / all open status windows / all same-lists even if not an active network
  60. alias -l farmout {
  61. var %m $mouse.key & 6 | var %ms %m & 4 | var %mc %m & 2 | if (!%m) { $1 $2- | return }
  62. if (%ms) var %j $scon(0)
  63. else var %j $hfind(server_cmds,$+($2,.*), 0,w)
  64. while (%j) {
  65. if (%ms) var %ml $+($2,.,$scon(%j).network)
  66. else var %ml $hfind(server_cmds,$+($2,.*), %j,w)
  67. if ($hget(server_cmds,$gettok(%ml,2-,46))) { $1 %ml $3- }
  68. dec %j
  69. }
  70. }
  71.  
  72. ; ADD2List *list itemname
  73. alias -l ADD2List { if (!$network) return
  74. while ($2) { var %f $findtok($hget(server_cmds,$listfmt($1)),$2,1,32)
  75. if (!%f) { last_change
  76. hadd server_cmds $listfmt($1) $hget(server_cmds,$listfmt($1)) $2
  77. if ($event !isin PARSELINE 421) Block_Msg Added to $1 $+ : $2
  78. if ($1 == whitelist) { DelFromList blacklist $2 | DelFromList graylist $2 }
  79. if ($1 == blacklist) { DelFromList whitelist $2 | DelFromList graylist $2 }
  80. if ($1 == graylist) { DelFromList whitelist $2 | DelFromList blacklist $2 }
  81. }
  82. tokenize 32 $1 $3-
  83. }
  84. }
  85. ; *list itemname
  86. alias -l DelFromList { if (!$network) return
  87. while ($2) { var %f $findtok($hget(server_cmds,$listfmt($1)),$2,1,32)
  88. if (%f) { hadd server_cmds $listfmt($1) $deltok($hget(server_cmds,$listfmt($1)),%f,32)
  89. if ($event !isin PARSELINE 421) block_msg $last_change Removed from $1 $+ : $2 }
  90. if ($hget(server_cmds,$listfmt($1)) == $null) hadd server_cmds $listfmt($1) PlaceHolder
  91. tokenize 32 $1 $3-
  92. }
  93. }
  94.  
  95. menu status,menubar {
  96. Server Commands BlackList $+($network,=,$iif($hget(server_cmds,$network),ON,OFF))
  97. .move from whitelist to graylist
  98. ..$submenu($listitem($1,whitelist,graylist))
  99. .move from whitelist to blacklist
  100. ..$submenu($listitem($1,whitelist,blacklist))
  101. .delete from whitelist
  102. ..$submenu($listitem($1,whitelist,delete))
  103. .-
  104. .move from graylist to whitelist
  105. ..$submenu($listitem($1,graylist,whitelist))
  106. .move from graylist to blacklist
  107. ..$submenu($listitem($1,graylist,blacklist))
  108. .delete from graylist
  109. ..$submenu($listitem($1,graylist,delete))
  110. .-
  111. .move from blacklist to whitelist
  112. ..$submenu($listitem($1,blacklist,whitelist))
  113. .move from blacklist to graylist
  114. ..$submenu($listitem($1,blacklist,graylist))
  115. .delete from blacklist
  116. ..$submenu($listitem($1,blacklist,delete))
  117. .-
  118. .manually add item to whitelist: Input2List whitelist
  119. .manually add item to graylist: Input2List graylist
  120. .manually add item to blacklist: Input2List blacklist
  121. .-
  122. .Shft+Click=open nets Ctrl+Click=non-blank lists:Block_msg Pressing Shift or Ctrl while clicking, on this page, extends action to all open-status-windows or all lists of same type that aren't blank.
  123. .-
  124. .CONFIG chg $asctime($hget(server_cmds,last.change),mm.dd HH $+ $chr(58) $+ nn) disk $asctime($hget(server_cmds,last.write),mm.dd HH $+ $chr(58) $+ nn)
  125. ..$iif($hget(server_cmds,$network),$style(1)) Toggle *LIST at $network only - Currently is $iif($hget(server_cmds,$network),ON,OFF) :{ last_change | hadd -s server_cmds $network $iif($hget(server_cmds,$network),0,1) }
  126. ..$iif( $hget(server_cmds,$listfmt(blockgrays)),$style(1)) Block all non-whitelisted commands (warning): if ($input(Warning: might cause mIRC to not work correctly if needed commands not on the whitelist)) { last_change | hadd -ms server_cmds $listfmt(blockgrays) 1 }
  127. ..$iif(!$hget(server_cmds,$listfmt(blockgrays)),$style(1)) Don't BLock graylisted commands too :{ last_change | hadd -ms server_cmds $listfmt(blockgrays) 0 }
  128. ..Flush hashtable to disk:server_cmds_timer flush
  129. ..-
  130. ..Clear $network WhiteList $numtok($hget(server_cmds,$listfmt(whitelist)),32):{ last_change | hdel -s server_cmds $listfmt(WhiteList) }
  131. ..Clear $network Gray List $numtok($hget(server_cmds,$listfmt( graylist)),32):{ last_change | hdel -s server_cmds $listfmt( GrayList) }
  132. ..Clear $network BlackList $numtok($hget(server_cmds,$listfmt(blacklist)),32):{ last_change | hdel -s server_cmds $listfmt(Blacklist) }
  133. ..-
  134. ..Clone WhiteList from Other Network
  135. ...$submenu($listnetwork($1,whitelist))
  136. ..Clone GrayList from Other Network
  137. ...$submenu($listnetwork($1,graylist))
  138. ..Clone BlackList from Other Network
  139. ...$submenu($listnetwork($1,blacklist))
  140. ..sort lists alpahbetically
  141. ...$iif($hget(server_cmds,$listfmt(whitelist)),sort whitelist):sortlist whitelist
  142. ...$iif($hget(server_cmds,$listfmt(blacklist)),sort blacklist):sortlist blacklist
  143. ...$iif($hget(server_cmds,$listfmt( graylist)),sort graylist):sortlist graylist
  144. ..-
  145. ..$iif($hget(server_cmds,auto_enable),$style(1)) Toggle AutoEnable New Networks at Connect - Currently is $iif($hget(server_cmds,auto_enable),ON,OFF) : hadd -s server_cmds auto_enable $iif($hget(server_cmds,auto_enable),0,1)
  146. ..reset $network whitelist to ONLY BASIC server commands:reset basic
  147. ..add OPER commands to $network whitelist:reset oper
  148. ..(Oper commands only needed at networks were you are OPER):reset oper
  149. ..remove OPER commands from $network whitelist: reset removeoper
  150. }
  151.  
  152. alias -l clonefromnetwork { hadd -s server_cmds $+($3,.,$2) $hget(server_cmds,$listfmt($3)) | last_change }
  153.  
  154. alias -l sortlist { hadd -s server_cmds $listfmt($1) $sorttok($hget(server_cmds,$listfmt($1)),32) | last_change }
  155.  
  156. alias -l input2list { var %f $input(Input Item to add to $1,e) | if (%f) farmout Add2List $1 %f }
  157.  
  158. alias -l reset {
  159. var %basic PRIVMSG MODE PONG ISON JOIN KICK NICK NOTICE PART AWAY NAMES NAMESX QUIT CONNECT CNOTICE CPRIVMSG ENCAP ERROR HELP INFO INVITE KNOCK LINKS LIST LUSERS MOTD PING RULES SERVER SERVICE SERVLIST SQUERY SETNAME SILENCE STATS SUMMON TIME TOPIC TRACE UHNAMES USER USERHOST USERIP USERS VERSION WALLOPS WATCH WHO WHOIS WHOWAS PROTOCTL CAP AUTHENTICATE NICKSERV NS CS CHANSERV MS MEMOSERV PASS OPER ADMIN
  160. var %oper globops chatops die locops adchat nachat kill kline zline gline shun gzline lag sethost setident chghost chgident chgname dccdeny undccdeny sajoin sapart samode squit rehash restart rping opermotd addmotd addomotd sdesc addline mkpasswd tsctl htm close
  161. if ($1 == basic) { hdel -ms server_cmds $listfmt(whitelist) | Add2List whitelist %basic }
  162. if ($1 == oper) Add2List whitelist %oper
  163. if ($1 == removeoper) DelFromList whitelist %oper
  164. if ($hget(server_cmds,$listfmt(blacklist)) == $null) hadd server_cmds $listfmt(blacklist) PlaceHolder
  165. if ($hget(server_cmds,$listfmt( graylist)) == $null) hadd server_cmds $listfmt( graylist) PlaceHolder
  166. last_change | server_cmds_timer flush
  167. }
  168.  
  169. ; alias used only for mIRC v7.42-7.43 where PARSELINE exists but $unsafe doesnt
  170. alias -l unsafe return $+($!decode,$chr(40),$encode($1,m),$chr(44),m,$chr(41))
  171.  
  172. on *:CONNECT:{
  173. if (($network) && ($hget(server_cmds,auto_enable)) && ($hget(server_cmds,$network) == $null)) { hadd -ms server_cmds $network 1 | reset basic }
  174. block_msg Server Commands Blacklist by maroon $+ $chr(169) at $network is $iif($hget(server_cmds,$network),ON!,OFF! - Use Status Window to enable!) WhiteList= $numtok($hget(server_cmds,$listfmt(whitelist)),32) BlackList= $numtok($hget(server_cmds,$listfmt(Blacklist)),32) GrayList= $numtok($hget(server_cmds,$listfmt(Graylist)),32)
  175. if ($numtok($hget(server_cmds,$listfmt(Graylist)),32)) Block_msg $network Graylist: $hget(server_cmds,$listfmt(Graylist))
  176.  
  177. }
  178. on *:EXIT:{ save_hash }
  179. on *:START:{ load_hash | server_cmds_timer }
  180.  
  181. alias -l last_write { hadd -m server_cmds last.write $ctime }
  182. alias -l last_change { hadd server_cmds last.change $ctime }
  183. alias -l server_cmds_timer {
  184. if (!$timer(server_cmds_timer)) .timerserver_cmds_timer -io 0 3600 server_cmds_timer
  185. var %lc $calc($ctime - $hget(server_cmds,last.change))
  186. var %lw $calc($ctime - $hget(server_cmds,last.write ))
  187. if (($1) || ((%lc < 3600) && (%lw >= 3600))) save_hash
  188. }
  189.  
  190. alias -l load_hash { if (!$hget(server_cmds)) hmake -s server_cmds | if ($isfile(server_cmds.txt)) hload -sm server_cmds server_cmds.txt | last_write }
  191. alias -l save_hash { hsave server_cmds server_cmds.txt | last_write | server_cmds_timer }
  192.  


Comments (1) - Replies (0)
September 23rd, 2018 - By: entropy
this is a test...