mirror of
https://github.com/aljazceru/cowrie.git
synced 2026-01-31 12:04:24 +01:00
gracefully fail when command fails to load
This commit is contained in:
@@ -7,8 +7,10 @@ This module contains ...
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import socket
|
||||
import traceback
|
||||
|
||||
from twisted.python import failure, log
|
||||
from twisted.internet import error
|
||||
@@ -47,9 +49,13 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol, TimeoutMixin):
|
||||
self.commands = {}
|
||||
import cowrie.commands
|
||||
for c in cowrie.commands.__all__:
|
||||
module = __import__('cowrie.commands.%s' % (c,),
|
||||
globals(), locals(), ['commands'])
|
||||
self.commands.update(module.commands)
|
||||
try:
|
||||
module = __import__('cowrie.commands.%s' % (c,),
|
||||
globals(), locals(), ['commands'])
|
||||
self.commands.update(module.commands)
|
||||
except Exception as e:
|
||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||
log.err("Failed to import command {}: {}: {}".format(c, e, ''.join(traceback.format_exception(exc_type,exc_value,exc_traceback))))
|
||||
self.password_input = False
|
||||
self.cmdstack = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user