Exemplo n.º 1
0
class ShellPlugin(ProxyPlugin):
    """
    Default plugin to allow use of a shell
    """
    variables = ['escape_key']

    def __init__(self, c, stdout, key):
        super(ShellPlugin, self).__init__(c)
        self.chat_header = packets_by_name["chat"]
        self.escape_key = key
        self.shell = ProxyShell(self, stdout)

    def packet(self, header, payload):
        if self._enabled:
            if header == self.chat_header:
                if payload.message[0] == self.escape_key:
                    # our shell cannot handle unicode...just convert it to plain ascii
                    msg = str(payload.message[1:])
                    self.shell.onecmd(msg)
Exemplo n.º 2
0
 def __init__(self, c, stdout, key):
     super(ShellPlugin, self).__init__(c)
     self.chat_header = packets_by_name["chat"]
     self.escape_key = key
     self.shell = ProxyShell(self, stdout)