mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2021
Posts: 87
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 87
Greetz folks,

we have been using this code (i found on the net ages ago) to catch text repeats from multiple nicks with different hosts to store them all and ban them ( we would like to add stacked modes and kicks if possible as well to limit ban settings and kicks we use this on dalnet i believe max stacked modes is 6 and max stacked kicks is 4)

it works somewhat except it doesnt catch the first nick who started the text repeats

here is what we work with:

Code

ON ^*:text:*:#:{ 
  if ($nick(#,$me,@&~%) && !$nick(#,$nick,@&~%)) {  
    if (*irccloud* iswm $site) { halt }
    Xpro_check $nick $strip($1-,burcmo) 
  }
}


Alias Xpro_check {
  if ($nick($chan,$1,@&~%)) return
  var %h = $hash($lower($strip($left($2-,400),burcmo)),32)
  if (%protect.r. [ $+ [ $chan ] $+ . $+ [ %h ] ] < 70) inc -z %protect.r. $+ $chan $+ . $+ %h 20
  inc -z %protect.r. $+ $chan $+ . $+ $chan $+ . $+ %h %protect.r. [ $+ [ $chan ] $+ . $+ [ %h ] ]
  inc -z %protect.r. $+ $chan $+ . $+ $chan $+ . $+ %h %protect.j. [ $+ [ $chan ] $+ . $+ [ $chan ] ]
  if (%protect.r. [ $+ [ $chan ] $+ . $+ [ $chan ] $+ . $+ [ %h ] ] > 2) { 
    mode # +b $address($1,4)
  }
}



Last edited by Simo; 17/11/22 12:58 PM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
This is having the same problem as a similar script you were asking about months ago. If you want to catch the 1st nick, then you need to keep track of all nicks for all messages, just in case one of them happens to get repeated later. This script is only taking action when the hash is repeated, without having saved the nick who did the original hash.

And as I'll remind you of what I mentioned the last time, that kicking the original nick would give great opportunity for lolz, where all I need to do to get someone kicked also - is to repeat what they innocently put into a channel message.

* *

Some things you might take a look at:

1. burcmo is excluding italic and strikethru. If your intent is to remove all control codes, then that 2nd parm can just be skipped.

2. Curious why you're limiting $2- to 400, and not just using the entire string. As a spammer, i can send a message where $left($2-,400) is different each time, followed by my repeated spam beginning at position 401 of $2-. Plus, you're limiting to 400 before stripping the controlcodes, so the string seen by $hash could be very short if someone used a lot of control codes

3. The script should be updated to use a different hash instead. For one thing, it's easy to create 2 different strings which match the same $hash(string,32) value. These match, and if you insert the same string in front of both examples, then those match each other too:

//echo -a $base($hash(ABCDEF,32),10,16) / $base($hash(ABDDEE,32),10,16)

For another thing, there are only 2^24 possible $hash(string,32) values, so you're better off using $crc($strip($2-),0). And if you're worried about someone creating intentional collisions, which can be done in a few seconds with $crc, you can make it a little harder with $crc(secret constant $strip($2-),0) and can have a simple mechanism to change the 'secret' daily

Something fairly fast and less likely to have a false match is:

Code
alias md5hash { return $right( $base($right($md5($1),13),16,36) , $iif($2 isnum 1-11,$2,11) ) }

This squeezes 2^52 possible hashes into a 1-11 digit hash, and you can use $2 if you want to shorten it even further. Or if string space isn't an issue you can just store the whole hash. Even though MD5 has been discredited from a crypto standpoint, that's because of the ease involved in creating 2 binary strings that match each other, but I've yet to find an example where someone has created an MD5 collision between 2 UTF8 text strings, and even the existing MD5 collisions take longer to create than your -z countdown.

4. Just confirming your intent is to halt all irccloud messages rather than just /return

5. You may want to switch to putting this all in a hash table. These are values which don't need to be a global variable that exists the next time mIRC restarts, which requires an ON START even to clear them up. Because if mIRC crashes after the variable is written to vars.ini and before it reaches zero, that variable will exist as a %global that's not in the -z countdown, just waiting to match someone.

Also, if you switch to using a hashtable, you can create hashtable items and check their values using $+(protect.r.,$chan,.,$chan,.,%h) without needing to use any compound braces at all, which means your scripts will be a lot easier for you to read later. Plus, since this is data that does not need to be saved for the next session, that's no problem because the hashtable doesn't get saved to disk unless you use /hsave.

Joined: Nov 2021
Posts: 87
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 87
thanks for the explanation maroon much arpreciated only im not sure how to translate that into code

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I'll probably need to wait to see you in channel, this code looks more confusing the more i look at it. You say that you're banning repeats, but it's not necessarily banning a repeat because of (> 2) and your -z countdown. I get the feeling there's more info that's not being mentioned here. For sure there's at least 1 variable here that swoops out of nowhere without being defined anywhere. This may end up being a case of what you need and what you say you need may not be the same things

Joined: Nov 2021
Posts: 87
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 87
the idea is to detect text repeats withing a time frame from multiple hosts and stack them to send to kick and ban

and to avoid detecting things like :

hello
hello
hi
hi

we can use text length i assume to only check on certain length

Joined: Nov 2021
Posts: 87
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 87
If anyone could help me out with this would be greatly appreciated as we get quite a lot of these repeated texts from multiple hosts

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Um, not sure what you're talking about. I spent a couple of hours with you in the help channel dealing with this, and then you wandered off, so I thought you had everything working

Joined: Nov 2021
Posts: 87
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 87
yes something came up i had to run sorry about that i tried testing some more with the code u gave me

Code

ON ^*:text:*:#test:{ Xpro_check $nick $strip($1-)  }


Alias Xpro_check {
  if ($nick(#,$1,a,r)) return
  var %h = $+($md5($lower($strip($2-))),.,$chan,.,$network) 
  if (!$hget(Xpro_check,%h)) { hadd -mu5 Xpro_check %h $1 | return }
  mode # +b $address($1,2) | if ($v1 != 1) mode # +b $address($v1,2) | hadd -mu5 Xpro_check %h 1
}



it doesnt seem to get the first nick that started the repeat

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
when you use if (!evaluates as number) it fills $v1 with the opposite state. i.e.

//if (!$false) noop | echo -a $v1 is $true
//if (!$true) noop | echo -a $v1 is $false


So this is another example if why I warn against using the if (thing) unless you know for sure that 'thing' is a number and can never be $null. Or in this case needing to use $v1. To keep from having the value flipped by the '!', you can do:

if ($hget(Xpro_check,%h) != $null)

... and that preserves $v1 as the expected value, and your problem would have been exposed by a debug echo of what the $v1 value would have been after the 1st nick is banned

And, it sounds like you intend to stack the bans, which means you'll eventually replace the ban command with some kind of pushmode command. But if that doesn't preserve the $v1 value, then you're suddenly hosed again, so in that case you need to save /var %v1 $v1 to keep it being destroyed by an alias.

Joined: Nov 2021
Posts: 87
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 87
thank you maroon i tried it like this and added the suggested change did some tests and it only seemed to ban the first nick that started the repeat

Code

Alias Xpro_check {
  if ($nick(#,$1,a,r)) return
  var %h = $+($md5($lower($strip($2-))),.,$chan,.,$network) 
  if ($hget(Xpro_check,%h) != $null) { hadd -mu5 Xpro_check %h $1 | return }
  mode # +b $address($1,2) | if ($v1 != 1) mode # +b $address($v1,2) | hadd -mu5 Xpro_check %h 1
}



Last edited by Simo; 22/11/22 01:30 PM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
if ($hget(Xpro_check,%h) != $null)

change the != into ==

Joined: Nov 2021
Posts: 87
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 87
edited tested it and the first nick that started the repeat doesnt get banned

Code
Alias Xpro_check {
  if ($nick(#,$1,a,r)) return
  var %h = $+($md5($lower($strip($2-))),.,$chan,.,$network) 
  if ($hget(Xpro_check,%h) == $null) { hadd -mu5 Xpro_check %h $1 | return }
  mode # +b $address($1,2) | if ($v1 != 1) mode # +b $address($v1,2) | hadd -mu5 Xpro_check %h 1
}

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I don't understand the problem. I took the same alias you just pasted and then modified the bans so they would be a green or red echo instead, then i called the alias twice. The 1st time it didn't do anything, but the 2nd time it showed a green echo by banning the 2nd person, and then following that is the red echo banning the original nick - assuming they're still in channel. Do you not see the green then red bans?

//Xpro_check AnyNick1 test test | /Xpro_check AnyNick2 test test

Code
alias Xpro_check {
  if ($nick(#,$1,a,r)) return
  var %h = $+($md5($lower($strip($2-))),.,$chan,.,$network) 
  if ($hget(Xpro_check,%h) == $null) { hadd -mu5 Xpro_check %h $1 | return }
  echo 3 -s mode # +b $address($1,2) | if ($v1 != 1) echo 4 -s  mode # +b $address($v1,2) | hadd -mu5 Xpro_check %h 1
}

Joined: Nov 2021
Posts: 87
Simo Offline OP
Babel fish
OP Offline
Babel fish
Joined: Nov 2021
Posts: 87
tested again excellent thanks maroon, anyway we could stack the nicks and banmasks to send away as stacked of 6 for bans and 4 for kicks as ircd allows that instead of spamming channel with bans and slow kicks

Last edited by Simo; 22/11/22 05:39 PM.
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
This is starting to turn into something that needs to be more of an in-person discussion, because there will be several issues with that.
Such as how is it supposed to know when to go ahead and send the less-than-6 bans instead of waiting for another. Because you can't know if there will be another repeat until it happens.
Weren't you the one who had a pushmode script that was already doing some of this?
One thing that this system would need to do is remember which bans have been made recently so it doesn't do the ban again if it's same nick doing a repeat, or if it's a 2nd nick matching the same banmask.
etc.


Link Copied to Clipboard