当前位置:网站首页>Batch detect whether there is CDN in URL - high accuracy
Batch detect whether there is CDN in URL - high accuracy
2022-07-02 02:32:00 【Mountains and rivers'】
Read the Internet and say url Batch testing cdn The script of is not much and inaccurate , Write here
General judgment cdn The method is as follows
The global ping
According to the ip More than one address is used cdn, This is the most reliable method
- Multiple locations ping The server - Website speed measurement - Webmaster Tools Home of stationmaster
- The global Ping test , On-line ping Tools - Network tools The fastest
- https://whoer.net/zh/ping The global ping
nslookup
1. nslookup Default resolution
Use "nslookup domain name ", If the goal has CDN service , that “ Non authoritative response ” Medium “addresses” Medium IP Count >=2 individual , But there will also be false positives

2. Different DNS Domain name resolution
Different DNS Comparison of domain name resolution , Determine whether it uses CDN. Different DNS If the analysis results are different , There is a good chance that CDN service
So we can judge whether it is used according to these two points cdn
Batch test scripts
If you quote global ping Of api Interface for testing , The detection efficiency will be limited by the server network speed and the possibility of being blocked ip The risk of . Use here nslookup Conduct multiple tests , To confirm whether to use cdn, Accuracy rate 99%

cdn.py
from subprocess import PIPE, Popen
import re
import os
from colorama import init,Fore
init(autoreset=True)
import argparse
def args():
parser = argparse.ArgumentParser(description='cdn Batch test scripts ')
parser.add_argument('-f',type=str,help=' Batch testing , Please put url Put it in txt In the document , One line at a time ')
args = parser.parse_args()
ssrc = """
______ _____________ ____
/ ___/ / ___/\_ __ \_/ ___\
\___ \ \___ \ | | \/\ \___
/____ >/____ > |__| \___ >
\/ \/ \/
Author: Mountains and rivers
"""
print(ssrc)
if args.f:
filename = args.f
if os.path.exists(filename):
check_cdn(filename)
else:
print(" The file name entered does not exist !")
def check_cdn(filename):
result_list = []
for url in open(filename,'r'):
url = url.replace("\n","")
ip = url.replace("http://","").replace("https://","").replace("/","").replace("\n","")
proc = Popen('nslookup %s' %(ip),stdin=None,stdout=PIPE,stderr=PIPE,shell=True)
outinfo, errinfo = proc.communicate()
info = outinfo.decode('gbk')
ip_list = re.findall(r"\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}",info,re.S)
if len(ip_list) >= 3:
print(Fore.RED+"[-]",url," There is cdn")
continue
if len(ip_list) == 1:
print(Fore.BLUE+"[-]",url," request timeout ")
continue
if len(ip_list) == 2:
# Second judgment , Improve accuracy
proc = Popen('nslookup %s 223.5.5.5' %(ip),stdin=None,stdout=PIPE,stderr=PIPE,shell=True)
outinfo, errinfo = proc.communicate()
info1 = outinfo.decode('gbk')
ip_list1 = re.findall(r"\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}",info1,re.S)
if len(ip_list1) >= 3:
print(Fore.RED+"[-]",url," There is cdn")
continue
if len(ip_list1) ==2:
name1 = re.findall(r' name :.*Address:.*?(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})',info,re.S)[0]
name2 = re.findall(r' name :.*Address:.*?(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})',info1,re.S)[0]
if name1 != name2:
print(Fore.RED+"[-]",url," There is cdn")
continue
if name1 == name2:
print(Fore.GREEN+"[+] %s non-existent cdn \t real ip: %s" %(url,name2))
result_list.append(name2)
lis = list(set(result_list))
if len(lis):
for r in lis:
with open("result.txt",'a') as f:
f.write(r+"\n")
print(" detection complete , non-existent cdn Of url ip Save in current path 'result.txt'")
if not len(lis):
print(" detection complete !")
if __name__ == '__main__':
args()边栏推荐
- 2022 safety officer-c certificate examination questions and mock examination
- 研发中台拆分过程的一些心得总结
- CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决
- 2022安全员-C证考试题及模拟考试
- flutter 中間一個元素,最右邊一個元素
- 剑指 Offer 47. 礼物的最大价值
- 【读书笔记】程序员修炼手册—实战式学习最有效(项目驱动)
- How does proxy IP participate in the direct battle between web crawlers and anti crawlers
- Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
- AR增强现实可应用的场景
猜你喜欢

If you want to rewind the video picture, what simple methods can you use?

How does MySQL solve the problem of not releasing space after deleting a large amount of data

Feature query of hypergraph iserver rest Service

Which kind of sports headphones is easier to use? The most recommended sports headphones

Leetcode face T10 (1-9) array, ByteDance interview sharing

CVPR 2022 | 大连理工提出自校准照明框架,用于现实场景的微光图像增强

大厂裁员潮不断,双非本科出身的我却逆风翻盘挺进阿里

RTL8189FS如何关闭Debug信息

Ar Augmented Reality applicable scenarios

Pytest testing framework
随机推荐
研发中台拆分过程的一些心得总结
trading
[untitled]
What are the common proxy servers and what are the differences?
AcWing 245. Can you answer these questions (line segment tree)
剑指 Offer 31. 栈的压入、弹出序列
剑指 Offer 42. 连续子数组的最大和
设置状态栏颜色
MySQL operates the database through the CMD command line, and the image cannot be found during the real machine debugging of fluent
Kibana controls es
How to use redis ordered collection
2022低压电工考试题模拟考试题库模拟考试平台操作
how to come in an investnent bank team
JPM 2021 most popular paper released (with download)
Build a modern data architecture on the cloud with Amazon AppFlow, Amazon lake formation and Amazon redshift
Kibana操控ES
[pit] how to understand "parameter fishing"
MySQL constraints and multi table query example analysis
A quick understanding of digital electricity
What is the MySQL column to row function