| View previous topic :: View next topic |
| Author |
Message |
hazzlah Voice
Joined: 13 May 2011 Posts: 4
|
Posted: Fri May 13, 2011 10:04 pm Post subject: tcl and lftp , need help with output |
|
|
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 |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun May 15, 2011 10:57 am Post subject: |
|
|
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 |
|
 |
|
|
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
|
|