This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Need help with a script

Old posts that have not been replied to for several years.
Locked
m
mesqal

Need help with a script

Post by mesqal »

Hi,

i have modified a given script that checks for badrealnames on join, so that the script should check on away messages in whois.

the whois-proc works fine, but it doesn´t set the ban that shall be imposed if the whois-output triggering one of the search-terms.....

Code: Select all

# awaycheckonjoin.tcl
# original code by papillon & caesar
# modified by elgringo
# version 0.1

# Wich Awaymessages should be banned?
set bada(list) {
"*sex*"
"FREE"
}

# wich channels to monitor?
set bada(chan) "#germany"

# how long lasts the ban (in minutes)
set bada(time) 5

# wich banmessage should be set?
set bada(reason) "No Drones!" 

##No MODs under this line except u know what you´re doing

bind join - "$bada(chan) *" away:join
bind raw - 301 away:check


#join

proc away:join {nick host hand chan args} { 
  if {[strlwr $nick] == [strlwr $::botnick] || [matchattr $hand of|fo $chan]} {
    return
  } 
  putserv "WHOIS $nick" 
}


#check

proc away:check {from key arg} { 
  set awy [strlwr [ctrl:filter [lindex [lrange [split $arg ":"] 1 end] 9]]]
  foreach bla $::bada(list) {
    if {![string match -nocase $bla $awy]} {
      continue
    }
    newchanban $::bada(chan) "*!*@[lindex [split $arg] 3]" $::botnick $::bada(reason) $::bada(time)
    break
  }
}


## 
# ppslim's filter

proc ctrl:filter {str} {
  regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $str "" str
  return $str
}

putlog "badaway.tcl by elgringo loaded."

Anyone got a clue why the script doesn´t work properly?

thank u beforehand :wink:

Regards

mesqal
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

replace

Code: Select all

set awy [strlwr [ctrl:filter [lindex [lrange [split $arg ":"] 1 end] 9]]] 
with

Code: Select all

set awy [strlwr [ctrl:filter [lindex [lrange [split $arg ":"] 1 end] 0]]]
and

Code: Select all

if {[strlwr $nick] == [strlwr $::botnick] || [matchattr $hand of|fo $chan]} {
with

Code: Select all

if {[isbotnick $nick] || [matchattr $hand of|fo $chan]} {
Once the game is over, the king and the pawn go back in the same box.
m
mesqal

Post by mesqal »

first of all: thank u ceasar for ypur reply!

But it doesn´t work neither.

i don´t have a clue whats wrong, im new into tcl. i thought the line:

Code: Select all

set awy [strlwr [ctrl:filter [lindex [lrange [split $arg ":"] 1 end] 9]]]
is setting the var awy stringlower, calling filter proc listindex listrange splitting the arguments at : from line one till end and the 9 is the line that should be intepreted? am i right?

the whois works proper, but the Bot wont set the ban on drones with away (raw 301) and the words sex or free in it....

could u please help me again?

Greets

mesqal
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

First check to see what output are you getting for $awy.

Code: Select all

putlog "AWAY MESSAGE: $awy"
If it is the text in the away message, using a string match function with a foreach loop you can match the text, or I think you have a list here right, so you can also use lsearch -exact to match out the words and then go ahead and ban that user.

For that use the bind raw, set uhost [getchanhost $nick]. First you have to get $nick from $from to use that or you can directly get the uhost from $arg too by splitting. Then go ahead and split it in the way you like to ban to be placed.

Code: Select all

  set nick [lindex [split $from "!"] 0]
  set uhost [getchanhost $nick]
  set host "*!*@[lindex [split $uhost "@"] 1]"

OR

  set nick [lindex [split $from "!"] 0]
  set uhost [getchanhost $nick]
  set temp [expr [string first @ $uhost] + 1]
  set host "*!*@[string range $uhost $temp end]"

Although I am not sure about the output for $arg.
Maybe $nick can be: (have to test it!)

set nick [lindex [split $from "!"] 0]
OR
set nick [lindex $arg 1] (#I use this for my badrealname script)
Something like this, should do it:

Code: Select all

#Which away messages should be banned? 
set awaywordlist { 
"sex" 
"free" 
} 

#Which channels to monitor? 
set awaybanchans "#germany" 

#How long lasts the ban (in minutes) 
set awaybantime "5" 

#Which ban message should be set? 
set awaybanreason "No Drones!" 

bind join - "*" away:join 
bind raw - 301 away:check 

proc away:join {nick uhost hand chan} {
 global botnick awaybanchans
  if {(![isbotnick $nick]) && (![matchattr $hand fo|fo $chan]) && ([lsearch -exact [split [string tolower $awaybanchans]] [string tolower $chan]] != -1)} { 
  putserv "WHOIS $nick"; return 0
  }
} 

proc away:check {from key arg} { 
 global botnick awaywordlist awaybanchans awaybantime awaybanreason
  set awaymsg [string tolower [ctrl:filter [lindex [lrange [split $arg ":"] 1 end] 9]]]
  putlog "Testing AWAY Message: $awaymsg"
  putlog "Testing Banmask: *!*@[lindex [split $arg] 3]"
  foreach awayword $awaywordlist { 
   if {([string match -nocase *$awayword* $awaymsg])} {
    newchanban $awaybanchans "*!*@[lindex [split $arg] 3]" away:msg $awaybanreason $awaybantime
    return 0 
    }
  } 
}

proc ctrl:filter {str} { 
  regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $str "" str 
  return $str 
} 
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
m
mesqal

doesn´t work :(

Post by mesqal »

Hi awyeah,

thank u for your reply :)

The Script doesn´t work neither. On Partyline the bot is writing this:
[18:11] [s->] WHOIS senaaa
[18:11] [@] Geneva.CH.EU.Undernet.org 311 blechi senaaa ~BIGGIRL^^ adsl-81-7-123-4.takas.lt * :shkwmenos
[18:11] [@] Geneva.CH.EU.Undernet.org 319 blechi senaaa :#germany #france
[18:11] [@] Geneva.CH.EU.Undernet.org 312 blechi senaaa *.undernet.org :The Undernet Underworld
[18:11] [@] Geneva.CH.EU.Undernet.org 301 blechi senaaa :FREE SEX & PORNO & PICS & OVIES http://teenssex.gen.ms
[18:11] Testing AWAY Message:
[18:11] Testing Banmask: *!*@SEX
i´m not familiar enough to get the error, i don´t know whats wrong.

The point why we need this script is the awaymessage as shown above. This awaymessage is used by a trojan/backdoor/worm that infects computers that visit the URL given in the awaymessage. the whole thing is like an avalanche, the more infected pc´s, the more spreading the worm/trojan/virus. Could u please help us to get a script to get rid of this infected drones?

Thank u beforehand

Regards

mesqal
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Have you tried what I've sugested? I'm talking about the "0" not "9" at the "set awy" line.
Once the game is over, the king and the pawn go back in the same box.
m
mesqal

Post by mesqal »

sorry, nope, it doesn´t work. I´ve tested it to replace both lines, then i replaced only the firts, then only the second, but it don´t do it :(

I hope i didn´t bother u to much, thanx again.

greets

mesqal
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

caesar:
I think the list index/range number might be incorrect. Other than that I think the script is working fine because the list index/range is not giving any result for the variable and the output is null. :roll:

mesqal:
This is wrong *!*@[lindex [split $arg] 3]. It will never return the host of the user. :wink:

You need to use it as I have defined in my earlier post. First find out $nick from the variable $from in the procedure binded on raw. Then from $nick you can get the uhost of the person, by using getchanhost. :mrgreen:

For the banmask try this:

Code: Select all

#This is it.

  set nick [lindex [split $from "!"] 0] 
  set uhost [getchanhost $nick] 
  set host "*!*@[lindex [split $uhost "@"] 1]" 
For the away message try this:

Code: Select all

set awaymsg [string tolower [ctrl:filter [lrange $arg 3 end]]]
or
set awaymsg [string tolower [ctrl:filter [lrange $arg 4 end]]]

#We can strip the ":" later. While matching you can use wildcards
#on both sides such as *$word* so they will be matched as well.
Have you binded on the correct raw number even?
Check the raw number with your IRCd type as well!
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

That's funny cos I've tested it myself and is working.. anyway, screw it! :x
Once the game is over, the king and the pawn go back in the same box.
m
mesqal

Improvement

Post by mesqal »

Hi awyeah,

i think there is an improvement :P

Heres the hole script:

Code: Select all

#badawayban 0.2

#Which away messages should be banned?
set awaywordlist {
"*sex*"
"*free*"
}

#Which channels to monitor?
set awaybanchans "#germany"

#How long lasts the ban (in minutes)
set awaybantime "5"

#Which ban message should be set?
set awaybanreason "To the hilt!"

bind join - "*" away:join
bind raw - 301 away:check

proc away:join {nick uhost hand chan} {
 global botnick awaybanchans
  if {(![isbotnick $nick]) && (![matchattr $hand fo|fo $chan]) && ([lsearch -exact [split [string tolower $awaybanchans]] [string tolower $chan]] != -1)} {
  putserv "WHOIS $nick"; return 0
  }
}

proc away:check {from key arg} {
 global botnick awaywordlist awaybanchans awaybantime awaybanreason
  set nick [lindex [split $from "!"] 0]
  set uhost [getchanhost $nick]
  set host "*!*@[lindex [split $uhost "@"] 1]"
  set awaymsg [string tolower [ctrl:filter [lrange $arg 3 end]]]
  putlog "Testing AWAY Message: $awaymsg"
  putlog "Testing Banmask: $host"
  foreach awayword $awaywordlist {
   if {([string match -nocase *$awayword* $awaymsg])} {
    newchanban $awaybanchans "*!*@[lindex [split $arg] 3]" away:msg $awaybanreason $awaybantime
    return 0
    }
  }
}

proc ctrl:filter {str} {
  regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $str "" str
  return $str
} 

putlog "badaway0.2.tcl loaded"
It provides the following infos on partyline:
[22:19] [s->] WHOIS elotroyo_
[22:19] [@] Geneva.CH.EU.Undernet.org 311 blechi elotroyo_ ohdannyboy 213.252.228.110 * :slma
[22:19] [@] Geneva.CH.EU.Undernet.org 319 blechi elotroyo_ :#germany #france
[22:19] [@] Geneva.CH.EU.Undernet.org 312 blechi elotroyo_ *.undernet.org :The Undernet Underworld
[22:19] [@] Geneva.CH.EU.Undernet.org 301 blechi elotroyo_ :FREE SEX & PORNO & PICS & OVIES http://teenssex.gen.ms
[22:19] Testing AWAY Message: sex & porno & pics & ovies http://teenssex.gen.ms
[22:19] Testing Banmask: *!*@
[22:19] [@] Geneva.CH.EU.Undernet.org 318 blechi elotroyo_ :End of /WHOIS list.
I think he gets the awaymessage at the right way, but nevertheless he don´t get the mask properly so a ban won´t be set.

how do u split the line

Code: Select all

[22:19] [@] Geneva.CH.EU.Undernet.org 311 blechi elotroyo_ ohdannyboy 213.252.228.110 * :slma
so u can get the nickname out of the string? I suggest it´s the fault that the script wont get the nick properly and therefore it wont get the host/uhost at the right way. Am i totaly wrong?

Thanks for reading and helping.

Hey caesar, thank u also, we´re using your badrealname script, and it works great!

Greets

mesqal

P.S.: The ircd (Undernet) is using RFC1459 compatible raw events, so 301 IS away.
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

[22:19] [@] Geneva.CH.EU.Undernet.org 311 blechi elotroyo_ ohdannyboy 213.252.228.110 * :slma
Which is the nick here? I don't know.
I know the host is in numbers which is 213.252.228.110

Just to get it use list index.

The first 'Geneva.xxxxxx' is index 0
The second '311' is index 1
The third 'blechi' is index 2.

And so on, so to get 311 out from that output
you can use [lindex $arg 1]. Remember the list index
starts from 0.

Logicially the banmask catching thing seems fine and I use the same method for finding user@hosts from raws and it works fine for me. Try unloading some scripts, maybe they are clashing or something. :P

I think it depends upon the raw. The raw only shows the away message. Try binding to another raw, for badrealname. Then output of that raw 311 shows the users nick, user@host, and realname in that kinda format. :mrgreen:

Try using, this within the code to check:

Code: Select all

#Use this after you have declared the variables.
putlog "Nick of user: $nick"
putlog "User@host of user: $uhost"
putlog "Banmask of user: $host"
If the bot gets the nick correctly, getchanhost should work! getchanhost $nick should definately work if the user is found on any channels matching with the bot is on. :roll:

As caesar said, screw it. I don't have time to test this though as I am not IRC'ing these days, maybe I will sometime!
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
m
mesqal

JUMP

Post by mesqal »

Hello again,

the script is running! i wish to thank awyeah and ceasar for the tips :)

Here´s the code:

Code: Select all

#badawayban 1.0

#Which away messages should be banned?
set awaywordlist {
"sex"
"free"
}

#Which channels to monitor?
set awaybanchans "#germany"

#How long lasts the ban (in minutes)
set awaybantime 5

#Which ban message should be set?
set awaybanreason "To the hilt!"

bind join - "*" away:join
bind raw - 311 get:host
bind raw - 301 away:check

proc away:join {nick uhost hand chan} {
 global botnick awaybanchans
  if {(![isbotnick $nick]) && (![matchattr $hand fo|fo $chan]) && ([lsearch -exact [split [string tolower $awaybanchans]] [string tolower $chan]] != -1)} {
  putserv "WHOIS $nick"; return 0
  }
}

proc get:host {from key arg} {
	global host
	set nick [lindex $arg 1]
	set uhost [getchanhost $nick]
	set host "*!*@[lindex [split $uhost "@"] 1]"
	
}     
 

proc away:check {from key arg} {
 global botnick awaywordlist awaybanchans awaybantime awaybanreason host
  set awaymsg [string tolower [ctrl:filter [lrange $arg 3 end]]]
  putlog "Testing AWAY Message: $awaymsg"
  putlog "Testing Banmask: $host"
  putlog "Testing Ban at itself: $::awaybanchans $::host $::botnick $::awaybantime $::awaybanreason"
  foreach awayword $awaywordlist {
   if {([string match -nocase $awayword $awaymsg])} {
   continue
   }
    newchanban $::awaybanchans $::host $::botnick $::awaybanreason $::awaybantime 
    return 0
    
  }
}

proc ctrl:filter {str} {
  regsub -all -- {\003[0-9]{0,2}(,[0-9]{0,2})?|\017|\037|\002|\026|\006|\007} $str "" str
  return $str
} 

putlog "badaway3.tcl by elgringo loaded."
The only thing i´ve to modify is that the script doesn´t get the awaywords proper, so it bans ALL users that are joining with AWAY. if an user sets away AFTER joining channel the script wont ban em, thats ok and as it should be.

Anyone have a clue what i´ve to modify to get the awaywords working?
:roll:

greets

mesqal
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Good thing it worked! :mrgreen:
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked