mirror of https://github.com/cowrie/cowrie.git
Remove connection limit support for now, since adding a protocol wrapper
changes the logging in newer twisted versions, and breaks dblog. git-svn-id: https://kippo.googlecode.com/svn/trunk@232 951d7100-d841-11de-b865-b3884708a8e2
This commit is contained in:
parent
9378c6ba22
commit
3912ffb603
|
@ -20,11 +20,6 @@ ssh_port = 2222
|
|||
# (default: sales)
|
||||
hostname = sales
|
||||
|
||||
# Maximum number of concurrent connections to the honeypot
|
||||
#
|
||||
# (default: 50)
|
||||
#connection_limit = 50
|
||||
|
||||
# Directory where to save log files in.
|
||||
#
|
||||
# (default: log)
|
||||
|
|
|
@ -33,8 +33,6 @@ factory.portal.registerChecker(honeypot.HoneypotPasswordChecker())
|
|||
factory.publicKeys = {'ssh-rsa': keys.Key.fromString(data=pubKeyString)}
|
||||
factory.privateKeys = {'ssh-rsa': keys.Key.fromString(data=privKeyString)}
|
||||
|
||||
wrapper = honeypot.HoneypotLimitConnections(factory)
|
||||
|
||||
cfg = config()
|
||||
if cfg.has_option('honeypot', 'ssh_addr'):
|
||||
ssh_addr = cfg.get('honeypot', 'ssh_addr')
|
||||
|
@ -44,7 +42,7 @@ else:
|
|||
application = service.Application('honeypot')
|
||||
for i in ssh_addr.split():
|
||||
service = internet.TCPServer(
|
||||
int(cfg.get('honeypot', 'ssh_port')), wrapper,
|
||||
int(cfg.get('honeypot', 'ssh_port')), factory,
|
||||
interface=i)
|
||||
service.setServiceParent(application)
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ from twisted.conch.insults import insults
|
|||
from twisted.application import service, internet
|
||||
from twisted.internet import reactor, protocol, defer
|
||||
from twisted.python import failure, log
|
||||
from twisted.protocols.policies import WrappingFactory
|
||||
from zope.interface import implements
|
||||
from copy import deepcopy, copy
|
||||
import sys, os, random, pickle, time, stat, shlex, anydbm
|
||||
|
@ -652,29 +651,6 @@ class HoneyPotSSHFactory(factory.SSHFactory):
|
|||
t.factory = self
|
||||
return t
|
||||
|
||||
class HoneypotLimitConnections(WrappingFactory):
|
||||
|
||||
connectionCount = 0
|
||||
connectionLimit = 50
|
||||
|
||||
def startFactory(self):
|
||||
cfg = config()
|
||||
if cfg.has_option('honeypot', 'connection_limit'):
|
||||
self.connectionLimit = int(cfg.get(
|
||||
'honeypot', 'connection_limit'))
|
||||
|
||||
def buildProtocol(self, addr):
|
||||
if self.connectionLimit is None or \
|
||||
self.connectionCount < self.connectionLimit:
|
||||
self.connectionCount += 1
|
||||
return WrappingFactory.buildProtocol(self, addr)
|
||||
else:
|
||||
print 'Connection limit reached (%s:%s)' % (addr.host, addr.port)
|
||||
return None
|
||||
|
||||
def unregisterProtocol(self, p):
|
||||
self.connectionCount -= 1
|
||||
|
||||
class HoneypotPasswordChecker:
|
||||
implements(checkers.ICredentialsChecker)
|
||||
|
||||
|
|
Loading…
Reference in New Issue