朱纯树博客
VPS测评推荐网站
cloudacead cloudacead

面向小白的CloudFront扫段Pyhon脚本

能用来干什么请看这个:
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

赞(0) 打赏
未经允许不得转载:VPS测评推荐网站 - 朱纯树博客 » 面向小白的CloudFront扫段Pyhon脚本

评论 23

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #30

    Hello! I know this is kinda off topic but I was wondering which blog platform are you using for this website?
    I’m getting tired of Wordpress because I’ve had issues with
    hackers and I’m looking at options for another platform.
    I would be great if you could point me in the direction of a
    good platform.

    Look at my homepage :: raycon

    raycon5小时前回复
  2. #29

    It’s an amazing paragraph designed for all the online viewers;
    they will get benefit from it I am sure.

  3. #28

    Thankfulness to my father who told me concerning this
    blog, this weblog is actually remarkable.

  4. #27

    An impressive share! I’ve just forwarded this onto a coworker who
    was conducting a little research on this. And he actually ordered me breakfast
    because I discovered it for him… lol. So allow me to reword
    this…. Thanks for the meal!! But yeah, thanks for spending
    the time to discuss this issue here on your site.

  5. #26

    Keep on writing, great job!

  6. #25

    I do not even know how I ended up here, but I thought
    this post was good. I do not know who you are but definitely you are going to a famous blogger if you aren’t
    already 😉 Cheers!

  7. #24

    Way cool! Some very valid points! I appreciate you penning this post
    and the rest of the website is also very good.

  8. #23

    I absolutely love your blog and find nearly all of your post’s to be exactly what I’m looking
    for. Would you offer guest writers to write content for yourself?

    I wouldn’t mind writing a post or elaborating on some of the subjects you write in relation to here.
    Again, awesome website!