当前位置:网站首页>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()边栏推荐
- essay structure
- Iterative unified writing method of binary tree
- 超图iServer rest服务之feature查询
- STM32__05—PWM控制直流电机
- CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决
- 2022低压电工考试题模拟考试题库模拟考试平台操作
- Coordinatorlayout + tablayout + viewpager2 (there is another recyclerview nested inside), and the sliding conflict of recyclerview is solved
- Connected block template and variants (4 questions in total)
- Ten minutes will take you in-depth understanding of multithreading - multithreaded teamwork: synchronous control
- Basic 01: print string
猜你喜欢

SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding

花一个星期时间呕心沥血整理出高频软件测试/自动化测试面试题和答案

Types of exhibition items available in the multimedia interactive exhibition hall

Sword finger offer 62 The last remaining number in the circle

【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表

STM32__05—PWM控制直流电机
![[pit] how to understand](/img/e9/f5315a03b6f3da07021f915bb18af8.jpg)
[pit] how to understand "parameter fishing"

【读书笔记】程序员修炼手册—实战式学习最有效(项目驱动)

What is the principle of bone conduction earphones and who is suitable for bone conduction earphones

Ar Augmented Reality applicable scenarios
随机推荐
Sword finger offer 62 The last remaining number in the circle
Sword finger offer 31 Stack push in and pop-up sequence
Provincial election + noi Part IV graph theory
Sword finger offer 47 Maximum value of gifts
连通块模板及变式(共4题)
Ten minutes will take you in-depth understanding of multithreading - multithreaded teamwork: synchronous control
大厂裁员潮不断,双非本科出身的我却逆风翻盘挺进阿里
Open that kind of construction document
Which brand of running headphones is good? How many professional running headphones are recommended
A quick understanding of analog electricity
[learn C and fly] day 5 chapter 2 program in C language (Exercise 2)
[pit] how to understand "parameter fishing"
What are the characteristics of common web proxy IP
What is the principle of bone conduction earphones and who is suitable for bone conduction earphones
Formatting logic of SAP ui5 currency amount display
【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表
Webgpu (I): basic concepts
[Chongqing Guangdong education] Sichuan University concise university chemistry · material structure part introductory reference materials
Sword finger offer 29 Print matrix clockwise
[liuyubobobo play with leetcode algorithm interview] [00] Course Overview