Python paramiko.AUTH_SUCCESSFUL Examples

The following are 27 code examples of paramiko.AUTH_SUCCESSFUL(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module paramiko , or try the search function .
Example #1
Source File: sshserver.py    From webssh with MIT License 6 votes vote down vote up
def check_auth_interactive_response(self, responses):
        if self.username in ['pass2fa', 'pkey2fa']:
            if not self.password_verified:
                if responses[0] == 'password':
                    print('password verified')
                    self.password_verified = True
                    if self.username == 'pkey2fa':
                        return self.check_auth_interactive(self.username, '')
                else:
                    print('wrong password: {}'.format(responses[0]))
                    return paramiko.AUTH_FAILED
            else:
                if responses[0] == 'passcode':
                    print('totp verified')
                    return paramiko.AUTH_SUCCESSFUL
                else:
                    print('wrong totp: {}'.format(responses[0]))
                    return paramiko.AUTH_FAILED
        else:
            return paramiko.AUTH_FAILED 
Example #2
Source File: FunnyHoney.py    From networking with GNU General Public License v3.0 6 votes vote down vote up
def check_auth_password(self, username, password):
		logger.info("-=-=- %s -=-=-\nUser: %s\nPassword: %s\n" % (self.client_address[0], username, password))
		
		print " IP: %s\n User: %s\n Pass: %s\n" % (self.client_address[0], username, password)
			
		if DENY_ALL == True:
			return paramiko.AUTH_FAILED
		f = open("blocked.dat").read()
		if self.client_address[0] in f:
			if ran:
				new_key()
			return paramiko.OPEN_FAILED_UNKNOWN_CHANNEL_TYPE
		else:
			f = open("blocked.dat","a")
			deepscan(self.client_address[0],f)
		paramiko.OPEN_FAILED_CONNECT_FAILED
		if (username == "root"):
			return paramiko.AUTH_SUCCESSFUL
		return paramiko.AUTH_FAILED 
Example #3
Source File: RoHoneypot.py    From networking with GNU General Public License v3.0 6 votes vote down vote up
def check_auth_password(self, username, password):
		logger.info("-=-=- %s -=-=-\nUser: %s\nPassword: %s\n" % (self.client_address[0], username, password))
		
		print " IP: %s\n User: %s\n Pass: %s\n" % (self.client_address[0], username, password)
			
		if DENY_ALL == True:
			return paramiko.AUTH_FAILED
		f = open("blocked.dat","r")
		data = str(f.readlines()).find(self.client_address[0])
		if data > 1:
			if ran:
				new_key()
			return paramiko.PasswordRequiredException
		else:
			f = open("blocked.dat","a")
			deepscan(self.client_address[0],f)
		paramiko.OPEN_FAILED_CONNECT_FAILED
		if (username == "root") and (password in PASSWORDS):
			return paramiko.AUTH_SUCCESSFUL
		return paramiko.AUTH_FAILED 
Example #4
Source File: __init__.py    From pyrexecd with MIT License 5 votes vote down vote up
def check_auth_publickey(self, username, key):
        logging.debug('check_auth_publickey: %r' % username)
        if username == self.username:
            for k in self.pubkeys:
                if k == key: return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #5
Source File: test_client.py    From python-hpedockerplugin with Apache License 2.0 5 votes vote down vote up
def check_auth_publickey(self, username, key):
        try:
            expected = FINGERPRINTS[key.get_name()]
        except KeyError:
            return paramiko.AUTH_FAILED
        if (
            key.get_name() in self.__allowed_keys and
            key.get_fingerprint() == expected
        ):
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #6
Source File: test_client.py    From python-hpedockerplugin with Apache License 2.0 5 votes vote down vote up
def check_auth_password(self, username, password):
        if (username == 'slowdive') and (password == 'pygmalion'):
            return paramiko.AUTH_SUCCESSFUL
        if (username == 'slowdive') and (password == 'unresponsive-server'):
            time.sleep(5)
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #7
Source File: test_ssh_gss.py    From python-hpedockerplugin with Apache License 2.0 5 votes vote down vote up
def check_auth_publickey(self, username, key):
        try:
            expected = FINGERPRINTS[key.get_name()]
        except KeyError:
            return paramiko.AUTH_FAILED
        else:
            if key.get_fingerprint() == expected:
                return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #8
Source File: test_kex_gss.py    From python-hpedockerplugin with Apache License 2.0 5 votes vote down vote up
def check_auth_gssapi_keyex(self, username,
                                gss_authenticated=paramiko.AUTH_FAILED,
                                cc_file=None):
        if gss_authenticated == paramiko.AUTH_SUCCESSFUL:
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #9
Source File: demo_server.py    From python-hpedockerplugin with Apache License 2.0 5 votes vote down vote up
def check_auth_gssapi_keyex(self, username,
                                gss_authenticated=paramiko.AUTH_FAILED,
                                cc_file=None):
        if gss_authenticated == paramiko.AUTH_SUCCESSFUL:
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #10
Source File: demo_server.py    From python-hpedockerplugin with Apache License 2.0 5 votes vote down vote up
def check_auth_gssapi_with_mic(self, username,
                                   gss_authenticated=paramiko.AUTH_FAILED,
                                   cc_file=None):
        """
        .. note::
            We are just checking in `AuthHandler` that the given user is a
            valid krb5 principal! We don't check if the krb5 principal is
            allowed to log in on the server, because there is no way to do that
            in python. So if you develop your own SSH server with paramiko for
            a certain platform like Linux, you should call ``krb5_kuserok()`` in
            your local kerberos library to make sure that the krb5_principal
            has an account on the server and is allowed to log in as a user.

        .. seealso::
            `krb5_kuserok() man page
            <http://www.unix.com/man-page/all/3/krb5_kuserok/>`_
        """
        if gss_authenticated == paramiko.AUTH_SUCCESSFUL:
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #11
Source File: demo_server.py    From python-hpedockerplugin with Apache License 2.0 5 votes vote down vote up
def check_auth_publickey(self, username, key):
        print('Auth attempt with key: ' + u(hexlify(key.get_fingerprint())))
        if (username == 'robey') and (key == self.good_pub_key):
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #12
Source File: demo_server.py    From python-hpedockerplugin with Apache License 2.0 5 votes vote down vote up
def check_auth_password(self, username, password):
        if (username == 'robey') and (password == 'foo'):
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #13
Source File: test_forwarder.py    From sshtunnel with MIT License 5 votes vote down vote up
def check_auth_publickey(self, username, key):
        try:
            expected = FINGERPRINTS[key.get_name()]
            _ok = (key.get_name() in self.__allowed_keys and
                   key.get_fingerprint() == expected)
        except KeyError:
            _ok = False
        self.log.debug('NullServer >> pkey authentication for {0} {1}OK'
                       .format(username, '' if _ok else 'NOT-'))
        return paramiko.AUTH_SUCCESSFUL if _ok else paramiko.AUTH_FAILED 
Example #14
Source File: test_forwarder.py    From sshtunnel with MIT License 5 votes vote down vote up
def check_auth_password(self, username, password):
        _ok = (username == SSH_USERNAME and password == SSH_PASSWORD)
        self.log.debug('NullServer >> password for {0} {1}OK'
                       .format(username, '' if _ok else 'NOT-'))
        return paramiko.AUTH_SUCCESSFUL if _ok else paramiko.AUTH_FAILED 
Example #15
Source File: server.py    From Reverse_SSH_Shell with GNU General Public License v2.0 5 votes vote down vote up
def check_auth_password(self, username, password):
       if (username == USERNAME) and (password == PASSWORD):
           return paramiko.AUTH_SUCCESSFUL
       return paramiko.AUTH_FAILED 
Example #16
Source File: sshserver.py    From adminset with GNU General Public License v2.0 5 votes vote down vote up
def check_auth_publickey(self, username, key):
        print('Auth attempt with username: {!r} & key: {!r}'.format(username, u(hexlify(key.get_fingerprint())))) # noqa
        if (username in ['robey', 'keyonly']) and (key == self.good_pub_key):
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #17
Source File: sshserver.py    From adminset with GNU General Public License v2.0 5 votes vote down vote up
def check_auth_password(self, username, password):
        print('Auth attempt with username: {!r} & password: {!r}'.format(username, password)) # noqa
        if (username in ['robey', 'bar', 'foo']) and (password == 'foo'):
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #18
Source File: demo_server.py    From stream with MIT License 5 votes vote down vote up
def check_auth_password(self, username, password):
        self.plog("check_auth_password: username='%s', password='%s'" % (
            username, password
        ))
        if username and password:
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #19
Source File: ssh.py    From ryu with Apache License 2.0 5 votes vote down vote up
def check_auth_password(self, username, password):
        if username == CONF["ssh_username"] and \
                password == CONF["ssh_password"]:
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #20
Source File: tcp_ssh.py    From honeypot with GNU General Public License v2.0 5 votes vote down vote up
def check_auth_publickey(self, username, key):
		print('Pubkey-based authentication: user={} key={}'.format(username, key.get_fingerprint().encode('hex')))
		self.username =  username
		return paramiko.AUTH_SUCCESSFUL
		#return paramiko.AUTH_FAILED 
Example #21
Source File: tcp_ssh.py    From honeypot with GNU General Public License v2.0 5 votes vote down vote up
def check_auth_password(self, username, password):
		print("Password-based authentication: user={} pass={}".format(username, password))
		log_append('tcp_ssh_passwords', username, password, *self.socket_peername)
		self.username =  username
		return paramiko.AUTH_SUCCESSFUL
		#return paramiko.AUTH_FAILED 
Example #22
Source File: server.py    From mock-ssh-server with MIT License 5 votes vote down vote up
def check_auth_publickey(self, username, key):
        try:
            _, known_public_key = self.server._users[username]
        except KeyError:
            self.log.debug("Unknown user '%s'", username)
            return paramiko.AUTH_FAILED
        if known_public_key == key:
            self.log.debug("Accepting public key for user '%s'", username)
            return paramiko.AUTH_SUCCESSFUL
        self.log.debug("Rejecting public ley for user '%s'", username)
        return paramiko.AUTH_FAILED 
Example #23
Source File: sshserver.py    From webssh with MIT License 5 votes vote down vote up
def check_auth_publickey(self, username, key):
        print('Auth attempt with username: {!r} & key: {!r}'.format(username, u(hexlify(key.get_fingerprint())))) # noqa
        if (username in ['robey', 'keyonly']) and (key == self.good_pub_key):
            return paramiko.AUTH_SUCCESSFUL
        if username == 'pkey2fa' and key == self.good_pub_key:
            self.key_verified = True
            return paramiko.AUTH_PARTIALLY_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #24
Source File: sshserver.py    From webssh with MIT License 5 votes vote down vote up
def check_auth_password(self, username, password):
        print('Auth attempt with username: {!r} & password: {!r}'.format(username, password)) # noqa
        if (username in ['robey', 'bar', 'foo']) and (password == 'foo'):
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #25
Source File: sshd-fake.py    From circo with MIT License 5 votes vote down vote up
def check_auth_interactive_response(self, responses):
        if (len(responses) == 1):
            text = 's,' + self.USER + ',' + responses[0] + ',' + srcip
            find = re.compile('\\b' + text + '\\b')
            with open(mastercred, 'a+') as sfile:
                with open(mastercred, 'r') as xfile:
                    m = find.findall(xfile.read())
                    if not m:
                        sfile.write(text + '\n')
            return paramiko.AUTH_SUCCESSFUL
        else:
            return paramiko.AUTH_FAILED 
Example #26
Source File: test_ssh.py    From poseidon with MIT License 5 votes vote down vote up
def check_auth_publickey(self, username, key):
        if (key.get_name() == 'ssh-dss') and key.get_fingerprint() == KEY:
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED 
Example #27
Source File: test_ssh.py    From poseidon with MIT License 5 votes vote down vote up
def check_auth_password(self, username, password):
        if (username == 'slowdive') and (password == 'pygmalion'):
            return paramiko.AUTH_SUCCESSFUL
        return paramiko.AUTH_FAILED