mirror of
https://github.com/cowrie/cowrie.git
synced 2025-07-01 18:07:27 -04:00
Support for shell escape sequences in echo command
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user