FtpScan是一个匿名FTP扫描工具,用于扫描检查允许匿名登录的FTP服务器。
经测试扫描速度和效率都还不错
#!/usr/bin/env python """ FtpScan.py - Scans for FTP servers allowing Anonymous Login Written by Sotd - twitter.com/#!/Sotd_ Performance update by q8r9e4 """ import sys import threading import Queue import ftplib import socket import time global ftpqueue ftpqueue = Queue.Queue() class Ftp(threading.Thread): """Handles connections""" def __init__(self, queue): threading.Thread.__init__(self) self.queue = queue def run(self): """Connects and checks for anonymous login""" while True: try: ip_add = self.queue.get(False) except Queue.Empty: break try: ftp = ftplib.FTP(ip_add) ftp.login() except ftplib.all_errors: print 'Not Working: %s' % (ip_add) else: print 'Working: %s' % (ip_add) write = open('Ftp.txt', "a+") write.write(ip_add + '\n') write.close() ftp.quit() finally: self.queue.task_done() class Scanner(threading.Thread): def __init__(self, queue): threading.Thread.__init__(self) self.queue = queue def run(self): """Connects and checks for anonymous login""" global ftpqueue while True: try: ip_add = self.queue.get(False) except Queue.Empty: break try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) check = s.connect_ex((str(ip_add), 21)) if check == 0: ftpqueue.put(ip_add) else: print 'No FTP: %s' % (ip_add) s.close() finally: self.queue.task_done() def iprange(): """Creates list of Ip's from Start_Ip to End_Ip and checks for port 21""" start_ip = sys.argv[1] end_ip = sys.argv[2] ip_range = Queue.Queue() start = list(map(int, start_ip.split("."))) end = list(map(int, end_ip.split("."))) tmp = start socket.setdefaulttimeout(3) ip_range.put(start_ip) while tmp != end: start[3] += 1 for i in (3, 2, 1): if tmp[i] == 256: tmp[i] = 0 tmp[i-1] += 1 ip_range.put(".".join(map(str, tmp))) for i in range(10): time.sleep(0.1) thread = Scanner(ip_range) thread.setDaemon(True) thread.start() ip_range.join() if ftpqueue.empty(): print '\nNo FTP servers found\n' sys.exit(0) for i in range(10): thread = Ftp(ftpqueue) thread.setDaemon(True) thread.start() ftpqueue.join() if __name__ == '__main__': if len(sys.argv) != 3: print 'Usage: ./FtpScan <start_ip> <end_ip>' print 'Example: ./FtpScan 127.0.0.1 127.0.0.5' sys.exit(1) else: iprange()
工具获取地址:
https://pastebin.com/stMF80is
原文始发于微信公众号(菜鸟小新):FtpScan:匿名FTP扫描工具
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论