def addtooutbuffer(self, args, raw=False): """ add to the outbuffer required: args - a string or a dictionary that contains a data key and a raw key optional: raw - set a raw flag, which means IAC will not be doubled """ data = '' dtype = 'fromclient' if isinstance(args, dict): data = args['data'] dtype = args['dtype'] if 'raw' in args: raw = args['raw'] else: data = args if len(dtype) == 1 and ord(dtype) in self.options: Telnet.addtooutbuffer(self, data, raw) elif dtype == 'fromclient': Telnet.addtooutbuffer(self, data, raw)
def addtooutbuffer(self, data, raw=False): """ add to the outbuffer required: data - a string or a dictionary that contains a data key and a raw key optional: raw - set a raw flag, which means IAC will not be doubled """ dtype = 'fromclient' datastr = "" trace = None if isinstance(data, dict): datastr = data['data'] dtype = data['dtype'] if 'raw' in data: raw = data['raw'] if 'trace' in data: trace = data['trace'] else: datastr = data if len(dtype) == 1 and ord(dtype) in self.options: if trace: trace['changes'].append({ 'flag': 'Sent', 'data': '"%s" to mud with raw: %s and datatype: %s' % (repr(datastr.strip()), raw, dtype), 'plugin': 'proxy', 'callstack': self.api('api.callstack')() }) Telnet.addtooutbuffer(self, datastr, raw) elif dtype == 'fromclient': if trace: trace['changes'].append({ 'flag': 'Sent', 'data': '"%s" to mud with raw: %s and datatype: %s' % (datastr.strip(), raw, dtype), 'plugin': 'proxy', 'callstack': self.api('api.callstack')() }) Telnet.addtooutbuffer(self, datastr, raw)
def addtooutbuffer(self, data, raw=False): """ add to the outbuffer required: data - a string or a dictionary that contains a data key and a raw key optional: raw - set a raw flag, which means IAC will not be doubled """ dtype = 'fromclient' datastr = "" trace = None if isinstance(data, dict): datastr = data['data'] dtype = data['dtype'] if 'raw' in data: raw = data['raw'] if 'trace' in data: trace = data['trace'] else: datastr = data if len(dtype) == 1 and ord(dtype) in self.options: if trace: trace['changes'].append({'flag':'Sent', 'data':'"%s" to mud with raw: %s and datatype: %s' % (repr(datastr.strip()), raw, dtype), 'plugin':'proxy', 'callstack':self.api('api.callstack')()}) Telnet.addtooutbuffer(self, datastr, raw) elif dtype == 'fromclient': if trace: trace['changes'].append({'flag':'Sent', 'data':'"%s" to mud with raw: %s and datatype: %s' % (datastr.strip(), raw, dtype), 'plugin':'proxy', 'callstack':self.api('api.callstack')()}) Telnet.addtooutbuffer(self, datastr, raw)
def addtooutbufferevent(self, args): """ this function adds to the output buffer """ if 'client' in args and args['client'] and args['client'] != self: return outbuffer = args['original'] dtype = None raw = False if 'dtype' in args: dtype = args['dtype'] if not dtype: dtype = 'fromproxy' if 'raw' in args: raw = args['raw'] if outbuffer is not None: if (dtype == 'fromproxy' or dtype == 'frommud') \ and self.state == CONNECTED: outbuffer = "".join([outbuffer, '\r\n']) Telnet.addtooutbuffer(self, outbuffer, raw) elif len(dtype) == 1 and ord(dtype) in self.options \ and self.state == CONNECTED: Telnet.addtooutbuffer(self, outbuffer, raw) elif dtype == 'passwd' and self.state == PASSWORD: outbuffer = "".join([outbuffer, '\r\n']) Telnet.addtooutbuffer(self, outbuffer, raw)
def addtooutbufferevent(self, args): """ this function adds to the output buffer """ outbuffer = args['original'] dtype = None raw = False if 'dtype' in args: dtype = args['dtype'] if not dtype: dtype = 'fromproxy' if 'raw' in args: raw = args['raw'] if outbuffer != None: if (dtype == 'fromproxy' or dtype == 'frommud') \ and self.state == CONNECTED: outbuffer = outbuffer + '\r\n' Telnet.addtooutbuffer(self, outbuffer, raw) elif len(dtype) == 1 and ord(dtype) in self.options \ and self.state == CONNECTED: Telnet.addtooutbuffer(self, outbuffer, raw) elif dtype == 'passwd' and self.state == PASSWORD: outbuffer = outbuffer + '\r\n' Telnet.addtooutbuffer(self, outbuffer, raw)