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 

tcl and lftp , need help with output

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
hazzlah
Voice


Joined: 13 May 2011
Posts: 4

PostPosted: Fri May 13, 2011 10:04 pm    Post subject: tcl and lftp , need help with output Reply with quote

Hi everybody first time apology for my bad english.

I have a problem with lftp / tcl.

The bot relays the commands to the FTP-Server without any problems.
But unfortunately no success Replay into the channel

Here is the code , I hope someone can help me.
Code:

set log "lftp.log"

proc lftp {nick host hand chan arg} {
    global log
    set cmd "[lrange $arg 0 end]"
    exec lftp -c open ip -u user,password -p port -e "site $cmd ; quit"
    set fp [open $log r]
    while {![eof $fp]} {
    gets $fp line
    putquick "PRIVMSG $chan :[join [lrange $line 1 end]]"
     }
    close $fp
}
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Sun May 15, 2011 10:57 am    Post subject: Reply with quote

First of all,
drop all those random list operations, they won't do you any good like that.

Secondly,
Have you verified that the lftp.log file is actually created by the lftp client? As far as I can tell, lftp sends logging to ~/.lftp/log, and only if the process is run in background mode (which you are currently not doing).

I would assume that you should actually catch the stdout output, and print this instead:
Code:
proc lftp {nick host handle channel text} {
  set result [exec lftp -c open ip -u user,password -p port -e "site $text ; quit"]

  #convert the result into a list - splitting on newlines
  #then iterate through the list and print each item (line)

  foreach line [split $result "\n"] {
    puthelp "PRIVMSG $channel :$line"
  }
}


Be adviced though, that there is a serious security-issue with the code. There is nothing to prevent a malicious user from adding a ; to the command string, and then using the ! command to run arbitrary code on the shell..
Code:
!lftp help ; !rm -rf .

There's quite a few other ways this could be abused, so I would stronlgy advice against letting irc users gain access to code such as this...
You have been warned
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help 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