python---批量扫描ftp anonymous

#!/usr/local/bin/python

-- coding: utf-8 --

批量扫描ftp匿名登录

from ftplib import FTP

def ftp_open(host=’’,user=’’,passwd=’’): #打开FTP
try:
ftp=FTP()
data=ftp.login(user,passwd) #空字符串代表匿名登录
print ()
return 1
except:
return 0

def ftp_test():
f = open(“url.txt”,”r”)
lines=f.readlines()
for ip in lines:
if ftp_open(ip,”anonymous”,):
print ‘\n[] ‘,u”存在漏洞”+ip
else:
print ‘\n[
] ‘,u”不存在漏洞”+ip
f.close()

if name==’main‘:
ftp_test()