egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

detect bad word hidden in long nicks
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Tue Aug 23, 2022 5:51 am    Post subject: detect bad word hidden in long nicks Reply with quote

greetingz folks,


we have been using this tcl for a while it works fine but we wanted to be able to check for hidden badnick paterns hidden withing the nickname nicks like

badnick hidden in:

Quote:
drgb-a}d-nzuickcqf


without having to use a lot of *


Code:

set bnick {
     "badnick"
   "someverylongbadword"
   "somewordthatsbad"
   "veryabussivelongword"
}


bind join - * join:badnick
bind nick - * nick:badnick

proc nick:badnick {nick uhost hand chan newnick} {
   join:badnick $newnick $uhost $hand $chan
}


proc join:badnick {nick uhost hand chan} {
   global bnick temp
   regsub -all -- {(.)\1+} $nick {\1} nick2x2

   set temp 0
   foreach i [string tolower $bnick] {
      if {[string match *$i* [string tolower $nick2x2]]} {
         set badpart $i
         set temp 1
      }
   }

   if {!$temp} { return } {
      pushmode $chan +b *$badpart*!*@*
   }
}


Last edited by simo on Sun Aug 28, 2022 1:53 am; edited 3 times in total
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Wed Aug 24, 2022 3:41 am    Post subject: Reply with quote

this is a way i know of in msl :

Code:


if ($regex($gettok($nick,/( $+ $regsubex(badword|badword|badword|badword|badword|badword|badword|badword|badword|badword|badword|badword,//g,.*) $+ )/i)) {  do stuff } 



Last edited by simo on Sun Aug 28, 2022 1:45 am; edited 1 time in total
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Fri Aug 26, 2022 4:09 am    Post subject: Reply with quote

the regex basically checks for

Quote:
*b*a*d*w*o*r*d*


in the nick

not sure if there is an equivalent of that in regex for eggdrop
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Sun Aug 28, 2022 1:43 am    Post subject: Reply with quote

Is this not doable with regexp / regsub or a combination of the two?

Or another way perhaps
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1058
Location: France

PostPosted: Mon Aug 29, 2022 11:05 am    Post subject: Reply with quote

This is because *b*a*d*w*o*r*d* must be (to be used in regexp) :
Code:
[^\s]*b[^\s]*a[^\s]*d[^\s]*w[^\s]*o[^\s]*r[^\s]*d[^\s]*


You can probably make a little proc which will transform all your badnicks into the good regexp

https://regex101.com/r/Ahp8OQ/1
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Mon Aug 29, 2022 6:02 pm    Post subject: Reply with quote

Thanks crazycat but when I said it checks for *b*a*d*n*i*c*k*
I didn't mean it checks for literally * in the nick but rather it searches between chars to find hidden badword hidden between characters to evade a ban
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1058
Location: France

PostPosted: Mon Aug 29, 2022 6:33 pm    Post subject: Reply with quote

Did you check my regex101.com link before answering ?
_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Tue Aug 30, 2022 5:59 pm    Post subject: Reply with quote

Thanks crazycat Yes i checked it it has a lot of * i wanted to prevent that to add a zillion * for each bad word to check for
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1058
Location: France

PostPosted: Tue Aug 30, 2022 6:43 pm    Post subject: Reply with quote

...
I said you that you can create a proc to transform your badnicks into regexp:
Code:
proc bn2reg {text} {
   set sep {[^\s]*}
   set reg $sep
   for {set i 0} {$i<=[string length $text]} {incr i} {
      append reg [string index $text $i]$sep
   }
   return $reg
}


Test in tclsh:
Code:
% proc bn2reg {text} {
   set sep {[^\s]*}
   set reg $sep
   for {set i 0} {$i<=[string length $text]} {incr i} {
      append reg [string index $text $i]$sep
   }
   return $reg
}
% bn2reg badnick
[^\s]*b[^\s]*a[^\s]*d[^\s]*n[^\s]*i[^\s]*c[^\s]*k[^\s]*

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Wed Aug 31, 2022 4:10 am    Post subject: Reply with quote

thanks CrazyCat let me try that
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Sat Sep 10, 2022 5:32 am    Post subject: Reply with quote

Sorry for the late reply, i wanted to try your last posted code crazycat but im not sure how to test it with the current badnick checker i have in use the one i posted above
Back to top
View user's profile Send private message
CrazyCat
Revered One


Joined: 13 Jan 2002
Posts: 1058
Location: France

PostPosted: Sat Sep 10, 2022 9:20 am    Post subject: Reply with quote

Just replace
Code:
if {[string match *$i* [string tolower $nick2x2]]}

with
Code:
if {[regexp [bn2reg $i] [string tolower $nick2x2]]}

_________________
https://www.eggdrop.fr - French IRC network
Offer me a coffee - Do not ask me help in PM, we are a community.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Sat Sep 10, 2022 11:00 am    Post subject: Reply with quote

thanks CrazyCat
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Sat Sep 10, 2022 11:07 am    Post subject: Reply with quote

after trial i get :

Quote:
couldn't compile regular expression pattern: quantifier operand invalid



i used :

Code:

      if {[regexp [bn2reg $i] [string tolower $nick2x2]]} {
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Sat Sep 10, 2022 11:09 am    Post subject: Reply with quote

ive changed to :


if {[regexp -- {[bn2reg $i]} [string tolower $nick2x2]]} {


but now it sets weird bans


17:13:25   Joins :   sfbdfadnicksdjh   [ident: Mibbit]     *!*@32.158.124.74
17:13:25 @Hawk Sets Mode on #test to: +b *veryabussivelongword*!*@*

i guess what we were looking is +b *b*a*d*n*i*c*k*!*@*

to set wild mask ban on the detected bad part of nick


Last edited by simo on Sat Sep 10, 2022 11:26 am; edited 3 times in total
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber