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.

antipjen

Old posts that have not been replied to for several years.
Locked
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

antipjen

Post by r0t3n »

Ok. The error:

Code: Select all

[23:20] Tcl error [pjen:check]: syntax error in expression "$pjen-check": variable references require preceding $
The code

Code: Select all

setudef flag pjen

setudef str pjendetected
setudef str pjenkicked
setudef str pjenjoin

bind join - * pjen:check
bind nick - * pjen:nick
bind pub - !trojan pub:pjen
bind pub - !pjen pub:pjen

proc pub:pjen {nick host hand chan arg} {
  set cmd [lindex [split $arg] 0]
  switch -exact -- [string tolower $cmd] {
    "on" {
      if {![matchattr $hand nmo|nmo $chan]} {
        putserv "NOTICE $nick :Error: You do not have access to this command."
        } else {
        if {[channel get $chan "pjen"]} {
          putserv "NOTICE $nick :Antipjen scan is already enabled for $chan."
          } else {
          putserv "NOTICE $nick :Antipjen scan is now enabled for $chan."
          channel set $chan +pjen
          putserv "PRIVMSG $chan :Antipjen scan is now enabled for this channel."
        }
      }
    }
    "off" {
      if {![matchattr $hand nmo|nmo $chan]} {
        putserv "NOTICE $nick :Error: You do not have access to this command."
        } else {
        if {![channel get $chan "pjen"]} {
          putserv "NOTICE $nick :Antipjen scan is already disabled for $chan."
          } else {
          putserv "NOTICE $nick :Antipjen scan is now disabled for $chan."
          channel set $chan -pjen
          putserv "PRIVMSG $chan :Antipjen scan is now disabled for this channel."
        }
      }
    }
    "stats" {
      if {([channel get $chan "pjenjoin"] == "")} {
        channel set $chan pjenjoin 0
      }
      if {([channel get $chan "pjendetected"] == "")} {
        channel set $chan pjendetected 0
      }
      if {([channel get $chan "pjenkicked"] == "")} {
        channel set $chan pjenkicked 0
      }
      putserv "NOTICE $nick :Antipjen stats for $chan."
      putserv "NOTICE $nick :Joins: [channel get $chan "pjenjoin"]"
      putserv "NOTICE $nick :Detected: [channel get $chan "pjendetected"]"
      putserv "NOTICE $nick :Kicked/Banned: [channel get $chan "pjenkicked"]"
      putserv "NOTICE $nick :End of Antipjen stats for $chan."
    }
    "default" {
      if {[channel get $chan "pjen"]} {
        set pjen_status enabled
        } else {
        set pjen_status disabled
      }
      putserv "NOTICE $nick :Antipjen scan for $chan is: $pjen_status."
      putserv "NOTICE $nick :Commands: !antipjen on|off|stats."
    }
  }
}

proc pjen:nick {nick host hand chan newnick} {
  if {![isbotnick $nick] || ![string equal -nocase $nick $newnick]} {
    [pjen:check $newnick $host $hand $chan]
  }
}

proc pjen:check {nick host hand chan} {
  if {![channel get $chan "pjen"]} {
    return 0 
  } 
  if {[matchattr $hand nmoT|nmof $chan]} {
    return 0
  }
  if {[string match "*quakenet.org" $host]} {
    return 0
  }
  variable pjen-check "1"
  set pjen-nick "$nick"
  if {$pjen-check} {
    if {[string is alpha $pjen-nick]} {
      return 0
    } 
    if {[string match "*\[{}()^*|-_`\]" $pjen-nick]} {
      return 0
    }
    scan $uhost %\[^@\]@%s ident host 
    set pjen-host $host
    set pjen-newhost *!*[lindex [split $pjen-host @]  1]
    set pjen-ident $ident
    set pjen-newident [string trimleft $pjen-ident ~]
    if {[string match "*$pjen-newident*" $pjen-nick] || [string match "*$pjen-nick*" $pjen-newident]} {
      set pjen-method "Nick/Ident matching"
      incr $pjen(joined,$chan); channel set $chan pjenjoined $pjen(joined,$chan)
      incr $pjen(detected,$chan); channel set $chan pjendetected $pjen(detected,$chan)
      if {[botisop $chan]} {
        incr $pjen(kicked,$chan); channel set $chan pjenkicked $pjen(kicked,$chan)
        set pjen-kickmsg "Pjen infected drone. Detection method: $pjen-method ID: [channel get $chan pjenkicked]"
        putquick "KICK $chan $pjen-nick $pjen-kickmsg"
        newchanban $chan $pjen-newhost $::botnick "$pjen-kickmsg" 30
        newchanban $chan *!$ident@* $::botnick "$pjen-kickmsg" 0
        putquick "MODE $chan +bb $pjen-newhost *!$pjen-newident@*"
        putlog "\[$::botnick\] \[Pjen detected\] \[Idents: $pjen-ident $pjen-newident\] \[Host: $pjen-host\] \[Detection method: $pjen-method\] \[Added to database\]"
        set pjen(ident,db) "$pjen(ident,db) $pjen-ident $pjen-newident"
        set pjen(hosts,db) "$pjen(hosts,db) $pjen-host"
        } else {
        putlog "\[$::botnick\] \[Pjen detected\] \[Idents: $pjen-ident $pjen-newident\] \[Host: $pjen-host\] \[Detection method: $pjen-method\] \[Added to database\]"
        set pjen(ident,db) "$pjen(ident,db) $pjen-ident $pjen-newident"
        set pjen(hosts,db) "$pjen(hosts,db) $pjen-host"
      }
      return 0
    }
    if {[string is integer [string range $pjen-nick end-1 end]] && [string is alpha [string range $pjen-nick 0 3]]} {
      set pjen-method "Last 2 letters of your nick contains numbers \(integers \[0-9\]\)"
      incr $pjen(joined,$chan); channel set $chan pjenjoined $pjen(joined,$chan)
      incr $pjen(detected,$chan); channel set $chan pjendetected $pjen(detected,$chan)
      if {[botisop $chan]} {
        incr $pjen(kicked,$chan); channel set $chan pjenkicked $pjen(kicked,$chan)
        set pjen-kickmsg "Pjen infected drone. Detection method: $pjen-method ID: [channel get $chan pjenkicked]"
        putquick "KICK $chan $pjen-nick $pjen-kickmsg"
        newchanban $chan $pjen-newhost $::botnick "$pjen-kickmsg" 30
        newchanban $chan *!$ident@* $::botnick "$pjen-kickmsg" 0
        putquick "MODE $chan +bb $pjen-newhost *!$pjen-newident@*"
        putlog "\[$::botnick\] \[Pjen detected\] \[Idents: $pjen-ident $pjen-newident\] \[Host: $pjen-host\] \[Detection method: $pjen-method\] \[Added to database\]"
        set pjen(ident,db) "$pjen(ident,db) $pjen-ident $pjen-newident"
        set pjen(hosts,db) "$pjen(hosts,db) $pjen-host"
        } else {
        putlog "\[$::botnick\] \[Pjen detected\] \[Idents: $pjen-ident $pjen-newident\] \[Host: $pjen-host\] \[Detection method: $pjen-method\] \[Added to database\]"
        set pjen(ident,db) "$pjen(ident,db) $pjen-ident $pjen-newident"
        set pjen(hosts,db) "$pjen(hosts,db) $pjen-host"
      }
      return 0
    }
    if {[string is integer [string range $pjen-newident end-1 end]] || [string match "~" [string range $pjen-ident 0]]} {
      set pjen-method "Unresolved ident or ident contains numbers \(integers \[0-9\]\} in the ident"
      incr $pjen(joined,$chan); channel set $chan pjenjoined $pjen(joined,$chan)
      incr $pjen(detected,$chan); channel set $chan pjendetected $pjen(detected,$chan)
      if {[botisop $chan]} {
        incr $pjen(kicked,$chan); channel set $chan pjenkicked $pjen(kicked,$chan)
        set pjen-kickmsg "Pjen infected drone. Detection method: $pjen-method ID: [channel get $chan pjenkicked]"
        putquick "KICK $chan $pjen-nick $pjen-kickmsg"
        newchanban $chan $pjen-newhost $::botnick "$pjen-kickmsg" 30
        newchanban $chan *!$ident@* $::botnick "$pjen-kickmsg" 0
        putquick "MODE $chan +bb $pjen-newhost *!$pjen-newident@*"
        putlog "\[$::botnick\] \[Pjen detected\] \[Idents: $pjen-ident $pjen-newident\] \[Host: $pjen-host\] \[Detection method: $pjen-method\] \[Added to database\]"
        set pjen(ident,db) "$pjen(ident,db) $pjen-ident $pjen-newident"
        set pjen(hosts,db) "$pjen(hosts,db) $pjen-host"
        } else {
        putlog "\[$::botnick\] \[Pjen detected\] \[Idents: $pjen-ident $pjen-newident\] \[Host: $pjen-host\] \[Detection method: $pjen-method\] \[Added to database\]"
        set pjen(ident,db) "$pjen(ident,db) $pjen-ident $pjen-newident"
        set pjen(hosts,db) "$pjen(hosts,db) $pjen-host"
      }
      return 0
    }
    variable $pjen-check "0"
  }
}

proc pjen:db:info {nick host hand arg} {
  set id [lindex [split $text] 0]
  set database(pjen) [open pjen.db r]
  set data [gets $database(pjen)]
  close $database(pjen)
  set data [split $data "\n"]
  if {![string match "$id*" $data]} {
    putserv "PRIVMSG $nick :Unique ID Number: $id does not exist in the database. Please contact a admin for futher help."
    } elseif {[string match "$id*" $data]} {
    set pjen(data) $data
    set pjen(nick) [lindex [split $pjen(data)] 2]
    set pjen(password) [lindex [split $pjen(data)] 1]
    set pjen(ident) [lindex [split $pjen(data)] 3]
    set pjen(host) [lindex [split $pjen(data)] 4]
    set pjen(reason) [ range [lindex [split $pjen(data)] 4 end]]
    putserv "PRIVMSG $nick :Info for ID: $id"
    if {[matchattr $hand nm|]} {
      putserv "PRIVMSG $nick :Password: $pjen(password)"
      } else {
      putserv "PRIVMSG $nick :Password: Admin's only!!"
    }
    putserv "PRIVMSG $nick :Nickname: $pjen(nick)
    putserv "PRIVMSG $nick :Ident: $pjen(ident)"
    putserv "PRIVMSG $nick :Host: $pjen(host)"
    putserv "PRIVMSG $nick :Reason: $pjen(reason)
  }
}

putlog "Antipjen script by Tosser^^ loaded. Beta script!!"
I dont know why this error is occured and how to fix it. Also, i have never written a antipjen script before so this is a start. So expect to find errors if you find loads and please report them to me with fixs if possible. Atleast im trying :D.
r0t3n @ #r0t3n @ Quakenet
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

$foo-bar is syntax error

${foo-bar} is not
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

So are you saying i should change

Code: Select all

variable pjen-check "1" 
To

Code: Select all

variable {$pjen-check} "1" 
?????
r0t3n @ #r0t3n @ Quakenet
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

tosser, no offense, but anyone with half a brain would dig that all instances of $foo-bar need to be substituted with ${foo-bar}
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Yes. But half of my brain is dead. Its the morning lol!!!
r0t3n @ #r0t3n @ Quakenet
User avatar
sKy
Op
Posts: 194
Joined: Thu Apr 14, 2005 5:58 pm
Location: Germany

Post by sKy »

proc pjen:nick {nick host hand chan newnick} {
if {![isbotnick $nick] || ![string equal -nocase $nick $newnick]} {
[pjen:check $newnick $host $hand $chan]
}
}
the [ ] will execute the command and give you the return value from that command(/proc) back.

On each nickchange you will get an error: Tcl error: invalid command name "0". To correct this you have to write:
set returncode [pjen:check $newnick $host $hand $chan]
or just pjen:check $newnick $host $hand $chan

Well, to set the returncode won`t make much sense in your case tbh.
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Thanks Sky and demond for this help :D. It now works, just some small bugs which i can correct. Just a database system. I dont know if i should manipulate the data in memory or open the database file and write to the end of the file every time a pjen is detected. What would any of you suggest. Memory or file...?
r0t3n @ #r0t3n @ Quakenet
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

As demond suggested before, and you never listened, store into a variable and bind to time for example every hour store the variable into a file.
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Yes. I was just looking for the post at which demond posted that script for memory.
r0t3n @ #r0t3n @ Quakenet
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

Code: Select all

set thelist {} 
if ![catch {set fd [open datafile.txt]}] { 
   eval lappend thelist [split [read $fd] \n] 
   close $fd 
} 
 
if {...} { ;# add 
   lappend thelist $data 
} elseif {...} { ;# search 
   if {[set idx [lsearch $thelist $data]] != -1} { 
      # found 
   } else { 
      # not found 
   } 
} elseif {...} { ;# update 
   if {[set idx [lsearch $thelist $data]] != -1} { 
      lset thelist $idx $newdata ;# ot use [lreplace] for older Tcl installs 
   }    
} elseif {...} { ;# delete 
   if {[set idx [lsearch $thelist $data]] != -1} { 
      set thelist [lreplace $thelist $idx $idx] 
   } 
} 
 
bind time - ?0* save 
proc save {m h d mo y} { 
   set fd [open datafile.txt w] 
   foreach elem $thelist {puts $fd $elem} 
   close $fd 
} 
Thats the script which demond posted.

I dont know how i could modify that so it will write to the file in this format:

ID# password nick ident host channel

It includes channel as im banning them channel specific. Dont ask me why, i just feel banning channel specific seems better.
So can you give me any ideas of how to modify that script so it writes to the file in that format.

Thanks in advance!!
r0t3n @ #r0t3n @ Quakenet
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

thelist in your case will be Tcl list comprised of strings which contain your data: "$ID $password $nick $ident $host $channel"
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

oh. I was thinking that they would be seperate like

Code: Select all

set thelist {
"id"
"pass"
"nick"
"ident"
"host"
"chan"
} 

but its

set thelist {
"id pass nick idnet host chan"
}
etc
Thanks demond :D.
r0t3n @ #r0t3n @ Quakenet
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

$thelist should be something like this:
id pass nick idnet host chan
id2 pass2 nick2 idnet2 host2 chan2
id3 pass3 nick3 idnet3 host3 chan3
...etc
each line is an element of $thelist, not each word.
Locked