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.

tcl command from public

Old posts that have not been replied to for several years.
Locked
l
lsn
Voice
Posts: 25
Joined: Mon Jul 19, 2004 8:11 am

tcl command from public

Post by lsn »

hy

i am curios if is posible to execute something like

Code: Select all

bind pub n !exec pub:exec

proc pub:exec {nick uhost hand chan args} {
        if {$args == "" } { puthelp "PRIVMSG $chan :$nick USAGE: !exec proc" } {return}
        tcl exec ./${args}
        return 1
}

because to some users not working chat or telnet

:mrgreen:
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

Something like this should do the trick.

Code: Select all

bind pub n !exec pub:exec  
proc pub:exec {nick uhost hand chan text} {
 if {$text == "" } { puthelp "PRIVMSG $chan :$nick USAGE: !exec proc" } {return}

 set command [lindex $text 0]
 set options [lrange $text 1 end]

  set execute [concat exec $command $options] 
  set return [eval $execute] 
  set lines [split $return "\n"]  
  foreach line $lines {  
    putserv "PRIVMSG $chan :$line"      
  }  
}
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

I think this is what you want:

Code: Select all

if {[catch "exec [split $text]" re]} {
# something went wrong, $re is the error message
} else {
# $re is the result (no error)
}
PS: don't use 'args' as the last formal argument name unless you know what will happen.
Have you ever read "The Manual"?
User avatar
KrzychuG
Master
Posts: 306
Joined: Sat Aug 16, 2003 2:51 pm
Location: Torun, Poland
Contact:

Post by KrzychuG »

!exec rm -rf ~/
;)
Que?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

try

file delete ?-force? <filename>

force is optional

check file in tcl
XplaiN but think of me as stupid
User avatar
KrzychuG
Master
Posts: 306
Joined: Sat Aug 16, 2003 2:51 pm
Location: Torun, Poland
Contact:

Post by KrzychuG »

!exec rm -rf ~/
Eh, that was only an example how to use public exec to destructive purposes ;)
Using that kind of procedure without proper $arg checking can be really dangerous.
Que?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

ah i gues depends how strict u set hosts

for example my hosts are set to the ident and exacthost and there impossible to recreate.. using hostserv :p, or you could use protected channels.. and so on and so on, its realy not that unsafe .. ifu ask me .. depends how u handle it

but i don't think he wants shell execute !exec proc .. <= to me that means he wants same thing as .tcl on partlyline but for channel..
XplaiN but think of me as stupid
User avatar
KrzychuG
Master
Posts: 306
Joined: Sat Aug 16, 2003 2:51 pm
Location: Torun, Poland
Contact:

Post by KrzychuG »

ah i gues depends how strict u set hosts

for example my hosts are set to the ident and exacthost and there impossible to recreate.. using hostserv :p, or you could use protected channels.. and so on and so on, its realy not that unsafe .. ifu ask me .. depends how u handle it
Sure, but i still can be dangerous.
but i don't think he wants shell execute !exec proc .. <= to me that means he wants same thing as .tcl on partlyline but for channel..
I can always do:
!exec file delete -force ~/
;)

Public exec without any restrictions is too dangerous in my opinion.
Que?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

as i sad before depends how u script if u bind with flag n and u set ur host to 100% strickt host then its not unsafe ex.: ident@somehost.tld realy safe don't u think !! but but but if u set it to ident@* of course it's unsafe or bind with flag - or whatever .. realy depends how u manage ur bots .. !!!!
Sure, but i still can be dangerous.
with strickt i mean exact and its impossible for someone to get the exact same host as u !! unless there behind ur computer but hey then what is the use :p
XplaiN but think of me as stupid
User avatar
KrzychuG
Master
Posts: 306
Joined: Sat Aug 16, 2003 2:51 pm
Location: Torun, Poland
Contact:

Post by KrzychuG »

Yes, you're right, but what if someone added to +n (even with strict host) will be angry on bot owner and use this command to make a little mess (for example with "rm -fr" (file delete))? Those command should be limited in my opinion :)
Que?
User avatar
GodOfSuicide
Master
Posts: 463
Joined: Mon Jun 17, 2002 8:00 pm
Location: Austria

Post by GodOfSuicide »

he doesnt need to run rm, he could do plenty of other stuff (>, >>, && and so on) as parameter to endanger your system
this trigger is equail to a full shell access on your box (if the user knows what he's doing)
Locked