统计
  • 文章总数:1055 篇
  • 评论总数:10 条
  • 分类总数:7 个
  • 最后更新:2023年08月19日

面向小白的CloudFront扫段Pyhon脚本

本文阅读 1 分钟
首页 技巧杂烩 正文

能用来干什么请看这个:
https://www.hostloc.com/thread-741034-1-1.html
https://www.hostloc.com/thread-741474-1-1.html
https://www.hostloc.com/thread-741616-1-1.html

运行截图:
运行截图
结果截图:
结果截图
首先声明,github抄的,改了一点点内容

使用方法: python cfscan.py 183.201.1.1-183.201.255.255 800

cfscan.py = 你保存的文件名

183.201.1.1-183.201.255.255 = 你要扫的起始IP-结尾IP

800 = 线程数

脚本代码:

#!/usr/bin/env python
# coding=utf-8
# python2.7 only

import threading
import requests
import Queue
import sys
import re

#ip to num
def ip2num(ip):
    ip = [int(x) for x in ip.split('.')]
    return ip[0] << 24 | ip[1] << 16 | ip[2] << 8 | ip[3]

#num to ip
def num2ip(num):
    return '%s.%s.%s.%s' % ((num & 0xff000000) >> 24,(num & 0x00ff0000) >> 16,(num & 0x0000ff00) >> 8,num & 0x000000ff)

#
def ip_range(start, end):
    return [num2ip(num) for num in range(ip2num(start), ip2num(end) + 1) if num & 0xff]

#
def bThread(iplist):
   
    threadl = []
    queue = Queue.Queue()
    for host in iplist:
        queue.put(host)

    for x in xrange(0, int(SETTHREAD)):
        threadl.append(tThread(queue))
        
    for t in threadl:
        t.start()
    for t in threadl:
        t.join()        

#create thread
class tThread(threading.Thread):
    def __init__(self, queue):
        threading.Thread.__init__(self)
        self.queue = queue

    def run(self):
        
        while not self.queue.empty():
            host = self.queue.get()
            try:
                checkServer(host)
            except:
                continue

def checkServer(host):
    header ={'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36'}
    aimurl = "http://"+host+":443"
    response = requests.get(url=aimurl,headers=header,timeout=10)
    serverText = response.headers['server']

    if len(serverText) > 0:
        print  "-"*50+"\n"+aimurl +"\nServer: "+serverText
        if (serverText == "CloudFront"):
            f.write(host+"\n")


if __name__ == '__main__':
    print '\n############# Cloud Front Scan  ################'
    print '                Author hostloc.com'
    print '################################################\n'

    global SETTHREAD

    try:
        SETTHREAD = sys.argv[2]
        f = open("result.txt", "w")
        iplist = ip_range(sys.argv[1].split('-')[0], sys.argv[1].split('-')[1])
        
        print '\n[Note] Will scan '+str(len(iplist))+" host...\n"

        bThread(iplist)
    except KeyboardInterrupt:
        print 'Keyboard Interrupt!'
        sys.exit()

转载至https://www.hostloc.com/thread-742035-1-1.html

本文来自投稿,不代表本站立场,如若转载,请注明出处:
-- 展开阅读全文 --
Shadowsocks AEAD 加密漏洞及防重放机制所带来的潜在危险
« 上一篇 04-19
OneDriveUploader:多线程上传文件/文件夹到OneDrive的工具,支持Linux、Windows、MacOS
下一篇 » 04-19

发表评论

发表评论
    请配置好页面缩略名选项

热门文章

标签TAG

热评文章