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 

SpamScan
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Thu Jun 30, 2005 3:49 am    Post subject: SpamScan Reply with quote

I made this script awhile back and have been testing it quite alot.
You can download the script here
http://www.development.woosah.org/download.php?view.8
Tell me what you think of it Smile

I'm sending it to slennox soon so you won't find it in the tcl archive right now
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Jul 01, 2005 9:22 pm    Post subject: Reply with quote

care to explain how does it do its job, maybe paste some relevant code?

I'm curious, but can't be bothered to download and examine it hehe
Back to top
View user's profile Send private message Visit poster's website
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Sat Jul 02, 2005 2:54 am    Post subject: Reply with quote

Here are parts of the script, that should make you understand i guess Smile

Code:
# /* Configuration
# * In seconds, If the last time they spammed was 20 seconds they will get 15 points added (default settings)
variable time      "10"
variable time2     "15"
variable time3     "20"

# * Points we give for spamming/advertising
variable advert    "40"
variable advert2   "50"
variable advert3   "60"

# * Points we give out for flood/spam
variable flood     "15"
variable flood2    "10"
variable flood3    "5"

# * Points they need to get punished.
variable warn      "80"
variable kick      "100"
variable ban       "120"


Code:
  if {$spamscan::spamscan} {
   if {[advertisement $arguments]} {
    if {$checktime >= $spamscan::time3} {
     incr db($channel,$ident) $spamscan::advert3
    } elseif {$checktime >= $spamscan::time2} {
     incr db($channel,$ident) $spamscan::advert2
    } else {
     incr db($channel,$ident) $spamscan::advert
    }
   }
  }


Code:
  if {$db($channel,$ident) >= $ban} {
    putlog "$nickname was \0034banned\003 in $channel. \(score: $db($channel,$ident)\)"
    set banmask [banmask $hostname]
    putquick "MODE $channel +b $banmask"
    putquick "KICK $channel $nickname :[string map "%nickname $nickname %channel $channel %id [expr [channel get $channel spamkicked] + 1]" [join $kickmsg]]"
    channel set $channel spamkicked "[expr [channel get $channel spamkicked] + 1]"
    if {$bantime != "0"} {
     timer $bantime [list pushmode $channel -b $banmask]
    }
  } elseif {$db($channel,$ident) >= $kick} {
    putlog "$nickname was \0038kicked\003 in $channel. \(score: $db($channel,$ident)\)"
    putquick "KICK $channel $nickname :[string map "%nickname $nickname %channel $channel %id [expr [channel get $channel spamkicked] + 1]" [join $kickmsg]]"
    channel set $channel spamkicked "[expr [channel get $channel spamkicked] + 1]"
  }


It will just add a score for each line said and decrease the score over time, If the score gets to a certain point the script will do something, like warn or kick that person.

It's purely for text and stuff, not other things Smile

(This is how the spamscan service on Quakenet works)
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Sat Jul 02, 2005 3:18 am    Post subject: Reply with quote

hmm I was actually more interested in the spam detection method - what your definition for spam is and how it gets applied to channel traffic

I presume it's in the [advertisement] proc
Back to top
View user's profile Send private message Visit poster's website
Dizzle
Op


Joined: 28 Apr 2005
Posts: 109

PostPosted: Tue Jul 05, 2005 3:19 am    Post subject: Reply with quote

I see its reacting on these advertise lines

Code:

proc spamscan::advertisement {line} {
 if {[regexp -- {\x23\S+|[a-zA-Z0-9]+://\S+\.[a-zA-Z0-9]+|www[0-9]*\.\S+\.[a-zA-Z]+} $line]} {
  return 1
 }
 return 0
}


Does this detect most off the advertisment??

Im going too test it outonmy channel if i find something ill post it here
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Tue Jul 05, 2005 9:37 am    Post subject: Reply with quote

That proc will detect if an channel name or website is being advertised and that's all it does. Hence the procname
Back to top
View user's profile Send private message
Dizzle
Op


Joined: 28 Apr 2005
Posts: 109

PostPosted: Wed Jul 06, 2005 11:55 am    Post subject: Reply with quote

i tested the script untill now i like it, no bugs or weird things happend, butt one question metroid.

Is there a way i can putt in aline where the doesnt react on ??

in my channel ppl can request relay's (based on your forum script)

butt ppl get warned or even kicked when they use !request 01 #chan

is there a way i can make the script ingore ONLY this ??

greetz Dizzle
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
awyeah
Revered One


Joined: 26 Apr 2004
Posts: 1580
Location: Switzerland

PostPosted: Thu Jul 07, 2005 7:37 am    Post subject: Reply with quote

Here is a good match pattern for regexp to detect all types of urls:

Code:

(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]


Also I was wondering how can I detect repeated words in a string through regexp or even string match? Then count how many are present? For regexp I found this:

Code:

(\w+)\s+\1


I can do that by using 2 foreach loops on the same string, checking one word, matching against others and going for the next one and doing all again and going further. But is there a simpler and easier way?
_________________
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
greenbear
Owner


Joined: 24 Sep 2001
Posts: 733
Location: Norway

PostPosted: Thu Jul 07, 2005 10:05 am    Post subject: Reply with quote

or you can use this if you want to find a url inside a string and dont want to use a regexp longer than your arm..
Code:
regexp -nocase {((http|ftp)://[^\s]+)} $text url
Back to top
View user's profile Send private message Send e-mail
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Thu Jul 07, 2005 11:02 am    Post subject: Reply with quote

I suggest adding a check for server advertising and those lame decode messages.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
awyeah
Revered One


Joined: 26 Apr 2004
Posts: 1580
Location: Switzerland

PostPosted: Fri Jul 08, 2005 3:35 am    Post subject: Reply with quote

So about that:

Quote:

Also I was wondering how can I detect repeated words in a string through regexp? Then count how many are present like with the -all switch I can do that. The main thing is to detect repeated words not characters.


Anyone?
_________________
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Jul 08, 2005 3:50 am    Post subject: Reply with quote

if by "word" you mean sequence of non-whitespace characters, you need to split, trim and then count repeating list elements (be careful to avoid redundant string comparisons); hint: use Tcl's associative array
Back to top
View user's profile Send private message Visit poster's website
awyeah
Revered One


Joined: 26 Apr 2004
Posts: 1580
Location: Switzerland

PostPosted: Fri Jul 08, 2005 4:28 am    Post subject: Reply with quote

First of all:
set string [string trim [split $text]]

Then:
Umm, tcl assoicated arrays. Actually I am unable to get the logic on how to count for repeated words using the array logic in my head currently. Have any rough example or so?
_________________
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Jul 08, 2005 4:46 am    Post subject: Reply with quote

Code:

foreach word $words {
   if {[info exists count($word)]} {
      incr count($word)
   } {
      set count($word) 1
   }
}


on a second thought, you can do that without splitting into a list, just by using [scan] - but I'm going to bed already Razz
Back to top
View user's profile Send private message Visit poster's website
awyeah
Revered One


Joined: 26 Apr 2004
Posts: 1580
Location: Switzerland

PostPosted: Fri Jul 08, 2005 4:56 am    Post subject: Reply with quote

Hehe, okay that wasn't difficult enough, just using normal arrays. Incr count if a similar word is found, else there is a new word.Very Happy

Sometimes the easiest things can take alot of time to receive from the brain.
No I am not good with scan, I use lindex, split to get away from it.

NOTE: I was trying to develop a way to deteriorate flood bots who use messages with repeating words and text. Based on varying score for words in a string this can be handy. Laughing
_________________
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases 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