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.

Optools

Help for those learning Tcl or writing their own scripts.
Post Reply
k
krieg
Voice
Posts: 13
Joined: Tue Nov 20, 2007 11:11 am

Optools

Post by krieg »

I have optools.tcl the codes like this

Code: Select all

# op tools por Marco Ferra aka nXistence
# http://clientes.netvisao.pt/mferra/
# marcoferra@netvisao.pt
# versao 1.1

# !c, !op <nick>, !vo <nick>, !k <nick> razao
# !b <host> razao, !ub <host>, !kb <nick> razao
# !t <topico>, !p, !jump servidor porta, !die razao
# !status, !broadcast <mensagem>

bind pub o !h pub:h
bind pub o !c pub:c
bind pub o !op pub:op
bind pub o !vo pub:vo
bind pub o !k pub:kick
bind pub o !b pub:ban
bind pub o !ub pub:ub
bind pub o !kb pub:kb
bind pub o !t pub:topic
bind pub - !p pub:p
bind pub n !jump pub:jump
bind pub n !die pub:die
bind pub o !status pub:status
bind pub o !broadcast pub:broadcast

proc pub:h {nick uhost hand chan text} {
  puthelp "NOTICE $nick :!c !op !vo !k !b !ub !kb !t !p !jump !die !status !broadcast"
}

proc pub:c {nick uhost hand chan text} {
  if {[botisop $chan] == 1} {
    if {[isop $nick $chan] == 1} { pushmode $chan -o $nick } else { pushmode $chan +o $nick }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:op {nick uhost hand chan text} {
  if {[botisop $chan] == 1} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[isop $tnick $chan]} { pushmode $chan -o $tnick } else { pushmode $chan +o $tnick }
      } else { puthelp "NOTICE $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !op <nick> - inverts the ops of a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:vo {nick uhost hand chan text} {
  if {[botisop $chan] == 1} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[isvoice $tnick $chan]} { pushmode $chan -v $tnick } else { pushmode $chan +v $tnick }
      } else { puthelp "NOTICE $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !op <nick> - inverts the voices of a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:kick {nick uhost hand chan text} {
  if {[botisop $chan]} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[string length [lindex $text 1]] == 0} { set reason kicked } else { set reason [lrange $text 1 end] }
      if {[onchan $tnick $chan]} { putkick $chan $tnick $reason } else { puthelp "NOTICE $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !k <nick> reason - kicks a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:ban {nick uhost hand chan text} {
  if {[botisop $chan]} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[string length [lindex $text 1]] == 0} { set reason banned } else { set reason [lrange $text 1 end] }
        newchanban $chan *!*@[lindex [split [getchanhost $tnick $chan] @] 1] $nick $reason 10
      } else { puthelp "notice $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !b <nick> reason - bans a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:ub {nick uhost hand chan text} {
  if {[botisop $chan]} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[ischanban $tnick $chan]} { killchanban $chan $tnick } else { puthelp "NOTICE $nick :no such ban on $chan" }
    } else { puthelp "NOTICE $nick :usage !ub <nick!user@host> - unbans an address" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:kb {nick uhost hand chan text} {
  if {[botisop $chan]} {
    if {[string length $text] > 0} {
      set tnick [lindex $text 0]
      if {[onchan $tnick $chan]} {
        if {[string length [lindex $text 1]] == 0} { set reason banned } else { set reason [lrange $text 1 end] }
        newchanban $chan *!*@[lindex [split [getchanhost $tnick $chan] @] 1] $nick $reason 10
        utimer 5 [putkick $chan $tnick $reason]
      } else { puthelp "notice $nick :no such nick on channel!" }
    } else { puthelp "NOTICE $nick :usage !kb <nick> reason - kicks and bans a nick" }
  } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:topic {nick uhost hand chan text} {
  if {[botisop $chan]} { putserv "TOPIC $chan :$text" } else { puthelp "NOTICE $nick :i dont have ops!" }
}

proc pub:p {nick uhost hand chan text} { putserv "PRIVMSG $chan :connected!" }

proc pub:jump {nick uhost hand chan text} { jump $text }

proc pub:die {nick uhost hand chan text} { die $text }

proc pub:status {nick uhost hand chan text} {
  global server botname version
  puthelp "NOTICE $nick :user records: [countusers], channels: [channels], date: [date], time: [time], os: [unames], server: $server, host: $botname, egg version: [lindex $version 0]"
}

proc pub:broadcast {nick uhost hand chan text} {
  if {[string length $text] > 0} {
    set text [string trim $text "{}"]
    foreach n [channels] { puthelp "PRIVMSG $n :$text" }
  } else { puthelp "NOTICE $nick :!broadcast <message> - sends message to all channels that the bot is" }
}

putlog "tcl: optools loaded"
I want to add some codes and features. For example when I write on channel !nb the bot should ban to nickname but do not kick. Only ban.

I want the bot don't kick banned users. For example only I want ban a person I can do it but immediately the bot kick the banned user. Bot should kick only while using !kb command. Because I ban a user with "!b nick" command bot is kicking the victim.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

try .chanset #yourchan -enforcebans whilst on partyline with your bot during dcc-chat... :o

btw, that optools script is a security risk (read this as it should not be used by your bot, ever). It contains no checks what so ever against its internal user records. Your kinda foolish in using it, hope you care very little about the channels your using it in, seriously.

Also, forgot to mention. It uses clumsy methods to accomplish things. Such as treating lists as strings then uses string trim to remove the list element boundaries, the {}'s.. haw.. I would suggest you find another script to use as this is yet antoher exploitable flaw. ;D
Your IRC Channel with this script wrote:<user> !op user
*** @Bot sets mode: +o user
<@user> !die be gone now
*** @Bot quits (be gone now)
k
krieg
Voice
Posts: 13
Joined: Tue Nov 20, 2007 11:11 am

Post by krieg »

<user> !op user
*** @Bot sets mode: +o user
<@user> !die be gone now
*** @Bot quits (be gone now)
If you write flag like this o|o there is no problem. This is not problem for bot.
.chanset #yourchan -enforcebans is not working.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

krieg wrote:
<user> !op user
*** @Bot sets mode: +o user
<@user> !die be gone now
*** @Bot quits (be gone now)
If you write flag like this o|o there is no problem. This is not problem for bot.
Yes, there is still a problem, the script allows anyone to get opped without checking who is getting opped. Sure, it can check who asks to op somebody with the flags like you say. Okay, but then....what checks who your opping? Understand now? (once rogue is opped, !die the bot, decimate channel). Not to mention, like I said, its using flawed logic treating lists as strings, then using clumsy work arounds that are exploitable to fix the problems you encounter when treating lists as strings. Is why I suggested no one ever use it and forget it exists.
krieg wrote:.chanset #yourchan -enforcebans is not working.
It gets overly annoying having people just use the phrase 'is not working'. So you want to me to guess now? Without even having standard clues such as what the reply was when you tried this command or a .set errorInfo.. Okay, here goes.. um... More than likely you need to open your eggdrop.conf and rebind the chanset command by #commenting out the unbind. If you want better help, give better clues. ;)

Edit: also, didn't notice this before...

Code: Select all

proc pub:topic {nick uhost hand chan text} {
  if {[botisop $chan]} { putserv "TOPIC $chan :$text" } else { puthelp "NOTICE $nick :i dont have ops!" }
} 
Can you tell why this proc is redundant and unneccessary? Try setting your irc channel -t and the ircd can let anyone in the channel change topic... There are many many reasons not to use this script, just pointing a few out.
Last edited by speechles on Sat Dec 15, 2007 1:43 pm, edited 2 times in total.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Actually, there is even worse issues with this script. Anyone matching an userrecord with o-flag could easily elevate their privileges to owner-status. This is due to insecure use of timers.
Try something like this, and you'll find some interresting behaviours:
!kb {botnick} {[die "Hacked by eviluser"]}
!kb {botnick} {[chattr yourhandle +n]Kicking myself}
!kb {botnick} {[exec "some_shellbackdoor"]}
NML_375
k
krieg
Voice
Posts: 13
Joined: Tue Nov 20, 2007 11:11 am

Post by krieg »

Is there any reliable op commands tcl?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Using /msg yourbot OP and the dcc-chat .op?
NML_375
Post Reply