So, I want to present to your attention a script that I created for you. It may not do everything all that you hoped it would, but in my opinion, this script does a good job of most of the things you would like to see. cool
This script will set a ban (ZLINE) on all incoming connections for those users whose host matches the host mask on the blacklist. Provided that the bot in which you install this code will have the privileges of IRCop Snomask (+cC)

The screenshot shows how I tried to simulate a user connecting from different host addresses, and that the script returns to me in echo-response when it found the user's host that matched the mask on the blacklist shown in the screenshot to the right. Each line in the screenshot shows the user's nickname, his host, line number and mask that were found in the black list:

      [Linked Image from i.ibb.co]

Now to a description of how it works. In the alias "cbl_data" you can configure all the necessary data to your liking. I think everything is clear here. But, just in case, I will give a help so that there are no questions:

%cbl_logo = CheckHostBL               | ;This value specifies the script logo for the message, so that it is clear from which script this line is.
%cbl_path = D:\blacklist.txt             | ;This is the path to your blacklist. It can be changed to a place convenient for you.
%cbl_btype = ZLINE                     | ;Here you specify the type of server ban that you want the script to execute if the host matches the mask. Possible options: <ZLINE/KLINE/GLINE>
%cbl_btime = 1h                      | ;Here, specify the time for which you want to ban the offender. Format: <1y/2w/3d/4h/5m/6s>
%cbl_reason = Possible "VPN/Tor/Proxy" | ;Here you can indicate the reason for the ban, as well as indicate an email so that in case of an error you can be contacted to unblock.

At the very bottom, in the alias "cbl_return", you can enable the type of messages through which you want to receive notifications when the script reacts to the intruder when connecting to the server. Just remove the ";" from the lines that should work. As a parameter "AdminNick" you must indicate the nickname of the administrator, to whom to send this message or your nickname. You can comment out these lines with a ";" because if this channel or nickname does not exist on the network you will get an error "No such nick/channel". You can also add your own commands as you see fit.

About filling in the black list. The check is performed according to the list, sequentially adding each part of the user's host, which is separated by periods. Therefore, it is recommended to set the "*" sign in the mask before the point or after. The most complex host masks, such as "*.hsi13.*" or "*.cn", recommended to write at the very top so that they come first. Otherwise it may not always work. Try to keep your blacklist more compact by using the subnet masks you want to banned, and watch for duplicates so that there are no identical addresses in the list.

Installing:

Uncover the spoiler. This code must be inserted into the scripts editor. To do this, press the key combination "ALT+R", select "File/New" and install as a new script and then save it entitled name "CheckHostBL.mrc":

Code
#####################################################################
#   Name: CheckHostBL v1.0
#   Description: Checking the Host/IP of the connecting user in the black list.
#   Author: Epic
#   Email: epicnet@mail.ru
#   Site: http://epicnet.ru
#####################################################################

on *:SNOTICE:*Client connecting*:{
  %cbl_mask = $remove($wildtok($1-,*@*,1,32),$chr(40),$chr(41))
  %cbl_nick = $gettok(%cbl_mask,1,33)
  %cbl_host = $gettok(%cbl_mask,2,64)
  cbl_data | cbl_check %cbl_host %cbl_nick %cbl_mask
}
alias -l cbl_data {
  %cbl_logo = CheckHostBL
  %cbl_path = D:\blacklist.txt
  %cbl_btype = ZLINE
  %cbl_btime = 1h
  %cbl_reason = Possible "VPN/Tor/Proxy"
}
alias -l cbl_check {
  cbl_data | var %cbl_w $numtok($1,46) | var %cbl_q 1 | while (%cbl_q <= $numtok($1,46)) {
    var %cbl_mh1 $gettok($1,$+(1-,%cbl_q),46) | var %cbl_mh2 $gettok($1,$+(%cbl_w,-,$numtok($1,46)),46) | var %cbl_mh3 $gettok($1,%cbl_q,46)
    if ($read(%cbl_path,w,$+(*,%cbl_mh1,*))) || ($read(%cbl_path,w,$+(*,%cbl_mh2,*))) || ($read(%cbl_path,w,$+(*,%cbl_mh3,*))) {
      var %cbl_r $readn | var %cbl_lh $read(%cbl_path,%cbl_r)
      if (%cbl_lh iswm %cbl_mh1) || (%cbl_lh iswm %cbl_mh2) || (%cbl_lh iswm %cbl_mh3) || (%cbl_lh == %cbl_mh1) || (%cbl_lh == $+(%cbl_mh1,*)) || (%cbl_lh == $+(%cbl_mh1,.,*)) || (%cbl_lh == $+(*,%cbl_mh2)) || (%cbl_lh == $+(*,.,%cbl_mh2)) || (%cbl_lh == $+(*,%cbl_mh3,*)) || (%cbl_lh == $+(*,.,%cbl_mh3,.,*)) {
        var %cbl_return = $+(%cbl_logo,:) $+(,$2,) -> $+(30,$1) -> $+($chr(40),line,$chr(32),%cbl_r,$chr(41)) 07 $v1
        cbl_ban $1 $2 %cbl_r | cbl_return %cbl_return | .break
      }
    }
    inc %cbl_q | dec %cbl_w
  }
}
alias -l cbl_ban {
  if (%cbl_btype == GLINE) .GLINE $+(*@,$1) %cbl_btime $+([,%cbl_logo,$chr(32),$3,]) $2 -> %cbl_reason
  if (%cbl_btype == KLINE) .KLINE $+(*@,$1) %cbl_btime $+([,%cbl_logo,$chr(32),$3,]) $2 -> %cbl_reason
  if (%cbl_btype == ZLINE) .ZLINE $1 %cbl_btime $+([,%cbl_logo,$chr(32),$3,]) $2 -> %cbl_reason
}
alias -l cbl_return {
  /echo -s $1-
  ;/msg #Services $1-
  ;/msg AdminNick $1-
  ;/notice AdminNick $1-
}


Remember that if something went wrong, or you accidentally erased something, then you can always reinstall this script again.
If you find any errors in the code and in its work, or maybe you have new ideas or if you think that this script needs to be improved, then be sure to write to me here about it, and we are together think about what we can do.



🌐 http://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples