本文整理汇总了Python中pxssh.pxssh方法的典型用法代码示例。如果您正苦于以下问题:Python pxssh.pxssh方法的具体用法?Python pxssh.pxssh怎么用?Python pxssh.pxssh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pxssh
的用法示例。
在下文中一共展示了pxssh.pxssh方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connect
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def connect(host, user, dict1):
errors=0
try:
s = pxssh.pxssh()
s.login(host, user, dict1)
print('\033[1;32mPassword Found: ' + dict1+"\033[1;31m")
return s
except Exception as e:
if errors > 5:
print
"!!! Too Many Socket Timeouts"
exit(0)
elif 'read_nonblocking' in str(e):
Fails += 1
time.sleep(5)
return connect(host, user, dict1)
elif 'synchronize with original prompt' in str(e):
time.sleep(1)
return connect(host, user, dict1)
return None
示例2: connect
# 需要导入模块: import pxssh [as 别名]
# 或者: from 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\n[+] Password found: ' + password + '\n\n'
FOUND = True
return s
except Exception, e:
if 'read_nonblocking' in str(e):
FAILS += 1
time.sleep(3)
connect(host, user, password, False)
elif 'synchronize with original prompt' in str(e):
time.sleep(1)
connect(host, user, password, False)
示例3: verify_database
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def verify_database(self, targetnode_ip):
result = True
handle = pxssh.pxssh()
ip = targetnode_ip
login = "root"
passwd = 'c0ntrail123'
prompt = "#"
try:
ret = handle.login (ip,login,passwd,original_prompt=prompt, login_timeout=1000,auto_prompt_reset=False)
except:
pass
cmd = "contrail-status"
output = send_cmd(handle,cmd,prompt,120)
pattern = ["supervisord-contrail-database:active",
"contrail-database active",
"contrail-database-nodemgr active"]
for line in pattern:
if line not in output:
print 'verify %s has Failed' %line
result = result and False
print "result of verify_database %s"%result
assert result
return result
# END of def verify_database(self, targetnode_ip):
示例4: verify_compute
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def verify_compute(self, targetnode_ip):
result = True
handle = pxssh.pxssh()
ip = targetnode_ip
login = "root"
passwd = 'c0ntrail123'
prompt = "#"
try:
ret = handle.login (ip,login,passwd,original_prompt=prompt, login_timeout=1000,auto_prompt_reset=False)
except:
pass
cmd = "contrail-status"
output = send_cmd(handle,cmd,prompt,120)
pattern = ["supervisor-vrouter: active",
"contrail-vrouter-agent active",
"contrail-vrouter-nodemgr active"]
for line in pattern:
if line not in output:
print 'verify %s has Failed' %line
result = result and False
print "result of verify_compute %s"%result
assert result
return result
#end verify_compute(self, targetnode_ip):
示例5: connect
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def connect(host, user, pw, release):
global found
global fails
try:
s = pxssh.pxssh()
s.login(host, user, pw)
print('[+] Password found: ' + pw)
found = True
except Exception as e:
if 'read_nonblocking' in str(e):
fails += 1
time.sleep(5)
connect(host, user, pw, False)
elif 'synchronize with original prompt' in str(e):
time.sleep(1)
connect(host, user, pw, False)
finally:
if release: connection_lock.release()
示例6: _login_remote_system
# 需要导入模块: import pxssh [as 别名]
# 或者: from 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
示例7: __init__
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def __init__ (self, timeout=30, maxread=2000, searchwindowsize=None, logfile=None, cwd=None, env=None):
spawn.__init__(self, None, timeout=timeout, maxread=maxread, searchwindowsize=searchwindowsize, logfile=logfile, cwd=cwd, env=env)
self.name = '<pxssh>'
#SUBTLE HACK ALERT! Note that the command to set 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 = "\[PEXPECT\][\$\#] "
self.PROMPT = self.UNIQUE_PROMPT
# used to set shell command-line prompt to UNIQUE_PROMPT.
self.PROMPT_SET_SH = "PS1='[PEXPECT]\$ '"
self.PROMPT_SET_CSH = "set prompt='[PEXPECT]\$ '"
self.SSH_OPTS = "-o'RSAAuthentication=no' -o 'PubkeyAuthentication=no'"
# 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.auto_prompt_reset = True
示例8: __init__
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def __init__ (self, timeout=30, maxread=2000, searchwindowsize=None,
logfile=None, cwd=None, env=None):
spawn.__init__(self, None, timeout=timeout, maxread=maxread, searchwindowsize=searchwindowsize, logfile=logfile, cwd=cwd, env=env)
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 = "\[PEXPECT\][\$\#] "
self.PROMPT = self.UNIQUE_PROMPT
# used to set shell command-line prompt to UNIQUE_PROMPT.
self.PROMPT_SET_SH = "PS1='[PEXPECT]\$ '"
self.PROMPT_SET_CSH = "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
示例9: brute
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def brute(word):
print "Trying:",word
try:
s = pxssh.pxssh()
s.login (ip, user, word, login_timeout=10)
s.sendline (command)
s.prompt()
print "\n",s.before
s.logout()
print "\t[!] Login Success:",user, word,"\n"
sys.exit(1)
except Exception, e:
#print "[-] Failed"
pass
示例10: brute
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def brute(ip, word):
if verbose != 0:
print "Trying:",word
try:
s = pxssh.pxssh()
s.login (ip, user, word, login_timeout=10)
s.sendline (command)
s.prompt()
print "\n",s.before
s.logout()
print "\t[!] Login Success:",user, word,"\n"
logins.writelines("SSH Login:"+ip+":22 "+user+" "+word+"\n")
except Exception, e:
#print "[-] Failed"
pass
示例11: verify_openstack
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def verify_openstack(self, targetnode_ip):
result = True
handle = pxssh.pxssh()
ip = targetnode_ip
login = "root"
passwd = 'c0ntrail123'
prompt = "#"
try:
ret = handle.login (ip,login,passwd,original_prompt=prompt, login_timeout=1000,auto_prompt_reset=False)
except:
pass
cmd = "openstack-status"
output = send_cmd(handle,cmd,prompt,120)
pattern = ["openstack-nova-api: active",
"openstack-nova-compute: active",
"openstack-nova-network: inactive (disabled on boot)",
"openstack-nova-scheduler: active",
"openstack-nova-volume: inactive (disabled on boot)",
"openstack-nova-conductor: active",
"openstack-glance-api: active",
"openstack-glance-registry: active",
"openstack-keystone: active",
"openstack-cinder-api: active",
"openstack-cinder-scheduler: active",
"openstack-cinder-volume: inactive (disabled on boot)",
"mysql: inactive (disabled on boot)",
"libvirt-bin: active",
"rabbitmq-server: active",
"memcached: inactive (disabled on boot)"]
for line in pattern:
if line not in output:
print 'verify %s has Failed' %line
result = result and False
assert result
return result
#end verify_openstack(self, targetnode_ip):
示例12: verify_collector
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def verify_collector(self, targetnode_ip):
result = True
handle = pxssh.pxssh()
ip = targetnode_ip
login = "root"
passwd = 'c0ntrail123'
prompt = "#"
try:
ret = handle.login (ip,login,passwd,original_prompt=prompt, login_timeout=1000,auto_prompt_reset=False)
except:
pass
cmd = "contrail-status"
output = send_cmd(handle,cmd,prompt,120)
pattern = ["supervisor-analytics: active",
"contrail-analytics-api active",
"contrail-analytics-nodemgr active",
"contrail-collector active",
"contrail-query-engine active"]
for line in pattern:
if line not in output:
print 'verify %s has Failed' %line
result = result and False
print "result of verify_collector %s"%result
assert result
return result
#end verify_collector(self):
示例13: verify_config
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def verify_config(self, targetnode_ip):
result = True
handle = pxssh.pxssh()
ip = targetnode_ip
login = "root"
passwd = 'c0ntrail123'
prompt = "#"
try:
ret = handle.login (ip,login,passwd,original_prompt=prompt, login_timeout=1000,auto_prompt_reset=False)
except:
pass
cmd = "contrail-status"
output = send_cmd(handle,cmd,prompt,120)
pattern = ["supervisor-config: active",
"contrail-api:0 active",
"contrail-config-nodemgr active",
"contrail-discovery:0 active",
"contrail-schema active",
"contrail-svc-monitor active",
"ifmap active"]
for line in pattern:
if line not in output:
print 'verify %s has Failed' %line
result = result and False
print "result of verify_config %s"%result
assert result
return result
#end verify_config(self, targetnode_ip):
示例14: verify_control
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def verify_control(self, targetnode_ip):
result = True
handle = pxssh.pxssh()
ip = targetnode_ip
login = "root"
passwd = 'c0ntrail123'
prompt = "#"
try:
ret = handle.login (ip,login,passwd,original_prompt=prompt, login_timeout=1000,auto_prompt_reset=False)
except:
pass
cmd = "contrail-status"
output = send_cmd(handle,cmd,prompt,120)
pattern = ["supervisor-control: active",
"contrail-control active",
"contrail-control-nodemgr active",
"contrail-dns active",
"contrail-named active"]
for line in pattern:
if line not in output:
print 'verify %s has Failed' %line
result = result and False
print "result of verify_control %s"%result
assert result
return result
#end verify_control(self, targetnode_ip):
示例15: brute
# 需要导入模块: import pxssh [as 别名]
# 或者: from pxssh import pxssh [as 别名]
def brute(word):
print "[?] Trying :",word
try:
s = pxssh.pxssh()
s.login (hostname, user, word, login_timeout=10)
print "\n\t[!] w00t,w00t you've successfully entering SSH target ! "
print "\t[!] Username :",user
print "\t[!] Password :",word, "\n"
print "\t\n[!] Gathering detail target information : "
time.sleep(3) # sorry only refresh your box... :P
# Check usefull commands in line 81 - 84
# You can change with you're command as you like
s.sendline(perintah)
s.prompt()
print "\n",s.before
s.sendline(perintah2)
s.prompt()
print "\n",s.before
s.sendline(perintah3)
s.prompt()
print "\n",s.before
s.sendline(perintah4)
s.prompt()
print "\n",s.before
s.logout()
sys.exit(1)
# End of commands
except Exception, e:
pass