当前位置:网站首页>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()边栏推荐
- query词权重, 搜索词权重计算
- Yyds dry goods inventory accelerating vacuum in PG
- Summary of some experiences in the process of R & D platform splitting
- 【带你学c带你飞】day 5 第2章 用C语言编写程序(习题2)
- Kibana controls es
- Which brand of sports headset is better? Bluetooth headset suitable for sports
- SAP ui5 beginner tutorial 19 - SAP ui5 data types and complex data binding
- SQL server calculates the daily average and annual average of the whole province
- How to turn off debug information in rtl8189fs
- CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决
猜你喜欢

pytest 测试框架
![[pit] how to understand](/img/e9/f5315a03b6f3da07021f915bb18af8.jpg)
[pit] how to understand "parameter fishing"

LFM signal denoising, time-frequency analysis, filtering

What kind of good and cost-effective Bluetooth sports headset to buy

As a software testing engineer, will you choose the bank post? Laolao bank test post

QT实现界面跳转

CoordinatorLayout + TabLayout + ViewPager2(里面再嵌套一个RecyclerView),RecyclerView的滑动冲突解决

Opencascade7.6 compilation

RTL8189FS如何关闭Debug信息

How to execute an SQL in MySQL
随机推荐
No programming code technology! Four step easy flower store applet
RTL8189FS如何关闭Debug信息
【带你学c带你飞】4day第2章 用C语言编写程序(练习 2.5 生成乘方表与阶乘表
Comparative analysis of MVC, MVP and MVVM, source code analysis
Pat a-1165 block reversing (25 points)
2022安全员-C证考试题及模拟考试
trading
剑指 Offer II 031. 最近最少使用缓存
QT uses sqllite
The middle element and the rightmost element of the shutter
How to turn off debug information in rtl8189fs
Sword finger offer 29 Print matrix clockwise
flutter 中間一個元素,最右邊一個元素
[learn C and fly] 1day Chapter 2 (exercise 2.2 find the temperature of Fahrenheit corresponding to 100 ° f)
JS slow animation
Face++ realizes face detection in the way of flow
【OpenCV】-5种图像滤波的综合示例
Divorce for 3 years to discover the undivided joint property, or
flutter 中间一个元素,最右边一个元素
JVM面试篇