mIRC Homepage
Posted By: Garou var question - 26/05/07 08:21 AM
Am using this to check version on join...Is it possible to store bad script names in text file instaed of var?

%CTCP MurderScript stealth.Inviter echoX inviter ozinviter echoxinviter VirusScript

Code:
ON !@*:JOIN:#: {
if (%CTCPREPLY == off) || !%CTCPREPLY || ($nick isop $chan) { return }
if !$($+(%,version.check,.,$fulladdress),2) {
.ctcp $nick VERSION 
set -e $+(%,version.check,.,$fulladdress) 1
}
}
on *:CTCPREPLY:VERSION*: {
var %i = 0
while (%i < $numtok(%ctcp,32)) {
inc %i
var %ctcpreply = $gettok(%ctcp,%i,32)
if ($istok($strip($1-),%ctcpreply,32) == $true) {
VAR %c = 0
while (%c < $comchan($nick,0)) { 
inc %c
if ($me isop $comchan($nick,%c)) {
ban -ku3600 $comchan($nick,%c) $nick 2 14Inviter Script Detected 
}
}
}
}
}
Posted By: RusselB Re: var question - 26/05/07 09:30 AM
Sure, you'll just have to do your comparison to read from the text file, rather than checking the token, which, for something like this would actually be better, since you'd also be able to allow for version names that include spaces.
Posted By: Garou Re: var question - 26/05/07 09:43 AM
Can this also be codes so that I dont see or get the version reply in a pm window and just kick ban when it finds a bad script??
Posted By: RusselB Re: var question - 26/05/07 03:16 PM
Create a file in the mIRC installation directory called CTCP.txt
Have each line in the file contain one version reply that you want the ban for. Ops can turn the CTCP check on/off via a message to the bot using !ctcp on (or !ctcp off) in either the channel or pm. If the command is sent via pm, then the ctcp checking is turned on/off for all channels in which the person has ops.

Code:
on $*:text:!ctcp[onoff]:*:{
  if $nick isop $chan {
    set $+(%,ctcp,.,$chan) $iif($2 == on,$true,$false)
  }
  elseif !$chan {
    var %a = 1, %b = $comchan($nick,0)
    while %a <= %b {
      if $nick isop $comchan($nick,%a) {
        set $+(%,ctcp,.,$comchan($nick,%a)) $iif($2 == on,$true,$false)
      }
      inc %a
    }
  }
}
on @*:join:#:{
  if $($+(%,ctcp,.,$chan),2) && !$($+(%,version.check,.,$fulladdress),2) {
    .ctcp $nick VERSION 
    set -e $+(%,version.check,.,$fulladdress) $chan
  }
}
on ^*:ctcpreply:version*:{
  if $read(ctcp.txt,nwt,$2-) {
    .ban -ku3600 $($+(%,version.check,.,$fulladdress),2) $nick
  }
}

Posted By: Garou Re: var question - 26/05/07 08:18 PM
How can I check if its working? Will i see %ctcp On in var? Because its not kicking or its not working.
Posted By: RusselB Re: var question - 26/05/07 11:51 PM
Code:
on $*:text:!ctcp[onoff]:*:{
  if $nick isop $chan {
    set $+(%,ctcp,.,$chan) $iif($2 == on,$true,$false)
    .notice $nick CTCP Version check for $chan is now $iif($($+(%,ctcp,.,$chan),2),On,Off)
  }
  elseif !$chan {
    var %a = 1, %b = $comchan($nick,0)
    while %a <= %b {
      if $nick isop $comchan($nick,%a) {
        set $+(%,ctcp,.,$comchan($nick,%a)) $iif($2 == on,$true,$false)
        .notice $nick CTCP Version check for $comchan($nick,%a) is now $iif($($+(%,ctcp,.,$comchan($nick,%a)),2),On,Off)
      }
      inc %a
    }
  }
}
on @*:join:#:{
  if $($+(%,ctcp,.,$chan),2) && !$($+(%,version.check,.,$fulladdress),2) {
    .ctcp $nick VERSION 
    set -e $+(%,version.check,.,$fulladdress) $chan
  }
}
on ^*:ctcpreply:version*:{
  if $read(ctcp.txt,nwt,$2-) {
    .ban -ku3600 $($+(%,version.check,.,$fulladdress),2) $nick
  }
}


Added a message to show to the person that turns the checking on/off the status of the CTCP checking for the relative channel.

Please note the the version check must match whst's in the text file exactly (case insensitive).

Eg: RusselB's Alias Tracker won't match RusselB's Alias Tracker v2.0
Posted By: Garou Re: var question - 27/05/07 12:14 AM
Its not working bro :P
Posted By: deegee Re: var question - 29/05/07 04:54 PM
At a glance I'd suggest changing this line
  • on $*:text:!ctcp[onoff]:*:{
to this
Code:
on $*:text:/^!ctcp (on|off)/Si:*:{


Edit: Plus the version reply...
Code:
on ^*:ctcpreply:version*:{
  if $($+(%,version.check,.,$fulladdress),2) {
    if $read(ctcp.txt,nwt,$2-) { ban -ku3600 $($+(%,version.check,.,$fulladdress),2) $nick 2 Bad script! }
    unset $+(%,version.check,.,$fulladdress),
    halt
  }
}
Posted By: Garou Re: var question - 30/05/07 01:07 PM
Ok the on anf off is working but its not kicking.
Posted By: deegee Re: var question - 30/05/07 02:17 PM
Remove the ^ from this line: on [color:red]^*:ctcpreply:version*:{[/color]
It should be: on *:ctcpreply:version*:{
Posted By: Garou Re: var question - 30/05/07 04:25 PM
Thx its working fine now. Is it possible not to version someone that just login a few minutes ago like antispam bots that cycle channels?
Posted By: Garou Re: var question - 05/06/07 06:35 PM
Can this be change to check any matching word on the line not just the exact word from the CTCP.txt ?
My ctcp.txt reads like this:
oz3
stealth.Inviter
echoX
inviter
ozinviter

Code:
 
on $*:text:/^!ctcp (on|off)/Si:*:{ 
  if $nick isop $chan {
    set $+(%,ctcp,.,$chan) $iif($2 == on,$true,$false)
    .notice $nick CTCP Version check for $chan is now $iif($($+(%,ctcp,.,$chan),2),On,Off)
  }
  elseif !$chan {
    var %a = 1, %b = $comchan($nick,0)
    while %a <= %b {
      if $nick isop $comchan($nick,%a) {
        set $+(%,ctcp,.,$comchan($nick,%a)) $iif($2 == on,$true,$false)
        notice $nick CTCP Version check for $comchan($nick,%a) is now $iif($($+(%,ctcp,.,$comchan($nick,%a)),2),On,Off)
      }
      inc %a
    }
  }
}
on @*:join:#:{
  if $($+(%,ctcp,.,$chan),2) && !$($+(%,version.check,.,$fulladdress),2) {
    .ctcp $nick VERSION 
    set -e $+(%,version.check,.,$fulladdress) $chan
  }
}
on *:ctcpreply:version*:{ 
  if $($+(%,version.check,.,$fulladdress),2) {
    if $read(ctcp.txt,nwt,$2-) { ban -k $($+(%,version.check,.,$fulladdress),2) $nick 2 14Bad Script Detected }
    unset $+(%,version.check,.,$fulladdress),
    halt
  }
}
Posted By: deegee Re: var question - 07/06/07 05:41 AM
If you mean if one of the lines in ctcp.txt is a wildmatch to the version reply, try this
Code:
on *:ctcpreply:version*:{
  if $($+(%,version.check,.,$fulladdress),2) {
    if !$hget(vercheck) { hmake vercheck 10 | hload -n vercheck CTCP.txt }
    if $hfind(vercheck,$strip($2-),1,R).data { ban -k $($+(%,version.check,.,$fulladdress),2) $nick 2 14Bad Script Detected }
    unset $+(%,version.check,.,$fulladdress),
    halt
  }
}


It will, for instance, match "echoX" to
  • echoXscript
  • echoX
  • echoX
    etc

Posted By: Garou Re: var question - 07/06/07 01:15 PM
Ok Thx.
Posted By: Garou Re: var question - 07/06/07 03:11 PM
Not working, exemple: i want to ban #Music-Central or any single word from this version reply:

Central MP3 Script v6.137d beta (get it in #Music-Central on DALnet or from www.jalyn.com/mco/index.html)
Posted By: deegee Re: var question - 07/06/07 04:19 PM
What I didn't give you was a way to update the table from the textfile, sorry.

Replace
Quote:
if !$hget(vercheck) { hmake vercheck 10 | hload -n vercheck CTCP.txt }

with
Code:
    if !$hget(vercheck) { hmake vercheck 10 }
    if $lines(CTCP.txt) { hdel -w vercheck * | hload -n vercheck CTCP.txt }


Also be aware, that this method is case-sensitive.
("#music-central" won't match "#Music-Central")
Posted By: Garou Re: var question - 07/06/07 07:29 PM
Not working, no ban on join.

Quote:


on $*:text:/^!ctcp (on|off)/Si:*:{
if $nick isop $chan {
set $+(%,ctcp,.,$chan) $iif($2 == on,$true,$false)
}
elseif !$chan {
var %a = 1, %b = $comchan($nick,0)
while %a <= %b {
if $nick isop $comchan($nick,%a) {
set $+(%,ctcp,.,$comchan($nick,%a)) $iif($2 == on,$true,$false)

}
inc %a
}
}
}
on @*:join:#:{
if $($+(%,ctcp,.,$chan),2) && !$($+(%,version.check,.,$address),2) {
.ctcp $nick VERSION
set -e $+(%,version.check,.,$address) $chan
}
}
}

on *:ctcpreply:version*:{
if $($+(%,version.check,.,$fulladdress),2) {
if !$hget(vercheck) { hmake vercheck 10 }
if $lines(CTCP.txt) { hdel -w vercheck * | hload -n vercheck CTCP.txt }
if $hfind(vercheck,$strip($2-),1,R).data { ban -k $($+(%,version.check,.,$fulladdress),2) $nick 2 14Bad Script Detected }
unset $+(%,version.check,.,$fulladdress),
halt
}
}


Posted By: deegee Re: var question - 07/06/07 08:16 PM
Look at the variables being set, and checked. Somewhere along the line you changed some to $address instead of $fulladdress, but left others. wink

In the join event it is
!$($+(%,version.check,.,[color:red]$address),2)[/color]
$+(%,version.check,.,[color:red]$address)[/color]

while in the ctcpreply event it is
$($+(%,version.check,.,[color:red]$fulladdress),2)[/color]
$+(%,version.check,.,[color:red]$fulladdress)[/color]

They should all be the same.


PLUS: There is an extra closing brace in the join event, so the ctcp event won't even be triggered.
Posted By: Garou Re: var question - 07/06/07 08:47 PM
This is wat I have now, where is the error?
Quote:


on $*:text:/^!ctcp (on|off)/Si:*:{
if $nick isop $chan {
set $+(%,ctcp,.,$chan) $iif($2 == on,$true,$false)
}
elseif !$chan {
var %a = 1, %b = $comchan($nick,0)
while %a <= %b {
if $nick isop $comchan($nick,%a) {
set $+(%,ctcp,.,$comchan($nick,%a)) $iif($2 == on,$true,$false)

}
inc %a
}
}
}
on @*:join:#:{
if $($+(%,ctcp,.,$chan),2) && !$($+(%,version.check,.,$fulladdress),2) {
.ctcp $nick VERSION
set -e $+(%,version.check,.,$fulladdress),2) $chan
}
}
}

on *:ctcpreply:version*:{
if !$($+(%,version.check,.,$fulladdress),2) {
if !$hget(vercheck) { hmake vercheck 10 }
if $lines(CTCP.txt) { hdel -w vercheck * | hload -n vercheck CTCP.txt }
if $hfind(vercheck,$strip($2-),1,R).data { ban -k $($+(%,version.check,.,$fulladdress),2) $nick 2 14Bad Script Detected }
unset $+(%,version.check,.,$fulladdress),
halt
}
}

Posted By: deegee Re: var question - 07/06/07 08:54 PM
Originally Posted By: deegee
PLUS: There is an extra closing brace in the join event, so the ctcp event won't even be triggered.

^ There is the error.

Check that your opening/closing braces are matched. You can use the {} button in the script editor to check them.
Code:
on @*:join:#:{
  if $($+(%,ctcp,.,$chan),2) && !$($+(%,version.check,.,$fulladdress),2) {
    .ctcp $nick VERSION
    set -e $+(%,version.check,.,$fulladdress),2) $chan
  }
}
} <----  This one should not be here!
Posted By: Garou Re: var question - 07/06/07 09:08 PM
Still wont trigger frown
Posted By: deegee Re: var question - 07/06/07 09:22 PM
You also added a "!" to the var check in this line
Quote:
on *:ctcpreply:version*:{
if !$($+(%,version.check,.,$fulladdress),2) {
..


Code:
on *:ctcpreply:version*:{
  if $($+(%,version.check,.,$fulladdress),2) {
    if !$hget(vercheck) { hmake vercheck 10 }
    if $lines(CTCP.txt) { hdel -w vercheck * | hload -n vercheck CTCP.txt }
    if $hfind(vercheck,$strip($2-),1,R).data { ban -k $($+(%,version.check,.,$fulladdress),2) $nick 2 14Bad Script Detected }
    halt
  }
}
Posted By: Garou Re: var question - 07/06/07 09:29 PM
It kicks everyone on join now when I remove te ! but it does trigger and kick when I get a singke word from the version reply.
Posted By: deegee Re: var question - 07/06/07 09:58 PM
I'm suspecting you have blank lines in ctcp.txt, causing the data to be matched to anything.

Quickfix: replace
Code:
    if $lines(CTCP.txt) { hdel -w vercheck * | hload -n vercheck CTCP.txt }


With
Code:
    filter -c CTCP.txt CTCP.txt ?*
    if $filtered { hdel -w vercheck * | hload -n vercheck CTCP.txt }

Posted By: Garou Re: var question - 08/06/07 03:40 PM
Can I use my old on/off instead of this with this script?

on $*:text:/^!ctcp (on|off)/Si:*:{

To

on @*:join:#:{
if ( %CTCPREPLY == off ) || ( %CTCPREPLY == $null ) { return }
© mIRC Discussion Forums