use try/except for config statements

This commit is contained in:
Michel Oosterhof
2015-11-22 12:19:57 +04:00
parent 38ed9d349a
commit 02f181057d
2 changed files with 8 additions and 7 deletions

View File

@@ -65,9 +65,9 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol, TimeoutMixin):
self.setTimeout(1800)
# Source IP of client in user visible reports (can be fake or real)
if self.cfg.has_option('honeypot', 'fake_addr'):
try:
self.clientIP = self.cfg.get('honeypot', 'fake_addr')
else:
except:
self.clientIP = self.realClientIP
if self.cfg.has_option('honeypot', 'internet_facing_ip'):
@@ -428,7 +428,7 @@ class LoggingServerProtocol(insults.ServerProtocol):
log.msg(eventid='KIPP0015', format='Data upload limit reached')
#self.loseConnection()
self.eofReceived()
return
return
if self.stdinlog_open:
with file(self.stdinlog_file, 'ab') as f:

View File

@@ -241,12 +241,11 @@ class HoneyPotSSHFactory(factory.SSHFactory):
_modulis = '/etc/ssh/moduli', '/private/etc/moduli'
# FIXME: try to mimic something real 100%
t = HoneyPotTransport()
if self.cfg.has_option('honeypot', 'ssh_version_string'):
try:
t.ourVersionString = self.cfg.get('honeypot', 'ssh_version_string')
else:
except:
t.ourVersionString = "SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2"
t.supportedPublicKeys = self.privateKeys.keys()
@@ -460,9 +459,11 @@ class CowrieUser(avatar.ConchUser):
self.home = '/home/' + username
# sftp support enabled only when option is explicitly set
if self.cfg.has_option('honeypot', 'sftp_enabled'):
try:
if (self.cfg.get('honeypot', 'sftp_enabled') == "true"):
self.subsystemLookup['sftp'] = filetransfer.FileTransferServer
except:
pass
def logout(self):
log.msg(