def main(): global COMMANDS global syslogger global config args = get_args() config = HoneyConfig(args.config) if args.verbose: honey_logger.setLevel(logging.DEBUG) try: syslogger = get_syslog_logger(config.syslog_address, config.syslog_port, config.syslog_protocol) if args.verbose: syslogger.setLevel(logging.DEBUG) honey_logger.info( "Setup syslog with parameters: IP:%s, PORT:%d, PROTOCOL:%s", config.syslog_address, config.syslog_port, config.syslog_protocol) except MissingConfigField: honey_logger.info( "Syslog reporting disabled, to enable it add its configuration to the configuration file" ) COMMANDS = config.commands server = gevent.server.StreamServer((config.ip, config.port), MyTelnetHandler.streamserver_handle) honey_logger.info("Listening on %d...", config.port) server.serve_forever()
def main(): global COMMANDS global OVERWRITE_COMMANDS global syslogger global config global custom_pool args = get_args() config = HoneyConfig(args.config) if args.output: logging.basicConfig( filename = args.output, level=logging.INFO, format='%(asctime)s [%(name)s] %(levelname)s %(filename)s:%(lineno)s %(message)s') else: logging.basicConfig( level=logging.INFO, format='%(asctime)s [%(name)s] %(levelname)s %(filename)s:%(lineno)s %(message)s') if args.verbose: honey_logger.setLevel(logging.DEBUG) try: syslogger = get_syslog_logger(config.syslog_address, config.syslog_port, config.syslog_protocol) if args.verbose: syslogger.setLevel(logging.DEBUG) honey_logger.info( "Setup syslog with parameters: IP:%s, PORT:%d, PROTOCOL:%s", config.syslog_address, config.syslog_port, config.syslog_protocol) except MissingConfigField: honey_logger.info("Syslog reporting disabled, to enable it add its configuration to the configuration file") COMMANDS = {cmd:resp.decode('string_escape') for (cmd, resp) in config.commands.items()} try: the_timeout = config.timeout except MissingConfigField: the_timeout = default_timeout try: OVERWRITE_COMMANDS = config.overwrite_commands except MissingConfigField: OVERWRITE_COMMANDS = {} socket.setdefaulttimeout(the_timeout) custom_pool = CustomPool.CustomPool(honey_logger, config.pool) server = gevent.server.StreamServer((config.ip, config.port), MyTelnetHandler.streamserver_handle, spawn=custom_pool) honey_logger.info("Listening on %s:%d with timeout=%d", config.ip, config.port, the_timeout) server.serve_forever()
def main(): global COMMANDS global syslogger global config args = get_args() config = HoneyConfig(args.config) if args.output: logging.basicConfig( filename=args.output, level=logging.INFO, format= '%(asctime)s [%(name)s] %(levelname)s %(filename)s:%(lineno)s %(message)s' ) else: logging.basicConfig( level=logging.INFO, format= '%(asctime)s [%(name)s] %(levelname)s %(filename)s:%(lineno)s %(message)s' ) if args.verbose: honey_logger.setLevel(logging.DEBUG) try: syslogger = get_syslog_logger(config.syslog_address, config.syslog_port, config.syslog_protocol) if args.verbose: syslogger.setLevel(logging.DEBUG) honey_logger.info( "Setup syslog with parameters: IP:%s, PORT:%d, PROTOCOL:%s", config.syslog_address, config.syslog_port, config.syslog_protocol) except MissingConfigField: honey_logger.info( "Syslog reporting disabled, to enable it add its configuration to the configuration file" ) COMMANDS = config.commands server = gevent.server.StreamServer((config.ip, 23), MyTelnetHandler.streamserver_handle) honey_logger.info("Listening on %d...", 23) server.serve_forever()