Support for shell escape sequences in echo command

This commit is contained in:
Ondrej Mikle
2015-06-26 14:28:02 +02:00
parent 56477389b8
commit 7f17401b6b

View File

@ -3,6 +3,8 @@
import time
import datetime
import functools
import getopt
from twisted.internet import reactor
from twisted.python import log
@ -100,7 +102,20 @@ commands['/usr/bin/who'] = command_who
class command_echo(HoneyPotCommand):
def call(self):
self.writeln(' '.join(self.args))
write_fn = self.writeln
escape_fn = lambda s: s
optlist, args = getopt.getopt(self.args, "eEn")
for opt in optlist:
if opt[0] == '-e':
escape_fn = functools.partial(str.decode, encoding="string_escape")
elif opt[0] == '-E':
escape_fn = lambda s: s
elif opt[0] == '-n':
write_fn = self.write
write_fn(escape_fn(' '.join(args)))
commands['/bin/echo'] = command_echo
# for testing purposes