コード例 #1
0
ファイル: factory.py プロジェクト: DarkmatterVale/cowrie
    def startFactory(self):
        """
        """
        # For use by the uptime command
        self.starttime = time.time()

        # Load/create keys
        rsaPubKeyString, rsaPrivKeyString = cowriekeys.getRSAKeys()
        dsaPubKeyString, dsaPrivKeyString = cowriekeys.getDSAKeys()
        self.publicKeys = {
            b'ssh-rsa': keys.Key.fromString(data=rsaPubKeyString),
            b'ssh-dss': keys.Key.fromString(data=dsaPubKeyString)
        }
        self.privateKeys = {
            b'ssh-rsa': keys.Key.fromString(data=rsaPrivKeyString),
            b'ssh-dss': keys.Key.fromString(data=dsaPrivKeyString)
        }

        _modulis = '/etc/ssh/moduli', '/private/etc/moduli'
        for _moduli in _modulis:
            try:
                self.primes = primes.parseModuliFile(_moduli)
                break
            except IOError as err:
                pass

        try:
            self.ourVersionString = CONFIG.get('ssh', 'version')
        except NoOptionError:
            self.ourVersionString = 'SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2'

        factory.SSHFactory.startFactory(self)
        log.msg("Ready to accept SSH connections")
コード例 #2
0
ファイル: factory.py プロジェクト: yp2800/cowrie
    def startFactory(self):
        # For use by the uptime command
        self.starttime = time.time()

        # Load/create keys
        rsaPubKeyString, rsaPrivKeyString = cowriekeys.getRSAKeys()
        dsaPubKeyString, dsaPrivKeyString = cowriekeys.getDSAKeys()
        self.publicKeys = {
            b"ssh-rsa": keys.Key.fromString(data=rsaPubKeyString),
            b"ssh-dss": keys.Key.fromString(data=dsaPubKeyString),
        }
        self.privateKeys = {
            b"ssh-rsa": keys.Key.fromString(data=rsaPrivKeyString),
            b"ssh-dss": keys.Key.fromString(data=dsaPrivKeyString),
        }

        _modulis = "/etc/ssh/moduli", "/private/etc/moduli"
        for _moduli in _modulis:
            try:
                self.primes = primes.parseModuliFile(_moduli)
                break
            except OSError:
                pass

        # this can come from backend in the future, check HonSSH's slim client
        self.ourVersionString = CowrieConfig.get(
            "ssh", "version", fallback="SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2")

        factory.SSHFactory.startFactory(self)
        log.msg("Ready to accept SSH connections")
コード例 #3
0
ファイル: factory.py プロジェクト: smelrain/cowrie
    def startFactory(self):
        # For use by the uptime command
        self.starttime = time.time()

        # Load/create keys
        rsaPubKeyString, rsaPrivKeyString = cowriekeys.getRSAKeys()
        dsaPubKeyString, dsaPrivKeyString = cowriekeys.getDSAKeys()
        self.publicKeys = {
            b'ssh-rsa': keys.Key.fromString(data=rsaPubKeyString),
            b'ssh-dss': keys.Key.fromString(data=dsaPubKeyString)
        }
        self.privateKeys = {
            b'ssh-rsa': keys.Key.fromString(data=rsaPrivKeyString),
            b'ssh-dss': keys.Key.fromString(data=dsaPrivKeyString)
        }

        _modulis = '/etc/ssh/moduli', '/private/etc/moduli'
        for _moduli in _modulis:
            try:
                self.primes = primes.parseModuliFile(_moduli)
                break
            except IOError:
                pass

        factory.SSHFactory.startFactory(self)
        log.msg("Ready to accept SSH connections")
コード例 #4
0
ファイル: factory.py プロジェクト: Mato-Z/cowrie
    def startFactory(self):
        # For use by the uptime command
        self.starttime = time.time()

        # Load/create keys
        rsaPubKeyString, rsaPrivKeyString = cowriekeys.getRSAKeys()
        dsaPubKeyString, dsaPrivKeyString = cowriekeys.getDSAKeys()
        self.publicKeys = {
            b'ssh-rsa': keys.Key.fromString(data=rsaPubKeyString),
            b'ssh-dss': keys.Key.fromString(data=dsaPubKeyString)
        }
        self.privateKeys = {
            b'ssh-rsa': keys.Key.fromString(data=rsaPrivKeyString),
            b'ssh-dss': keys.Key.fromString(data=dsaPrivKeyString)
        }

        _modulis = '/etc/ssh/moduli', '/private/etc/moduli'
        for _moduli in _modulis:
            try:
                self.primes = primes.parseModuliFile(_moduli)
                break
            except IOError:
                pass

        try:
            self.ourVersionString = CONFIG.get('ssh', 'version')
        except NoOptionError:
            self.ourVersionString = 'SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2'

        factory.SSHFactory.startFactory(self)
        log.msg("Ready to accept SSH connections")
コード例 #5
0
    def startFactory(self):
        # For use by the uptime command
        self.starttime = time.time()

        # Load/create keys
        self.publicKeys = {}
        self.privateKeys = {}
        try:
            public_key_auth = [
                i.encode("utf-8")
                for i in CowrieConfig.get("ssh", "public_key_auth").split(",")
            ]
        except NoOptionError:
            # no keys defined, use the three most common pub keys of OpenSSH
            public_key_auth = [
                b"ssh-rsa", b"ecdsa-sha2-nistp256", b"ssh-ed25519"
            ]
        for key in public_key_auth:
            if key == b"ssh-rsa":
                rsaPubKeyString, rsaPrivKeyString = cowriekeys.getRSAKeys()
                self.publicKeys[key] = keys.Key.fromString(
                    data=rsaPubKeyString)
                self.privateKeys[key] = keys.Key.fromString(
                    data=rsaPrivKeyString)
            elif key == b"ssh-dss":
                dsaaPubKeyString, dsaPrivKeyString = cowriekeys.getDSAKeys()
                self.publicKeys[key] = keys.Key.fromString(
                    data=dsaaPubKeyString)
                self.privateKeys[key] = keys.Key.fromString(
                    data=dsaPrivKeyString)
            elif key == b"ecdsa-sha2-nistp256":
                ecdsaPuKeyString, ecdsaPrivKeyString = cowriekeys.getECDSAKeys(
                )
                self.publicKeys[key] = keys.Key.fromString(
                    data=ecdsaPuKeyString)
                self.privateKeys[key] = keys.Key.fromString(
                    data=ecdsaPrivKeyString)
            elif key == b"ssh-ed25519":
                ed25519PubKeyString, ed25519PrivKeyString = cowriekeys.geted25519Keys(
                )
                self.publicKeys[key] = keys.Key.fromString(
                    data=ed25519PubKeyString)
                self.privateKeys[key] = keys.Key.fromString(
                    data=ed25519PrivKeyString)

        _modulis = "/etc/ssh/moduli", "/private/etc/moduli"
        for _moduli in _modulis:
            try:
                self.primes = primes.parseModuliFile(_moduli)
                break
            except OSError:
                pass

        # this can come from backend in the future, check HonSSH's slim client
        self.ourVersionString = CowrieConfig.get(
            "ssh", "version", fallback="SSH-2.0-OpenSSH_6.0p1 Debian-4+deb7u2")

        factory.SSHFactory.startFactory(self)
        log.msg("Ready to accept SSH connections")
コード例 #6
0
    def startFactory(self):
        """
        """
        # For use by the uptime command
        self.starttime = time.time()

        # Load/create keys
        rsaPubKeyString, rsaPrivKeyString = cowriekeys.getRSAKeys()
        dsaPubKeyString, dsaPrivKeyString = cowriekeys.getDSAKeys()
        self.publicKeys = {
          b'ssh-rsa': keys.Key.fromString(data=rsaPubKeyString),
          b'ssh-dss': keys.Key.fromString(data=dsaPubKeyString)}
        self.privateKeys = {
          b'ssh-rsa': keys.Key.fromString(data=rsaPrivKeyString),
          b'ssh-dss': keys.Key.fromString(data=dsaPrivKeyString)}

        factory.SSHFactory.startFactory(self)
        log.msg("Ready to accept SSH connections")