Пример #1
0
    def connectionMade(self):
        try:
            client = self.transport.getPeer().host  # client ip
            log.msg("Incoming connection: %s" % client)
            fd = self.transport.fileno()
            flags = fcntl(fd, F_GETFL)  # Get current fd flags
            fcntl(fd, F_SETFL, flags | os.O_NONBLOCK)
            ready, _, _ = select.select((fd, ), (), (), .5)
            if fd in ready:
                # Get some data.
                req = os.read(fd, 4096)
            if "Mozilla/5.0" in req:
                # Probably it is Nesca, fire!
                self.transport.write(b'%s\r\n' %
                                     (self.ourVersionString + PAYLOAD, ))
                log.msg("Nesca scan detected, attacking: %s" % client)
            else:
                # Regular ssh connection or another shit, drop it
                log.msg("Dropping connection with host: %s" % client)
                self.transport.loseConnection()

        except Exception as e:
            log.msg("Exception in SSHServerTransport: %s" % str(e))
        # Passing connection to normal transport.
        SSHServerTransport.connectionMade(self)
Пример #2
0
 def connectionMade(self):
     SSHServerTransport.connectionMade(self)
     self.transport.setTcpKeepAlive(True)
Пример #3
0
 def connectionMade(self):
     # upon receiving a connection connect on towards the HTTP side
     self.dest_server_addr = None
     SSHServerTransport.connectionMade(self)
Пример #4
0
 def connectionMade(self):
     # upon receiving a connection connect on towards the HTTP side
     self.dest_server_addr = None
     SSHServerTransport.connectionMade(self)
Пример #5
0
 def connectionMade(self):
     SSHServerTransport.connectionMade(self)
     self.transport.setTcpKeepAlive(True)
Пример #6
0
 def connectionMade(self):
     log.msg(metric='num_clients')
     return SSHServerTransport.connectionMade(self)