python脚本–扫描匿名FTP服务器
这几天没有写什么脚本,今天写了个扫描匿名FTP服务器的脚本,其实用处感觉不是很大,但也有某一次测试就会用到,以备日后在用吧。
=============分割线=============
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: IcySun
# 脚本功能:匿名FTP扫描
from Queue import Queue
import threading,sys
import ftplib
def use():
print '#' * 50
print '/t Scan Anonymous FTP'
print '/t/t Code By: IcySun'
print '#' * 50
def anonTest(hostname):
try:
ftp = ftplib.FTP(hostname)
ftp.login('anonymous','me@xx.com')
print '/n[*] ' + str(hostname) + '/tFTP Anonymous Logon Succeeded!'
ftp.quit()
return True
except Exception, e:
pass
class MyThread(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
global queue
while not queue.empty():
hostname = queue.get()
anonTest(hostname)
def main():
use()
global hostname,queue
queue = Queue()
f = open('ip.txt','r')
for host in f.readlines():
host = host.strip('/n')
queue.put(host)
for i in range(100):
c = MyThread()
c.start()
if __name__ == '__main__':
main()
=============分割线=============
代码如图
测试如图:
备注:需要自行提前扫描某IP段的21端口,如果你喜欢也可以继续修改脚本。