make telnet optional, small prompt fixes

This commit is contained in:
Michel Oosterhof
2016-08-22 15:56:19 +04:00
parent 31bdc68b0d
commit 1602fa735a
4 changed files with 61 additions and 43 deletions

View File

@@ -100,16 +100,20 @@ class CowrieServiceMaker(object):
factory.portal.registerChecker(
core.checkers.HoneypotNoneChecker())
if cfg.has_option('honeypot', 'listen_ssh_addr'):
listen_ssh_addr = cfg.get('honeypot', 'listen_ssh_addr')
if cfg.has_option('ssh', 'listen_addr'):
listen_ssh_addr = cfg.get('ssh', 'listen_addr')
elif cfg.has_option('honeypot', 'listen_addr'):
listen_ssh_addr = cfg.get('honeypot', 'listen_addr')
else:
listen_ssh_addr = '0.0.0.0'
# Preference: 1, option, 2, config, 3, default of 2222
if options['port'] != 0:
listen_ssh_port = int(options["port"])
elif cfg.has_option('honeypot', 'listen_ssh_port'):
listen_ssh_port = int(cfg.get('honeypot', 'listen_ssh_port'))
elif cfg.has_option('ssh', 'listen_port'):
listen_ssh_port = int(cfg.get('ssh', 'listen_port'))
elif cfg.has_option('honeypot', 'listen_port'):
listen_ssh_port = int(cfg.get('honeypot', 'listen_port'))
else:
listen_ssh_port = 2222
@@ -118,29 +122,32 @@ class CowrieServiceMaker(object):
# FIXME: Use addService on topService ?
svc.setServiceParent(topService)
# TODO deduplicate telnet and ssh into a generic loop for each service
if cfg.has_option('honeypot', 'listen_telnet_addr'):
listen_telnet_addr = cfg.get('honeypot', 'listen_telnet_addr')
else:
listen_telnet_addr = '0.0.0.0'
# Preference: 1, config, 2, default of 2223
if cfg.has_option('honeypot', 'listen_telnet_port'):
listen_telnet_port = int(cfg.get('honeypot', 'listen_telnet_port'))
else:
listen_telnet_port = 2223
f = cowrie.telnet.transport.HoneyPotTelnetFactory(cfg)
f.portal = portal.Portal(core.realm.HoneyPotRealm(cfg))
f.portal.registerChecker(core.checkers.HoneypotPasswordChecker(cfg))
if cfg.has_option('honeypot', 'auth_none_enabled') and \
cfg.get('honeypot', 'auth_none_enabled').lower() in \
if cfg.has_option('telnet', 'enabled') and \
cfg.get('telnet', 'enabled').lower() in \
('yes', 'true', 'on'):
f.portal.registerChecker(core.checkers.HoneypotNoneChecker())
for i in listen_telnet_addr.split():
tsvc = internet.TCPServer(listen_telnet_port, f, interface=i)
# FIXME: Use addService on topService ?
tsvc.setServiceParent(topService)
if cfg.has_option('telnet', 'listen_addr'):
listen_telnet_addr = cfg.get('telnet', 'listen_addr')
else:
listen_telnet_addr = '0.0.0.0'
# Preference: 1, config, 2, default of 2223
if cfg.has_option('telnet', 'listen_port'):
listen_telnet_port = int(cfg.get('telnet', 'listen_port'))
else:
listen_telnet_port = 2223
f = cowrie.telnet.transport.HoneyPotTelnetFactory(cfg)
f.portal = portal.Portal(core.realm.HoneyPotRealm(cfg))
f.portal.registerChecker(core.checkers.HoneypotPasswordChecker(cfg))
if cfg.has_option('honeypot', 'auth_none_enabled') and \
cfg.get('honeypot', 'auth_none_enabled').lower() in \
('yes', 'true', 'on'):
f.portal.registerChecker(core.checkers.HoneypotNoneChecker())
for i in listen_telnet_addr.split():
tsvc = internet.TCPServer(listen_telnet_port, f, interface=i)
# FIXME: Use addService on topService ?
tsvc.setServiceParent(topService)
if cfg.has_option('honeypot', 'interact_enabled') and \
cfg.get('honeypot', 'interact_enabled').lower() in \