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 

antipjen

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Thu Aug 04, 2005 6:24 pm    Post subject: antipjen Reply with quote

Ok. The error:

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


The code

Code:
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 Very Happy.
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
demond
Revered One


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

PostPosted: Thu Aug 04, 2005 7:39 pm    Post subject: Reply with quote

$foo-bar is syntax error

${foo-bar} is not
Back to top
View user's profile Send private message Visit poster's website
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Thu Aug 04, 2005 7:42 pm    Post subject: Reply with quote

So are you saying i should change

Code:
variable pjen-check "1"


To

Code:
variable {$pjen-check} "1"


?????
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
demond
Revered One


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

PostPosted: Thu Aug 04, 2005 7:59 pm    Post subject: Reply with quote

tosser, no offense, but anyone with half a brain would dig that all instances of $foo-bar need to be substituted with ${foo-bar}
Back to top
View user's profile Send private message Visit poster's website
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Thu Aug 04, 2005 8:04 pm    Post subject: Reply with quote

Yes. But half of my brain is dead. Its the morning lol!!!
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
sKy
Op


Joined: 14 Apr 2005
Posts: 194
Location: Germany

PostPosted: Sat Aug 06, 2005 8:43 am    Post subject: Reply with quote

Quote:
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.
Back to top
View user's profile Send private message
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sat Aug 06, 2005 3:21 pm    Post subject: Reply with quote

Thanks Sky and demond for this help Very Happy. 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
Back to top
View user's profile Send private message MSN Messenger
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Aug 06, 2005 3:27 pm    Post subject: Reply with quote

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.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sat Aug 06, 2005 3:29 pm    Post subject: Reply with quote

Yes. I was just looking for the post at which demond posted that script for memory.
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sat Aug 06, 2005 3:43 pm    Post subject: Reply with quote

Code:
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
Back to top
View user's profile Send private message MSN Messenger
demond
Revered One


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

PostPosted: Sat Aug 06, 2005 5:13 pm    Post subject: Reply with quote

thelist in your case will be Tcl list comprised of strings which contain your data: "$ID $password $nick $ident $host $channel"
Back to top
View user's profile Send private message Visit poster's website
r0t3n
Owner


Joined: 31 May 2005
Posts: 507
Location: UK

PostPosted: Sat Aug 06, 2005 6:17 pm    Post subject: Reply with quote

oh. I was thinking that they would be seperate like

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

but its

set thelist {
"id pass nick idnet host chan"
}
etc


Thanks demond Very Happy.
_________________
r0t3n @ #r0t3n @ Quakenet
Back to top
View user's profile Send private message MSN Messenger
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Sat Aug 06, 2005 8:58 pm    Post subject: Reply with quote

$thelist should be something like this:
Quote:
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.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Page 1 of 1

 
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